From nobody Thu May 15 19:14:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1504133525322491.170911765838; Wed, 30 Aug 2017 15:52:05 -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 469C54A6EF; Wed, 30 Aug 2017 22:52:03 +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 1F961173D7; Wed, 30 Aug 2017 22:52:03 +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 CAD04180610F; Wed, 30 Aug 2017 22:52: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 v7UMkKT5022318 for ; Wed, 30 Aug 2017 18:46:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id A0FDB77709; Wed, 30 Aug 2017 22:46:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-88.phx2.redhat.com [10.3.116.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56F4E7093F; Wed, 30 Aug 2017 22:46:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 469C54A6EF 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: John Ferlan To: libvir-list@redhat.com Date: Wed, 30 Aug 2017 18:46:05 -0400 Message-Id: <20170830224613.24738-6-jferlan@redhat.com> In-Reply-To: <20170830224613.24738-1-jferlan@redhat.com> References: <20170830224613.24738-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: ashish.mittal@veritas.com Subject: [libvirt] [PATCH v6 05/13] util: storage: Add JSON backing volume parse for VxHS 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]); Wed, 30 Aug 2017 22:52:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Ashish Mittal Add the backing parse and a test case to verify parsing of VxHS backing storage. Signed-off-by: Ashish Mittal Signed-off-by: John Ferlan --- This combines v5 patch3 and src/util/virstoragefile.c from patch1. The main change is to modify the port to be 9999. But I also added the "type":"tcp" since that'll be something apparent in the next patch. src/util/virstoragefile.c | 37 +++++++++++++++++++++++++++++++++++++ tests/virstoragetest.c | 11 +++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e0ec717..f3fe529 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3212,6 +3212,40 @@ virStorageSourceParseBackingJSONRaw(virStorageSource= Ptr src, return virStorageSourceParseBackingJSONInternal(src, json); } =20 + +static int +virStorageSourceParseBackingJSONVxHS(virStorageSourcePtr src, + virJSONValuePtr json, + int opaque ATTRIBUTE_UNUSED) +{ + const char *vdisk_id =3D virJSONValueObjectGetString(json, "vdisk-id"); + virJSONValuePtr server =3D virJSONValueObjectGetObject(json, "server"); + + if (!vdisk_id || !server) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing 'vdisk-id' or 'server' attribute in " + "JSON backing definition for VxHS volume")); + return -1; + } + + src->type =3D VIR_STORAGE_TYPE_NETWORK; + src->protocol =3D VIR_STORAGE_NET_PROTOCOL_VXHS; + + if (VIR_STRDUP(src->path, vdisk_id) < 0) + return -1; + + if (VIR_ALLOC_N(src->hosts, 1) < 0) + return -1; + src->nhosts =3D 1; + + if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts, + server) < 0) + return -1; + + return 0; +} + + struct virStorageSourceJSONDriverParser { const char *drvname; int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque); @@ -3234,6 +3268,7 @@ static const struct virStorageSourceJSONDriverParser = jsonParsers[] =3D { {"ssh", virStorageSourceParseBackingJSONSSH, 0}, {"rbd", virStorageSourceParseBackingJSONRBD, 0}, {"raw", virStorageSourceParseBackingJSONRaw, 0}, + {"vxhs", virStorageSourceParseBackingJSONVxHS, 0}, }; =20 =20 @@ -3995,6 +4030,8 @@ virStorageSourceNetworkDefaultPort(virStorageNetProto= col protocol) return 0; =20 case VIR_STORAGE_NET_PROTOCOL_VXHS: + return 9999; + case VIR_STORAGE_NET_PROTOCOL_LAST: case VIR_STORAGE_NET_PROTOCOL_NONE: return 0; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 60e3164..ffebd4d 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1592,6 +1592,17 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"vxhs\"," + "\"vdisk-id\":\"c6718f6b-0401-441d-= a8c3-1f0064d75ee0\"," + "\"server\": { \"type\":\"tcp\"," + "\"host\":\"example.= com\"," + "\"port\":\"9999\"" + "}" + "}" + "}", + "\n" + " \n" + "\n"); #endif /* WITH_YAJL */ =20 cleanup: --=20 2.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list