提交 9772beba 编写于 作者: D Daniel P. Berrange

Fix QEMU text monitor command error checking

The text monitor code was checking for a '\n' prefix on several
places. Previously this would work, but since the monitor code
re-write the '\n' is already stripped off, so mustn't be checked
for.

* src/qemu/qemu_monitor_text.c: Fix monitor error checking
上级 a980d123
...@@ -787,7 +787,7 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon, ...@@ -787,7 +787,7 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon,
/* If the command failed qemu prints: 'unknown command' /* If the command failed qemu prints: 'unknown command'
* No message is printed on success it seems */ * No message is printed on success it seems */
if (strstr(reply, "\nunknown command:")) { if (strstr(reply, "unknown command:")) {
/* Don't set error - it is expected memory balloon fails on many qemu */ /* Don't set error - it is expected memory balloon fails on many qemu */
ret = 0; ret = 0;
} else { } else {
...@@ -816,7 +816,7 @@ int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online) ...@@ -816,7 +816,7 @@ int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online)
if (qemuMonitorCommand(mon, cmd, &reply) < 0) { if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("could nt change CPU online status")); "%s", _("could not change CPU online status"));
VIR_FREE(cmd); VIR_FREE(cmd);
return -1; return -1;
} }
...@@ -824,7 +824,7 @@ int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online) ...@@ -824,7 +824,7 @@ int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online)
/* If the command failed qemu prints: 'unknown command' /* If the command failed qemu prints: 'unknown command'
* No message is printed on success it seems */ * No message is printed on success it seems */
if (strstr(reply, "\nunknown command:")) { if (strstr(reply, "unknown command:")) {
/* Don't set error - it is expected CPU onlining fails on many qemu - caller will handle */ /* Don't set error - it is expected CPU onlining fails on many qemu - caller will handle */
ret = 0; ret = 0;
} else { } else {
...@@ -857,7 +857,7 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon, ...@@ -857,7 +857,7 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
/* If the command failed qemu prints: /* If the command failed qemu prints:
* device not found, device is locked ... * device not found, device is locked ...
* No message is printed on success it seems */ * No message is printed on success it seems */
if (strstr(reply, "\ndevice ")) { if (strstr(reply, "device ")) {
qemuReportError(VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s: %s"), devname, reply); _("could not eject media on %s: %s"), devname, reply);
goto cleanup; goto cleanup;
...@@ -901,14 +901,14 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon, ...@@ -901,14 +901,14 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
/* If the command failed qemu prints: /* If the command failed qemu prints:
* device not found, device is locked ... * device not found, device is locked ...
* No message is printed on success it seems */ * No message is printed on success it seems */
if (strstr(reply, "\ndevice ")) { if (strstr(reply, "device ")) {
qemuReportError(VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s: %s"), devname, reply); _("could not eject media on %s: %s"), devname, reply);
goto cleanup; goto cleanup;
} }
/* Could not open message indicates bad filename */ /* Could not open message indicates bad filename */
if (strstr(reply, "\nCould not open ")) { if (strstr(reply, "Could not open ")) {
qemuReportError(VIR_ERR_OPERATION_FAILED, qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not change media on %s: %s"), devname, reply); _("could not change media on %s: %s"), devname, reply);
goto cleanup; goto cleanup;
...@@ -2291,7 +2291,7 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon, ...@@ -2291,7 +2291,7 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
goto cleanup; goto cleanup;
} }
if (strstr(reply, "\nunknown command:")) { if (strstr(reply, "unknown command:")) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("setting disk password is not supported")); _("setting disk password is not supported"));
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册