Saving VM Settings

I have two VMs that will not stay saved. After every reboot they revert back to an older setting. I’ve tried everything I could find with Google with no solution. Does anyone know why Virsh refuses to save new settings? I am using this command to save the settings,

sudo virsh define Win10.xml

I have also tried undefining the VM and then defining with the above command. Also tried a

sudo virsh edit Win10

Nothing seems to work.

Does virsh edit work without the .xml bit?

You use define to define from an XML file, you use edit to edit the imported config, don’t add .xml to the end of the machine name when using edit.

sudo virsh define Win10.xml
sudo virsh edit Win10

1 Like

Sorry, right you are, I tried edit as you wrote, it doesn’t save the edit after a reboot.

Also, corrected my post.

Oh that’s strange, I don’t think I’ve heard of that happening before. Does it stick if you just restart libvirtd or does that wipe it too?

Reverts when I run

service libvirtd restart

So no that doesn’t work.

Perhaps any changes you made weren’t stored on disk.
Have you verified that Win10.xml is actually changed?

The config isn’t saved in the xml it is saved in a virsh file. The question did make me wonder if virsh was actually saving the changes in virsh so I checked and it is. I still don’t understand why it keeps getting reset. Maybe it has something to do with the service that monitors the system for unauthorized changes? I am not sure how to check that.

Perhaps I’m speaking out of ignorance, however any changes made on my pc with virsh or virt-manager are reflected in the xml files in the folder /etc/libvirt/qemu/

As far as I understand it, virsh grabs the configuration currently stored in memory, wich has been loaded from disk during libvirtd startup.

If it is the case that you are not authorized to make changes, I doubt you could have made those changes in the first place.

If the changes are stored on disk, than I can think of a (unlikely) scenario:

Any changes made with virsh are not persistent due to some configuration (A quick search doesn’t reveal such an option)

Yes, my virsh changes are reflected into the same folder. Authorization is not the problem. Maybe it has something to do with the type of changes I am making? I am assigning which CPUs the Guest OS can use. And I have the host constrained to only two CPUs.

I haven’t found anyway to make the changes stick. Other than this problem this system rocks. I run one gaming OS (Win 10) with 8 CPUs and one general purpose OS (Linux) with 4 CPUs, with the option to start a third OS for secure banking.

What you could try is to make a backup of your VM’s and completely reinstall libvirtd, all while hoping that the problem magically disappears. :face_with_monocle:

Other than that,
If your changes are reverted upon shutdown of libvirtd, you could try changing the settings just before starting libvirtd.

What distro are you running and what version of libvirtd is installed?

Just curious, after modifying the VM to your liking use sudo virsh dumpxml Win10 >> win10_up.xml to dump it out, then delete it and restart libvirtd, it should still be gone, then define it with the new XML and restart libvirtd again, does it stick or revert to some old config still?

I used undefine to remove all of the VMs but one. The Win10 VM is using nvram and doesn’t like being undefine without the --nvram flag. I didn’t do that since I am unsure what that flag may do to defining it again. However when I ran

virsh list -all

the only VM showing was Win10 as expected. After the libvirtd restart the two VMs I undefined where back.

Checking the Safe VM config showed it was restored to the old settings.

I had to do ‘sudo su’ to run dumpxml so that got me thinking that perhaps I didn’t have enough authority. So I repeated everything in the the root terminal and still the same results.

I just realized I forgot to include the versions.

Compiled against library: libvirt 5.1.0
Using library: libvirt 5.1.0
Using API: QEMU 5.1.0
Running hypervisor: QEMU 3.1.0

Virtual Machine Manager: 2.1.0

Xubuntu 18.04

Just a random question, but you don’t have them on a RAM disk, or a temporary file system?
I ask because the settings reverting like that make it sound almost like it’s not saving out the changes, just reloading the store from an image each boot

Nope, the OS and the VM configs (/etc/libvirt/qemu/) are on an SD drive. I have the VM drive images on a RAID drive.

I did some searching around and didn’t really find any similar topics about this, the only thing I came across that may be relevant is what editor you are using by default, I use vi. I made a change to my VM from virt-manager and the change was reflected on disk right away.

-rw------- 1 root root 9456 Jun 15 12:06 Windows10.xml

-rw------- 1 root root 9248 Jun 20 21:23 Windows10.xml

Maybe check with journalctl -f for any errors when you make a change, I’m not running an ubuntu based distro so could be something with AppArmor or something like that. Otherwise sorry I’m at a bit of a loss. :frowning:

I am leaving for holiday today and will look into your suggestion when I return on the 30.

I do know the xml files with the correct config survive a reboot or libvirtd restart.

If it is stored on an SD, perhaps you have delayed write turned on. after making the change. run the sync command in a terminal. See if that makes a difference.

I have the same problem. I run virsh edit . The changes work until after reboot, when all changes are reverted.

After editing, there are two files for the domain in /etc/libvirt/qemu:

<domain>-orig.xml with no changes, and <domain>.xml with the changes.

If I delete the <domain>-orig.xml file, the changes persist after a reboot.