From nobody Thu May 15 09:46:04 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719457138944.3751159755964; Fri, 3 Nov 2017 07:30:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 668914E90B; Fri, 3 Nov 2017 14:30:55 +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 0A4565D979; Fri, 3 Nov 2017 14:30:55 +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 F0C234BB79; Fri, 3 Nov 2017 14:30:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vA3ETnql028702 for ; Fri, 3 Nov 2017 10:29:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8E7560618; Fri, 3 Nov 2017 14:29:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3050B60851 for ; Fri, 3 Nov 2017 14:29:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 668914E90B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 3 Nov 2017 15:29:18 +0100 Message-Id: <192e5a941b31a936b57641799a4439998e8fe627.1509719227.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/12] qemu: block: Use proper type for servers for VxHS disks 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 03 Nov 2017 14:30:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Original implementation used 'SocketAddress' equivalent from qemu for the disk server field, while qemu documentation specifies 'InetSocketAddress'. The backing store parser uses the correct parsing function but the formatter used the incorrect one (and also with the legacy mode enabled which was wrong). --- src/qemu/qemu_block.c | 36 ++++++++++++++++++= +++- ...muxml2argv-disk-drive-network-tlsx509-vxhs.args | 8 ++--- .../qemuxml2argv-disk-drive-network-vxhs.args | 4 +-- tests/virstoragetest.c | 3 +- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 0761f8991..96db19226 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -501,6 +501,40 @@ qemuBlockStorageSourceBuildHostsJSONSocketAddress(virS= torageSourcePtr src, } +/** + * qemuBlockStorageSourceBuildJSONInetSocketAddress + * @host: the virStorageNetHostDefPtr definition to build + * + * Formats @hosts into a json object conforming to the 'InetSocketAddress'= type + * in qemu. + * + * Returns a virJSONValuePtr for a single server. + */ +static virJSONValuePtr +qemuBlockStorageSourceBuildJSONInetSocketAddress(virStorageNetHostDefPtr h= ost) +{ + virJSONValuePtr ret =3D NULL; + char *port =3D NULL; + + if (host->transport !=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("only TCP protocol can be converted to InetSocket= Address")); + return NULL; + } + + if (virAsprintf(&port, "%u", host->port) < 0) + return NULL; + + ignore_value(virJSONValueObjectCreate(&ret, + "s:host", host->name, + "s:port", port, + NULL)); + + VIR_FREE(port); + return ret; +} + + static virJSONValuePtr qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src) { @@ -540,7 +574,7 @@ qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr = src) return NULL; } - if (!(server =3D qemuBlockStorageSourceBuildJSONSocketAddress(src->hos= ts, true))) + if (!(server =3D qemuBlockStorageSourceBuildJSONInetSocketAddress(&src= ->hosts[0]))) return NULL; /* VxHS disk specification example: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-tlsx509= -vxhs.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-tlsx509= -vxhs.args index a75272454..eaa8699a9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-tlsx509-vxhs.a= rgs +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-tlsx509-vxhs.a= rgs @@ -23,7 +23,7 @@ server,nowait \ -object tls-creds-x509,id=3Dobjvirtio-disk0_tls0,dir=3D/etc/pki/libvirt-vx= hs,\ endpoint=3Dclient,verify-peer=3Dyes \ -drive file.driver=3Dvxhs,file.tls-creds=3Dobjvirtio-disk0_tls0,\ -file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4dc251,file.server.type=3Dtc= p,\ +file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4dc251,\ file.server.host=3D192.168.0.1,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ id=3Ddrive-virtio-disk0,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ @@ -31,13 +31,13 @@ id=3Dvirtio-disk0 \ -object tls-creds-x509,id=3Dobjvirtio-disk1_tls0,dir=3D/etc/pki/libvirt-vx= hs,\ endpoint=3Dclient,verify-peer=3Dyes \ -drive file.driver=3Dvxhs,file.tls-creds=3Dobjvirtio-disk1_tls0,\ -file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4dc252,file.server.type=3Dtc= p,\ +file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4dc252,\ file.server.host=3D192.168.0.2,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ id=3Ddrive-virtio-disk1,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x5,drive=3Ddrive-virtio-disk1,\ id=3Dvirtio-disk1 \ -drive file.driver=3Dvxhs,file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4d= c253,\ -file.server.type=3Dtcp,file.server.host=3D192.168.0.3,file.server.port=3D9= 999,\ -format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk2,cache=3Dnone \ +file.server.host=3D192.168.0.3,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ +id=3Ddrive-virtio-disk2,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x6,drive=3Ddrive-virtio-disk2,\ id=3Dvirtio-disk2 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-vxhs.ar= gs b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-vxhs.args index b62ace3de..1747dc80f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-vxhs.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-vxhs.args @@ -21,7 +21,7 @@ server,nowait \ -boot c \ -usb \ -drive file.driver=3Dvxhs,file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4d= c251,\ -file.server.type=3Dtcp,file.server.host=3D192.168.0.1,file.server.port=3D9= 999,\ -format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk0,cache=3Dnone \ +file.server.host=3D192.168.0.1,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ +id=3Ddrive-virtio-disk0,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ id=3Dvirtio-disk0 diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index e1d875172..78f24ad78 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1601,8 +1601,7 @@ mymain(void) "\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"vxhs\"," "\"vdisk-id\":\"c6718f6b-0401-441d-= a8c3-1f0064d75ee0\"," - "\"server\": { \"type\":\"tcp\"," - "\"host\":\"example.= com\"," + "\"server\": { \"host\":\"example.= com\"," "\"port\":\"9999\"" "}" "}" --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list