From nobody Tue Apr 30 00:18:21 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.zoho.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 1497880732983109.2079370046954; Mon, 19 Jun 2017 06:58:52 -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 BD1C8C01BD43; Mon, 19 Jun 2017 13:58:49 +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 8E65E1802B; Mon, 19 Jun 2017 13:58:49 +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 43C654A499; Mon, 19 Jun 2017 13:58:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDwWku020832 for ; Mon, 19 Jun 2017 09:58:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E5B78229C; Mon, 19 Jun 2017 13:58:32 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC6A21802B; Mon, 19 Jun 2017 13:58:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BD1C8C01BD43 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BD1C8C01BD43 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:28 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 1/8] util: storage: Add support for type 'inet' in virStorageSourceParseBackingJSONSocketAddress 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.32]); Mon, 19 Jun 2017 13:58:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 'SocketAddress' structure was changed to contain 'inet' instead of 'tcp' since qemu commit c5f1ae3ae7b. Existing entries have a backward compatibility layer. Libvirt will parse 'inet' and 'tcp' as equivalents. --- src/util/virstoragefile.c | 23 +++++++++-------------- tests/virstoragetest.c | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 92bc561a2..7f2a50fd1 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2802,18 +2802,17 @@ virStorageSourceParseBackingJSONSocketAddress(virSt= orageNetHostDefPtr host, const char *hostname =3D virJSONValueObjectGetString(json, "host"); const char *port =3D virJSONValueObjectGetString(json, "port"); const char *socket =3D virJSONValueObjectGetString(json, "socket"); - int transport; - if ((transport =3D virStorageNetHostTransportTypeFromString(type)) < 0= ) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown backing store transport protocol '%s'"),= type); + if (!type) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing socket address type in " + "JSON backing volume definition")); return -1; } - host->transport =3D transport; + if (STREQ(type, "tcp") || STREQ(type, "inet")) { + host->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - switch ((virStorageNetHostTransport) transport) { - case VIR_STORAGE_NET_HOST_TRANS_TCP: if (!hostname) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing hostname for tcp backing server in " @@ -2824,9 +2823,9 @@ virStorageSourceParseBackingJSONSocketAddress(virStor= ageNetHostDefPtr host, if (VIR_STRDUP(host->name, hostname) < 0 || VIR_STRDUP(host->port, port) < 0) return -1; - break; + } else if (STREQ(type, "unix")) { + host->transport =3D VIR_STORAGE_NET_HOST_TRANS_UNIX; - case VIR_STORAGE_NET_HOST_TRANS_UNIX: if (!socket) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing socket path for udp backing server i= n " @@ -2834,13 +2833,9 @@ virStorageSourceParseBackingJSONSocketAddress(virSto= rageNetHostDefPtr host, return -1; } - if (VIR_STRDUP(host->socket, socket) < 0) return -1; - break; - - case VIR_STORAGE_NET_HOST_TRANS_RDMA: - case VIR_STORAGE_NET_HOST_TRANS_LAST: + } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("backing store protocol '%s' is not yet supported= "), type); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 70e24a1b7..117208289 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1431,7 +1431,7 @@ mymain(void) "{ \"type\":\"unix\"," "\"socket\":\"/path/socke= t\"" "}," - "{ \"type\":\"tcp\"," + "{ \"type\":\"inet\"," "\"host\":\"example.com\"" "}" "]" --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 00:18:21 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.zoho.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 1497880719395337.64819779611616; Mon, 19 Jun 2017 06:58:39 -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 6E62B8553F; Mon, 19 Jun 2017 13:58:36 +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 375001820F; Mon, 19 Jun 2017 13:58:36 +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 EC0194A491; Mon, 19 Jun 2017 13:58:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDwX01020843 for ; Mon, 19 Jun 2017 09:58:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 53D391802B; Mon, 19 Jun 2017 13:58:33 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C0C18229D; Mon, 19 Jun 2017 13:58:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E62B8553F 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6E62B8553F From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:29 +0200 Message-Id: <8aead7bc6494ca29aa18dd72c815615fc3590465.1497880533.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 2/8] util: storage: Split out parsing of TCP network host from JSON pseudoprotocol 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.28]); Mon, 19 Jun 2017 13:58:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Few backing protocols support only TCP. Split out the function which will correspond to parsing qemu's InetSocketAddressBase. --- Notes: v2: - resolved merge conflict after adding a patch - changed ordering of setting of the transport type src/util/virstoragefile.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7f2a50fd1..9af0cdbcd 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2795,12 +2795,34 @@ virStorageSourceParseBackingJSONUri(virStorageSourc= ePtr src, static int +virStorageSourceParseBackingJSONInetSocketAddress(virStorageNetHostDefPtr = host, + virJSONValuePtr json) +{ + const char *hostname =3D virJSONValueObjectGetString(json, "host"); + const char *port =3D virJSONValueObjectGetString(json, "port"); + + if (!hostname) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing hostname for tcp backing server in " + "JSON backing volume definition")); + return -1; + } + + host->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + + if (VIR_STRDUP(host->name, hostname) < 0 || + VIR_STRDUP(host->port, port) < 0) + return -1; + + return 0; +} + + +static int virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host, virJSONValuePtr json) { const char *type =3D virJSONValueObjectGetString(json, "type"); - const char *hostname =3D virJSONValueObjectGetString(json, "host"); - const char *port =3D virJSONValueObjectGetString(json, "port"); const char *socket =3D virJSONValueObjectGetString(json, "socket"); if (!type) { @@ -2811,18 +2833,8 @@ virStorageSourceParseBackingJSONSocketAddress(virSto= rageNetHostDefPtr host, } if (STREQ(type, "tcp") || STREQ(type, "inet")) { - host->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + return virStorageSourceParseBackingJSONInetSocketAddress(host, jso= n); - if (!hostname) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("missing hostname for tcp backing server in " - "JSON backing volume definition")); - return -1; - } - - if (VIR_STRDUP(host->name, hostname) < 0 || - VIR_STRDUP(host->port, port) < 0) - return -1; } else if (STREQ(type, "unix")) { host->transport =3D VIR_STORAGE_NET_HOST_TRANS_UNIX; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 00:18:21 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.zoho.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 1497880719428349.06352917417996; Mon, 19 Jun 2017 06:58:39 -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 7609B80477; Mon, 19 Jun 2017 13:58:37 +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 506D37DFFE; Mon, 19 Jun 2017 13:58:37 +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 008F21800C81; Mon, 19 Jun 2017 13:58:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDwYs6020851 for ; Mon, 19 Jun 2017 09:58:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6540D8229C; Mon, 19 Jun 2017 13:58:34 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id B56DD1802B; Mon, 19 Jun 2017 13:58:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7609B80477 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7609B80477 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:30 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 3/8] util: storage: Report errors when source host data is missing 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.28]); Mon, 19 Jun 2017 13:58:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Merge the reporting of the missing source host data into the parser functions so that callers don't have to do it separately. --- Notes: v2: - fixed merge conflicts src/util/virstoragefile.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 9af0cdbcd..0bbbba650 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2798,8 +2798,18 @@ static int virStorageSourceParseBackingJSONInetSocketAddress(virStorageNetHostDefPtr = host, virJSONValuePtr json) { - const char *hostname =3D virJSONValueObjectGetString(json, "host"); - const char *port =3D virJSONValueObjectGetString(json, "port"); + const char *hostname; + const char *port; + + if (!json) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing remote server specification in JSON " + "backing volume definition")); + return -1; + } + + hostname =3D virJSONValueObjectGetString(json, "host"); + port =3D virJSONValueObjectGetString(json, "port"); if (!hostname) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -2822,10 +2832,17 @@ static int virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host, virJSONValuePtr json) { - const char *type =3D virJSONValueObjectGetString(json, "type"); - const char *socket =3D virJSONValueObjectGetString(json, "socket"); + const char *type; + const char *socket; + + if (!json) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing remote server specification in JSON " + "backing volume definition")); + return -1; + } - if (!type) { + if (!(type =3D virJSONValueObjectGetString(json, "type"))) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing socket address type in " "JSON backing volume definition")); @@ -2838,7 +2855,7 @@ virStorageSourceParseBackingJSONSocketAddress(virStor= ageNetHostDefPtr host, } else if (STREQ(type, "unix")) { host->transport =3D VIR_STORAGE_NET_HOST_TRANS_UNIX; - if (!socket) { + if (!(socket =3D virJSONValueObjectGetString(json, "socket"))) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing socket path for udp backing server i= n " "JSON backing volume definition")); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 00:18:21 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.zoho.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 1497880736149240.23483865823448; Mon, 19 Jun 2017 06:58:56 -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 4B1DB8124A; Mon, 19 Jun 2017 13:58:54 +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 2367588EF6; Mon, 19 Jun 2017 13:58:54 +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 C3F661800C89; Mon, 19 Jun 2017 13:58:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDwZRh020861 for ; Mon, 19 Jun 2017 09:58:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E65282298; Mon, 19 Jun 2017 13:58:35 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id B09921802B; Mon, 19 Jun 2017 13:58:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4B1DB8124A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4B1DB8124A From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:31 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 4/8] util: storage: Add JSON parser for new options in 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 19 Jun 2017 13:58:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Starting from qemu 2.9, more granular options are supported. Add parser for the relevant bits. With this patch libvirt is able to parse the host and target IQN of from the JSON pseudo-protocol specification. This corresponds to BlockdevOptionsIscsi in qemu qapi. --- Notes: v2: - parse 'port' from the portal string - treat 'lun' as an integer in json src/util/virstoragefile.c | 63 +++++++++++++++++++++++++++++++++++++++++++= +--- tests/virstoragetest.c | 19 ++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 0bbbba650..8e6631b45 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2935,18 +2935,73 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSou= rcePtr src, virJSONValuePtr json, int opaque ATTRIBUTE_UNUSED) { + const char *transport =3D virJSONValueObjectGetString(json, "transport= "); + const char *portal =3D virJSONValueObjectGetString(json, "portal"); + const char *target =3D virJSONValueObjectGetString(json, "target"); const char *uri; + char *port; + unsigned int lun =3D 0; + char *fulltarget =3D NULL; + int ret =3D -1; /* legacy URI based syntax passed via 'filename' option */ if ((uri =3D virJSONValueObjectGetString(json, "filename"))) return virStorageSourceParseBackingJSONUriStr(src, uri, VIR_STORAGE_NET_PROT= OCOL_ISCSI); - /* iSCSI currently supports only URI syntax passed in as filename */ - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("missing iSCSI URI in JSON backing volume definition"= )); + src->type =3D VIR_STORAGE_TYPE_NETWORK; + src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - return -1; + if (VIR_ALLOC(src->hosts) < 0) + goto cleanup; + + src->nhosts =3D 1; + + if (STRNEQ_NULLABLE(transport, "tcp")) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("only TCP transport is supported for iSCSI volume= s")); + goto cleanup; + } + + src->hosts->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + + if (!portal) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing 'portal' address in iSCSI backing defini= tion")); + goto cleanup; + } + + if (!target) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing 'target' in iSCSI backing definition")); + goto cleanup; + } + + if (VIR_STRDUP(src->hosts->name, portal) < 0) + goto cleanup; + + if ((port =3D strchr(src->hosts->name, ':'))) { + if (VIR_STRDUP(src->hosts->port, port + 1) < 0) + goto cleanup; + + if (strlen(src->hosts->port) =3D=3D 0) + VIR_FREE(src->hosts->port); + + *port =3D '\0'; + } + + ignore_value(virJSONValueObjectGetNumberUint(json, "lun", &lun)); + + if (virAsprintf(&fulltarget, "%s/%u", target, lun) < 0) + goto cleanup; + + VIR_STEAL_PTR(src->path, fulltarget); + + ret =3D 0; + + cleanup: + VIR_FREE(fulltarget); + return ret; } diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 117208289..894f78ba9 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1502,6 +1502,25 @@ mymain(void) "\"driver\": \"file\"," "\"filename\": \"/path/to/file\" } } }= ", "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," + "\"transport\":\"tcp\"," + "\"portal\":\"test.org\"," + "\"target\":\"iqn.2016-12.com.virtt= est:emulated-iscsi-noauth.target\"" + "}" + "}", + "\n" + " \n" + "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," + "\"transport\":\"tcp\"," + "\"portal\":\"test.org:1234\"," + "\"target\":\"iqn.2016-12.com.virtt= est:emulated-iscsi-noauth.target\"," + "\"lun\":6" + "}" + "}", + "\n" + " \n" + "\n"); cleanup: /* Final cleanup */ --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 00:18:21 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.zoho.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 149788073443681.85566198090726; Mon, 19 Jun 2017 06:58:54 -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 BE864B177; Mon, 19 Jun 2017 13:58:49 +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 8CBD588EFF; Mon, 19 Jun 2017 13:58:49 +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 4144A4A498; Mon, 19 Jun 2017 13:58:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDwaZ2020868 for ; Mon, 19 Jun 2017 09:58:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5546B82298; Mon, 19 Jun 2017 13:58:36 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A963D1802B; Mon, 19 Jun 2017 13:58:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BE864B177 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BE864B177 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:32 +0200 Message-Id: <50087d6d176b8be54333183c58d1789046d2efd8.1497880533.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 5/8] util: storage: adapt to changes in JSON format for NBD 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.30]); Mon, 19 Jun 2017 13:58:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since 2.9 the host and port for NBD are no longer directly under the json pseudo-protocol object, but rather belong to a sub-object called 'server'. --- Notes: v2: - changed type 'tcp' to 'inet' according to the qemu schema src/util/virstoragefile.c | 28 +++++++++++++++++----------- tests/virstoragetest.c | 11 +++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 8e6631b45..b0dc92942 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3014,11 +3014,12 @@ virStorageSourceParseBackingJSONNbd(virStorageSourc= ePtr src, const char *host =3D virJSONValueObjectGetString(json, "host"); const char *port =3D virJSONValueObjectGetString(json, "port"); const char *export =3D virJSONValueObjectGetString(json, "export"); + virJSONValuePtr server =3D virJSONValueObjectGetObject(json, "server"); - if (!path && !host) { + if (!path && !host && !server) { virReportError(VIR_ERR_INVALID_ARG, "%s", - _("missing path or host of NBD server in JSON backi= ng " - "volume definition")); + _("missing host specification of NBD server in JSON= " + "backing volume definition")); return -1; } @@ -3032,17 +3033,22 @@ virStorageSourceParseBackingJSONNbd(virStorageSourc= ePtr src, return -1; src->nhosts =3D 1; - if (path) { - src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_UNIX; - if (VIR_STRDUP(src->hosts[0].socket, path) < 0) + if (server) { + if (virStorageSourceParseBackingJSONSocketAddress(src->hosts, serv= er) < 0) return -1; } else { - src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - if (VIR_STRDUP(src->hosts[0].name, host) < 0) - return -1; + if (path) { + src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_UNIX; + if (VIR_STRDUP(src->hosts[0].socket, path) < 0) + return -1; + } else { + src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + if (VIR_STRDUP(src->hosts[0].name, host) < 0) + return -1; - if (VIR_STRDUP(src->hosts[0].port, port) < 0) - return -1; + if (VIR_STRDUP(src->hosts[0].port, port) < 0) + return -1; + } } return 0; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 894f78ba9..ca2601de7 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1471,6 +1471,17 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\"," + "\"export\":\"blah\"," + "\"server\": { \"type\":\"inet\"," + "\"host\":\"example.o= rg\"," + "\"port\":\"6000\"" + "}" + "}" + "}", + "\n" + " \n" + "\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\"," "\"host\":\"example.org\"," "\"port\":\"6000\"," --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 00:18:21 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.zoho.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 1497880740558287.97917653845116; Mon, 19 Jun 2017 06:59:00 -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 9AD5280C27; Mon, 19 Jun 2017 13:58:57 +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 759F581EE5; Mon, 19 Jun 2017 13:58:57 +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 16BA41800C8D; Mon, 19 Jun 2017 13:58:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDwb6W020881 for ; Mon, 19 Jun 2017 09:58:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1D3C82746; Mon, 19 Jun 2017 13:58:37 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A23EB82743; Mon, 19 Jun 2017 13:58:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9AD5280C27 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9AD5280C27 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:33 +0200 Message-Id: <79bbe211171149fbd74de89036753a945dd31594.1497880533.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 6/8] util: storage: adapt to changes in JSON format for ceph/rbd 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.26]); Mon, 19 Jun 2017 13:58:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since qemu 2.9 the options changed from a monolithic string into fine grained options for the json pseudo-protocol object. --- src/util/virstoragefile.c | 50 +++++++++++++++++++++++++++++++++++++++++++= ---- tests/virstoragetest.c | 19 ++++++++++++++++++ 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index b0dc92942..220a55d9b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3122,6 +3122,15 @@ virStorageSourceParseBackingJSONRBD(virStorageSource= Ptr src, int opaque ATTRIBUTE_UNUSED) { const char *filename; + const char *pool =3D virJSONValueObjectGetString(json, "pool"); + const char *image =3D virJSONValueObjectGetString(json, "image"); + 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; src->type =3D VIR_STORAGE_TYPE_NETWORK; src->protocol =3D VIR_STORAGE_NET_PROTOCOL_RBD; @@ -3130,11 +3139,44 @@ virStorageSourceParseBackingJSONRBD(virStorageSourc= ePtr src, if ((filename =3D virJSONValueObjectGetString(json, "filename"))) return virStorageSourceParseRBDColonString(filename, src); - /* RBD currently supports only URI syntax passed in as filename */ - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("missing RBD filename in JSON backing volume definiti= on")); + if (!pool || !image) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing pool or image name in ceph backing volum= e " + "JSON specification")); + return -1; + } - 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 || + VIR_STRDUP(src->configFile, conf) < 0) + goto cleanup; + + VIR_STEAL_PTR(src->path, fullname); + + if (servers) { + nservers =3D virJSONValueArraySize(servers); + + if (VIR_ALLOC_N(src->hosts, nservers) < 0) + goto cleanup; + + src->nhosts =3D nservers; + + for (i =3D 0; i < nservers; i++) { + if (virStorageSourceParseBackingJSONInetSocketAddress(src->hos= ts + i, + virJSONV= alueArrayGet(servers, i)) < 0) + goto cleanup; + } + } + + ret =3D 0; + cleanup: + VIR_FREE(fullname); + + return ret; } static int diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index ca2601de7..9c7314bff 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1507,6 +1507,25 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"rbd\"," + "\"image\":\"test\"," + "\"pool\":\"libvirt\"," + "\"conf\":\"/path/to/conf\"," + "\"snapshot\":\"snapshotname\"," + "\"server\":[ {\"host\":\"example.c= om\"," + "\"port\":\"1234\"" + "}," + "{\"host\":\"example2.= com\"" + "}" + "]" + "}" + "}", + "\n" + " \n" + " \n" + " \n" + " \n" + "\n"); TEST_BACKING_PARSE("json:{ \"file\": { " "\"driver\": \"raw\"," "\"file\": {" --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 00:18:21 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.zoho.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 1497880745046931.5076391184749; Mon, 19 Jun 2017 06:59:05 -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 D838319CBC5; Mon, 19 Jun 2017 13:59:00 +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 A40D28229D; Mon, 19 Jun 2017 13:59:00 +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 527EB4A495; Mon, 19 Jun 2017 13:59:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDweUg020894 for ; Mon, 19 Jun 2017 09:58:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0708C82743; Mon, 19 Jun 2017 13:58:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E49582746; Mon, 19 Jun 2017 13:58:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D838319CBC5 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D838319CBC5 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:34 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 7/8] util: storage: adapt to changes in JSON format for ssh 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.29]); Mon, 19 Jun 2017 13:59:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since qemu 2.9 the options changed from a monolithic string into fine grained options for the json pseudo-protocol object. --- Notes: v2: - tweaked error message src/util/virstoragefile.c | 21 +++++++++++++-------- tests/virstoragetest.c | 11 +++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 220a55d9b..b8a3de85c 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3087,10 +3087,11 @@ virStorageSourceParseBackingJSONSSH(virStorageSourc= ePtr src, const char *path =3D virJSONValueObjectGetString(json, "path"); const char *host =3D virJSONValueObjectGetString(json, "host"); const char *port =3D virJSONValueObjectGetString(json, "port"); + virJSONValuePtr server =3D virJSONValueObjectGetObject(json, "server"); - if (!host || !path) { + if (!(host || server) || !path) { virReportError(VIR_ERR_INVALID_ARG, "%s", - _("missing host or path of SSH JSON backing " + _("missing host/server or path of SSH JSON backing " "volume definition")); return -1; } @@ -3105,12 +3106,16 @@ virStorageSourceParseBackingJSONSSH(virStorageSourc= ePtr src, return -1; src->nhosts =3D 1; - src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - if (VIR_STRDUP(src->hosts[0].name, host) < 0) - return -1; - - if (VIR_STRDUP(src->hosts[0].port, port) < 0) - return -1; + if (server) { + if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts, + server) < 0) + return -1; + } else { + src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + if (VIR_STRDUP(src->hosts[0].name, host) < 0 || + VIR_STRDUP(src->hosts[0].port, port) < 0) + return -1; + } return 0; } diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 9c7314bff..08f6c9003 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1501,6 +1501,17 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\"," + "\"path\":\"blah\"," + "\"server\":{ \"host\":\"example.or= g\"," + "\"port\":\"6000\"" + "}," + "\"user\":\"user\"" + "}" + "}", + "\n" + " \n" + "\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"rbd\"," "\"file.filename\":\"rbd:testshare:id=3Dasdf:= mon_host=3Dexample.com\"" "}", --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 00:18:21 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.zoho.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 1497880735541867.0419007166321; Mon, 19 Jun 2017 06:58:55 -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 50A5E4E4C8; Mon, 19 Jun 2017 13:58:53 +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 C12D889C5F; Mon, 19 Jun 2017 13:58:52 +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 7F9CA4A49A; Mon, 19 Jun 2017 13:58:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5JDwfSq020904 for ; Mon, 19 Jun 2017 09:58:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E8D082755; Mon, 19 Jun 2017 13:58:41 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53D3B17B0B; Mon, 19 Jun 2017 13:58:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 50A5E4E4C8 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 50A5E4E4C8 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:35 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 8/8] util: storage: adapt to changes in JSON format for sheepdog 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]); Mon, 19 Jun 2017 13:58:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since qemu 2.9 the options changed from a monolithic string into fine grained options for the json pseudo-protocol object. --- Notes: v2: - fixed server type to 'inet' in test - removed spurious 'transport' value in test src/util/virstoragefile.c | 28 ++++++++++++++++++++++++---- tests/virstoragetest.c | 11 +++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index b8a3de85c..3cbbb6c8f 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3061,6 +3061,8 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSo= urcePtr src, int opaque ATTRIBUTE_UNUSED) { const char *filename; + const char *vdi =3D virJSONValueObjectGetString(json, "vdi"); + virJSONValuePtr server =3D virJSONValueObjectGetObject(json, "server"); /* legacy URI based syntax passed via 'filename' option */ if ((filename =3D virJSONValueObjectGetString(json, "filename"))) { @@ -3069,13 +3071,31 @@ virStorageSourceParseBackingJSONSheepdog(virStorage= SourcePtr src, VIR_STORAGE_NET_= PROTOCOL_SHEEPDOG); /* libvirt doesn't implement a parser for the legacy non-URI synta= x */ + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing sheepdog URI in JSON backing volume defi= nition")); + return -1; } - /* Sheepdog currently supports only URI and legacy syntax passed in as= filename */ - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("missing sheepdog URI in JSON backing volume definiti= on")); + src->type =3D VIR_STORAGE_TYPE_NETWORK; + src->protocol =3D VIR_STORAGE_NET_PROTOCOL_SHEEPDOG; - return -1; + if (!vdi) { + virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing sheepdog vdi = name")); + return -1; + } + + if (VIR_STRDUP(src->path, vdi) < 0) + return -1; + + if (VIR_ALLOC(src->hosts) < 0) + return -1; + + src->nhosts =3D 1; + + if (virStorageSourceParseBackingJSONSocketAddress(src->hosts, server) = < 0) + return -1; + + return 0; } diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 08f6c9003..6c1287380 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1562,6 +1562,17 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"sheepdog\"," + "\"vdi\":\"test\"," + "\"server\":{ \"type\":\"inet\"," + "\"host\":\"example.co= m\"," + "\"port\":\"321\"" + "}" + "}" + "}", + "\n" + " \n" + "\n"); cleanup: /* Final cleanup */ --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list