提交 d6fc3b93 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
上级 4fbdebea
...@@ -1258,24 +1258,9 @@ qemuMonitorHMPCommand(qemuMonitorPtr mon, ...@@ -1258,24 +1258,9 @@ qemuMonitorHMPCommand(qemuMonitorPtr mon,
const char *cmd, const char *cmd,
char **reply) char **reply)
{ {
char *json_cmd = NULL;
int ret = -1;
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
/* hack to avoid complicating each call to text monitor functions */ return qemuMonitorJSONHumanCommand(mon, cmd, reply);
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;
} }
......
...@@ -38,15 +38,10 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon, ...@@ -38,15 +38,10 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
char *cmd = NULL; char *cmd = NULL;
char *reply = NULL; char *reply = NULL;
int ret = -1; 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 /* 'dummy' here is just a placeholder since there is no PCI
* address required when attaching drives to a controller */ * 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; goto cleanup;
if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
...@@ -85,7 +80,6 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon, ...@@ -85,7 +80,6 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
cleanup: cleanup:
VIR_FREE(cmd); VIR_FREE(cmd);
VIR_FREE(reply); VIR_FREE(reply);
VIR_FREE(safe_str);
return ret; return ret;
} }
...@@ -95,13 +89,9 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon, ...@@ -95,13 +89,9 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
{ {
char *cmd = NULL; char *cmd = NULL;
char *reply = NULL; char *reply = NULL;
char *safedev;
int ret = -1; int ret = -1;
if (!(safedev = qemuMonitorEscapeArg(drivestr))) if (virAsprintf(&cmd, "drive_del %s", drivestr) < 0)
goto cleanup;
if (virAsprintf(&cmd, "drive_del %s", safedev) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
...@@ -129,7 +119,6 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon, ...@@ -129,7 +119,6 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
cleanup: cleanup:
VIR_FREE(cmd); VIR_FREE(cmd);
VIR_FREE(reply); VIR_FREE(reply);
VIR_FREE(safedev);
return ret; return ret;
} }
...@@ -140,10 +129,8 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, ...@@ -140,10 +129,8 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon,
char *cmd = NULL; char *cmd = NULL;
char *reply = NULL; char *reply = NULL;
int ret = -1; int ret = -1;
char *safename;
if (!(safename = qemuMonitorEscapeArg(name)) || if (virAsprintf(&cmd, "savevm \"%s\"", name) < 0)
virAsprintf(&cmd, "savevm \"%s\"", safename) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorHMPCommand(mon, cmd, &reply)) if (qemuMonitorHMPCommand(mon, cmd, &reply))
...@@ -166,7 +153,6 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, ...@@ -166,7 +153,6 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon,
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(safename);
VIR_FREE(cmd); VIR_FREE(cmd);
VIR_FREE(reply); VIR_FREE(reply);
return ret; return ret;
...@@ -179,8 +165,7 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name) ...@@ -179,8 +165,7 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
int ret = -1; int ret = -1;
char *safename; char *safename;
if (!(safename = qemuMonitorEscapeArg(name)) || if (virAsprintf(&cmd, "loadvm \"%s\"", name) < 0)
virAsprintf(&cmd, "loadvm \"%s\"", safename) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorHMPCommand(mon, cmd, &reply)) if (qemuMonitorHMPCommand(mon, cmd, &reply))
...@@ -223,10 +208,8 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name) ...@@ -223,10 +208,8 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
char *cmd = NULL; char *cmd = NULL;
char *reply = NULL; char *reply = NULL;
int ret = -1; int ret = -1;
char *safename;
if (!(safename = qemuMonitorEscapeArg(name)) || if (virAsprintf(&cmd, "delvm \"%s\"", name) < 0)
virAsprintf(&cmd, "delvm \"%s\"", safename) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorHMPCommand(mon, cmd, &reply)) if (qemuMonitorHMPCommand(mon, cmd, &reply))
goto cleanup; goto cleanup;
...@@ -249,7 +232,6 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name) ...@@ -249,7 +232,6 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(safename);
VIR_FREE(cmd); VIR_FREE(cmd);
VIR_FREE(reply); VIR_FREE(reply);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册