3

I've created a virtual machine using virt-manager and saved a snapshot of it's current state.

Now I'd like to create an exact duplicate machine with all snapshots from the first machine.

How could I accomplish that?

michaelr524
  • 139
  • 1
  • 4

1 Answers1

4

There are two parts to a VM - the disk image (or set of images in a snapshot chain) and the VM definitions.

Cloning VM definitions can be both simple and complex. For the clone to run on another host, all you need is virsh dumpxml VMNAME > VM.xml on the source; and then virsh define VM.xml on the destination host. If the clone is going to be running locally, you will have to manually edit the XML and change the UUIDs and names from the original ones, change the MACs, and pretty much anything else that can be unique to the VM, so there is no clash. Changing the disk image paths is also required obviously.

Cloning disk images is a matter of copying the files elsewhere. qemu-img is he utility you need to use to do the disk copying. Drop the image chain set into a separate folder, point the domxml at the leaf image, and it should just work.

Having said all that, you have virt-clone, a part of virt-install to take care of things for you

dyasny
  • 18,482
  • 6
  • 48
  • 63
  • thanks for the elaborate answer! what i'm looking for is to copy the vm with it's disk snapshots and memory snapshots.. i have the virsh command with snapshot-create-as to create both disk and memory snapshots, but i'm not sure how to proceed and copy that vm with the disk and the snapshots and run it on another host. the clone action from virt-manager does not clone with snapshots and checking virt-clone i didn't notice anything about snapshots in it's help. – michaelr524 Apr 13 '16 at 09:49
  • If there is no snapshot support, you will have to do everything manually, as I described above. Last time I had to do something like this at scale was around 2008, but it was a script that recursively followed disks from the leaf (defined in the domxml) all the way to the root, the base image, and moved them one by one to the new location. going one snapshot further up with each iteration. In any case, I would avoid using snapshots in production, they have quite the performance penalty, on any virtualization system – dyasny Apr 13 '16 at 13:18