]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
snapshot: detect when qemu lacks disk-snapshot support
authorEric Blake <eblake@redhat.com>
Tue, 18 Oct 2011 21:28:47 +0000 (15:28 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 18 Oct 2011 22:03:42 +0000 (16:03 -0600)
Noticed when testing new libvirt against old qemu that lacked the
snapshot_blkdev HMP command.  Libvirt was mistakenly treating the
command as successful, and re-writing the domain XML to use the
just-created 0-byte file, rendering the domain broken on restart.

* src/qemu/qemu_monitor_text.c (qemuMonitorTextDiskSnapshot):
Notice another possible error message.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive): Don't keep 0-byte file
on failure.

src/qemu/qemu_driver.c
src/qemu/qemu_monitor_text.c

index f833655b8ae2f9e43622e1806c3c6cdc7593cfa6..84ef4dd0782b04940a2eaa4f97ced855d2e92eb7 100644 (file)
@@ -9027,7 +9027,6 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver,
             VIR_WARN("Unable to release lock on %s", source);
         goto cleanup;
     }
-    need_unlink = false;
 
     disk->src = origsrc;
     origsrc = NULL;
@@ -9041,6 +9040,7 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver,
         goto cleanup;
 
     /* Update vm in place to match changes.  */
+    need_unlink = false;
     VIR_FREE(disk->src);
     disk->src = source;
     source = NULL;
index 2f31d990e9b035d67ba8e61f1fcb99fe95aa3999..4774df99867040596957cbc55f80f00bf18e8e2b 100644 (file)
@@ -3064,7 +3064,8 @@ qemuMonitorTextDiskSnapshot(qemuMonitorPtr mon, const char *device,
         goto cleanup;
     }
 
-    if (strstr(reply, "error while creating qcow2") != NULL) {
+    if (strstr(reply, "error while creating qcow2") != NULL ||
+        strstr(reply, "unknown command:") != NULL) {
         qemuReportError(VIR_ERR_OPERATION_FAILED,
                         _("Failed to take snapshot: %s"), reply);
         goto cleanup;