[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 2/2] snapshot: enforce REVERT_FORCE on qemu



On 10/04/2011 04:02 PM, Eric Blake wrote:
* src/qemu/qemu_driver.c (qemuDomainRevertToSnapshot): Check for
risky situations, and allow force to get past them.

ACK.

Before pushing this, I'm running some sanity tests. So far, this test
sequence (adjusted to the fixed code) shows where force helps with older
snapshots (I'll send separate email for showing how force helps active
ABI-incompatible snapshots):

Test 2:
$ virsh define dom # domain with qcow2 disk
$ virsh start dom
$ virsh snapshot-create-as dom snap
$ virsh shutdown dom # and wait for it to work
$ virsh edit dom # and add a second disk
$ virsh start dom
$ virt-manager # and open a window on the guest
$ virsh snapshot-revert dom snap
error: unsupported configuration: Target domain disk count 1 does not match source 2
# Error was expected(*), cannot do live revert across ABI break
$ virsh snapshot-revert dom snap --force
# --force let things work, and virt-manager display bounced due to
# need to start a new qemu process
$ virsh dumpxml dom # confirm only one disk present
$ virsh snapshot-revert dom snap
# revert happens without complaint and without display bounce

(*)That was the message shown before squashing in this patch; after squashing in this patch, the message properly mentions "force":

error: revert requires force: Target domain disk count 1 does not match source 2

diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c
index 55398f6..2e6f3e4 100644
--- i/src/qemu/qemu_driver.c
+++ w/src/qemu/qemu_driver.c
@@ -9771,12 +9771,16 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
             /* Transitions 5, 6, 8, 9 */
             /* Check for ABI compatibility.  */
if (config && !virDomainDefCheckABIStability(vm->def, config)) {
+                virErrorPtr err = virGetLastError();
+
                 if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
-                    /* Alter existing error to give correct category. */
-                    virErrorPtr err = virGetLastError();
-                    err->code = VIR_ERR_SNAPSHOT_REVERT_RISKY;
+                    /* Re-spawn error using correct category. */
+                    if (err->code == VIR_ERR_CONFIG_UNSUPPORTED)
+ qemuReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, "%s",
+                                        err->str2);
                     goto endjob;
                 }
+                virResetError(err);
                 qemuProcessStop(driver, vm, 0,
                                 VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT);
                 virDomainAuditStop(vm, "from-snapshot");


--
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]