]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONDelDevice: Return -2 on DeviceNotFound error
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 14 Mar 2019 07:46:37 +0000 (08:46 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Mar 2019 12:45:34 +0000 (13:45 +0100)
A caller might be interested in differentiating the cause for
error, especially if DeviceNotFound error occurred.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor_json.c

index 8bd4d4d76199bab9447defa4231577ae3c913c2a..0eb7f60e38a8e9e1792c58e45c830b804d5e1af0 100644 (file)
@@ -3008,6 +3008,16 @@ qemuMonitorDriveDel(qemuMonitorPtr mon,
 }
 
 
+/**
+ * @mon: monitor object
+ * @devalias: alias of the device to detach
+ *
+ * Sends device detach request to qemu.
+ *
+ * Returns: 0 on success,
+ *         -2 if DeviceNotFound error encountered (error NOT reported)
+ *         -1 otherwise (error reported)
+ */
 int
 qemuMonitorDelDevice(qemuMonitorPtr mon,
                      const char *devalias)
index 0236323a5106804eb93be6df07ad074debfd41a6..5c16e1f3a13184bf5f45cd6834e1b0b17f075afd 100644 (file)
@@ -4191,6 +4191,11 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
         goto cleanup;
 
+    if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
+        ret = -2;
+        goto cleanup;
+    }
+
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
         goto cleanup;