From 19f8309a3b7681aa963fe94b763c99b0aebda2f0 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 19 Sep 2019 17:53:45 +0200
Subject: [PATCH] qemu: monitor: Don't handle HMP in
 qemuMonitorJSONArbitraryCommand

Call to qemuMonitorJSONHumanCommand directly from
qemuMonitorArbitraryCommand.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_monitor.c      |  5 ++++-
 src/qemu/qemu_monitor_json.c | 19 +++++++------------
 src/qemu/qemu_monitor_json.h |  3 +--
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index f52a381982..af4c41fa16 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3191,7 +3191,10 @@ qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
 
     QEMU_CHECK_MONITOR(mon);
 
-    return qemuMonitorJSONArbitraryCommand(mon, cmd, reply, hmp);
+    if (hmp)
+        return qemuMonitorJSONHumanCommand(mon, cmd, reply);
+    else
+        return qemuMonitorJSONArbitraryCommand(mon, cmd, reply);
 }
 
 
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 891d2c3089..b8ec9ac59a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4624,25 +4624,20 @@ qemuMonitorJSONDiskNameLookup(qemuMonitorPtr mon,
 
 int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
                                     const char *cmd_str,
-                                    char **reply_str,
-                                    bool hmp)
+                                    char **reply_str)
 {
     virJSONValuePtr cmd = NULL;
     virJSONValuePtr reply = NULL;
     int ret = -1;
 
-    if (hmp) {
-        return qemuMonitorJSONHumanCommand(mon, cmd_str, reply_str);
-    } else {
-        if (!(cmd = virJSONValueFromString(cmd_str)))
-            goto cleanup;
+    if (!(cmd = virJSONValueFromString(cmd_str)))
+        goto cleanup;
 
-        if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-            goto cleanup;
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        goto cleanup;
 
-        if (!(*reply_str = virJSONValueToString(reply, false)))
-            goto cleanup;
-    }
+    if (!(*reply_str = virJSONValueToString(reply, false)))
+        goto cleanup;
 
     ret = 0;
 
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 5330697885..a608410703 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -286,8 +286,7 @@ char *qemuMonitorJSONDiskNameLookup(qemuMonitorPtr mon,
 
 int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
                                     const char *cmd_str,
-                                    char **reply_str,
-                                    bool hmp);
+                                    char **reply_str);
 
 int qemuMonitorJSONInjectNMI(qemuMonitorPtr mon);