mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
qemu: fallback to HMP drive_add/drive_del
fallback to HMP drive_add/drive_del commands if not found in QMP
This commit is contained in:
parent
24c56ceb08
commit
c33ac2e3b9
@ -2289,11 +2289,19 @@ int qemuMonitorJSONAddDrive(qemuMonitorPtr mon,
|
|||||||
if (!cmd)
|
if (!cmd)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
|
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply) < 0))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
|
||||||
|
qemuMonitorCheckHMP(mon, "drive_add")) {
|
||||||
|
VIR_DEBUG0("drive_add command not found, trying HMP");
|
||||||
|
ret = qemuMonitorTextAddDrive(mon, drivestr);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (ret == 0)
|
|
||||||
ret = qemuMonitorJSONCheckError(cmd, reply);
|
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -2314,15 +2322,18 @@ int qemuMonitorJSONDriveDel(qemuMonitorPtr mon,
|
|||||||
if (!cmd)
|
if (!cmd)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
|
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
/* See if drive_del isn't supported */
|
|
||||||
if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
|
if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
|
||||||
|
if (qemuMonitorCheckHMP(mon, "drive_del")) {
|
||||||
|
VIR_DEBUG0("drive_del command not found, trying HMP");
|
||||||
|
ret = qemuMonitorTextDriveDel(mon, drivestr);
|
||||||
|
} else {
|
||||||
VIR_ERROR0(_("deleting disk is not supported. "
|
VIR_ERROR0(_("deleting disk is not supported. "
|
||||||
"This may leak data if disk is reassigned"));
|
"This may leak data if disk is reassigned"));
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto cleanup;
|
}
|
||||||
} else if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
|
} else if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
|
||||||
/* NB: device not found errors mean the drive was
|
/* NB: device not found errors mean the drive was
|
||||||
* auto-deleted and we ignore the error */
|
* auto-deleted and we ignore the error */
|
||||||
@ -2330,7 +2341,6 @@ int qemuMonitorJSONDriveDel(qemuMonitorPtr mon,
|
|||||||
} else {
|
} else {
|
||||||
ret = qemuMonitorJSONCheckError(cmd, reply);
|
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user