Hide Forgot
Description of problem: Libvirt is not maintaining enough information about snapshots, and risks corrupting guests that have done any hot plug or other configuration changes between the time a snapshot is created then later reverted to. Version-Release number of selected component (if applicable): libvirt-0.9.4-7.el6 How reproducible: 100% Steps to Reproduce: 1. virsh start dom 2. virsh snapshot-create-as dom snap 3. virsh snapshot-dumpxml dom snap 4. virsh shutdown dom 5. virsh setmaxmem dom $(larger value) 6. virsh start dom 7. virsh snapshot-revert dom snap Actual results: in step 2, libvirt saves only the domain uuid in the snapshot. As a result, in step 7, libvirt has no way of knowing that the snapshot was tied to a different amount of guest RAM, tries to revert to the snapshot using a monitor command while keeping a single qemu process, and the difference in memory sizes makes things go haywire Expected results: libvirt should have tracked the full domain xml (visible in step 3), and used that in step 7 to either reject the revert (due to incompatible ABI) or to stop the one qemu process, and start another one with the former memory sizing. Additional info: Upstream patches to reject things based on incompatible ABI: https://www.redhat.com/archives/libvir-list/2011-September/msg00137.html Upstream plan to add a VIR_DOMAIN_SNAPSHOT_REVERT_FORCE flag to allow starting a new qemu (note that restarting qemu is not seamless, which is why it should require a flag): https://www.redhat.com/archives/libvir-list/2011-August/msg00361.html
Getting this fixed, at least to the point of recognizing incompatible ABI, is a prereq to bug 638510 support for live snapshots via the snapshot_blkdev qemu monitor command. Upstream does not yet have a solution for VIR_DOMAIN_SNAPSHOT_REVERT_FORCE implemented, so depending on time constraints, we may have to split that half into a separate BZ for later enhancement.
In POST: http://post-office.corp.redhat.com/archives/rhvirt-patches/2011-September/msg00135.html
Got an error when revert from created snapshot, move back to ASSIGNED. # virsh start foo Domain foo started # virsh snapshot-create-as foo snap Domain snapshot snap created # virsh snapshot-dumpxml foo snap <domainsnapshot> <name>snap</name> <state>running</state> <creationTime>1315915439</creationTime> <domain type='kvm'> <name>foo</name> <uuid>d3782e1f-e34a-bf7c-414b-4f74d3837e96</uuid> <memory>524288</memory> <currentMemory>524288</currentMemory> <vcpu>1</vcpu> <os> <type arch='x86_64' machine='rhel6.1.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='writeback'/> <source file='/var/lib/libvirt/images/foo.qcow2'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/boot/cdrom.img'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' unit='0'/> </disk> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='fdc' index='0'/> <interface type='bridge'> <mac address='52:54:00:85:15:ce'/> <source bridge='rhevm'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <graphics type='spice' autoport='yes'> <image compression='auto_glz'/> <jpeg compression='auto'/> <zlib compression='auto'/> <playback compression='on'/> </graphics> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices> </domain> </domainsnapshot> # virsh destroy foo Domain foo destroyed # virsh setmaxmem foo 1048576 # virsh start foo Domain foo started # virsh snapshot-revert foo snap error: operation failed: Error -22 while loading VM state
Aha - the ABI compatibility checking was incomplete, and we happened to trip on one of the few places where the change is guest-visible but the code didn't flag it. Proposed this upstream: https://www.redhat.com/archives/libvir-list/2011-September/msg00471.html
Back in POST: http://post-office.corp.redhat.com/archives/rhvirt-patches/2011-September/msg00458.html
Tested with libvirt-0.9.4-12.el6.x86_64, already been fixed. Move to VERIFIED. [root@localhost ~]# virsh start foo Domain foo started [root@localhost ~]# virsh snapshot-create-as foo snap Domain snapshot snap created [root@localhost ~]# virsh snapshot-list foo Name Creation Time State ------------------------------------------------------------ snap 2010-02-08 20:58:16 -0500 running [root@localhost ~]# virsh snapshot-dumpxml foo snap <domainsnapshot> <name>snap</name> <state>running</state> <creationTime>1265680696</creationTime> <domain type='kvm'> <name>foo</name> <uuid>5035868c-6f23-63d1-d05c-1fc5ff963134</uuid> <memory>524288</memory> <currentMemory>524288</currentMemory> <vcpu>1</vcpu> <os> <type arch='x86_64' machine='rhel6.2.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/var/lib/libvirt/images/foo.img'/> <target dev='vda' bus='ide'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk> <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </controller> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='network'> <mac address='52:54:00:11:df:7f'/> <source network='default'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> <channel type='pty'> <target type='virtio' name='org.linux-kvm.port.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> <sound model='ich6'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> </domain> </domainsnapshot> [root@localhost ~]# virsh destroy foo Domain foo destroyed [root@localhost ~]# virsh setmaxmem foo 1048576 [root@localhost ~]# virsh start foo Domain foo started [root@localhost ~]# virsh snapshot-revert foo snap error: unsupported configuration: Target domain max memory 524288 does not match source 1048576
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2011-1513.html