From: Michal Privoznik Date: Thu, 14 Mar 2019 07:46:37 +0000 (+0100) Subject: qemuMonitorJSONDelDevice: Return -2 on DeviceNotFound error X-Git-Tag: v5.2.0-rc1~181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=229a0358f0678d414b765e533b53c74e40d5189c;p=thirdparty%2Flibvirt.git qemuMonitorJSONDelDevice: Return -2 on DeviceNotFound error A caller might be interested in differentiating the cause for error, especially if DeviceNotFound error occurred. Signed-off-by: Michal Privoznik ACKed-by: Peter Krempa --- diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 8bd4d4d761..0eb7f60e38 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -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) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 0236323a51..5c16e1f3a1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -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;