From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158097555824173.70869424370687; Wed, 5 Feb 2020 23:52:38 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-K_6WOJrgNVGxNu5n-sqrbg-1; Thu, 06 Feb 2020 02:52:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 365C214E7; Thu, 6 Feb 2020 07:52:29 +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 03D3C26167; Thu, 6 Feb 2020 07:52:29 +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 A24FD866A8; Thu, 6 Feb 2020 07:52:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qBvb009907 for ; Thu, 6 Feb 2020 02:52:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9A821001B07; Thu, 6 Feb 2020 07:52:11 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42872100194E for ; Thu, 6 Feb 2020 07:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975557; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BhSJBGee6OStJAcEz9Gu7g8xQRula74xd//yJMXZ3Jw=; b=KqVA/BuGyJW8IKgDZytn++Hsf2dhXJ+g6BNv6MMlv4sbNDilIhq1apLxikmhT5Z3+XJfJK kbg+C8FIhCP60+hWR0iLDS6BnQCmaJ6P47gQCVDCUKZiLKkEVfw6UboUT7jogv9vBZi9iC 5IPD79cAlhN+rKbY5jFcteXU/TAx0qM= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/15] virStorageSourceParseBackingJSON: Pass around original backing file string Date: Thu, 6 Feb 2020 08:51:53 +0100 Message-Id: <6f3e8adfc8f88bee1ce98ac3d92d077d43b38cab.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: K_6WOJrgNVGxNu5n-sqrbg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are a few error messages which might want to report the original backing store string. Pass it around rather than trying to re-generate it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a08705603a..bdf82b04bb 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3051,12 +3051,14 @@ virStorageSourceParseBackingColon(virStorageSourceP= tr src, static int virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, - virJSONValuePtr json); + virJSONValuePtr json, + const char *jsonstr); static int virStorageSourceParseBackingJSONPath(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int type) { const char *path; @@ -3101,6 +3103,7 @@ virStorageSourceParseBackingJSONUriStr(virStorageSour= cePtr src, static int virStorageSourceParseBackingJSONUri(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int protocol) { const char *uri; @@ -3204,6 +3207,7 @@ virStorageSourceParseBackingJSONSocketAddress(virStor= ageNetHostDefPtr host, static int virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int opaque G_GNUC_UNUSED) { const char *uri =3D virJSONValueObjectGetString(json, "filename"); @@ -3257,6 +3261,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSou= rcePtr src, static int virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int opaque G_GNUC_UNUSED) { const char *transport =3D virJSONValueObjectGetString(json, "transport= "); @@ -3326,6 +3331,7 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourc= ePtr src, static int virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int opaque G_GNUC_UNUSED) { const char *path =3D virJSONValueObjectGetString(json, "path"); @@ -3373,6 +3379,7 @@ virStorageSourceParseBackingJSONNbd(virStorageSourceP= tr src, static int virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int opaque G_GNUC_UNUSED) { const char *filename; @@ -3416,6 +3423,7 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSo= urcePtr src, static int virStorageSourceParseBackingJSONSSH(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int opaque G_GNUC_UNUSED) { const char *path =3D virJSONValueObjectGetString(json, "path"); @@ -3458,6 +3466,7 @@ virStorageSourceParseBackingJSONSSH(virStorageSourceP= tr src, static int virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int opaque G_GNUC_UNUSED) { const char *filename; @@ -3509,18 +3518,20 @@ virStorageSourceParseBackingJSONRBD(virStorageSourc= ePtr src, static int virStorageSourceParseBackingJSONRaw(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr, int opaque G_GNUC_UNUSED) { /* There are no interesting attributes in raw driver. * Treat it as pass-through. */ - return virStorageSourceParseBackingJSONInternal(src, json); + return virStorageSourceParseBackingJSONInternal(src, json, jsonstr); } static int virStorageSourceParseBackingJSONVxHS(virStorageSourcePtr src, virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, int opaque G_GNUC_UNUSED) { const char *vdisk_id =3D virJSONValueObjectGetString(json, "vdisk-id"); @@ -3559,7 +3570,7 @@ struct virStorageSourceJSONDriverParser { * can't be converted to libvirt's configuration (e.g. inline authenti= cation * credentials are present). */ - int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque); + int (*func)(virStorageSourcePtr src, virJSONValuePtr json, const char = *jsonstr, int opaque); int opaque; }; @@ -3586,36 +3597,34 @@ static const struct virStorageSourceJSONDriverParse= r jsonParsers[] =3D { static int virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, - virJSONValuePtr json) + virJSONValuePtr json, + const char *jsonstr) { g_autoptr(virJSONValue) deflattened =3D NULL; virJSONValuePtr file; const char *drvname; size_t i; - g_autofree char *str =3D NULL; if (!(deflattened =3D virJSONValueObjectDeflatten(json))) return -1; if (!(file =3D virJSONValueObjectGetObject(deflattened, "file"))) { - str =3D virJSONValueToString(json, false); virReportError(VIR_ERR_INVALID_ARG, _("JSON backing volume definition '%s' lacks 'file'= object"), - NULLSTR(str)); + jsonstr); return -1; } if (!(drvname =3D virJSONValueObjectGetString(file, "driver"))) { - str =3D virJSONValueToString(json, false); virReportError(VIR_ERR_INVALID_ARG, _("JSON backing volume definition '%s' lacks driver= name"), - NULLSTR(str)); + jsonstr); return -1; } for (i =3D 0; i < G_N_ELEMENTS(jsonParsers); i++) { if (STREQ(drvname, jsonParsers[i].drvname)) - return jsonParsers[i].func(src, file, jsonParsers[i].opaque); + return jsonParsers[i].func(src, file, jsonstr, jsonParsers[i].= opaque); } virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3634,7 +3643,7 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr = src, if (!(root =3D virJSONValueFromString(json))) return -1; - return virStorageSourceParseBackingJSONInternal(src, root); + return virStorageSourceParseBackingJSONInternal(src, root, json); } --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580975545078139.6523707862175; Wed, 5 Feb 2020 23:52:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-VZSQ8gRiNO2v1622Qq6Lmg-1; Thu, 06 Feb 2020 02:52:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3DC5184AEA3; Thu, 6 Feb 2020 07:52:16 +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 8EA05790EF; Thu, 6 Feb 2020 07:52:16 +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 5330A866A7; Thu, 6 Feb 2020 07:52:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qCBK009912 for ; Thu, 6 Feb 2020 02:52:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A66B100194E; Thu, 6 Feb 2020 07:52:12 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1309210018FF for ; Thu, 6 Feb 2020 07:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975544; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HiapqYqkrbbQI/ED2PeIdOAG0oKgJB4yHAj64SchvEA=; b=WFYSzL/LaZ2MNG69zkoIMs2Uoa6cRy6HNiZtXyYCKsRBer1mDr+Dl9VLthjFrvsGEW2GM6 u5EOZCg1SPuBL1u4mrUnfj85qLdEM4gfMesig7UbIIFZdHwIbLM84niSb/roXOJ3gSGKoR kETPArzCtny/4qFnG4m7TbvogteDIZo= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/15] virStorageSourceParseBackingJSON: Move deflattening of json: URIs out of recursion Date: Thu, 6 Feb 2020 08:51:54 +0100 Message-Id: <9f6437bfa796107ea1b7b7c2725b349aaa9ba21b.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: VZSQ8gRiNO2v1622Qq6Lmg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Originally virStorageSourceParseBackingJSON didn't recurse, but when the 'raw' driver support was added we need to parse it's information which contains nested 'file' object. Since the deflattening helper recurses already there's no need to call it again. Move it one level up to the entry point. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index bdf82b04bb..fd0069a4fa 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3600,15 +3600,11 @@ virStorageSourceParseBackingJSONInternal(virStorage= SourcePtr src, virJSONValuePtr json, const char *jsonstr) { - g_autoptr(virJSONValue) deflattened =3D NULL; virJSONValuePtr file; const char *drvname; size_t i; - if (!(deflattened =3D virJSONValueObjectDeflatten(json))) - return -1; - - if (!(file =3D virJSONValueObjectGetObject(deflattened, "file"))) { + if (!(file =3D virJSONValueObjectGetObject(json, "file"))) { virReportError(VIR_ERR_INVALID_ARG, _("JSON backing volume definition '%s' lacks 'file'= object"), jsonstr); @@ -3639,11 +3635,15 @@ virStorageSourceParseBackingJSON(virStorageSourcePt= r src, const char *json) { g_autoptr(virJSONValue) root =3D NULL; + g_autoptr(virJSONValue) deflattened =3D NULL; if (!(root =3D virJSONValueFromString(json))) return -1; - return virStorageSourceParseBackingJSONInternal(src, root, json); + if (!(deflattened =3D virJSONValueObjectDeflatten(root))) + return -1; + + return virStorageSourceParseBackingJSONInternal(src, deflattened, json= ); } --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580975547100983.7149097133324; Wed, 5 Feb 2020 23:52:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-YIL5QX80M7G_0RgXuqlO1A-1; Thu, 06 Feb 2020 02:52:24 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18A2B184AEA4; Thu, 6 Feb 2020 07:52:19 +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 CB5A1790EB; Thu, 6 Feb 2020 07:52:18 +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 B780B866A5; Thu, 6 Feb 2020 07:52:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qDhN009920 for ; Thu, 6 Feb 2020 02:52:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C21A1001B07; Thu, 6 Feb 2020 07:52:13 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id D97E4100194E for ; Thu, 6 Feb 2020 07:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975546; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4wVM0+SFI+PLVn7P4S8IjDgEJZ4KgDXtrxirzruy5BM=; b=YpXZfjBT9hcCqKoFmypXZZU2SoK4OeCbL6GF8YxVQ6dOjw+iowHpERD+PpwFoL6hXQZdHU YAbDMyu9t3z5lxKr9ayP388afBbnzSf0fpcfKe3VPd8T8EGznRthGbcSfp2dYZicqz4rBF XVWXnjJgU0hC7gekg2DF/XuejUldcjg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/15] virStorageSourceJSONDriverParser: annotate 'format' drivers Date: Thu, 6 Feb 2020 08:51:55 +0100 Message-Id: <19e6dda67cb1f8ddb063b491081e28502c01a439.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: YIL5QX80M7G_0RgXuqlO1A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The parser was originally designed only for protocol parsers. Since we already have 'raw' format driver in the list we'll need to be able to parse it too. In later patches this will be used to prevent parsing nested format drivers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index fd0069a4fa..565ba08319 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3563,6 +3563,7 @@ virStorageSourceParseBackingJSONVxHS(virStorageSource= Ptr src, struct virStorageSourceJSONDriverParser { const char *drvname; + bool formatdriver; /** * The callback gets a pre-allocated storage source @src and the JSON * object to parse. The callback shall return -1 on error and report e= rror @@ -3575,22 +3576,22 @@ struct virStorageSourceJSONDriverParser { }; static const struct virStorageSourceJSONDriverParser jsonParsers[] =3D { - {"file", virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_FILE}, - {"host_device", virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE= _BLOCK}, - {"host_cdrom", virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE_= BLOCK}, - {"http", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL= _HTTP}, - {"https", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCO= L_HTTPS}, - {"ftp", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL_= FTP}, - {"ftps", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL= _FTPS}, - {"tftp", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL= _TFTP}, - {"gluster", virStorageSourceParseBackingJSONGluster, 0}, - {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0}, - {"nbd", virStorageSourceParseBackingJSONNbd, 0}, - {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0}, - {"ssh", virStorageSourceParseBackingJSONSSH, 0}, - {"rbd", virStorageSourceParseBackingJSONRBD, 0}, - {"raw", virStorageSourceParseBackingJSONRaw, 0}, - {"vxhs", virStorageSourceParseBackingJSONVxHS, 0}, + {"file", false, virStorageSourceParseBackingJSONPath, VIR_STORAGE_TYPE= _FILE}, + {"host_device", false, virStorageSourceParseBackingJSONPath, VIR_STORA= GE_TYPE_BLOCK}, + {"host_cdrom", false, virStorageSourceParseBackingJSONPath, VIR_STORAG= E_TYPE_BLOCK}, + {"http", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_P= ROTOCOL_HTTP}, + {"https", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_= PROTOCOL_HTTPS}, + {"ftp", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PR= OTOCOL_FTP}, + {"ftps", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_P= ROTOCOL_FTPS}, + {"tftp", false, virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_P= ROTOCOL_TFTP}, + {"gluster", false, virStorageSourceParseBackingJSONGluster, 0}, + {"iscsi", false, virStorageSourceParseBackingJSONiSCSI, 0}, + {"nbd", false, virStorageSourceParseBackingJSONNbd, 0}, + {"sheepdog", false, virStorageSourceParseBackingJSONSheepdog, 0}, + {"ssh", false, virStorageSourceParseBackingJSONSSH, 0}, + {"rbd", false, virStorageSourceParseBackingJSONRBD, 0}, + {"raw", true, virStorageSourceParseBackingJSONRaw, 0}, + {"vxhs", false, virStorageSourceParseBackingJSONVxHS, 0}, }; --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 15809755642571020.7129961902544; Wed, 5 Feb 2020 23:52:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-7LoirxayOyesBvEppDa5cA-1; Thu, 06 Feb 2020 02:52:40 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0480101FC67; Thu, 6 Feb 2020 07:52:34 +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 C7D425DA84; Thu, 6 Feb 2020 07:52:34 +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 8C25F18089D7; Thu, 6 Feb 2020 07:52:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qEKA009932 for ; Thu, 6 Feb 2020 02:52:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2DB6B1001B09; Thu, 6 Feb 2020 07:52:14 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAB101001B07 for ; Thu, 6 Feb 2020 07:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975563; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rNWFYJIeLL02qG2+BS2oIFMtH1Fi5TO3FKfIeB7w5CA=; b=OWk10Cjq5p8BuemveMV4SfDrYifOdluCmqUByxkOH5DJgucINBz4v0mHtcIzC7d1YDnLJq F6udBBt11ciOsNYYBXhT0YTkRPVJTRm4+Vi1ELT9ULo2f1eDTlic/ejuXMszlC6NzxjUwC d79lxdoEXH6ndbA+x/DFlNah+wfcPSg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/15] virStorageSourceParseBackingJSON: Allow 'json:' pseudo URIs without 'file' wrapper Date: Thu, 6 Feb 2020 08:51:56 +0100 Message-Id: <2ece964f71f8a9e228180fe100f406f25df4965d.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 7LoirxayOyesBvEppDa5cA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are two possibilities: 1) json:{"file":{"driver":...}} 2) json:{"driver":...} Our code didn't work properly with the second one as it was expecting the 'file' wrapper. Conditionalize the removal to only the situation when the top level doesn't have "driver". Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 41 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 565ba08319..ddf837c3b3 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3521,10 +3521,17 @@ virStorageSourceParseBackingJSONRaw(virStorageSourc= ePtr src, const char *jsonstr, int opaque G_GNUC_UNUSED) { - /* There are no interesting attributes in raw driver. - * Treat it as pass-through. - */ - return virStorageSourceParseBackingJSONInternal(src, json, jsonstr); + virJSONValuePtr file; + + /* 'raw' is a format driver so it can have protocol driver children */ + if (!(file =3D virJSONValueObjectGetObject(json, "file"))) { + virReportError(VIR_ERR_INVALID_ARG, + _("JSON backing volume definition '%s' lacks 'file'= object"), + jsonstr); + return -1; + } + + return virStorageSourceParseBackingJSONInternal(src, file, jsonstr); } @@ -3601,18 +3608,10 @@ virStorageSourceParseBackingJSONInternal(virStorage= SourcePtr src, virJSONValuePtr json, const char *jsonstr) { - virJSONValuePtr file; const char *drvname; size_t i; - if (!(file =3D virJSONValueObjectGetObject(json, "file"))) { - virReportError(VIR_ERR_INVALID_ARG, - _("JSON backing volume definition '%s' lacks 'file'= object"), - jsonstr); - return -1; - } - - if (!(drvname =3D virJSONValueObjectGetString(file, "driver"))) { + if (!(drvname =3D virJSONValueObjectGetString(json, "driver"))) { virReportError(VIR_ERR_INVALID_ARG, _("JSON backing volume definition '%s' lacks driver= name"), jsonstr); @@ -3621,7 +3620,7 @@ virStorageSourceParseBackingJSONInternal(virStorageSo= urcePtr src, for (i =3D 0; i < G_N_ELEMENTS(jsonParsers); i++) { if (STREQ(drvname, jsonParsers[i].drvname)) - return jsonParsers[i].func(src, file, jsonstr, jsonParsers[i].= opaque); + return jsonParsers[i].func(src, json, jsonstr, jsonParsers[i].= opaque); } virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3637,6 +3636,7 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr = src, { g_autoptr(virJSONValue) root =3D NULL; g_autoptr(virJSONValue) deflattened =3D NULL; + virJSONValuePtr file =3D NULL; if (!(root =3D virJSONValueFromString(json))) return -1; @@ -3644,7 +3644,18 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr= src, if (!(deflattened =3D virJSONValueObjectDeflatten(root))) return -1; - return virStorageSourceParseBackingJSONInternal(src, deflattened, json= ); + /* There are 2 possible syntaxes: + * 1) json:{"file":{"driver":...}} + * 2) json:{"driver":...} + * Remove the 'file' wrapper object in case 1. + */ + if (!virJSONValueObjectHasKey(deflattened, "driver")) + file =3D virJSONValueObjectGetObject(deflattened, "file"); + + if (!file) + file =3D deflattened; + + return virStorageSourceParseBackingJSONInternal(src, file, json); } --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580975566827520.3890459892207; Wed, 5 Feb 2020 23:52:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-HEuU1oBNMB2ojJRleX_19w-1; Thu, 06 Feb 2020 02:52:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35727DB25; Thu, 6 Feb 2020 07:52:38 +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 1127F790EB; Thu, 6 Feb 2020 07:52:38 +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 C375718089D8; Thu, 6 Feb 2020 07:52:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qF3b009940 for ; Thu, 6 Feb 2020 02:52:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3A841001B09; Thu, 6 Feb 2020 07:52:14 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BF371001B07 for ; Thu, 6 Feb 2020 07:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975565; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=az69VhkkGoFCycTUu2fmE0DGCcJbT5KpChZX6126NZ4=; b=Z+hA8MtTkcfHRuT7Cy50FsmwbxVRjzPb9yRMfeetDY3wu+B41wxIBvJMFuBhZQj7bWLzgQ y5kEduRXKtejbFmOp+wUIQyXiOmvBAVrvRKYcn+iiy5QyOa3b8E/BZoTkNoS1ZQLawuX5L aNx1BVi8Lt9PpOQuWdH2Gjw2hxe25Hs= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/15] virStorageSourceParseBackingJSON: Prevent arbitrary nesting with format drivers Date: Thu, 6 Feb 2020 08:51:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: HEuU1oBNMB2ojJRleX_19w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since we parse attributes for 'raw' which is a format driver and thus has nested 'file' structure we must prevent that this isn't nested arbitrarily. Add a flag for the function which allows parsing of 'format' type drivers only on the first pass. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ddf837c3b3..7ffb2cdcf4 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3052,7 +3052,8 @@ virStorageSourceParseBackingColon(virStorageSourcePtr= src, static int virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, virJSONValuePtr json, - const char *jsonstr); + const char *jsonstr, + bool allowformat); static int @@ -3531,7 +3532,7 @@ virStorageSourceParseBackingJSONRaw(virStorageSourceP= tr src, return -1; } - return virStorageSourceParseBackingJSONInternal(src, file, jsonstr); + return virStorageSourceParseBackingJSONInternal(src, file, jsonstr, fa= lse); } @@ -3606,7 +3607,8 @@ static const struct virStorageSourceJSONDriverParser = jsonParsers[] =3D { static int virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, virJSONValuePtr json, - const char *jsonstr) + const char *jsonstr, + bool allowformat) { const char *drvname; size_t i; @@ -3619,8 +3621,17 @@ virStorageSourceParseBackingJSONInternal(virStorageS= ourcePtr src, } for (i =3D 0; i < G_N_ELEMENTS(jsonParsers); i++) { - if (STREQ(drvname, jsonParsers[i].drvname)) - return jsonParsers[i].func(src, json, jsonstr, jsonParsers[i].= opaque); + if (STRNEQ(drvname, jsonParsers[i].drvname)) + continue; + + if (jsonParsers[i].formatdriver && !allowformat) { + virReportError(VIR_ERR_INVALID_ARG, + _("JSON backing volume definition '%s' must not= have nested format drivers"), + jsonstr); + return -1; + } + + return jsonParsers[i].func(src, json, jsonstr, jsonParsers[i].opaq= ue); } virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3655,7 +3666,7 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr = src, if (!file) file =3D deflattened; - return virStorageSourceParseBackingJSONInternal(src, file, json); + return virStorageSourceParseBackingJSONInternal(src, file, json, true); } --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 15809755597171008.0194304159902; Wed, 5 Feb 2020 23:52:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-eefihPgPNI65SLzpJRLfCw-1; Thu, 06 Feb 2020 02:52:36 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5208C8018A3; Thu, 6 Feb 2020 07:52:31 +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 20FEB10018FF; Thu, 6 Feb 2020 07:52:31 +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 C7EA018089D0; Thu, 6 Feb 2020 07:52:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qFaJ009952 for ; Thu, 6 Feb 2020 02:52:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id C45B0100194E; Thu, 6 Feb 2020 07:52:15 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D1DA10018FF for ; Thu, 6 Feb 2020 07:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975558; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3wwhBm2kcdMUp81ln3bhEbJ241e07wDUGKVBMC4wa90=; b=g2j197XdTDgfV8hErgPIhG6eW4zcNoJmR6XcVYFvNRLpQFeypGQ7KtNV4EGVtJ8s3mYjV0 6xPNmestwgWIJDqZdaKjY3dQbvMVKUJmCHMLKIqXWVBP1SpKWoOaiTNBtULiCfxIe0reLH 7la5YTY7i1dYvXbPMUAfzlDp5M0amTY= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/15] tests: virstorage: Add test cases for "json:" pseudo-URI without 'file' wrapper Date: Thu, 6 Feb 2020 08:51:58 +0100 Message-Id: <3374547b172d0395c530641b68abdc77fcb4b907.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: eefihPgPNI65SLzpJRLfCw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add few cases that prove the second format of "json:" pseudo-URIs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virstoragetest.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 4341c04b1e..6d62aab654 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1315,6 +1315,10 @@ mymain(void) "}" "}", "\n"); + TEST_BACKING_PARSE("json:{\"driver\":\"file\"," + "\"filename\":\"/path/to/file\"" + "}", + "\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"host_device\", " "\"file.filename\":\"/path/to/dev\"}", "\n"); @@ -1389,6 +1393,12 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE("json:{\"driver\":\"nbd\"," + "\"path\":\"/path/to/socket\"" + "}", + "\n" + " \n" + "\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"nbd\"," "\"file.path\":\"/path/to/socket\"" "}", --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580975559915197.79638862636557; Wed, 5 Feb 2020 23:52:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-56--1ZycxM3NfWPaY04z0dqCg-1; Thu, 06 Feb 2020 02:52:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EC7E102CE15; Thu, 6 Feb 2020 07:52:31 +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 1E1C6790EB; Thu, 6 Feb 2020 07:52:31 +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 C4B9218089CF; Thu, 6 Feb 2020 07:52:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qG0s009957 for ; Thu, 6 Feb 2020 02:52:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 962C41001B07; Thu, 6 Feb 2020 07:52:16 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F0DB100194E for ; Thu, 6 Feb 2020 07:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975558; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=l9EVpTVkfv5Pqj2+zkp30KtGcBRJ++PudU3B5jvn2CM=; b=SgAm8vB1tzIsH3275OkETr7235BB10rBYMmrwhRCFt2jNHfrQatS2t4CsiOfiyBVwqjcUm +hngTurAFi/6/hE8Aa4KR0GvArGSxsEsLEtF0o6W9dfMuLOqpBfx9Lk7PcsJl+tmTRCdWO 03rB5tu5fqqhqQMge5HrStjnv3L8HIk= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/15] tests: virstorage: Add test data for json specified raw image with offset/size Date: Thu, 6 Feb 2020 08:51:59 +0100 Message-Id: <5d11031b5c08dcb4e6a4e89667c06bdde7c15e2e.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: -1ZycxM3NfWPaY04z0dqCg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" QEMU allows specifying the offset and size into a raw file to expose a sub-slice of the image to the guest with the raw driver. Libvirt currently doesn't support it but we can add test case for future reference. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virstoragetest.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 6d62aab654..25d41f0de4 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1593,6 +1593,15 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE_FULL("json:{ \"driver\": \"raw\"," + "\"offset\": 10752," + "\"size\": 4063232," + "\"file\": { \"driver\": \"file\"," + "\"filename\": \"/tmp/test= fle\"" + "}" + "}", + "\n", 0); + #endif /* WITH_YAJL */ cleanup: --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580975571976115.8629074203809; Wed, 5 Feb 2020 23:52:51 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-y4EDIkMkO2u-0GoHoz1lYw-1; Thu, 06 Feb 2020 02:52:48 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07924DB2D; Thu, 6 Feb 2020 07:52:42 +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 D7C23790F7; Thu, 6 Feb 2020 07:52:41 +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 8EC7C180887A; Thu, 6 Feb 2020 07:52:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qHKK009962 for ; Thu, 6 Feb 2020 02:52:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6745F1001B07; Thu, 6 Feb 2020 07:52:17 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4E99100194E for ; Thu, 6 Feb 2020 07:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975571; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IVUWaIfGmWldmbcp0PUQBR2/xfK3fk4elfnAjLdKBjk=; b=PKzJiKyUnbGUsxEirsf24exx1tuT9iE9dBqY0icADRGFYqVNX+SaqCHDI5ptESWRMXMAWY 7nnxA0hmjnIYwPe5Mpj07Hpyg5HC3KKNkwE4NJxa9SCMpPwc1jMFuQHIIcKgzdqAu7vap/ 0fwZ0n+d5W0V29dgESxQSa1H/HnqK6Y= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/15] util: virstoragefile: Add data structure for storing storage source slices Date: Thu, 6 Feb 2020 08:52:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: y4EDIkMkO2u-0GoHoz1lYw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Introduce virStorageSourceSlice which will store the 'offset' and 'size' of a virStorageSource and declare it as 'sliceStorage' and 'sliceFormat' attributes of a virStorageSource. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 18 ++++++++++++++++++ src/util/virstoragefile.h | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7ffb2cdcf4..30d5a2fe67 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2248,6 +2248,18 @@ virStorageSourcePoolDefCopy(const virStorageSourcePo= olDef *src) } +static virStorageSourceSlicePtr +virStorageSourceSliceCopy(const virStorageSourceSlice *src) +{ + virStorageSourceSlicePtr ret =3D g_new0(virStorageSourceSlice, 1); + + ret->offset =3D src->offset; + ret->size =3D src->size; + + return ret; +} + + /** * virStorageSourcePtr: * @@ -2302,6 +2314,9 @@ virStorageSourceCopy(const virStorageSource *src, def->tlsAlias =3D g_strdup(src->tlsAlias); def->tlsCertdir =3D g_strdup(src->tlsCertdir); + def->sliceFormat =3D virStorageSourceSliceCopy(src->sliceFormat); + def->sliceStorage =3D virStorageSourceSliceCopy(src->sliceStorage); + if (src->nhosts) { if (!(def->hosts =3D virStorageNetHostDefCopy(src->nhosts, src->ho= sts))) return NULL; @@ -2581,6 +2596,9 @@ virStorageSourceClear(virStorageSourcePtr def) VIR_FREE(def->timestamps); VIR_FREE(def->externalDataStoreRaw); + VIR_FREE(def->sliceFormat); + VIR_FREE(def->sliceStorage); + virObjectUnref(def->externalDataStore); def->externalDataStore =3D NULL; diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 39e50a989d..a6b474ec51 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -242,6 +242,15 @@ struct _virStorageSourceNVMeDef { /* Don't forget to update virStorageSourceNVMeDefCopy */ }; + +typedef struct _virStorageSourceSlice virStorageSourceSlice; +typedef virStorageSourceSlice *virStorageSourceSlicePtr; +struct _virStorageSourceSlice { + unsigned long long offset; + unsigned long long size; +}; + + typedef struct _virStorageDriverData virStorageDriverData; typedef virStorageDriverData *virStorageDriverDataPtr; @@ -286,6 +295,9 @@ struct _virStorageSource { bool nocow; bool sparse; + virStorageSourceSlicePtr sliceFormat; + virStorageSourceSlicePtr sliceStorage; + virStoragePermsPtr perms; virStorageTimestampsPtr timestamps; unsigned long long capacity; /* in bytes, 0 if unknown */ --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580975584850363.5198293201421; Wed, 5 Feb 2020 23:53:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-iyk0qptdM_Ko4yFgx-bWYA-1; Thu, 06 Feb 2020 02:52:39 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E500C2F61; Thu, 6 Feb 2020 07:52:34 +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 BE2355DA83; Thu, 6 Feb 2020 07:52:34 +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 800F7866B3; Thu, 6 Feb 2020 07:52:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qIJt009980 for ; Thu, 6 Feb 2020 02:52:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3869A1001B2B; Thu, 6 Feb 2020 07:52:18 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id B54EC1001B07 for ; Thu, 6 Feb 2020 07:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975582; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VL654TE5pwlBBg+E9N2ejFzg5tyq3HD3bgna83Idnlk=; b=VpPh/1vEYqr3SQ3R0qc/zpn8Cu03TTInY0pAMP/td553o8pPFFQrzxgU1X4AGHDrZVHpRO hcaMk0f6EJw5sZaEZ9bhN5YVKxq/LS+bwWeOOrjsFZS1Aumt7zGrHH3ZXUbhKHNFoiNP8m ETuiQrOmqFVDwvthGKc5YDpABQ8BF4c= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/15] qemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size' for slice Date: Thu, 6 Feb 2020 08:52:01 +0100 Message-Id: <407c48ace753352b8a02d0fd222935f787579b37.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: iyk0qptdM_Ko4yFgx-bWYA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If we have a 'format' type slice for a raw driver we can directly format the values. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 63116ef5f2..5fac8c17b4 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1187,16 +1187,18 @@ qemuBlockStorageSourceGetFormatRawProps(virStorageS= ourcePtr src, secretalias =3D srcPriv->encinfo->s.aes.alias; } - /* currently unhandled properties for the 'raw' driver: - * 'offset' - * 'size' - */ - if (virJSONValueObjectAdd(props, "s:driver", driver, "S:key-secret", secretalias, NULL) < 0) return -1; + if (src->sliceFormat && + virJSONValueObjectAdd(props, + "p:offset", src->sliceFormat->offset, + "p:size", src->sliceFormat->size, + NULL) < 0) + return -1; + return 0; } --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580975601494564.769138033737; Wed, 5 Feb 2020 23:53:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-1k4rM65INbm7-y5KIq_7dQ-1; Thu, 06 Feb 2020 02:52:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 515D1184AEA3; Thu, 6 Feb 2020 07:52:38 +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 2DA788EA0C; Thu, 6 Feb 2020 07:52:38 +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 E1FF5866B8; Thu, 6 Feb 2020 07:52:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qJLN009993 for ; Thu, 6 Feb 2020 02:52:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0BB411001B2C; Thu, 6 Feb 2020 07:52:19 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87D4C1001B07 for ; Thu, 6 Feb 2020 07:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975600; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aJR0G7S7M1Q8UThzJ4ER0XdxsXQJryXvM5NFBh7qO5I=; b=ZxOeIZbu+Hc53ZK3ZwtX+TIP/jEqcYhL5vYzvjdG1GtYn6EBkr1sowyZDEYA4gBEmDmOjJ QX1RasUWlQQfSjNuVGkojkSsstnAJN9sf1ntgj6sZa+reD8+v2ZwMYimaSohEdNCrTck/8 dTjyvhHuvU2sM4N6fix5PPaiQmXf+x0= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/15] qemuDomainValidateStorageSource: Reject unsupported slices Date: Thu, 6 Feb 2020 08:52:02 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 1k4rM65INbm7-y5KIq_7dQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We will currently support slice only for the 'raw' format slice reject any other option. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6ebee4d5f4..8a38101bea 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6823,6 +6823,21 @@ qemuDomainValidateStorageSource(virStorageSourcePtr = src, return -1; } + if (src->sliceStorage) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("storage slice is not supported for format '%s'"), + virStorageFileFormatTypeToString(src->format)); + return -1; + } + + if (src->sliceFormat && + src->format !=3D VIR_STORAGE_FILE_RAW) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("format slice is not supported for format '%s'"), + virStorageFileFormatTypeToString(src->format)); + return -1; + } + return 0; } --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580975570755806.2117600562486; Wed, 5 Feb 2020 23:52:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-fdy4x0IHNLilPPDMehQB-A-1; Thu, 06 Feb 2020 02:52:47 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D054184AEBD; Thu, 6 Feb 2020 07:52:42 +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 191A81A8E4; Thu, 6 Feb 2020 07:52:42 +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 D11D31808878; Thu, 6 Feb 2020 07:52:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qLOX010014 for ; Thu, 6 Feb 2020 02:52:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id BCA441001B09; Thu, 6 Feb 2020 07:52:21 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4578C1001B07 for ; Thu, 6 Feb 2020 07:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975569; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VvdQ8uzXE6c7/lidbqfvA0q+QGICCX9d0dxowe5CG2Q=; b=hECTb+Fep+cpGeh21jYN4OKwFK2eZaVN2SnoOVdTF+bejAPasQRe+sejPs8BWsxt5tmWzs 9TaAs/3gbifqtHOqgXlEK14CAz1pH/q3ZWP3KrrOGWC0129xQmWIXxeC1z63FJUfNETqYL RGwgZlzZyT06DnTcqUhVtcNa0Y3sx+4= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/15] docs: formatdomain: Close on one of disk examples Date: Thu, 6 Feb 2020 08:52:03 +0100 Message-Id: <7bfe4f26ab3c131e0d4c196d54e97abddd22ab0d.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: fdy4x0IHNLilPPDMehQB-A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.html.in | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 60a103d7c6..acb604e9c7 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2881,6 +2881,7 @@ <reservations managed=3D'no'> <source type=3D'unix' path=3D'/path/to/qemu-pr-helper' mode=3D'= client'/> </reservations> + </source> <target dev=3D'sda' bus=3D'scsi'/> <address type=3D'drive' controller=3D'0' bus=3D'0' target=3D'3' uni= t=3D'0'/> </disk> --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580975592753533.9687848359005; Wed, 5 Feb 2020 23:53:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-4xyzhlm0PsG56G0s-8u5Tg-1; Thu, 06 Feb 2020 02:52:50 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7201A184AEB5; Thu, 6 Feb 2020 07:52:45 +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 507A85DA7E; Thu, 6 Feb 2020 07:52:45 +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 123B2866B0; Thu, 6 Feb 2020 07:52:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qMvQ010019 for ; Thu, 6 Feb 2020 02:52:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8CE051001B09; Thu, 6 Feb 2020 07:52:22 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1672A1001B07 for ; Thu, 6 Feb 2020 07:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975591; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kcvqt2lhJZpGNFYaXos6dKd5tjwflIOX4Snr9YN/+9Y=; b=DEFC9gwQ27+NzI4VCWZKfSdhwZ7iqn9swzXjbwRSIAkIz4M1Z+f1j1RVWcEstKiqwtMQOq X453hh8Iu0iOLfdhZmREo9MpijsYS7wObdygKvxbFI97MeuphR9/hBC/V6JUoHDKbH8F8n 5QVZyzHICOPuC7O7bUP3YnRPFkcrqR0= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/15] docs: Document the new sub-element of disk's Date: Thu, 6 Feb 2020 08:52:04 +0100 Message-Id: <506d79a932b9668b66b13f60e37a14d00b5bcd06.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: 4xyzhlm0PsG56G0s-8u5Tg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We are going to add support for specifying offset and size attributes which will allow controling where the image and where the guest data itself starts in the source of the disk. This will be represented by a element filled with either a for the offset of the image format itself. then controls where the guest data starts in the image. Add the XML documentation and RNG schema. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.html.in | 11 +++++++++++ docs/schemas/domaincommon.rng | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index acb604e9c7..2143e57b11 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2878,6 +2878,9 @@ <disk type=3D'block' device=3D'lun'> <driver name=3D'qemu' type=3D'raw'/> <source dev=3D'/dev/sda'> + <slices> + <slice type=3D'format' offset=3D'12345' size=3D'123'/> + </slices> <reservations managed=3D'no'> <source type=3D'unix' path=3D'/path/to/qemu-pr-helper' mode=3D'= client'/> </reservations> @@ -3360,6 +3363,14 @@ controller. Since 6.0.0 +
slices
+
The slices element using its slice + sub-elements allows configuring offset and size of either the + location of the image format (slice type=3D'storage') or + the guest data in the image container (slice type=3D'for= mat'). + + The offset and size values are in by= tes. +

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ea237a05e5..720e4e3da7 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1595,12 +1595,45 @@ + + + + + + + + + + + + + + + + + storage + + + + + + + + format + + + + + + + + --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580975644246810.4622157889778; Wed, 5 Feb 2020 23:54:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-Q8qNphjnPSyVJD4vOOeoEA-1; Thu, 06 Feb 2020 02:52:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A9628024CE; Thu, 6 Feb 2020 07:52:45 +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 292AF790F5; Thu, 6 Feb 2020 07:52:45 +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 DE3691804744; Thu, 6 Feb 2020 07:52:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qNjZ010029 for ; Thu, 6 Feb 2020 02:52:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5E7BF1001B09; Thu, 6 Feb 2020 07:52:23 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB8921001B07 for ; Thu, 6 Feb 2020 07:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975642; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WeAkZSFRFKeMduXbGac2LwdWD73QDC9+iDhFMFzqb90=; b=gWqoF7JZcy5gNr84md9Sl2et1FAqjg8nihrT3keXSZYVHg/bLtgphLh3JSoiICsC4sCGcH nAGJi7Wgdon6dkMkYRwlicjmLvW7hU9TJh7+tVubcWc8PmW/JgjrvEgmP7o2orLFcOQ5Jl drrZOLXnfvfvLqq22RCI4c9rWjTS9oU= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/15] conf: Implement support for of disk source Date: Thu, 6 Feb 2020 08:52:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: Q8qNphjnPSyVJD4vOOeoEA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Implement parsing and formatting of the 'source' and 'format' slices. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c95bd34fb5..4d1bace700 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9467,6 +9467,62 @@ virDomainStorageSourceParseBase(const char *type, } +static virStorageSourceSlicePtr +virDomainStorageSourceParseSlice(xmlNodePtr node, + xmlXPathContextPtr ctxt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt); + g_autofree char *offset =3D NULL; + g_autofree char *size =3D NULL; + g_autofree virStorageSourceSlicePtr ret =3D g_new0(virStorageSourceSli= ce, 1); + + ctxt->node =3D node; + + if (!(offset =3D virXPathString("string(./@offset)", ctxt)) || + !(size =3D virXPathString("string(./@size)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing offset or size attribute of slice")); + return NULL; + } + + if (virStrToLong_ullp(offset, NULL, 10, &ret->offset) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("malformed value '%s' of 'offset' attribute of sl= ice"), + offset); + return NULL; + } + + if (virStrToLong_ullp(size, NULL, 10, &ret->size) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("malformed value '%s' of 'size' attribute of slic= e"), + size); + return NULL; + } + + return g_steal_pointer(&ret); +} + + +static int +virDomainStorageSourceParseSlices(virStorageSourcePtr src, + xmlXPathContextPtr ctxt) +{ + xmlNodePtr node; + + if ((node =3D virXPathNode("./slices/slice[@type=3D'storage']", ctxt))= ) { + if (!(src->sliceStorage =3D virDomainStorageSourceParseSlice(node,= ctxt))) + return -1; + } + + if ((node =3D virXPathNode("./slices/slice[@type=3D'format']", ctxt)))= { + if (!(src->sliceFormat =3D virDomainStorageSourceParseSlice(node, = ctxt))) + return -1; + } + + return 0; +} + + /** * virDomainStorageSourceParse: * @node: XML node pointing to the source element to parse @@ -9532,6 +9588,9 @@ virDomainStorageSourceParse(xmlNodePtr node, if (virDomainDiskSourcePRParse(node, ctxt, &src->pr) < 0) return -1; + if (virDomainStorageSourceParseSlices(src, ctxt) < 0) + return -1; + if (virSecurityDeviceLabelDefParseXML(&src->seclabels, &src->nseclabel= s, ctxt, flags) < 0) return -1; @@ -24373,6 +24432,37 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr = buf, } +static void +virDomainDiskSourceFormatSlice(virBufferPtr buf, + const char *slicetype, + virStorageSourceSlicePtr slice) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + + if (!slice) + return; + + virBufferAsprintf(&attrBuf, " type=3D'%s'", slicetype); + virBufferAsprintf(&attrBuf, " offset=3D'%llu'", slice->offset); + virBufferAsprintf(&attrBuf, " size=3D'%llu'", slice->size); + + virXMLFormatElement(buf, "slice", &attrBuf, NULL); +} + + +static void +virDomainDiskSourceFormatSlices(virBufferPtr buf, + virStorageSourcePtr src) +{ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + + virDomainDiskSourceFormatSlice(&childBuf, "format", src->sliceFormat); + virDomainDiskSourceFormatSlice(&childBuf, "storage", src->sliceStorage= ); + + virXMLFormatElement(buf, "slices", NULL, &childBuf); +} + + /** * virDomainDiskSourceFormat: * @buf: output buffer @@ -24443,6 +24533,8 @@ virDomainDiskSourceFormat(virBufferPtr buf, return -1; } + virDomainDiskSourceFormatSlices(&childBuf, src); + if (src->type !=3D VIR_STORAGE_TYPE_NETWORK) virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, src->seclabels, flags); --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580975567342576.7417256885403; Wed, 5 Feb 2020 23:52:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-WS_SbWSQP5G51NvZ_OV9rg-1; Thu, 06 Feb 2020 02:52:40 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7D86101FC75; Thu, 6 Feb 2020 07:52:35 +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 9E65A60BEC; Thu, 6 Feb 2020 07:52:35 +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 571FF866AD; Thu, 6 Feb 2020 07:52:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qOaU010035 for ; Thu, 6 Feb 2020 02:52:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 30A1D1001B09; Thu, 6 Feb 2020 07:52:24 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD5491001B07 for ; Thu, 6 Feb 2020 07:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975566; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=82P88mu7bPO4alPawBtHKkhYImHAUE2kYkkJCW+x2tY=; b=ctdGE1AWRhkqIzFdeq7c1/yJDVTKF00iOrXFEKb45jJ7zcJfC0gdEPrKUyknSMLmOYTPGx rk8J1zlERt+mIvdobAz7cHppz1Hj9K5rM/LC6RxIdhXL5VSMIZ3YIT8fHtGZdXSiZ0ngRF AACv7kFQiDM9UjOZrEkoOVGrjeKKy/M= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/15] tests: qemu: Add test data for the new element Date: Thu, 6 Feb 2020 08:52:06 +0100 Message-Id: <2531680d08622c9838f50442ded39ce3f826dfaa.1580975374.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , 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-MC-Unique: WS_SbWSQP5G51NvZ_OV9rg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- .../disk-slices.x86_64-latest.args | 50 +++++++++++++++++ tests/qemuxml2argvdata/disk-slices.xml | 45 +++++++++++++++ tests/qemuxml2argvtest.c | 2 + .../disk-slices.x86_64-latest.xml | 56 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 5 files changed, 155 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-slices.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-slices.xml create mode 100644 tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-slices.x86_64-latest.args new file mode 100644 index 0000000000..9beb07798e --- /dev/null +++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args @@ -0,0 +1,50 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-cpu qemu64 \ +-m 214 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img",\ +"node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"raw= ",\ +"offset":1234,"size":321,"file":"libvirt-3-storage"}' \ +-device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x2,drive=3Dlibvirt-3= -format,\ +id=3Dvirtio-disk0,bootindex=3D1 \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img",\ +"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw"= ,\ +"offset":9876,"size":123456789,"file":"libvirt-2-storage"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/overlay.qc= ow2",\ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qco= w2",\ +"file":"libvirt-1-storage","backing":"libvirt-2-format"}' \ +-device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x3,drive=3Dlibvirt-1= -format,\ +id=3Dvirtio-disk1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-slices.xml b/tests/qemuxml2argvdat= a/disk-slices.xml new file mode 100644 index 0000000000..1385cc3b95 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-slices.xml @@ -0,0 +1,45 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a36183bf34..79b2d0f435 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1162,6 +1162,8 @@ mymain(void) DO_TEST_CAPS_VER("disk-backing-chains-noindex", "2.12.0"); DO_TEST_CAPS_LATEST("disk-backing-chains-noindex"); + DO_TEST_CAPS_LATEST("disk-slices"); + DO_TEST("graphics-egl-headless", QEMU_CAPS_EGL_HEADLESS, QEMU_CAPS_DEVICE_CIRRUS_VGA); diff --git a/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml b/tests= /qemuxml2xmloutdata/disk-slices.x86_64-latest.xml new file mode 100644 index 0000000000..d3520a5ba4 --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml @@ -0,0 +1,56 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + + + + + +

+ + + + + + + + + + + + + + +
+ + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index fa238ec339..5856d802f4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -530,6 +530,8 @@ mymain(void) DO_TEST("pci-rom-disabled-invalid", NONE); DO_TEST("pci-serial-dev-chardev", NONE); + DO_TEST_CAPS_LATEST("disk-slices"); + DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS); DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS); DO_TEST("luks-disks", NONE); --=20 2.24.1 From nobody Wed Apr 24 23:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158097557727659.42896001205088; Wed, 5 Feb 2020 23:52:57 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-nzYvUStHNBmBwbqkypwMvQ-1; Thu, 06 Feb 2020 02:52:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5246DB2A; Thu, 6 Feb 2020 07:52:48 +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 9EBA1790FE; Thu, 6 Feb 2020 07:52:48 +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 58BF7866B9; Thu, 6 Feb 2020 07:52:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0167qPpZ010049 for ; Thu, 6 Feb 2020 02:52:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 011361001B07; Thu, 6 Feb 2020 07:52:25 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EA3010018FF for ; Thu, 6 Feb 2020 07:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580975576; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Hs0kE0XomEClOLtvish2sI4psTciK+w1IZ6YYZi0pQw=; b=ctuggYlNu5s2f5HIgYiG3eHPLpBigO4GR5gUKKmzrAz+6eW6688dHHL0kskKlvbJip6eBY KEZ8DFVT5FRVrcPe/rIroWrw4Neo8ZDv4+ZPOfsjypKIQJTJsPxGzHfAHWUfX4TpkssoqH NLtQsta9c8ymaIjgWVlJ7kMeV2Bd8Ek= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/15] virStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size' attributes Date: Thu, 6 Feb 2020 08:52:07 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: nzYvUStHNBmBwbqkypwMvQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If the parsed 'raw' format JSON string has 'offset' or 'size' attributes parse them as the format slice. https://bugzilla.redhat.com/show_bug.cgi?id=3D1791788 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 20 ++++++++++++++++++++ tests/virstoragetest.c | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 30d5a2fe67..802f3d59be 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3540,8 +3540,28 @@ virStorageSourceParseBackingJSONRaw(virStorageSource= Ptr src, const char *jsonstr, int opaque G_GNUC_UNUSED) { + bool has_offset =3D virJSONValueObjectHasKey(json, "offset"); + bool has_size =3D virJSONValueObjectHasKey(json, "size"); virJSONValuePtr file; + if (has_offset || has_size) { + src->sliceFormat =3D g_new0(virStorageSourceSlice, 1); + + if (has_offset && + virJSONValueObjectGetNumberUlong(json, "offset", &src->sliceFo= rmat->offset) < 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("malformed 'offset' property of 'raw' driver"= )); + return -1; + } + + if (has_size && + virJSONValueObjectGetNumberUlong(json, "size", &src->sliceForm= at->size) < 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("malformed 'size' property of 'raw' driver")); + return -1; + } + } + /* 'raw' is a format driver so it can have protocol driver children */ if (!(file =3D virJSONValueObjectGetObject(json, "file"))) { virReportError(VIR_ERR_INVALID_ARG, diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 25d41f0de4..8dda349b5c 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1600,7 +1600,11 @@ mymain(void) "\"filename\": \"/tmp/test= fle\"" "}" "}", - "\n", 0); + "\n" + " \n" + " \n" + " \n" + "\n", 0); #endif /* WITH_YAJL */ --=20 2.24.1