Programmatically Launching a QEMU Virtual Machine Instance from a Snapshot

I have a QEMU image with a snapshot stored in it. Right now I am using libvirt to start it.

However, I want to be able to run more than one instance from the same snapshot / snapshot.

I think I can do this by cloning a virtual hd and installing / creating a new domain (virsh), and then starting it from the snapshot. But I want to be able to do this pretty much on the fly with as little delay as possible from the moment I decided that I need to run another instance of the X image until the instance starts from the stored snapshot.

Has anyone done something like this? I started thinking, maybe libvirt is not low enough for this?

[EDIT: Sorry if that was unclear - I'm talking about a RAM + HD snapshot, not just an HD snapshot, which I already know how to create ...]

thank

+4
source share
1 answer

I managed to run several parallel qemu from the same snapshot using the following command. (Obviously, arguments -arm, -kernel, -cpuetc. In your case will be different)

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

An important argument here is -snapshot, therefore, temporary memory is used to write to disk.

What I did was force access to the base device, I suspect that any chaos could happen, if possible, and it happened ... basically, don't forget the argument -snapshot!

, - , , , :

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 &

, MAC- hostfw .

+3

Source: https://habr.com/ru/post/1542840/


All Articles