From patchwork Wed May 4 14:56:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 67141 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp229784qge; Wed, 4 May 2016 07:59:43 -0700 (PDT) X-Received: by 10.176.3.172 with SMTP id 41mr5906911uau.108.1462373983168; Wed, 04 May 2016 07:59:43 -0700 (PDT) Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com. [209.132.183.37]) by mx.google.com with ESMTPS id 38si2566109uai.40.2016.05.04.07.59.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 07:59:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u44EvCRt027525; Wed, 4 May 2016 10:57:12 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u44Ev1Yo008254 for ; Wed, 4 May 2016 10:57:01 -0400 Received: from colepc.redhat.com (ovpn-113-44.phx2.redhat.com [10.3.113.44]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u44EuxH1010179; Wed, 4 May 2016 10:57:00 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 4 May 2016 10:56:53 -0400 Message-Id: <58f5269f061bd3c9494019eebd0d4b032fbe5b01.1462314536.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/4] qemu: command: escape commas in secret master path 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: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com Need to convert the local function to virBuffer usage, so we can use virBufferEscape --- src/qemu/qemu_command.c | 7 +++++-- tests/qemuxml2argvdata/qemuxml2argv-name-escape.args | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b13df49..d54d0d1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -180,6 +180,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd, int ret = -1; char *alias = NULL; char *path = NULL; + virBuffer buf = VIR_BUFFER_INITIALIZER; /* If the -object secret does not exist, then just return. This just * means the domain won't be able to use a secret master key and is @@ -202,12 +203,14 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd, goto cleanup; virCommandAddArg(cmd, "-object"); - virCommandAddArgFormat(cmd, "secret,id=%s,format=raw,file=%s", - alias, path); + virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias); + virBufferEscape(&buf, ',', ",", "%s", path); + virCommandAddArgBuffer(cmd, &buf); ret = 0; cleanup: + virBufferFreeAndReset(&buf); VIR_FREE(alias); VIR_FREE(path); return ret; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args index 94a3133..a5e35b8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args @@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=none \ /usr/bin/qemu \ -name foo,,bar,debug-threads=on \ -S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-foo,\ +-object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-foo,,\ bar/master-key.aes \ -M pc \ -m 214 \