From nobody Sun May 5 09:50:20 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529500644110294.58078531962883; Wed, 20 Jun 2018 06:17:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EB38550CF; Wed, 20 Jun 2018 13:17:22 +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 0FA6C308BDAE; Wed, 20 Jun 2018 13:17:22 +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 A4E6C24F62; Wed, 20 Jun 2018 13:17:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5KDHBL1012571 for ; Wed, 20 Jun 2018 09:17:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 583E320180F2; Wed, 20 Jun 2018 13:17:11 +0000 (UTC) Received: from dhcp-17-130.bos.redhat.com (dhcp-17-130.bos.redhat.com [10.18.17.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4068E2026D6B; Wed, 20 Jun 2018 13:17:11 +0000 (UTC) From: Anya Harter To: libvir-list@redhat.com Date: Wed, 20 Jun 2018 09:16:59 -0400 Message-Id: <96628e00423dba389523e593ee7018758917bbe6.1529441081.git.aharter@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Anya Harter Subject: [libvirt] [PATCH 1/2] qemu: use virBuffer in qemuBuildSCSIiSCSIHostdevDrvStr 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 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Jun 2018 13:17:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of source to enable use of virBuffer functions in string construction. Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e05b106a5e..a99240992a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4657,7 +4657,8 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { - char *source =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + char *netsource =3D NULL; virJSONValuePtr srcprops =3D NULL; virDomainHostdevSubsysSCSIPtr scsisrc =3D &dev->source.subsys.u.scsi; @@ -4670,21 +4671,25 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef= Ptr dev, goto cleanup; if (!(netsource =3D virQEMUBuildDriveCommandlineFromJSON(srcprops)= )) goto cleanup; - if (virAsprintf(&source, "%s,if=3Dnone,format=3Draw", netsource) <= 0) - goto cleanup; + virBufferAsprintf(&buf, "%s,if=3Dnone,format=3Draw", netsource); } else { /* Rather than pull what we think we want - use the network disk c= ode */ if (!(netsource =3D qemuBuildNetworkDriveStr(iscsisrc->src, srcPri= v ? srcPriv->secinfo : NULL= ))) goto cleanup; - if (virAsprintf(&source, "file=3D%s,if=3Dnone,format=3Draw", netso= urce) < 0) - goto cleanup; + virBufferAsprintf(&buf, "file=3D%s,if=3Dnone,format=3Draw", netsou= rce); } =20 + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + return virBufferContentAndReset(&buf); + cleanup: VIR_FREE(netsource); virJSONValueFree(srcprops); - return source; + virBufferFreeAndReset(&buf); + return NULL; } =20 char * --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 09:50:20 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152950063763227.54348982910051; Wed, 20 Jun 2018 06:17:17 -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 295324E8A8; Wed, 20 Jun 2018 13:17:16 +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 C9D49608F6; Wed, 20 Jun 2018 13:17:15 +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 5332D1800537; Wed, 20 Jun 2018 13:17:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5KDHBe8012577 for ; Wed, 20 Jun 2018 09:17:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7BD2B20180F5; Wed, 20 Jun 2018 13:17:11 +0000 (UTC) Received: from dhcp-17-130.bos.redhat.com (dhcp-17-130.bos.redhat.com [10.18.17.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 639502026D6B; Wed, 20 Jun 2018 13:17:11 +0000 (UTC) From: Anya Harter To: libvir-list@redhat.com Date: Wed, 20 Jun 2018 09:17:00 -0400 Message-Id: <408fc42b322da7319f45aeff3a5d4854e770d591.1529441081.git.aharter@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Anya Harter Subject: [libvirt] [PATCH 2/2] qemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr 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 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.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Jun 2018 13:17:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add comma escaping for netsource Signed-off-by: Anya Harter --- src/qemu/qemu_command.c | 4 +++- tests/qemuxml2argvdata/name-escape.args | 6 +++++- tests/qemuxml2argvdata/name-escape.xml | 7 +++++++ tests/qemuxml2argvtest.c | 5 ++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a99240992a..96c6c08c2d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4677,7 +4677,9 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPt= r dev, if (!(netsource =3D qemuBuildNetworkDriveStr(iscsisrc->src, srcPri= v ? srcPriv->secinfo : NULL= ))) goto cleanup; - virBufferAsprintf(&buf, "file=3D%s,if=3Dnone,format=3Draw", netsou= rce); + virBufferAddLit(&buf, "file=3D"); + virQEMUBuildBufferEscapeComma(&buf, netsource); + virBufferAddLit(&buf, ",if=3Dnone,format=3Draw"); } =20 if (virBufferCheckError(&buf) < 0) diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvda= ta/name-escape.args index aef7c238ca..1cbb1efd66 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -22,6 +22,7 @@ bar=3D2/monitor.sock,server,nowait \ -no-shutdown \ -no-acpi \ -boot c \ +-device lsi,id=3Dscsi0,bus=3Dpci.0,addr=3D0x3 \ -device usb-ccid,id=3Dccid0,bus=3Dusb.0,port=3D1 \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Dqcow2,if=3Dnone,id=3Ddrive-i= de0-0-0,\ @@ -41,4 +42,7 @@ cert3=3Dcert3,db=3D/etc/pki/nssdb,,foo,id=3Dsmartcard0,bu= s=3Dccid0.0 \ -spice unix,addr=3D/tmp/lib/domain--1-foo=3D1,,bar=3D2/spice.sock,gl=3Don,\ rendernode=3D/dev/dri/foo,,bar \ -device cirrus-vga,id=3Dvideo0,bus=3Dpci.0,addr=3D0x2 \ --device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 +-drive file=3Discsi://example,,foo.org:3260/iqn.1992-01.com.example/0,if= =3Dnone,\ +format=3Draw,id=3Ddrive-hostdev0 \ +-device scsi-generic,bus=3Dscsi0.0,scsi-id=3D4,drive=3Ddrive-hostdev0,id= =3Dhostdev0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdat= a/name-escape.xml index 70a1ce09d3..24dd248842 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -27,6 +27,13 @@
+ + + + + +
+ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 582a9de7bb..2e891a0bea 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2772,7 +2772,10 @@ mymain(void) QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_CHARDEV_FILE_APPEND, - QEMU_CAPS_CCID_EMULATED); + QEMU_CAPS_CCID_EMULATED, + QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_SCSI_LSI, + QEMU_CAPS_DEVICE_SCSI_GENERIC); DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); =20 DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list