On Tue, 5 Dec 2023 at 04:53, Philipp Hahn <h...@univention.de> wrote: > > Hello, > > by accident I stumbled over "VMware Instant Clone" ¹, which allows > cloning of running VMs by copy-on-write-sharing the disk images and > memory content; the network MAC address gets changed (or a different > bridge is used?). > I wonder if something similar can also be done with Qemu? My current > solution would be to: > - start and install the VM > - create a live-snapshot into the qcow2 file > - clone the disk image, e.g. put a qcow2 overlay on it per clone > - start and restore the clones from that live-snapshot > - put the clones in individual bridges and let the host do some network > address translation (NAT) to give each clone a unique external IP address. > > Has someone done something similar or is there even a better alternative? > > Background: our test suite currently provisions a set of multiple VMs, > which are dependent on each other. Provisioning them takes sometimes > many hours. After that the test suite runs inside these VMs and again > takes many hours. > I'd like to speed that up by parallelizing these tests, e.g. > 1. setup the VM environment once > 2. clone the VM environments as the resources allow > 3. distribute tests over these environments to run in parallel and to > allow running flaky tests multiple times from a clean clone again
It would be simplest to use qcow2 backing files and boot each new instance from scratch. This involves setting up a master image and then "qemu-img create -f qcow2 -b master.img vm001.qcow2" to create the instance image. You may be able to use systemd or your distro's "first boot" functionality to recreate unique IDs and cryptographic keys when the new instance boots. If you really want to use a RAM snapshot then I suggest creating a qcow2 master image with the savevm command and using "cp --reflink=always master.qcow2 vm001.qcow2" to create an efficient copy of the qcow2 file. You'll need some custom scripts to recreate unique IDs and cryptographic keys inside the new instance after loadvm. Stefan > > ¹<https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-853B1E2B-76CE-4240-A654-3806912820EB.html> > -- > Philipp Hahn > Open Source Software Engineer > > Univention GmbH > Mary-Somerville-Str. 1 > 28359 Bremen > Germany | Deutschland > Phone: +49 (0)421 22232-0 | E-Mail: i...@univention.de > > https://www.univention.de | https://www.univention.com > > Managing Directors: Peter H. Ganten, Stefan Gohmann > Local court: Amtsgericht Bremen > HRB 20755 | Ust-ID: DE220051310 >