From nobody Mon Feb 9 06:27:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568909555; cv=none; d=zoho.com; s=zohoarc; b=JUBB3uq0wZyhs9BcKMeTgEtp48M2S8M3D3CBvG/DRJUKDwliJWWLzYo3wZDWzc65yCjwEkHxEi1GqOD6JYpSJMKO7r6FOM+Z7RgT9SXT2blojkfTrvQd3goEnaIot2cFSREbbuGrB83NAHSnc36kgwQbc4NAHNmW4zN/cQRSjas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568909555; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=epZU7tWM0hLGcXVUSrEaiuc0RZsraN5+zVt1jnAYzr4=; b=HsqAMlj5YQQGBIJLhLvL8h0eDy0Sqr6+fy+X2xfJt8DbwOGoVPzPZ84U7xqnGM+xkJz2TyzIjdPyeditPYJnlfarqBVmSSsvhb0aTBIewZbEXhps5Pw4JbdoYND0nTYceV0nU3WzeRRPukvwmEuZB5Z5gnU6243lMmvDWz/+4i0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568909555780628.1447018739583; Thu, 19 Sep 2019 09:12:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18B7C8A1C9C; Thu, 19 Sep 2019 16:12:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E56D660628; Thu, 19 Sep 2019 16:12:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A440018037CD; Thu, 19 Sep 2019 16:12:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8JGAXic032285 for ; Thu, 19 Sep 2019 12:10:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3900D60C18; Thu, 19 Sep 2019 16:10:33 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B322F60BF1 for ; Thu, 19 Sep 2019 16:10:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 18:10:19 +0200 Message-Id: <5962f499b1ea0fc8ce7be50687295accf3c33e3a.1568909221.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] qemu: monitor: Don't escape HMP commands just to unescape them right away X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Thu, 19 Sep 2019 16:12:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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 --- src/qemu/qemu_monitor.c | 17 +---------------- src/qemu/qemu_monitor_text.c | 28 +++++----------------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6a09ba91ed..c15b194bb5 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1258,24 +1258,9 @@ qemuMonitorHMPCommand(qemuMonitorPtr mon, const char *cmd, char **reply) { - char *json_cmd =3D NULL; - int ret =3D -1; - QEMU_CHECK_MONITOR(mon); - /* hack to avoid complicating each call to text monitor functions */ - json_cmd =3D 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 =3D qemuMonitorJSONHumanCommand(mon, json_cmd, reply); - - cleanup: - VIR_FREE(json_cmd); - return ret; + return qemuMonitorJSONHumanCommand(mon, cmd, reply); } diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index a15c3df76e..7bc28e54c0 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -38,15 +38,10 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon, char *cmd =3D NULL; char *reply =3D NULL; int ret =3D -1; - char *safe_str; - - safe_str =3D 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 =3D NULL; char *reply =3D NULL; - char *safedev; int ret =3D -1; - if (!(safedev =3D 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 =3D NULL; char *reply =3D NULL; int ret =3D -1; - char *safename; - if (!(safename =3D 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 =3D 0; cleanup: - VIR_FREE(safename); VIR_FREE(cmd); VIR_FREE(reply); return ret; @@ -179,8 +165,7 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, con= st char *name) int ret =3D -1; char *safename; - if (!(safename =3D 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 =3D NULL; char *reply =3D NULL; int ret =3D -1; - char *safename; - if (!(safename =3D 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, c= onst char *name) ret =3D 0; cleanup: - VIR_FREE(safename); VIR_FREE(cmd); VIR_FREE(reply); return ret; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list