From nobody Fri May 16 12:42:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.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