On Thu, Jan 09, 2025 at 07:27:16PM +0000, Felipe Franciosi wrote: > Hello! > > I have a use case which I'm struggling to support with libvirt: > saving a VM to a file, cloning it (which renames the VM), and restoring it. > > My search revealed a number of tutorials for using virt-clone [1], but that > doesn't seem to cover VMs which are _saved_ (only running or paused). Saved in what way ? Managed save ? > > [1] https://github.com/virt-manager/virt-manager/blob/main/virtinst/virtclone.py > > In a nutshell, I want to power on a VM and do some setup, then save its full > state to disk (e.g., with virsh save). Finally I want to modify the XML to: > - rename the VM > - change which bridge its NICs are on (while maintaining mac addresses) > - change the disk image to a copy (done while the VM is saved) > > But the restore operation fails because of a target domain name check > implemented in virDomainDefCheckABIStabilityFlags(). I've debated how to best > address this and I'm looking for your views. If you're cloning a VM, it needs both a new UUID and name, so I'm surprised the ABI stability check hasn't already blocked you on the UUID change before getting to the name change check. > I suspect this call is there for a reason (which may still be relevant), > although the name is clearly not part of the ABI; it's the host identifier for > that domain and not guest-visible. My first stab at this is therefore just to > drop this check (patch attached). The most important thing is that Libvirt has to ensure uniqueness of the name, within the host. If the name can be silently changed by passing in change XML, the unique checks will be missing and you can end up with many VMs with the same name. Likewise for UUID checks. > I'm open to suggestions, for example by plumbing through a flag which makes the > check optional. Please let me know how you prefer that I take this forward. If you're using managed save, then I would think it is already possible to achieve. First cloning the VM: virsh dumpxml myvm > myvm.xml cp myvm.xml myvm-clone.xml ..modify name & uuid & bridge & disk of myvm-clone.xml virsh define myvm-clone.xml Now modify the saved state virsh managedsave-dumpxml myvm-clone > save.xml ...modify save.xml to change name & uuid to match myvm-clonme... virsh managedsave-define save.xml The ABI stability check done by managedsave-define, will validate against the name + uuid of the cloned VM, so in fact it will force you to change the name + uuid in the save XML before loading it back in, and it should be not possible to restore from the managed save image until fixing this With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|