Package: libvirt0
Version: 0.9.12-6
Severity: normal
Tags: patch

Hello Guido,

qemu-1.0 introduced a new error message, when a snapshot is created, but
the VM uses a raw device. This is not detected by libvirt.
Patch attached.

-- System Information:
Debian Release: 7.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libvirt0 depends on:
ii  libavahi-client3    0.6.31-1
ii  libavahi-common3    0.6.31-1
ii  libc6               2.13-37
ii  libcap-ng0          0.6.6-2
ii  libdbus-1-3         1.6.8-1
ii  libdevmapper1.02.1  2:1.02.74-4
ii  libgcrypt11         1.5.0-3
ii  libgnutls26         2.12.20-4
ii  libnetcf1           0.1.9-2
ii  libnl1              1.1-7
ii  libnuma1            2.0.8~rc4-1
ii  libpcap0.8          1.3.0-1
ii  libsasl2-2          2.1.25.dfsg1-6
ii  libxenstore3.0      4.1.4-2
ii  libxml2             2.8.0+dfsg1-7
ii  libyajl2            2.0.4-2

Versions of packages libvirt0 recommends:
ii  lvm2  2.02.95-4

libvirt0 suggests no packages.

-- no debconf information
>From 7034e3285f80c3744a79a4df912d20d8b9aba7d5 Mon Sep 17 00:00:00 2001
Message-Id: <7034e3285f80c3744a79a4df912d20d8b9aba7d5.1360938805.git.h...@univention.de>
From: Philipp Hahn <h...@univention.de>
Date: Fri, 15 Feb 2013 15:13:05 +0100
Subject: [PATCH] qemu: handle not supported writable devices
Organization: Univention GmbH, Bremen, Germany
To: libvir-l...@redhat.com

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 <h...@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
@@ -3004,6 +3004,10 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
         qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
         goto cleanup;
     }
+    else if (strstr(reply, "does not support snapshots") != NULL) {
+        qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
+        goto cleanup;
+    }
 
     ret = 0;
 
-- 
1.7.10.4

Reply via email to