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

[libvirt] [PATCH] qemu: handle not supported writable devices



If the running VM contains a writable raw image, creating snapshot fails
internally in QEMU, but the error is not detected by libvirt. Success is
still reported to the user, who will see the snapshot in libvirt, even
they are NOT created by qemu.

virsh # qemu-monitor-command --hmp winxp-1  savevm \"test\"
Device 'drive-fdc0-0-0' is writable but does not support snapshots.

virsh # snapshot-create-as winxp-1 test
Domain snapshot test created

Since there is no QMP command in QEMU, libvirtd sends a HMP command to the
running QEMU and parses the returned text. There only the following 4 strings
are detected as errors:

src/qemu/qemu_monitor_text.c:2822 # qemuMonitorTextCreateSnapshot()
> "Error while creating snapshot"
> "No block device can accept snapshots"
> "Could not open VM state file"
> "Error" + "while writing VM"

Since none of them match the above message, libvirt thinks the command
succeeded.

Add "does not support snapshots" as an additional error condition.

Signed-off-by: Philipp Hahn <hahn univention de>
---
 src/qemu/qemu_monitor_text.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index bc0a11d..5880ab9 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2854,6 +2854,10 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
         virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
         goto cleanup;
     }
+    else if (strstr(reply, "does not support snapshots") != NULL) {
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
+        goto cleanup;
+    }
 
     ret = 0;
 
-- 
1.7.10.4


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