From nobody Mon Feb 9 00:56:17 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=1568909563; cv=none; d=zoho.com; s=zohoarc; b=iQk06sTa7ugW/SftoNsEt04AIEJFF0kzhtYQ+hISoHrkH7O1GJq51LO/tBpV/9fOZ6btR7wntPcxzIGDqqvO9Id8oxZVqjl/W90gQntTlTe3yFnmBdd+YM5mu/KYToe1z9ClPl8IphTdJ9gVW06+zzdtNtqArC+LCaLXhZ01oiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568909563; 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=dPBIS6scpn95iVn7P/arFEoR8tJvriEnDa7Hc7geDJ8=; b=hWpZMdcL4xdXccVFy87OaStUunZSwzMcvOXiSOztxOcrfj7aAavmLdZdIVNKGvtQoIyOcEHqV9SaxL9cnynYPA1dxNqD4u8PMH6yHFR6BobPDTMJYieWJHSs63ETVCPoGish1NwYCdjrJPLyRdQCT6PnPyE51dsG45G5vaIH9pY= 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 1568909563457955.922967197843; Thu, 19 Sep 2019 09:12:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8B97302C095; Thu, 19 Sep 2019 16:12:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EBC210027B9; Thu, 19 Sep 2019 16:12:41 +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 3A6594EE6D; Thu, 19 Sep 2019 16:12:41 +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 x8JGAYBO032295 for ; Thu, 19 Sep 2019 12:10:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0A55C60C18; Thu, 19 Sep 2019 16:10:34 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86B5660BF1 for ; Thu, 19 Sep 2019 16:10:33 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 18:10:20 +0200 Message-Id: <2ccf90cdde64a58154e0d6f4fde847f1d091abac.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 5/8] qemu: monitor: Remove HMP command (un)escaping infrastructure 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 19 Sep 2019 16:12:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We don't need to escape the commands any more since we use QMP passthrough, which means we can delete the functions. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 93 ------------------------------------ src/qemu/qemu_monitor.h | 3 -- tests/qemumonitortestutils.c | 6 +-- 3 files changed, 1 insertion(+), 101 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c15b194bb5..f52a381982 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -197,99 +197,6 @@ VIR_ENUM_IMPL(qemuMonitorDumpStatus, "none", "active", "completed", "failed", ); -char * -qemuMonitorEscapeArg(const char *in) -{ - int len =3D 0; - size_t i, j; - char *out; - - /* To pass through the QEMU monitor, we need to use escape - sequences: \r, \n, \", \\ - */ - - for (i =3D 0; in[i] !=3D '\0'; i++) { - switch (in[i]) { - case '\r': - case '\n': - case '"': - case '\\': - len +=3D 2; - break; - default: - len +=3D 1; - break; - } - } - - if (VIR_ALLOC_N(out, len + 1) < 0) - return NULL; - - for (i =3D j =3D 0; in[i] !=3D '\0'; i++) { - switch (in[i]) { - case '\r': - out[j++] =3D '\\'; - out[j++] =3D 'r'; - break; - case '\n': - out[j++] =3D '\\'; - out[j++] =3D 'n'; - break; - case '"': - case '\\': - out[j++] =3D '\\'; - out[j++] =3D in[i]; - break; - default: - out[j++] =3D in[i]; - break; - } - } - out[j] =3D '\0'; - - return out; -} - - -char * -qemuMonitorUnescapeArg(const char *in) -{ - size_t i, j; - char *out; - int len =3D strlen(in); - char next; - - if (VIR_ALLOC_N(out, len + 1) < 0) - return NULL; - - for (i =3D j =3D 0; i < len; ++i) { - next =3D in[i]; - if (in[i] =3D=3D '\\') { - ++i; - switch (in[i]) { - case 'r': - next =3D '\r'; - break; - case 'n': - next =3D '\n'; - break; - case '"': - case '\\': - next =3D in[i]; - break; - default: - /* invalid input (including trailing '\' at end of in) */ - VIR_FREE(out); - return NULL; - } - } - out[j++] =3D next; - } - out[j] =3D '\0'; - - return out; -} - #if DEBUG_RAW_IO # include diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 7385fafeea..af1ec56525 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -382,9 +382,6 @@ struct _qemuMonitorCallbacks { qemuMonitorDomainRdmaGidStatusChangedCallback domainRdmaGidStatusChang= ed; }; -char *qemuMonitorEscapeArg(const char *in); -char *qemuMonitorUnescapeArg(const char *in); - qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm, virDomainChrSourceDefPtr config, bool retry, diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 4cc07b8772..e9dff123f8 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -187,7 +187,6 @@ int ATTRIBUTE_FMT_PRINTF(2, 3) qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...) { va_list msgargs; - VIR_AUTOFREE(char *) tmp =3D NULL; VIR_AUTOFREE(char *) msg =3D NULL; VIR_AUTOFREE(char *) jsonmsg =3D NULL; int ret =3D -1; @@ -197,13 +196,10 @@ qemuMonitorReportError(qemuMonitorTestPtr test, const= char *errmsg, ...) if (virVasprintf(&msg, errmsg, msgargs) < 0) goto cleanup; - if (!(tmp =3D qemuMonitorEscapeArg(msg))) - goto cleanup; - if (virAsprintf(&jsonmsg, "{ \"error\": " " { \"desc\": \"%s\", " " \"class\": \"UnexpectedCommand\" } }", - tmp) < 0) + msg) < 0) goto cleanup; ret =3D qemuMonitorTestAddResponse(test, jsonmsg); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list