qemu: monitor: Don't escape HMP commands just to unescape them right away

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>
This commit is contained in:
Peter Krempa 2019-09-19 17:37:57 +02:00
parent 4fbdebea40
commit d6fc3b937b
2 changed files with 6 additions and 39 deletions

View 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);
}

View 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;