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

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

 



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
found.

Thanks,
Cole
commit 8caba367b62b4fb961722cd641d8172bb441b84e
Author: Cole Robinson <crobinso@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
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,
         VIR_FREE(newsrc);
         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;
+    }
+
     VIR_FREE(reply);
     VIR_FREE(cmd);
 
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]