[libvirt] [PATCH] do not return -1 when human-monitor-command is not supported

Wen Congyang wency at cn.fujitsu.com
Thu Mar 17 03:22:47 UTC 2011


It is not a fatal error if some monitor command is not supported.
So we should not return -1 when human-monitor-command is not supported.
Set reply_str to "unknown command: 'human-monitor-command'", and the caller
can deal this error the same as the command that we want to run by
human-monitor-command.

Signed-off-by: Wen Congyang <wency at cn.fujitsu.com>

---
 src/qemu/qemu_monitor_json.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 13d12c8..7ec4ce7 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -694,6 +694,16 @@ qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
     if (!cmd || qemuMonitorJSONCommandWithFd(mon, cmd, scm_fd, &reply) < 0)
         goto cleanup;
 
+    if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
+        *reply_str = strdup("unknown command: 'human-monitor-command'");
+        if (!*reply_str) {
+            virReportOOMError();
+            goto cleanup;
+        }
+        ret = 0;
+        goto cleanup;
+    }
+
     if (qemuMonitorJSONCheckError(cmd, reply))
         goto cleanup;
 
-- 
1.7.1




More information about the libvir-list mailing list