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

[libvirt] [PATCH] Attempt to detect cdrom change failures

If a 'change' or 'eject' qemu monitor command fails,
an error message is printed to the monitor of the
form "device {not found, is locked, is not 
removable"}. This is really the only indication we
have that the command errored out, so scrape the
monitor reply for "\ndevice " and fail if it is

commit 8caba367b62b4fb961722cd641d8172bb441b84e
Author: Cole Robinson <crobinso dhcp-100-19-219 bos redhat com>
Date:   Fri Aug 22 16:35:24 2008 -0400

    Scrape cdrom attach/eject monitor output to try and determine failure.

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 9a26375..05e7402 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2994,6 +2994,19 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
         return -1;
+    /* If the command failed qemu prints:
+     * device not found, device is locked ...
+     * No message is printed on success it seems */
+    DEBUG ("cdrom change reply: %s", reply);
+    if (strstr(reply, "\ndevice ")) {
+        qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+                          "%s", _("changing cdrom media failed));
+        VIR_FREE(reply);
+        VIR_FREE(cmd);
+        return -1;
+    }

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