From nobody Mon Feb 9 06:34:01 2026 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