From nobody Wed May 1 14:01:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487026636424606.602062548307; Mon, 13 Feb 2017 14:57:16 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1DMrpoU013517; Mon, 13 Feb 2017 17:53:51 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1DMrnir001028 for ; Mon, 13 Feb 2017 17:53:49 -0500 Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1DMrnck007069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 13 Feb 2017 17:53:49 -0500 Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8E6E80477 for ; Mon, 13 Feb 2017 22:53:48 +0000 (UTC) Received: by mail-wm0-f70.google.com with SMTP id x4so1607757wme.3 for ; Mon, 13 Feb 2017 14:53:47 -0800 (PST) Received: from localhost.localdomain (ip-78-45-140-98.net.upcbroadband.cz. [78.45.140.98]) by smtp.gmail.com with ESMTPSA id k4sm1012195wmf.22.2017.02.13.14.53.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Feb 2017 14:53:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gOyjH1SAO/wF71GbK2Fdjf8kjC0EW+pFiEgldGwld7c=; b=hPbLG3RkXqhclVS2L97qmDIIebLRXuzBlbuUMsipktoaEZHb8T91FqZwl6vlDVagfl SlNRwuW688qv5M4ouEQr2Z4CXXprMuwiz0VsmU0DOaaBO8p91k0PxrhDnmDehO3DqVGh EpbYaaKYXGTPRUA4xhLTSTZ7gosP6AS/0bn0DUdHKsYLQoIRoIh02QpOsV2oDvp4qQLd NC9lJW+bbemFo1rEBlhnMvpGqgaj9J8dSOpaIj9IuzljcwlOGXgJoSnPtv9X9kgWbw6c 2FyNjEM60xs3PKBMeKaHSx8jm3sRAnuXzedAdxjE2RfS3P/GAN5R+3Cfff8KnTW8lRB/ T16A== X-Gm-Message-State: AMke39ltOJS919OwAHUBM9mvVpfEEI3mkeF4x0Ojrt8CSu+A5zfBwPHf1FanlkX2uZ5u/GmdidShXliu6rVjR/1KUmTLw1Xq4UsahJCyaFtv5cvX7Yi7N8hOTisFFrXJPb30np1vpfHCLDPsFaU= X-Received: by 10.28.20.209 with SMTP id 200mr524796wmu.64.1487026426409; Mon, 13 Feb 2017 14:53:46 -0800 (PST) X-Received: by 10.28.20.209 with SMTP id 200mr524788wmu.64.1487026426239; Mon, 13 Feb 2017 14:53:46 -0800 (PST) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: libvir-list@redhat.com Date: Mon, 13 Feb 2017 23:53:42 +0100 Message-Id: <6da7975f31051be1435c5a553272dcd722e5702f.1487026405.git.tgolembi@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Subject: [libvirt] [PATCH 1/2] util: storage: split function for JSON backing volume parsing in two 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Split virStorageSourceParseBackingJSON into two functions so that the core can be reused by other functions. The new function called virStorageSourceParseBackingJSONInternal accepts virJSONValuePtr. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- src/util/virstoragefile.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3d4bda700..3698eeeda 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3053,29 +3053,28 @@ virStorageSourceParseBackingJSONDeflatten(virJSONVa= luePtr json) =20 =20 static int -virStorageSourceParseBackingJSON(virStorageSourcePtr src, - const char *json) +virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, + virJSONValuePtr json) { - virJSONValuePtr root =3D NULL; virJSONValuePtr fixedroot =3D NULL; virJSONValuePtr file; const char *drvname; size_t i; int ret =3D -1; =20 - if (!(root =3D virJSONValueFromString(json))) - return -1; - - if (!(file =3D virJSONValueObjectGetObject(root, "file"))) { - if (!(fixedroot =3D virStorageSourceParseBackingJSONDeflatten(root= ))) + if (!(file =3D virJSONValueObjectGetObject(json, "file"))) { + if (!(fixedroot =3D virStorageSourceParseBackingJSONDeflatten(json= ))) goto cleanup; =20 file =3D fixedroot; } =20 if (!(drvname =3D virJSONValueObjectGetString(file, "driver"))) { + char *str =3D virJSONValueToString(json, false); virReportError(VIR_ERR_INVALID_ARG, _("JSON backing volume definti= on " - "'%s' lacks driver name"), j= son); + "'%s' lacks driver name"), + NULLSTR(str)); + VIR_FREE(str); goto cleanup; } =20 @@ -3091,12 +3090,28 @@ virStorageSourceParseBackingJSON(virStorageSourcePt= r src, "driver '%s'"), drvname); =20 cleanup: - virJSONValueFree(root); virJSONValueFree(fixedroot); return ret; } =20 =20 +static int +virStorageSourceParseBackingJSON(virStorageSourcePtr src, + const char *json) +{ + virJSONValuePtr root =3D NULL; + int ret =3D -1; + + if (!(root =3D virJSONValueFromString(json))) + return -1; + + ret =3D virStorageSourceParseBackingJSONInternal(src, root); + + virJSONValueFree(root); + return ret; +} + + virStorageSourcePtr virStorageSourceNewFromBackingAbsolute(const char *path) { --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 14:01:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487026635190478.1259641974682; Mon, 13 Feb 2017 14:57:15 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1DMrrNZ010877; Mon, 13 Feb 2017 17:53:53 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1DMroWD001038 for ; Mon, 13 Feb 2017 17:53:50 -0500 Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1DMroKS019128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 13 Feb 2017 17:53:50 -0500 Received: from mail-wj0-f198.google.com (mail-wj0-f198.google.com [209.85.210.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E0BC7F36F for ; Mon, 13 Feb 2017 22:53:50 +0000 (UTC) Received: by mail-wj0-f198.google.com with SMTP id h7so48638031wjy.6 for ; Mon, 13 Feb 2017 14:53:48 -0800 (PST) Received: from localhost.localdomain (ip-78-45-140-98.net.upcbroadband.cz. [78.45.140.98]) by smtp.gmail.com with ESMTPSA id k4sm1012195wmf.22.2017.02.13.14.53.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Feb 2017 14:53:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LQlymaHLGVy5t/pURE3XKG191Nrl3r9pLVJdrdRwP7s=; b=AsGtKxOzP5CQEMU8ZiZ7x7ej4SnsVadnVPcHEzIVN3NKF99MIXoyZ1YQoaVfAV7qOz lQ4xAr9OJud3gLKFgv9f22KqNRhtiBVYVaJh21utUH9Hmv241fKJRDdRSZRhWaI7eV4H BNF3v+82p6BKigZHOvtZRJN3SAWdIgP0wNrl8VaCkZUe0WU173jFb0oLM7GIgr2ofrQn uYO5Qu9ROBhIfzYZNg9BRBWqxFW/bu2mpnbS7IbBnPTYkUyEysCxPNzQHRxrSBpAkUzM zM89ok6bBHg+6owPmXaHun2b2KKYmkWN1xxF+qjjQn43OvDRzf894MvKYRRS+vNBfLE0 E6ig== X-Gm-Message-State: AMke39nohLf/8Tbvu79rMgVywvutaU0KC4J/px2wnTQnREahGOlo5riwBhF9Z7YN099XfNDn89yZ3Gx8OUfIUzuBPMMJ8IUpwFoLKNgHAp+31fzH92+KrbpPvWICZCELAKwzJt4KRu/wZ9h5n2s= X-Received: by 10.223.130.118 with SMTP id 109mr24866143wrb.10.1487026427653; Mon, 13 Feb 2017 14:53:47 -0800 (PST) X-Received: by 10.223.130.118 with SMTP id 109mr24866139wrb.10.1487026427479; Mon, 13 Feb 2017 14:53:47 -0800 (PST) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: libvir-list@redhat.com Date: Mon, 13 Feb 2017 23:53:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Subject: [libvirt] [PATCH 2/2] util: storage: add JSON backing volume parser 'raw' block driver 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 The 'raw' block driver in Qemu is not directly interesting from libvirt's perspective, but it can be layered above some other block drivers and this may be interesting for the user. The patch adds support for the 'raw' block driver. The driver is treated simply as a pass-through and child driver in JSON is queried to get the necessary information. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- src/util/virstoragefile.c | 16 ++++++++++++++++ tests/virstoragetest.c | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3698eeeda..0447016bf 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2648,6 +2648,11 @@ virStorageSourceParseBackingColon(virStorageSourcePt= r src, =20 =20 static int +virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, + virJSONValuePtr json); + + +static int virStorageSourceParseBackingJSONPath(virStorageSourcePtr src, virJSONValuePtr json, int type) @@ -2963,6 +2968,16 @@ virStorageSourceParseBackingJSONRBD(virStorageSource= Ptr src, return -1; } =20 +static int +virStorageSourceParseBackingJSONRaw(virStorageSourcePtr src, + virJSONValuePtr json, + int opaque ATTRIBUTE_UNUSED) +{ + /* There are no interesting attributes in raw driver. + * Treat it as pass-through. + */ + return virStorageSourceParseBackingJSONInternal(src, json); +} =20 struct virStorageSourceJSONDriverParser { const char *drvname; @@ -2985,6 +3000,7 @@ static const struct virStorageSourceJSONDriverParser = jsonParsers[] =3D { {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0}, {"ssh", virStorageSourceParseBackingJSONSSH, 0}, {"rbd", virStorageSourceParseBackingJSONRBD, 0}, + {"raw", virStorageSourceParseBackingJSONRaw, 0}, }; =20 =20 diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index f766df115..1bf490c43 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1492,6 +1492,12 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{ \"file\": { " + "\"driver\": \"raw\"," + "\"file\": {" + "\"driver\": \"file\"," + "\"filename\": \"/path/to/file\" } } }= ", + "\n"); =20 cleanup: /* Final cleanup */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list