From nobody Wed Jul 16 05:04:41 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 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