From nobody Sat May 4 09:07:44 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 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 From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719463471954.2413346980625; Fri, 3 Nov 2017 07:31:03 -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 C4E596A09; Fri, 3 Nov 2017 14:31:01 +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 8FCE05D973; Fri, 3 Nov 2017 14:31:01 +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 4803C1800BD1; Fri, 3 Nov 2017 14:31:01 +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 vA3ETqHb028715 for ; Fri, 3 Nov 2017 10:29:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 693AC60618; Fri, 3 Nov 2017 14:29:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id E55BE60619 for ; Fri, 3 Nov 2017 14:29:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C4E596A09 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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:19 +0100 Message-Id: <685f5c1976dafdf7c85e524b9ef89d1604cb1785.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 02/12] qemu: process: Split out useful parts from qemuBuildNetworkDriveURI 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.39]); Fri, 03 Nov 2017 14:31:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract the part formatting the basic URI part so that it can be reused to format JSON backing definitions. Parts specific to the command line format will remain in qemuBuildNetworkDriveURI. The new function is called qemuBlockStorageSourceGetURI. --- src/qemu/qemu_block.c | 58 +++++++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_block.h | 4 ++++ src/qemu/qemu_command.c | 38 +------------------------------- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 96db19226..018d7c7ec 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -390,6 +390,64 @@ qemuBlockGetNodeData(virJSONValuePtr data) } +/** + * qemuBlockStorageSourceGetURI: + * @src: disk storage source + * + * Formats a URI from a virStorageSource */ +virURIPtr +qemuBlockStorageSourceGetURI(virStorageSourcePtr src) +{ + virURIPtr uri =3D NULL; + virURIPtr ret =3D NULL; + + if (src->nhosts !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("protocol '%s' accepts only one host"), + virStorageNetProtocolTypeToString(src->protocol)); + goto cleanup; + } + + if (VIR_ALLOC(uri) < 0) + goto cleanup; + + if (src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { + uri->port =3D src->hosts->port; + + if (VIR_STRDUP(uri->scheme, + virStorageNetProtocolTypeToString(src->protocol)) <= 0) + goto cleanup; + } else { + if (virAsprintf(&uri->scheme, "%s+%s", + virStorageNetProtocolTypeToString(src->protocol), + virStorageNetHostTransportTypeToString(src->hosts-= >transport)) < 0) + goto cleanup; + } + + if (src->path) { + if (src->volume) { + if (virAsprintf(&uri->path, "/%s%s", + src->volume, src->path) < 0) + goto cleanup; + } else { + if (virAsprintf(&uri->path, "%s%s", + src->path[0] =3D=3D '/' ? "" : "/", + src->path) < 0) + goto cleanup; + } + } + + if (VIR_STRDUP(uri->server, src->hosts->name) < 0) + goto cleanup; + + VIR_STEAL_PTR(ret, uri); + + cleanup: + virURIFree(uri); + return ret; +} + + /** * qemuBlockStorageSourceBuildJSONSocketAddress * @host: the virStorageNetHostDefPtr definition to build diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index f0a2c9aa7..b9ee97f48 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -26,6 +26,7 @@ # include "virhash.h" # include "virjson.h" +# include "viruri.h" typedef struct qemuBlockNodeNameBackingChainData qemuBlockNodeNameBackingC= hainData; typedef qemuBlockNodeNameBackingChainData *qemuBlockNodeNameBackingChainDa= taPtr; @@ -56,4 +57,7 @@ qemuBlockGetNodeData(virJSONValuePtr data); virJSONValuePtr qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src); +virURIPtr +qemuBlockStorageSourceGetURI(virStorageSourcePtr src); + #endif /* __QEMU_BLOCK_H__ */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b1cfafa79..25d5fdf18 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -829,41 +829,8 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, virURIPtr uri =3D NULL; char *ret =3D NULL; - if (src->nhosts !=3D 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("protocol '%s' accepts only one host"), - virStorageNetProtocolTypeToString(src->protocol)); + if (!(uri =3D qemuBlockStorageSourceGetURI(src))) goto cleanup; - } - - if (VIR_ALLOC(uri) < 0) - goto cleanup; - - if (src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { - uri->port =3D src->hosts->port; - - if (VIR_STRDUP(uri->scheme, - virStorageNetProtocolTypeToString(src->protocol)) <= 0) - goto cleanup; - } else { - if (virAsprintf(&uri->scheme, "%s+%s", - virStorageNetProtocolTypeToString(src->protocol), - virStorageNetHostTransportTypeToString(src->hosts-= >transport)) < 0) - goto cleanup; - } - - if (src->path) { - if (src->volume) { - if (virAsprintf(&uri->path, "/%s%s", - src->volume, src->path) < 0) - goto cleanup; - } else { - if (virAsprintf(&uri->path, "%s%s", - src->path[0] =3D=3D '/' ? "" : "/", - src->path) < 0) - goto cleanup; - } - } if (src->hosts->socket && virAsprintf(&uri->query, "socket=3D%s", src->hosts->socket) < 0) @@ -872,9 +839,6 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, if (qemuBuildGeneralSecinfoURI(uri, secinfo) < 0) goto cleanup; - if (VIR_STRDUP(uri->server, src->hosts->name) < 0) - goto cleanup; - ret =3D virURIFormat(uri); cleanup: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150971953375860.234498240570815; Fri, 3 Nov 2017 07:32:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6236D4E90D; Fri, 3 Nov 2017 14:32:12 +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 15F7A5EE02; Fri, 3 Nov 2017 14:32:12 +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 BD04714B1C; Fri, 3 Nov 2017 14:32:11 +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 vA3ETrFg028720 for ; Fri, 3 Nov 2017 10:29:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C4AC60618; Fri, 3 Nov 2017 14:29:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id B724C60619 for ; Fri, 3 Nov 2017 14:29:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6236D4E90D 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:20 +0100 Message-Id: <8cf0392318993ab406948ce4e2de098a7b7cc94f.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 03/12] storage: Don't store leading '/' in image name when splitting out volume 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.15 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:32:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Libvirt historically stores storage source path including the volume as one string in the XML, but that is not really flexible enough when dealing with the fields in the code. Previously we'd store the slash separating the two as part of the image name. This was fine for gluster but it's not necessary and does not scale well when converting other protocols. Don't store the slash as part of the path. The resulting change from absolute to relative path within the gluster driver should be okay, as the root directory is the default when accessing gluster. --- src/conf/domain_conf.c | 4 ++= -- src/qemu/qemu_block.c | 2 +- src/util/virstoragefile.c | 4 ++= -- tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 77c20c697..01cd3811c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8398,7 +8398,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, src->volume =3D src->path; - if (VIR_STRDUP(src->path, tmp) < 0) + if (VIR_STRDUP(src->path, tmp + 1) < 0) goto cleanup; tmp[0] =3D '\0'; @@ -22158,7 +22158,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrB= uf, virStorageNetProtocolTypeToString(src->protocol)); if (src->volume) { - if (virAsprintf(&path, "%s%s", src->volume, src->path) < 0) + if (virAsprintf(&path, "%s/%s", src->volume, src->path) < 0) return -1; } diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 018d7c7ec..08020d797 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -426,7 +426,7 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src) if (src->path) { if (src->volume) { - if (virAsprintf(&uri->path, "/%s%s", + if (virAsprintf(&uri->path, "/%s/%s", src->volume, src->path) < 0) goto cleanup; } else { diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3a2d2aa05..d48358abb 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2450,7 +2450,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, src->volume =3D src->path; - if (VIR_STRDUP(src->path, tmp) < 0) + if (VIR_STRDUP(src->path, tmp + 1) < 0) goto cleanup; tmp[0] =3D '\0'; @@ -2931,7 +2931,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSou= rcePtr src, src->protocol =3D VIR_STORAGE_NET_PROTOCOL_GLUSTER; if (VIR_STRDUP(src->volume, volume) < 0 || - virAsprintf(&src->path, "/%s", path) < 0) + VIR_STRDUP(src->path, path) < 0) return -1; nservers =3D virJSONValueArraySize(server); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster= .args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args index 990616955..6cfbe36fe 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args @@ -27,7 +27,7 @@ id=3Dvirtio-disk0 \ format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk1' \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk1,\ id=3Dvirtio-disk1 \ --drive file.driver=3Dgluster,file.volume=3DVolume3,file.path=3D/Image.qcow= 2,\ +-drive file.driver=3Dgluster,file.volume=3DVolume3,file.path=3DImage.qcow2= ,\ file.server.0.type=3Dtcp,file.server.0.host=3Dexample.org,file.server.0.po= rt=3D6000,\ file.server.1.type=3Dtcp,file.server.1.host=3Dexample.org,file.server.1.po= rt=3D24007,\ file.server.2.type=3Dunix,file.server.2.socket=3D/path/to/sock,file.debug= =3D4,\ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719464970769.8983890441284; Fri, 3 Nov 2017 07:31:04 -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 80CAB8048C; Fri, 3 Nov 2017 14:31:02 +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 5696C60621; Fri, 3 Nov 2017 14:31:02 +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 1BDC04A469; Fri, 3 Nov 2017 14:31:02 +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 vA3ETsJB028726 for ; Fri, 3 Nov 2017 10:29:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 228406061B; Fri, 3 Nov 2017 14:29:54 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DCB460619 for ; Fri, 3 Nov 2017 14:29:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80CAB8048C Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.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:21 +0100 Message-Id: <0e922c4ed929275cb57f5bfc4cde658830786f58.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 04/12] storage: Store RBD image name as pool and image 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 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.28]); Fri, 03 Nov 2017 14:31:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Similarly to how we store gluster names, split the name into a pool and image portions when paring the XML and store them separately. --- src/conf/domain_conf.c | 13 +++++++------ src/libxl/libxl_conf.c | 2 +- src/qemu/qemu_command.c | 2 +- src/util/virstoragefile.c | 22 +++++++++++---------= -- src/xenconfig/xen_xl.c | 2 +- tests/domainsnapshotxml2xmlin/disk_snapshot.xml | 2 +- tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 2 +- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 01cd3811c..a7fe1ac85 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8383,16 +8383,17 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, src->tlsFromConfig =3D !!tlsCfgVal; } - /* for historical reasons the volume name for gluster volume is stored - * as a part of the path. This is hard to work with when dealing with - * relative names. Split out the volume into a separate variable */ - if (src->path && src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER= ) { + /* for historical reasons we store the volume and image name in one XML + * element although it complicates thing when attempting to access the= m. */ + if (src->path && + (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER || + src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD)) { char *tmp; if (!(tmp =3D strchr(src->path, '/')) || tmp =3D=3D src->path) { virReportError(VIR_ERR_XML_ERROR, - _("missing volume name or file name in " - "gluster source path '%s'"), src->path); + _("can't split path '%s' into pool name and ima= ge " + "name"), src->path); goto cleanup; } diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index ecbabfc79..63397e94c 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -657,7 +657,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src, goto cleanup; } - virBufferStrcat(&buf, "rbd:", src->path, NULL); + virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL); if (username) { virBufferEscape(&buf, '\\', ":", ":id=3D%s", username); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 25d5fdf18..0dcdc8976 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -951,7 +951,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src, goto cleanup; } - virBufferStrcat(&buf, "rbd:", src->path, NULL); + virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NUL= L); if (src->snapshot) virBufferEscape(&buf, '\\', ":", "@%s", src->snapshot); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index d48358abb..9cee64312 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2545,6 +2545,14 @@ virStorageSourceParseRBDColonString(const char *rbds= tr, *p =3D '\0'; } + /* pool vs. image name */ + if ((p =3D strchr(src->path, '/'))) { + VIR_STEAL_PTR(src->volume, src->path); + if (VIR_STRDUP(src->path, p + 1) < 0) + goto error; + *p =3D '\0'; + } + /* options */ if (!options) return 0; /* all done */ @@ -3178,7 +3186,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourceP= tr src, const char *conf =3D virJSONValueObjectGetString(json, "conf"); const char *snapshot =3D virJSONValueObjectGetString(json, "snapshot"); virJSONValuePtr servers =3D virJSONValueObjectGetArray(json, "server"); - char *fullname =3D NULL; size_t nservers; size_t i; int ret =3D -1; @@ -3197,17 +3204,12 @@ virStorageSourceParseBackingJSONRBD(virStorageSourc= ePtr src, return -1; } - /* currently we need to store the pool name and image name together, s= ince - * the rest of the code is not prepared for it */ - if (virAsprintf(&fullname, "%s/%s", pool, image) < 0) - return -1; - - if (VIR_STRDUP(src->snapshot, snapshot) < 0 || + if (VIR_STRDUP(src->volume, pool) < 0 || + VIR_STRDUP(src->path, image) < 0 || + VIR_STRDUP(src->snapshot, snapshot) < 0 || VIR_STRDUP(src->configFile, conf) < 0) goto cleanup; - VIR_STEAL_PTR(src->path, fullname); - if (servers) { nservers =3D virJSONValueArraySize(servers); @@ -3225,8 +3227,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourceP= tr src, ret =3D 0; cleanup: - VIR_FREE(fullname); - return ret; } diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 8acbfe3f6..a61f1d7d5 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -1040,7 +1040,7 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src) goto cleanup; } - virBufferStrcat(&buf, "rbd:", src->path, NULL); + virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL); virBufferAddLit(&buf, ":auth_supported=3Dnone"); diff --git a/tests/domainsnapshotxml2xmlin/disk_snapshot.xml b/tests/domain= snapshotxml2xmlin/disk_snapshot.xml index aa1522a45..cf5ea0814 100644 --- a/tests/domainsnapshotxml2xmlin/disk_snapshot.xml +++ b/tests/domainsnapshotxml2xmlin/disk_snapshot.xml @@ -24,7 +24,7 @@ - + diff --git a/tests/domainsnapshotxml2xmlout/disk_snapshot.xml b/tests/domai= nsnapshotxml2xmlout/disk_snapshot.xml index c2e77d7ac..0e81f35c6 100644 --- a/tests/domainsnapshotxml2xmlout/disk_snapshot.xml +++ b/tests/domainsnapshotxml2xmlout/disk_snapshot.xml @@ -23,7 +23,7 @@ - + --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719536586245.55026314683948; Fri, 3 Nov 2017 07:32:16 -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 2010C806C6; Fri, 3 Nov 2017 14:32:15 +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 C236C5D97A; Fri, 3 Nov 2017 14:32:14 +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 8196414B20; Fri, 3 Nov 2017 14:32:14 +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 vA3ETsY9028735 for ; Fri, 3 Nov 2017 10:29:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id E8E156061B; Fri, 3 Nov 2017 14:29:54 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7008860618 for ; Fri, 3 Nov 2017 14:29:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2010C806C6 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:22 +0100 Message-Id: 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 05/12] qemu: block: Add JSON props generator for 'curl' based storage backends 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.26]); Fri, 03 Nov 2017 14:32:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU uses curl for accessing files using http(s) and ftp(s). They share common options so let's generate them in one helper. --- src/qemu/qemu_block.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 08020d797..dedb92fd5 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -652,6 +652,57 @@ qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr= src) } +static virJSONValuePtr +qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src) +{ + qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); + const char *passwordalias =3D NULL; + const char *username =3D NULL; + virJSONValuePtr ret =3D NULL; + virURIPtr uri =3D NULL; + char *uristr =3D NULL; + const char *driver; + + /** + * Common options: + * url, readahead, timeout, username, password-secret, proxy-username, + * proxy-password secret + * + * Options for http transport: + * cookie, cookie-secret + * + * Options for secure transport (ftps, https): + * sslverify + */ + + driver =3D virStorageNetProtocolTypeToString(src->protocol); + + if (!(uri =3D qemuBlockStorageSourceGetURI(src))) + goto cleanup; + + if (!(uristr =3D virURIFormat(uri))) + goto cleanup; + + if (src->auth) { + username =3D src->auth->username; + passwordalias =3D srcPriv->secinfo->s.aes.alias; + } + + ignore_value(virJSONValueObjectCreate(&ret, + "s:driver", driver, + "s:url", uristr, + "S:username", username, + "S:password-secret", passwordali= as, + NULL)); + + cleanup: + virURIFree(uri); + VIR_FREE(uristr); + + return ret; +} + + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -692,15 +743,19 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourc= ePtr src) return NULL; break; - case VIR_STORAGE_NET_PROTOCOL_NBD: - case VIR_STORAGE_NET_PROTOCOL_RBD: - case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: - case VIR_STORAGE_NET_PROTOCOL_ISCSI: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: case VIR_STORAGE_NET_PROTOCOL_FTP: case VIR_STORAGE_NET_PROTOCOL_FTPS: case VIR_STORAGE_NET_PROTOCOL_TFTP: + if (!(fileprops =3D qemuBlockStorageSourceGetCURLProps(src))) + return NULL; + break; + + case VIR_STORAGE_NET_PROTOCOL_NBD: + case VIR_STORAGE_NET_PROTOCOL_RBD: + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + case VIR_STORAGE_NET_PROTOCOL_ISCSI: case VIR_STORAGE_NET_PROTOCOL_SSH: case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_LAST: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719466893658.8264345848787; Fri, 3 Nov 2017 07:31:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 160B1C047B8C; Fri, 3 Nov 2017 14:31:05 +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 D9FD95C7DB; Fri, 3 Nov 2017 14:31:04 +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 A9900410A9; Fri, 3 Nov 2017 14:31:04 +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 vA3ETuEZ028740 for ; Fri, 3 Nov 2017 10:29:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DEDC60636; Fri, 3 Nov 2017 14:29:56 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8856860633 for ; Fri, 3 Nov 2017 14:29:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 160B1C047B8C Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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:23 +0100 Message-Id: <96a37cdbe893053bfc16078685ea3bffbc30cbb3.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 06/12] qemu: block: Add JSON props generator for iSCSI protocol 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 03 Nov 2017 14:31:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: John Ferlan --- src/qemu/qemu_block.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index dedb92fd5..4e588c724 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -703,6 +703,70 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr= src) } +static virJSONValuePtr +qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src) +{ + qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); + const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); + char *target =3D NULL; + char *lunStr =3D NULL; + char *username =3D NULL; + char *objalias =3D NULL; + char *portal =3D NULL; + unsigned int lun =3D 0; + virJSONValuePtr ret =3D NULL; + + /* { driver:"iscsi", + * transport:"tcp", ("iser" also possible) + * portal:"example.com", + * target:"iqn.2017-04.com.example:iscsi-disks", + * lun:1, + * user:"username", + * password-secret:"secret-alias", + * } + */ + + if (VIR_STRDUP(target, src->path) < 0) + goto cleanup; + + /* Separate the target and lun */ + if ((lunStr =3D strchr(target, '/'))) { + *(lunStr++) =3D '\0'; + if (virStrToLong_ui(lunStr, NULL, 10, &lun) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse target for lunStr '%s'"), + target); + goto cleanup; + } + } + + /* combine host and port into portal */ + if (virAsprintf(&portal, "%s:%u", src->hosts[0].name, src->hosts[0].po= rt) < 0) + goto cleanup; + + if (src->auth) { + username =3D src->auth->username; + objalias =3D srcPriv->secinfo->s.aes.alias; + } + + ignore_value(virJSONValueObjectCreate(&ret, + "s:driver", protocol, + "s:portal", portal, + "s:target", target, + "u:lun", lun, + "s:transport", "tcp", + "S:user", username, + "S:password-secret", objalias, + NULL)); + goto cleanup; + + cleanup: + VIR_FREE(target); + VIR_FREE(portal); + return ret; +} + + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -752,10 +816,14 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourc= ePtr src) return NULL; break; + case VIR_STORAGE_NET_PROTOCOL_ISCSI: + if (!(fileprops =3D qemuBlockStorageSourceGetISCSIProps(src))) + return NULL; + break; + case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: - case VIR_STORAGE_NET_PROTOCOL_ISCSI: case VIR_STORAGE_NET_PROTOCOL_SSH: case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_LAST: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150971953994930.897735424599205; Fri, 3 Nov 2017 07:32:19 -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 7A7247D0F1; Fri, 3 Nov 2017 14:32:18 +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 58E3C6061B; Fri, 3 Nov 2017 14:32:18 +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 2477614B20; Fri, 3 Nov 2017 14:32:18 +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 vA3ETu9v028757 for ; Fri, 3 Nov 2017 10:29:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id D54DD60636; Fri, 3 Nov 2017 14:29:56 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B6D460633 for ; Fri, 3 Nov 2017 14:29:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A7247D0F1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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:24 +0100 Message-Id: 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 07/12] qemu: block: Add JSON props generator for NBD storage backing 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.27]); Fri, 03 Nov 2017 14:32:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/qemu/qemu_block.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4e588c724..451d04694 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -767,6 +767,34 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePt= r src) } +static virJSONValuePtr +qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr src) +{ + virJSONValuePtr serverprops; + virJSONValuePtr ret =3D NULL; + + if (src->nhosts !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nbd protocol accepts only one host")); + return NULL; + } + + serverprops =3D qemuBlockStorageSourceBuildJSONSocketAddress(&src->hos= ts[0], + false); + if (!serverprops) + return NULL; + + ignore_value(virJSONValueObjectCreate(&ret, + "s:driver", "nbd", + "a:server", serverprops, + "S:export", src->path, + "S:tls-creds", src->tlsAlias, + NULL)); + + return ret; +} + + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -822,6 +850,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource= Ptr src) break; case VIR_STORAGE_NET_PROTOCOL_NBD: + if (!(fileprops =3D qemuBlockStorageSourceGetNBDProps(src))) + return NULL; + break; + case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_SSH: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719542973773.0180791444407; Fri, 3 Nov 2017 07:32:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53CB385A02; Fri, 3 Nov 2017 14:32:21 +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 E57E05C899; Fri, 3 Nov 2017 14:32:20 +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 A908F1800BD3; Fri, 3 Nov 2017 14:32:20 +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 vA3ETvm5028766 for ; Fri, 3 Nov 2017 10:29:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8B7260636; Fri, 3 Nov 2017 14:29:57 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EAD660633 for ; Fri, 3 Nov 2017 14:29:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 53CB385A02 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:25 +0100 Message-Id: <23e63c1cd2703f2ed0d2726429be61bb5d52740f.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 08/12] qemu: block: Add JSON props generator for RBD storage backing 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 03 Nov 2017 14:32:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/qemu/qemu_block.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 74 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 451d04694..8a1ce8262 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -593,6 +593,47 @@ qemuBlockStorageSourceBuildJSONInetSocketAddress(virSt= orageNetHostDefPtr host) } +/** + * qemuBlockStorageSourceBuildHostsJSONInetSocketAddress: + * @src: disk storage source + * + * Formats src->hosts into a json object conforming to the 'InetSocketAddr= ess' + * type in qemu. + */ +static virJSONValuePtr +qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(virStorageSourcePtr = src) +{ + virJSONValuePtr servers =3D NULL; + virJSONValuePtr server =3D NULL; + virJSONValuePtr ret =3D NULL; + virStorageNetHostDefPtr host; + size_t i; + + if (!(servers =3D virJSONValueNewArray())) + goto cleanup; + + for (i =3D 0; i < src->nhosts; i++) { + host =3D src->hosts + i; + + if (!(server =3D qemuBlockStorageSourceBuildJSONInetSocketAddress(= host))) + goto cleanup; + + if (virJSONValueArrayAppend(servers, server) < 0) + goto cleanup; + + server =3D NULL; + } + + VIR_STEAL_PTR(ret, servers); + + cleanup: + virJSONValueFree(servers); + virJSONValueFree(server); + + return ret; +} + + static virJSONValuePtr qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src) { @@ -795,6 +836,35 @@ qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr = src) } +static virJSONValuePtr +qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src) +{ + qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); + virJSONValuePtr servers =3D NULL; + virJSONValuePtr ret =3D NULL; + const char *username =3D NULL; + + if (src->nhosts > 0 && + !(servers =3D qemuBlockStorageSourceBuildHostsJSONInetSocketAddres= s(src))) + return NULL; + + if (src->auth) + username =3D srcPriv->secinfo->s.aes.username; + + ignore_value(virJSONValueObjectCreate(&ret, + "s:driver", "rbd", + "s:pool", src->volume, + "s:image", src->path, + "S:snapshot", src->snapshot, + "S:conf", src->configFile, + "A:server", servers, + "S:user", username, + NULL)); + + return ret; +} + + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -855,6 +925,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource= Ptr src) break; case VIR_STORAGE_NET_PROTOCOL_RBD: + if (!(fileprops =3D qemuBlockStorageSourceGetRBDProps(src))) + return NULL; + break; + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_SSH: case VIR_STORAGE_NET_PROTOCOL_NONE: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15097194706695.189211442052738; Fri, 3 Nov 2017 07:31:10 -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 15624AC2DE; Fri, 3 Nov 2017 14:31:08 +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 6D62A5D978; Fri, 3 Nov 2017 14:31:07 +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 2D98E1800BD4; Fri, 3 Nov 2017 14:31:07 +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 vA3ETwWG028782 for ; Fri, 3 Nov 2017 10:29:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 828A360633; Fri, 3 Nov 2017 14:29:58 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AD3260BE2 for ; Fri, 3 Nov 2017 14:29:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15624AC2DE 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:26 +0100 Message-Id: <203072e6329d303d6da82a4a0c2a41c9f2e4adef.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 09/12] qemu: block: Add JSON props generator for sheepdog storage backing 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:31:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/qemu/qemu_block.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8a1ce8262..5f28c4dd6 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -865,6 +865,33 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr = src) } +static virJSONValuePtr +qemuBlockStorageSourceGetSheepdogProps(virStorageSourcePtr src) +{ + virJSONValuePtr serverprops; + virJSONValuePtr ret =3D NULL; + + if (src->nhosts !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("sheepdog protocol accepts only one host")); + return NULL; + } + + serverprops =3D qemuBlockStorageSourceBuildJSONSocketAddress(&src->hos= ts[0], + false); + if (!serverprops) + return NULL; + + /* libvirt does not support the 'snap-id' and 'tag' properties */ + ignore_value(virJSONValueObjectCreate(&ret, + "s:driver", "sheepdog", + "a:server", serverprops, + "s:vdi", src->path, + NULL)); + + return ret; +} + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -930,6 +957,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource= Ptr src) break; case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + if (!(fileprops =3D qemuBlockStorageSourceGetSheepdogProps(src= ))) + return NULL; + break; + case VIR_STORAGE_NET_PROTOCOL_SSH: case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_LAST: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150971946867545.5212777456328; Fri, 3 Nov 2017 07:31:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B553778EC1; Fri, 3 Nov 2017 14:31:05 +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 36C2260BE0; Fri, 3 Nov 2017 14:31:05 +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 034683FCFD; Fri, 3 Nov 2017 14:31:05 +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 vA3ETxR8028787 for ; Fri, 3 Nov 2017 10:29:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 585F660636; Fri, 3 Nov 2017 14:29:59 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3ADB60633 for ; Fri, 3 Nov 2017 14:29:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B553778EC1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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:27 +0100 Message-Id: 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 10/12] qemu: block: Add JSON props generator for ssh storage backing 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 03 Nov 2017 14:31:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/qemu/qemu_block.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 5f28c4dd6..6f6d294bf 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -892,6 +892,38 @@ qemuBlockStorageSourceGetSheepdogProps(virStorageSourc= ePtr src) return ret; } + +static virJSONValuePtr +qemuBlockStorageSourceGetSshProps(virStorageSourcePtr src) +{ + virJSONValuePtr serverprops; + virJSONValuePtr ret =3D NULL; + const char *username =3D NULL; + + if (src->nhosts !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("sheepdog protocol accepts only one host")); + return NULL; + } + + serverprops =3D qemuBlockStorageSourceBuildJSONInetSocketAddress(&src-= >hosts[0]); + if (!serverprops) + return NULL; + + if (src->auth) + username =3D src->auth->username; + + ignore_value(virJSONValueObjectCreate(&ret, + "s:driver", "ssh", + "s:path", src->path, + "a:server", serverprops, + "S:user", username, + NULL)); + + return ret; +} + + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -962,6 +994,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource= Ptr src) break; case VIR_STORAGE_NET_PROTOCOL_SSH: + if (!(fileprops =3D qemuBlockStorageSourceGetSshProps(src))) + return NULL; + break; + case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_LAST: break; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719545048491.32611293447246; Fri, 3 Nov 2017 07:32:25 -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 B087C356CF; Fri, 3 Nov 2017 14:32:23 +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 88A045D976; Fri, 3 Nov 2017 14:32:23 +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 515E9180474E; Fri, 3 Nov 2017 14:32:23 +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 vA3EU0iS028802 for ; Fri, 3 Nov 2017 10:30:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7F01360636; Fri, 3 Nov 2017 14:30:00 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0690160633 for ; Fri, 3 Nov 2017 14:29:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B087C356CF Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.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:28 +0100 Message-Id: <7b668d2ffba3ad555e692cb60f1122df030fb40b.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 11/12] qemu: block: Add node-names to JSON backing storage strings 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.30]); Fri, 03 Nov 2017 14:32:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Format out the node-name if it was assigned for JSON-based storage specification. --- src/qemu/qemu_block.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 6f6d294bf..6df0dc0fb 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1005,5 +1005,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSour= cePtr src) break; } + if (virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestorage, = NULL) < 0) { + virJSONValueFree(fileprops); + return NULL; + } + return fileprops; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 09:07:44 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1509719471132680.551659141547; Fri, 3 Nov 2017 07:31:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0009264C; Fri, 3 Nov 2017 14:31:07 +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 B5C6E5D755; Fri, 3 Nov 2017 14:31:07 +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 7EC2E3894; Fri, 3 Nov 2017 14:31:07 +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 vA3EU1b8028812 for ; Fri, 3 Nov 2017 10:30:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5922E60633; Fri, 3 Nov 2017 14:30:01 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D28E360636 for ; Fri, 3 Nov 2017 14:30:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0009264C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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:29 +0100 Message-Id: <7d0c107e7c6ca491210b02fbeeb46e9e0cf85f56.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 12/12] tests: Add testing of storage backend JSON props formatter 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 03 Nov 2017 14:31:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a new test program called 'qemublocktest' to test the block layer related stuff and test storage source to JSON generator by comparing it to the JSON parser. --- tests/Makefile.am | 14 +++- tests/qemublocktest.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 tests/qemublocktest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 0b2305d70..939acb0a1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -282,7 +282,9 @@ test_programs +=3D qemuxml2argvtest qemuxml2xmltest \ qemumonitortest qemumonitorjsontest qemuhotplugtest \ qemuagenttest qemucapabilitiestest qemucaps2xmltest \ qemumemlocktest \ - qemucommandutiltest + qemucommandutiltest \ + qemublocktest \ + $(NULL) test_helpers +=3D qemucapsprobe test_libraries +=3D libqemumonitortestutils.la \ libqemutestdriver.la \ @@ -668,6 +670,15 @@ qemuhotplugtest_SOURCES =3D \ $(NULL) qemuhotplugtest_LDADD =3D libqemumonitortestutils.la $(qemu_LDADDS) $(LDAD= DS) +qemublocktest_SOURCES =3D \ + qemublocktest.c testutils.h testutils.c +qemublocktest_LDADD =3D $(LDADDS) \ + ../src/libvirt_conf.la \ + ../src/libvirt_util.la \ + $(qemu_LDADDS) \ + ../gnulib/lib/libgnu.la \ + $(NULL) + domainsnapshotxml2xmltest_SOURCES =3D \ domainsnapshotxml2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h @@ -686,6 +697,7 @@ EXTRA_DIST +=3D qemuxml2argvtest.c qemuxml2xmltest.c qe= muargv2xmltest.c \ qemuagenttest.c qemucapabilitiestest.c \ qemucaps2xmltest.c qemucommandutiltest.c \ qemumemlocktest.c qemucpumock.c testutilshostcpus.h \ + qemublocktest.c \ $(QEMUMONITORTESTUTILS_SOURCES) endif ! WITH_QEMU diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c new file mode 100644 index 000000000..52ecbde36 --- /dev/null +++ b/tests/qemublocktest.c @@ -0,0 +1,189 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include + +#include "testutils.h" +#include "virstoragefile.h" +#include "virstring.h" +#include "virlog.h" +#include "qemu/qemu_block.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +VIR_LOG_INIT("tests.storagetest"); + +struct testBackingXMLjsonXMLdata { + int type; + const char *xml; +}; + +static int +testBackingXMLjsonXML(const void *args) +{ + const struct testBackingXMLjsonXMLdata *data =3D args; + xmlDocPtr xml =3D NULL; + xmlXPathContextPtr ctxt =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + virStorageSourcePtr xmlsrc =3D NULL; + virStorageSourcePtr jsonsrc =3D NULL; + virJSONValuePtr backendprops =3D NULL; + virJSONValuePtr wrapper =3D NULL; + char *propsstr =3D NULL; + char *protocolwrapper =3D NULL; + char *actualxml =3D NULL; + int ret =3D -1; + + if (VIR_ALLOC(xmlsrc) < 0) + return -1; + + xmlsrc->type =3D data->type; + + if (!(xml =3D virXMLParseStringCtxt(data->xml, "(test storage source X= ML)", &ctxt))) + goto cleanup; + + if (virDomainDiskSourceParse(ctxt->node, ctxt, xmlsrc, 0) < 0) { + fprintf(stderr, "failed to parse disk source xml\n"); + goto cleanup; + } + + if (!(backendprops =3D qemuBlockStorageSourceGetBackendProps(xmlsrc)))= { + fprintf(stderr, "failed to format disk source json\n"); + goto cleanup; + } + + if (virJSONValueObjectCreate(&wrapper, "a:file", backendprops, NULL) <= 0) + goto cleanup; + + backendprops =3D NULL; + + if (!(propsstr =3D virJSONValueToString(wrapper, false))) + goto cleanup; + + if (virAsprintf(&protocolwrapper, "json:%s", propsstr) < 0) + goto cleanup; + + if (!(jsonsrc =3D virStorageSourceNewFromBackingAbsolute(protocolwrapp= er))) { + fprintf(stderr, "failed to parse disk json\n"); + goto cleanup; + } + + if (virDomainDiskSourceFormat(&buf, jsonsrc, 0, 0) < 0 || + !(actualxml =3D virBufferContentAndReset(&buf))) { + fprintf(stderr, "failed to format disk source xml\n"); + goto cleanup; + } + + if (STRNEQ(actualxml, data->xml)) { + fprintf(stderr, "\n expected storage source xml:\n'%s'\n" + "actual storage source xml:\n%s\n" + "intermediate json:\n%s\n", + data->xml, actualxml, protocolwrapper); + goto cleanup; + } + + ret =3D 0; + + cleanup: + virStorageSourceFree(xmlsrc); + virStorageSourceFree(jsonsrc); + VIR_FREE(propsstr); + VIR_FREE(protocolwrapper); + VIR_FREE(actualxml); + virJSONValueFree(backendprops); + virJSONValueFree(wrapper); + virBufferFreeAndReset(&buf); + xmlFreeDoc(xml); + + return ret; +} + + +static int +mymain(void) +{ + int ret =3D 0; + struct testBackingXMLjsonXMLdata data; + + virTestCounterReset("qemu storage source xml->json->xml "); + +#define TEST_JSON_FORMAT(tpe, xmlstr) \ + do { \ + data.type =3D tpe; \ + data.xml =3D xmlstr; \ + if (virTestRun(virTestCounterNext(), testBackingXMLjsonXML, &data)= < 0) \ + ret =3D -1; \ + } while (0) + +#define TEST_JSON_FORMAT_NET(xmlstr)\ + TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NETWORK, xmlstr) + + TEST_JSON_FORMAT(VIR_STORAGE_TYPE_FILE, "\n"); + + /* type VIR_STORAGE_TYPE_BLOCK is not tested since it parses back to '= file' */ + /* type VIR_STORAGE_TYPE_DIR it is a 'format' driver in qemu */ + + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\= n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + " \n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\= n" + " \n" + " \n" + " \n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + TEST_JSON_FORMAT_NET("\n" + " \n" + "\n"); + + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} + +VIR_TEST_MAIN(mymain) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list