How to properly modify xml in snapshot memory / managed save file
I am trying to move virtual machines to a new location on the same host. I want to preserve not only snapshots, but domain manage saved state as well as snapshot saved state. The xml is embedded in the snapshot and domain saved state and paths base image files are hard coded. I tried to sed replace the paths and necessary info, but it seems like libvirt expects the xml to be a certain length so it fails parsing. Parsing fails at different points of the embedded xml when I change the length of the path in the embedded xml. How can I properly edit the snapshot and domain managed saved state xml?
On Sun, Feb 08, 2026 at 13:32:51 +0000, wrangle wrote:
I am trying to move virtual machines to a new location on the same host. I want to preserve not only snapshots, but domain manage saved state as well as snapshot saved state.
Libvirt provides APIs to be able to re-define the XML embedded in the save images. With virsh you can do: virsh managedsave-edit VMNAME and virsh save-image-edit --file IMAGEFILE
The xml is embedded in the snapshot and domain saved state and paths base image files are hard coded. I tried to sed replace the paths anda
For external snapshots with memory, the memory image a save image so to edit that you can use 'virsh save-image-edit' as there isn't a specific API which would take the snapshot name. Just use the name of the memory image as present in the snapshot XML.
necessary info, but it seems like libvirt expects the xml to be a certain length so it fails parsing. Parsing fails at different points of the embedded xml when I change the length of the path in the embedded xml.
That's right, the files need to be edited with the APIs.
On Thu, Feb 12, 2026 at 2:44 PM Peter Krempa <pkrempa@redhat.com> wrote:
On Sun, Feb 08, 2026 at 13:32:51 +0000, wrangle wrote:
I am trying to move virtual machines to a new location on the same host. I want to preserve not only snapshots, but domain manage saved state as well as snapshot saved state.
Libvirt provides APIs to be able to re-define the XML embedded in the save images. With virsh you can do:
virsh managedsave-edit VMNAME
and
virsh save-image-edit --file IMAGEFILE
The xml is embedded in the snapshot and domain saved state and paths base image files are hard coded. I tried to sed replace the paths anda
For external snapshots with memory, the memory image a save image so to edit that you can use 'virsh save-image-edit' as there isn't a specific API which would take the snapshot name. Just use the name of the memory image as present in the snapshot XML.
necessary info, but it seems like libvirt expects the xml to be a certain length so it fails parsing. Parsing fails at different points of the embedded xml when I change the length of the path in the embedded xml.
That's right, the files need to be edited with the APIs.
I encountered a situation where I need to move vms from a different host. No snapshots, just saved memory state. I changed the path in the xml and virsh define on the new host; used save-image-edit to change the image path and copied to /var/lib/libvirt/qemu/save on new host, but I get the following domain is not running error when I start the vm before asking to discard the saved state. Any suggestions?: Traceback (most recent call last): File "/usr/share/virt-manager/virtManager/asyncjob.py", line 71, in cb_wrapper callback(asyncjob, *args, **kwargs) ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/virt-manager/virtManager/asyncjob.py", line 107, in tmpcb callback(*args, **kwargs) ~~~~~~~~^^^^^^^^^^^^^^^^^ File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn ret = fn(self, *args, **kwargs) File "/usr/share/virt-manager/virtManager/object/domain.py", line 1384, in startup self._backend.create() ~~~~~~~~~~~~~~~~~~~~^^ File "/usr/lib64/python3.13/site-packages/libvirt.py", line 1379, in create raise libvirtError('virDomainCreate() failed') libvirt.libvirtError: operation failed: domain is not running
participants (2)
-
Peter Krempa -
wrangle