From nobody Fri May 16 07:35:31 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 1497627023254538.2307624539676; Fri, 16 Jun 2017 08:30:23 -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 89C4A804F0; Fri, 16 Jun 2017 15:30:21 +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 5B505978D6; Fri, 16 Jun 2017 15:30:21 +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 0EEE71800C8E; Fri, 16 Jun 2017 15:30:21 +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 v5GFU1XF013540 for ; Fri, 16 Jun 2017 11:30:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8EEE92288; Fri, 16 Jun 2017 15:30:01 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20B1D92282; Fri, 16 Jun 2017 15:29:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 89C4A804F0 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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 89C4A804F0 From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Jun 2017 17:29:46 +0200 Message-Id: <4ffa46236b46731fa8e45e322d0da7ed9e22f9ba.1497626884.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 09/10] 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 16 Jun 2017 15:30:22 +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 | 19 ++++++++++++------- tests/virstoragetest.c | 11 +++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 2526bac0b..dc06bec94 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3083,8 +3083,9 @@ virStorageSourceParseBackingJSONSSH(virStorageSourceP= tr 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 " "volume definition")); @@ -3101,12 +3102,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 890b5c37c..7abd30c55 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