问题原文
原帖链接 · user54 · CC BY-SA 3.0
Is it possible somehow to use -snapshot and -loadvm snap_id together during starting guest by using qemu-system?
Currently, if I use these options together, guest can not be started.
I need to prevent saving data into guest disk to avoid it's growing. -snapshot allows to achive it on the fly, but I also need -loadvm snap_id to to get already booted VM instead of waiting for it's booting.
社区高分解答
原帖链接 · shluvme · CC BY-SA 4.0
Unfortunately QEMU doesn't permit this for the reason that you might save an internal-snapshot (i.e savevm command) while running with the flag -snapshot.
This is because of an edge case: when you use -snapshot QEMU creates a temporary image where all copy-on-writes are saved to. Now if you run savevm while in this mode, QEMU will write the internal-snapshot to the temporary image, and once you shut off the machine you lose your snapshot.
To overcome this edge case we have to manually perform what's called an external-snapshot. Do the following steps to achieve this (https://bugs.launchpad.net/qemu/+bug/1184089/comments/2)
- Run QEMU with
-snapshotand-monitor stdio - Hit
Enterto get the(qemu)monitor prompt migrate "exec: gzip -c > memsnapshot.gz"ormigrate "exec: cat > memsnapshot"(for instant load time)- Now use
-snapshotwith the above memsnapshot:qemu-* <whatever flags> -incoming "exec: gzip -c -d snapshot.gz" -snapshotorqemu-* <whatever flags> -incoming "exec: cat memsnapshot" -snapshot
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
