]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Don't escape HMP commands just to unescape them right away
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Sep 2019 15:37:57 +0000 (17:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Sep 2019 06:41:50 +0000 (08:41 +0200)
Historically HMP commands needed to be escaped to work properly.

The backdoor for calling HMP commands via QMP must unescape them so that
arguments aren't messed up.

Since we now only support the QMP passthrough the escape->unescape dance
is pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor_text.c

index 6a09ba91ed6ad7f0aa67b78d697b849bae0ae36c..c15b194bb5a5ba6478abb2005420b022aac1beae 100644 (file)
@@ -1258,24 +1258,9 @@ qemuMonitorHMPCommand(qemuMonitorPtr mon,
                       const char *cmd,
                       char **reply)
 {
-    char *json_cmd = NULL;
-    int ret = -1;
-
     QEMU_CHECK_MONITOR(mon);
 
-    /* hack to avoid complicating each call to text monitor functions */
-    json_cmd = qemuMonitorUnescapeArg(cmd);
-    if (!json_cmd) {
-        VIR_DEBUG("Could not unescape command: %s", cmd);
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Unable to unescape command"));
-        goto cleanup;
-    }
-    ret = qemuMonitorJSONHumanCommand(mon, json_cmd, reply);
-
- cleanup:
-    VIR_FREE(json_cmd);
-    return ret;
+    return qemuMonitorJSONHumanCommand(mon, cmd, reply);
 }
 
 
index a15c3df76eed8895aae3859a1a498e9ec886423d..7bc28e54c0af0402a0e75074baa7132fe05c0d12 100644 (file)
@@ -38,15 +38,10 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
     char *cmd = NULL;
     char *reply = NULL;
     int ret = -1;
-    char *safe_str;
-
-    safe_str = qemuMonitorEscapeArg(drivestr);
-    if (!safe_str)
-        return -1;
 
     /* 'dummy' here is just a placeholder since there is no PCI
      * address required when attaching drives to a controller */
-    if (virAsprintf(&cmd, "drive_add dummy %s", safe_str) < 0)
+    if (virAsprintf(&cmd, "drive_add dummy %s", drivestr) < 0)
         goto cleanup;
 
     if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
@@ -85,7 +80,6 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
  cleanup:
     VIR_FREE(cmd);
     VIR_FREE(reply);
-    VIR_FREE(safe_str);
     return ret;
 }
 
@@ -95,13 +89,9 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
 {
     char *cmd = NULL;
     char *reply = NULL;
-    char *safedev;
     int ret = -1;
 
-    if (!(safedev = qemuMonitorEscapeArg(drivestr)))
-        goto cleanup;
-
-    if (virAsprintf(&cmd, "drive_del %s", safedev) < 0)
+    if (virAsprintf(&cmd, "drive_del %s", drivestr) < 0)
         goto cleanup;
 
     if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
@@ -129,7 +119,6 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
  cleanup:
     VIR_FREE(cmd);
     VIR_FREE(reply);
-    VIR_FREE(safedev);
     return ret;
 }
 
@@ -140,10 +129,8 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon,
     char *cmd = NULL;
     char *reply = NULL;
     int ret = -1;
-    char *safename;
 
-    if (!(safename = qemuMonitorEscapeArg(name)) ||
-        virAsprintf(&cmd, "savevm \"%s\"", safename) < 0)
+    if (virAsprintf(&cmd, "savevm \"%s\"", name) < 0)
         goto cleanup;
 
     if (qemuMonitorHMPCommand(mon, cmd, &reply))
@@ -166,7 +153,6 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon,
     ret = 0;
 
  cleanup:
-    VIR_FREE(safename);
     VIR_FREE(cmd);
     VIR_FREE(reply);
     return ret;
@@ -179,8 +165,7 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
     int ret = -1;
     char *safename;
 
-    if (!(safename = qemuMonitorEscapeArg(name)) ||
-        virAsprintf(&cmd, "loadvm \"%s\"", safename) < 0)
+    if (virAsprintf(&cmd, "loadvm \"%s\"", name) < 0)
         goto cleanup;
 
     if (qemuMonitorHMPCommand(mon, cmd, &reply))
@@ -223,10 +208,8 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
     char *cmd = NULL;
     char *reply = NULL;
     int ret = -1;
-    char *safename;
 
-    if (!(safename = qemuMonitorEscapeArg(name)) ||
-        virAsprintf(&cmd, "delvm \"%s\"", safename) < 0)
+    if (virAsprintf(&cmd, "delvm \"%s\"", name) < 0)
         goto cleanup;
     if (qemuMonitorHMPCommand(mon, cmd, &reply))
         goto cleanup;
@@ -249,7 +232,6 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
     ret = 0;
 
  cleanup:
-    VIR_FREE(safename);
     VIR_FREE(cmd);
     VIR_FREE(reply);
     return ret;