大网数据广告活动
服务器运维问答

Combine -snapshot and -loadvm snap_id in qemu-system

· 52CE 我爱测

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 …

问题原文

原帖链接 · 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)

  1. Run QEMU with -snapshot and -monitor stdio
  2. Hit Enter to get the (qemu) monitor prompt
  3. migrate "exec: gzip -c > memsnapshot.gz" or migrate "exec: cat > memsnapshot" (for instant load time)
  4. Now use -snapshot with the above memsnapshot: qemu-* <whatever flags> -incoming "exec: gzip -c -d snapshot.gz" -snapshot or qemu-* <whatever flags> -incoming "exec: cat memsnapshot" -snapshot

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-12-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。