If the QEMU system you’re trying to debug doesn’t have a disk image at all, you can create a dummy disk which will be used for nothing but snapshots like this:Īnd then add this option to your command line: (As a bonus it should be faster and take less disk space too!)
Qemu-img convert -f raw -O qcow2 your-disk.img your-disk.qcow2Īnd then change your command line to use the qcow2 file rather than the old raw image. If you have a different format like a raw disk, you can convert it with qemu-img: To use savevm snapshots you’ll need to be using a disk image format which supports them, like QCOW2. It’s then often practical to use debug techniques like turning on QEMU’s slow and voluminous tracing of all execution, now that you’re only dealing with a short run of execution. If you take a snapshot of the VM state just before the bug manifests itself, you can create a simpler and shorter test case by making QEMU start execution from the snapshot point. This can be very awkward to debug because it takes so long to get to the point of failure, especially if it requires user interaction along the way. Suppose you have a guest image which misbehaves when you run a particular userspace program inside the guest. QEMU’s savevm snapshot feature is designed as a user feature, but it’s surprisingly handy as a developer tool too.
For the next entry in this occasional series of posts about tricks for debugging QEMU I want to talk about savevm snapshots.