if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
- if (rc == -2) {
+ if (rc < 0) {
/* we've already tried, error out */
if (ejectRetry)
goto error;
- VIR_DEBUG("tray is locked, wait for the guest to unlock "
- "the tray and try to eject it again");
+
ejectRetry = true;
- } else if (rc < 0) {
- goto error;
+ VIR_DEBUG("tray may be locked, wait for the guest to unlock "
+ "the tray and try to eject it again");
}
if (virTimeMillisNow(&now) < 0)
if (virDomainObjWaitUntil(vm, now + CHANGE_MEDIA_TIMEOUT) != 0)
goto error;
}
- } while (ejectRetry && rc != 0);
+ } while (rc < 0);
if (!virStorageSourceIsEmpty(newsrc)) {
if (qemuGetDriveSourceString(newsrc, conn, &sourcestr) < 0)
* Run QMP command to eject a media from ejectable device.
*
* Returns:
- * -2 on error, when the tray is locked
- * -1 on all other errors
+ * -1 on error
* 0 on success
*/
int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
- if (ret < 0) {
- virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
- if (error) {
- const char *errorStr = virJSONValueObjectGetString(error, "desc");
- if (errorStr && c_strcasestr(errorStr, "is locked"))
- ret = -2;
- }
- }
-
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
* Run HMP command to eject a media from ejectable device.
*
* Returns:
- * -2 on error, when the tray is locked
- * -1 on all other errors
+ * -1 on error
* 0 on success
*/
int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
* device not found, device is locked ...
* No message is printed on success it seems */
if (c_strcasestr(reply, "device ")) {
- if (c_strcasestr(reply, "is locked"))
- ret = -2;
virReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s: %s"), dev_name, reply);
goto cleanup;