From nobody Fri May 16 08:34:44 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 1497880745046931.5076391184749; Mon, 19 Jun 2017 06:59:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D838319CBC5; Mon, 19 Jun 2017 13:59:00 +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 A40D28229D; Mon, 19 Jun 2017 13:59:00 +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 527EB4A495; Mon, 19 Jun 2017 13:59:00 +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 v5JDweUg020894 for ; Mon, 19 Jun 2017 09:58:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0708C82743; Mon, 19 Jun 2017 13:58:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E49582746; Mon, 19 Jun 2017 13:58:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D838319CBC5 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D838319CBC5 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 19 Jun 2017 15:58:34 +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 7/8] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 19 Jun 2017 13:59:01 +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: - tweaked error message src/util/virstoragefile.c | 21 +++++++++++++-------- tests/virstoragetest.c | 11 +++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 220a55d9b..b8a3de85c 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3087,10 +3087,11 @@ virStorageSourceParseBackingJSONSSH(virStorageSourc= ePtr 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 " + _("missing host/server or path of SSH JSON backing " "volume definition")); return -1; } @@ -3105,12 +3106,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 9c7314bff..08f6c9003 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