mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
Misc error handling fixes in text mode monitor commands
A couple of places in the text monitor were overwriting the 'ret' variable with a >= 0 value before success was actually determined. So later error paths would not correctly return the -1 value. The drive_add code was not checking for errors like missing command * src/qemu/qemu_monitor_text.c: Misc error handling fixes
This commit is contained in:
parent
347d266c51
commit
a1de6ba0f1
@ -2094,11 +2094,10 @@ int qemuMonitorTextAttachDrive(qemuMonitorPtr mon,
|
|||||||
}
|
}
|
||||||
|
|
||||||
try_command:
|
try_command:
|
||||||
ret = virAsprintf(&cmd, "drive_add %s%.2x:%.2x:%.2x %s",
|
if (virAsprintf(&cmd, "drive_add %s%.2x:%.2x:%.2x %s",
|
||||||
(tryOldSyntax ? "" : "pci_addr="),
|
(tryOldSyntax ? "" : "pci_addr="),
|
||||||
controllerAddr->domain, controllerAddr->bus,
|
controllerAddr->domain, controllerAddr->bus,
|
||||||
controllerAddr->slot, safe_str);
|
controllerAddr->slot, safe_str) < 0) {
|
||||||
if (ret == -1) {
|
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -2109,6 +2108,12 @@ try_command:
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strstr(reply, "unknown command:")) {
|
||||||
|
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("drive hotplug is not supported"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (qemudParseDriveAddReply(reply, driveAddr) < 0) {
|
if (qemudParseDriveAddReply(reply, driveAddr) < 0) {
|
||||||
if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
|
if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
|
||||||
VIR_FREE(reply);
|
VIR_FREE(reply);
|
||||||
@ -2360,8 +2365,7 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
/* 'dummy' here is just a placeholder since there is no PCI
|
/* 'dummy' here is just a placeholder since there is no PCI
|
||||||
* address required when attaching drives to a controller */
|
* address required when attaching drives to a controller */
|
||||||
ret = virAsprintf(&cmd, "drive_add dummy %s", safe_str);
|
if (virAsprintf(&cmd, "drive_add dummy %s", safe_str) < 0) {
|
||||||
if (ret == -1) {
|
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -2372,6 +2376,12 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strstr(reply, "unknown command:")) {
|
||||||
|
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("drive hotplug is not supported"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -2397,8 +2407,8 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virAsprintf(&cmd, "block_passwd %s%s \"%s\"", QEMU_DRIVE_HOST_PREFIX, alias, safe_str);
|
if (virAsprintf(&cmd, "block_passwd %s%s \"%s\"",
|
||||||
if (ret == -1) {
|
QEMU_DRIVE_HOST_PREFIX, alias, safe_str) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user