mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +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:
|
||||
ret = virAsprintf(&cmd, "drive_add %s%.2x:%.2x:%.2x %s",
|
||||
(tryOldSyntax ? "" : "pci_addr="),
|
||||
controllerAddr->domain, controllerAddr->bus,
|
||||
controllerAddr->slot, safe_str);
|
||||
if (ret == -1) {
|
||||
if (virAsprintf(&cmd, "drive_add %s%.2x:%.2x:%.2x %s",
|
||||
(tryOldSyntax ? "" : "pci_addr="),
|
||||
controllerAddr->domain, controllerAddr->bus,
|
||||
controllerAddr->slot, safe_str) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2109,6 +2108,12 @@ try_command:
|
||||
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 (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
|
||||
VIR_FREE(reply);
|
||||
@ -2360,8 +2365,7 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
|
||||
|
||||
/* 'dummy' here is just a placeholder since there is no PCI
|
||||
* address required when attaching drives to a controller */
|
||||
ret = virAsprintf(&cmd, "drive_add dummy %s", safe_str);
|
||||
if (ret == -1) {
|
||||
if (virAsprintf(&cmd, "drive_add dummy %s", safe_str) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
@ -2372,6 +2376,12 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (strstr(reply, "unknown command:")) {
|
||||
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||
_("drive hotplug is not supported"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
@ -2397,8 +2407,8 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = virAsprintf(&cmd, "block_passwd %s%s \"%s\"", QEMU_DRIVE_HOST_PREFIX, alias, safe_str);
|
||||
if (ret == -1) {
|
||||
if (virAsprintf(&cmd, "block_passwd %s%s \"%s\"",
|
||||
QEMU_DRIVE_HOST_PREFIX, alias, safe_str) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user