From patchwork Fri Apr 22 22:46: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: 66508 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp972842qge; Fri, 22 Apr 2016 15:50:25 -0700 (PDT) X-Received: by 10.194.41.104 with SMTP id e8mr21544620wjl.177.1461365425199; Fri, 22 Apr 2016 15:50:25 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id iv3si11115864wjb.153.2016.04.22.15.50.24 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Apr 2016 15:50:25 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 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 mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3MMleDw026856; Fri, 22 Apr 2016 18:47:40 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3MMl1ik005750 for ; Fri, 22 Apr 2016 18:47:01 -0400 Received: from colepc.redhat.com (ovpn-113-101.phx2.redhat.com [10.3.113.101]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3MMkxe8020389; Fri, 22 Apr 2016 18:47:00 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 22 Apr 2016 18:46:53 -0400 Message-Id: <41c9fe277b73ad8ea6a527ddb484f649340d6fdf.1461365053.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] qemu: command: escape commas in VM name 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 This isn't sufficient on its own, since the VM name is used for things like monitor paths, which we don't escape yet --- src/qemu/qemu_command.c | 2 +- .../qemuxml2argvdata/qemuxml2argv-name-escape.args | 24 ++++++++++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-name-escape.xml | 18 ++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-name-escape.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-name-escape.xml -- 2.7.3 -- 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 ef4a62d..8324639 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6729,7 +6729,7 @@ qemuBuildNameCommandLine(virCommandPtr cmd, virCommandAddArg(cmd, "-name"); - virBufferAsprintf(&buf, "%s", def->name); + virBufferEscape(&buf, ',', ",", "%s", def->name); if (cfg->setProcessName && virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_PROCESS)) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args new file mode 100644 index 0000000..94a3133 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args @@ -0,0 +1,24 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +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,\ +bar/master-key.aes \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-foo,bar/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-usb \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.xml b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.xml new file mode 100644 index 0000000..3a8c3cd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.xml @@ -0,0 +1,18 @@ + + foo,bar + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8842b2f..13b07c7 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1875,6 +1875,8 @@ mymain(void) VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS, NONE); + DO_TEST("name-escape", QEMU_CAPS_NAME_DEBUG_THREADS, + QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_CHARDEV); DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);