I have a QEMU image with a snapshot stored in it. Right now I'm using libvirt to start it.
However, I want to be able to run more than one instance out of the same image/snapshot.
I guess I can do that by cloning the virtual-hd and installing/creating a new domain (virsh) and then running revert from snapshot. But I want to be able to do that pretty much "on-the-fly" with as little as possible latency from the time I decide I need to run another instance of image X to the time that instance is running from the stored snapshot.
Anyone did anything like that? I started thinking maybe libvirt is not low-level enough for this ?
[EDIT: Sorry if this wasn't clear - I'm talking about a RAM+HD snapshot, not just HD snapshot, which I already know how to create...]
Thanks
I was able to run multiple concurrent qemu from the same snapshot using a command like the following. (Obviously the -arm
, -kernel
, -cpu
etc. arguments will be different in your case)
qemu-system-arm -hda snapshot.qcow2 -snapshot -kernel some_vmlinux \
-serial stdio -append 'root=/dev/sda2 rootfstype=ext4 rw'\
-cpu arm1176 -m 256 -M versatilepb
The important argument here is -snapshot
, so that temporary memory is used for disk writes.
What I havent tried is forcing a writeback to the underlying device, I suspect all manner of havoc could occur if this is possible and it happened... basically, don't forget the -snapshot
argument!
If you want some writable storage that is different per instance you probably need to add a second virtual hard disk and have the common snapshot mount that somehow:
qemu-system-arm -hda snapshot.qcow2 -snapshot -kernel some_vmlinux \
-serial stdio -append 'root=/dev/sda2 rootfstype=ext4 rw'\
-cpu arm1176 -m 256 -M versatilepb -hdb drive_system1.img &
qemu-system-arm -hda snapshot.qcow2 -snapshot -kernel some_vmlinux \
-serial stdio -append 'root=/dev/sda2 rootfstype=ext4 rw'\
-cpu arm1176 -m 256 -M versatilepb -hdb drive_system2.img &
If you are using networking, dont forget to make the MAC address and any hostfw
port values different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With