Hi Kashyap, Thanks for your answer! Unfortunately my use case requires cloning the exact memory state, so I won't be able to use virt-sysprep. But the snapshot command looks like something I could use. Could you suggest how to proceed and create/start a new vm from that snapshot? Thanks, Michael On Tue, Apr 12, 2016 at 2:37 PM, Kashyap Chamarthy <kchamart@redhat.com> wrote:> On Mon, Apr 11, 2016 at 12:01:08PM +0300, Michael Ravits wrote: > > Hi, > > > > My use case involves creating duplicates of saved virtual machines. > > While I realize you want to trivially clone VMs with some state at > random point in time, you might want to look into `virt-builder` about > cloning VMs. It has some sensible advice: > > http://libguestfs.org/virt-builder.1.html#clones > > Using `virt-builder` to clone images, will 'sysprep' the images, which > will ensure that (a) each VM copy gets a fresh pair of SSH host keys; > (b) a new random seed; (c) all security/sensitive information is > removed; (d) log files are cleaned (in the below URL, look up the string > "logfiles *" to see what all it removes), and much more. Take a look > here for what all it does: > > http://libguestfs.org/virt-sysprep.1.html#operations > http://libguestfs.org/virt-sysprep.1.html#security > > > Tried with virt-manager and with virsh but so far it seems like this > > case is not supported by these tools. Does anyone know how I could > > achieve the above? > > With 'virsh', you _can_ save the live disk and memory state: > > $ virsh snapshot-create-as \ > --domain myvm snap1 \ > --diskspec vda,file=./disk-snap.qcow2,snapshot=external \ > --memspec file=./mem-snap.qcow2,snapshot=external \ > --atomic > > > -- > /kashyap >
On Tue, Apr 12, 2016 at 03:15:16PM +0300, Michael Ravits wrote:> Hi Kashyap, > > Thanks for your answer! > > Unfortunately my use case requires cloning the exact memory state, so I > won't be able to use virt-sysprep. > But the snapshot command looks like something I could use. > Could you suggest how to proceed and create/start a new vm from that > snapshot?Afraid, I don't know of a trivial way to create a new VM from the kind of snapshot ('external system checkpoint' snapshot) where you have two files: disk state, and memory state. You might have to play around a bit and construct a script + XML definition file that allows you to create a new VM from these files. Maybe Eric Blake has better suggestions. If you _just_ want to save memory state, then you can try `virsh save` and `virsh restore` (read more about them here: `man virsh`). [...]> > With 'virsh', you _can_ save the live disk and memory state: > > > > $ virsh snapshot-create-as \ > > --domain myvm snap1 \ > > --diskspec vda,file=./disk-snap.qcow2,snapshot=external \ > > --memspec file=./mem-snap.qcow2,snapshot=external \ > > --atomic > > > > > > -- > > /kashyap > >-- /kashyap
> -----Oorspronkelijk bericht----- > Van: libvirt-users-bounces@redhat.com [mailto:libvirt-users- > bounces@redhat.com] Namens Kashyap Chamarthy > Verzonden: woensdag 13 april 2016 14:12 > Aan: Michael Ravits > CC: libvirt-users@redhat.com > Onderwerp: Re: [libvirt-users] Clone VM with saved state > > On Tue, Apr 12, 2016 at 03:15:16PM +0300, Michael Ravits wrote: > > Hi Kashyap, > > > > Thanks for your answer! > > > > Unfortunately my use case requires cloning the exact memory state, so > > I won't be able to use virt-sysprep. > > But the snapshot command looks like something I could use. > > Could you suggest how to proceed and create/start a new vm from that > > snapshot? > > Afraid, I don't know of a trivial way to create a new VM from the kind of > snapshot ('external system checkpoint' snapshot) where you have two > files: disk state, and memory state. You might have to play around a bit and > construct a script + XML definition file that allows you to > create a new VM from these files. Maybe Eric Blake has better > suggestions.Once I restored a machine from saved stated but with the disk image from a shutdown state (not the disk image from the saved state), by accident. This breaks the guest because the disk is corrupt. Make sense if you think about it... Maybe It's better to let the guest hibernate and work from there?> > If you _just_ want to save memory state, then you can try `virsh save` and `virsh > restore` (read more about them here: `man virsh`). > > [...] > > > > With 'virsh', you _can_ save the live disk and memory state: > > > > > > $ virsh snapshot-create-as \ > > > --domain myvm snap1 \ > > > --diskspec vda,file=./disk-snap.qcow2,snapshot=external \ > > > --memspec file=./mem-snap.qcow2,snapshot=external \ > > > --atomic > > > > > > > > > -- > > > /kashyap > > > > > -- > /kashyap > > _______________________________________________ > libvirt-users mailing list > libvirt-users@redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-users