virsh edit vs virsh dumpxml

Latest response

Tried to do a virsh edit to modify an interface and discovered the xml in the edit does not match the running xml.
Doing virsh dumpxml shows the correct information.

It appears edit is pulling from /etc/libvirt/qemu/ while dumpxml pulls from var/run/libvirt/qemu.

The question is why the discrepancy and what is the proper way to ensure edit and dumpxml are in synch?

Responses

Did you find your changes in a running VM? IMHO. May be the changes require shutdown and start VM and only after that you can see the same information between "virsh edit" and "virsh dumpxml". I thing you have pending changes - so "virsh dumpxml" show real time state of your domain.

The VMs have been cycled and so has the host - When the VM comes up, it uses the information shown in dumpxml, not the information shown in virsh edit. I would assume there is some way of syncing the two or configuring to use the same source but I have not seen any information along those lines.

Since the RH docs are somewhat sparse on this topic, here is what I found out:

  1. XML files in /var/run/libvirt/qemu are the current in memory ones – same thing dumpxml would show.

  2. XML files in /etc/libvirt/qemu are the real config files.

    • these files can only be edited properly by virsh edit or by having the VM machine off and editing the files manually.

Any changes from command line not executed with “--persistent” will only remain in the memory side and will appear in the /var/run/libvirt/qemu xml files. This appears to survive a reboot of the VM but will not survive a shutdown and restart. What threw me for a bit of a loop was that the host was saving and pausing VM state and on reboot simply resumed them which made it appear to have kept the changes.

To correctly add an interface to a running VM live and populate the config file with the same information, one needs to include the “--persistent” - just like windows ;)

Example: virsh attach-interface --type bridge --model virtio --source --mac 52:54:00:18:8f:b3 --persistent –live

Otherwise, one can add the config lines via virsh -edit and restart the VM.