From nobody Thu May 15 19:25:25 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 1504286884878445.49998563179133; Fri, 1 Sep 2017 10:28:04 -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 9C38119C33B; Fri, 1 Sep 2017 17:28: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 7E21317C18; Fri, 1 Sep 2017 17:28: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 46F9A1806109; Fri, 1 Sep 2017 17:28:03 +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 v81HABAh021761 for ; Fri, 1 Sep 2017 13:10:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id A845A7821A; Fri, 1 Sep 2017 17:10:11 +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 627077835E; Fri, 1 Sep 2017 17:10:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9C38119C33B 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Fri, 1 Sep 2017 13:09:54 -0400 Message-Id: <20170901170955.20281-11-jferlan@redhat.com> In-Reply-To: <20170901170955.20281-1-jferlan@redhat.com> References: <20170901170955.20281-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: ashmit602@gmail.com Subject: [libvirt] [PATCH v7 10/11] util: Add virstoragetest to parse/format a tls='yes' 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.29]); Fri, 01 Sep 2017 17:28:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Ashish Mittal Add a test case to verify TLS arguments are parsed correctly for a VxHS disk. This includes saving off a found tls-creds into the storage source @tlsAlias field since that's what's used to link the TLS object for the authentication credentials and the disk. Test case verifies that XML is generated correctly for a VxHS disk having TLS enabled. Signed-off-by: Ashish Mittal Signed-off-by: John Ferlan --- src/util/virstoragefile.c | 9 +++++++++ tests/virstoragetest.c | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index da137f7..078d475 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3225,6 +3225,7 @@ virStorageSourceParseBackingJSONVxHS(virStorageSource= Ptr src, { const char *vdisk_id =3D virJSONValueObjectGetString(json, "vdisk-id"); virJSONValuePtr server =3D virJSONValueObjectGetObject(json, "server"); + const char *haveTLS =3D virJSONValueObjectGetString(json, "tls-creds"); =20 if (!vdisk_id || !server) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -3243,6 +3244,14 @@ virStorageSourceParseBackingJSONVxHS(virStorageSourc= ePtr src, return -1; src->nhosts =3D 1; =20 + if (haveTLS) { + VIR_FREE(src->tlsAlias); + if (VIR_STRDUP(src->tlsAlias, haveTLS) < 0) + return -1; + + src->haveTLS =3D VIR_TRISTATE_BOOL_YES; + } + if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts, server) < 0) return -1; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index ffebd4d..75ad633 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1603,6 +1603,18 @@ 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\"" + "}," + "\"tls-creds\":\"objvirtio-disk0_tl= s0\"" + "}" + "}", + "\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