From patchwork Sun May 8 18:43:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 67329 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1260999qge; Sun, 8 May 2016 11:47:10 -0700 (PDT) X-Received: by 10.233.232.16 with SMTP id a16mr32699337qkg.25.1462733230473; Sun, 08 May 2016 11:47:10 -0700 (PDT) Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com. [209.132.183.39]) by mx.google.com with ESMTPS id a185si16323554qha.39.2016.05.08.11.47.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 May 2016 11:47:10 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 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 mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u48Ihm1R007932; Sun, 8 May 2016 14:43:48 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u48Ihjsj016810 for ; Sun, 8 May 2016 14:43:45 -0400 Received: from colepc.redhat.com (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u48IhhIV024246; Sun, 8 May 2016 14:43:44 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Sun, 8 May 2016 14:43:36 -0400 Message-Id: <886f322529c8ee4bf8eea4fac1f810c0304e0a83.1462732781.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 1/6] qemu: command: Add qemuBufferEscapeComma 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 Centralize the magic invocation for escaping commas on the qemu command line, and document it a bit --- src/qemu/qemu_command.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 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 2966b07..e400e5f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -149,6 +149,22 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST, "preferred", "interleave"); + +/** + * qemuBufferEscapeComma: + * @buf: buffer to append the escaped string + * @str: the string to escape + * + * qemu requires that any values passed on the command line which contain + * a ',' must escape it using an extra ',' as the escape character + */ +static void +qemuBufferEscapeComma(virBufferPtr buf, const char *str) +{ + virBufferEscape(buf, ',', ",", "%s", str); +} + + /** * qemuBuildHasMasterKey: * @qemuCaps: QEMU binary capabilities @@ -1213,7 +1229,8 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, break; } - virBufferEscape(&opt, ',', ",", "%s,", source); + qemuBufferEscapeComma(&opt, source); + virBufferAddLit(&opt, ","); if (disk->src->format > 0 && disk->src->type != VIR_STORAGE_TYPE_DIR) @@ -3785,7 +3802,7 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, goto error; } virBufferAsprintf(&buf, "virtio-input-host%s,id=%s,evdev=", suffix, dev->info.alias); - virBufferEscape(&buf, ',', ",", "%s", dev->source.evdev); + qemuBufferEscapeComma(&buf, dev->source.evdev); break; case VIR_DOMAIN_INPUT_TYPE_LAST: break; @@ -9086,10 +9103,10 @@ qemuBuildTPMBackendStr(const virDomainDef *def, goto error; } virBufferAddLit(&buf, ",path="); - virBufferEscape(&buf, ',', ",", "%s", devset ? devset : tpmdev); + qemuBufferEscapeComma(&buf, devset ? devset : tpmdev); virBufferAddLit(&buf, ",cancel-path="); - virBufferEscape(&buf, ',', ",", "%s", cancel_path); + qemuBufferEscapeComma(&buf, cancel_path); VIR_FREE(devset); VIR_FREE(cancel_path);