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 <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Michal Privoznik
2019-03-15 13:45:34 +01:00
parent 4cd13478ac
commit 229a0358f0
2 changed files with 15 additions and 0 deletions
+10
View 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)
+5
View 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;