From nobody Sun Feb 8 23:54:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952016; cv=none; d=zoho.com; s=zohoarc; b=HIVjvBOFONyWkPHmF6SqMWLXeSUkyLy+5F2MkzpBVKhP3wrjgNHsbo6TcJn5dZHcoMI1mllQftZT56v2MzOUiiPh9Li8ZeOZMmvfOAUcyfaMSiK9zL/Xr+yTZS1H2016j3axQ7Nx47aXBbF9OjkVTQHghUrB5KeaAnvD7e340Tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952016; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=C4TdYFTYIdhplYHcf7+eshdWSYEaBYxi6Lh8AmtBXzs=; b=Ay4WW40fBxYJNwEmhhoDQmFf1RiN9THhI/z91mNrpegU2x7Cb5v4rPlKAGeh8hTFMuIt6guLA9i+NB5rzNjbv5/J0FZA6S3ewZf6ozQ5aKcE7VGQ68830Sl9zXJKIXnSCrh8ba2YtThm0m1dL0QIMHZ/Qqp3IGdMLcHTgcZ0kas= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565952016088931.8351137737899; Fri, 16 Aug 2019 03:40:16 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CF7C34FCD9; Fri, 16 Aug 2019 10:40:14 +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 A58A11001B17; Fri, 16 Aug 2019 10:40:14 +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 5C26AEEFD; Fri, 16 Aug 2019 10:40:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7GAdrCN021601 for ; Fri, 16 Aug 2019 06:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9F75A4FA0; Fri, 16 Aug 2019 10:39:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 750829654D for ; Fri, 16 Aug 2019 10:39:53 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:32 +0200 Message-Id: <211d8f702f21c605e9bcad9817319019f75a583e.1565951850.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/14] util: storagefile: Add handling of unusable storage sources 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-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 16 Aug 2019 10:40:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce new semantics to virStorageSourceNewFromBacking and some of the helpers used by it which propagate the return value from the callers. The new return value introduced by this patch allows to notify the calller that the parsed virStorageSource correctly describes the source but contains data such as inline authentication which libvirt does not want to support directly. This means that such file would e.g. unusable as a storage source (e.g. when actively commiting the overlay to it) or would not work with blockdev. The caller will then be able to decide whether to consider this backing file as viable or just fall back to qemu dealing with it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 8447c014f0..fa0233376b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3554,6 +3554,13 @@ virStorageSourceParseBackingJSONVxHS(virStorageSourc= ePtr src, struct virStorageSourceJSONDriverParser { const char *drvname; + /** + * 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 + * 0 on success and 1 in cases when the configuration itself is valid,= but + * 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 opaque; }; @@ -3638,15 +3645,17 @@ virStorageSourceParseBackingJSON(virStorageSourcePt= r src, * @path: string representing absolute location of a storage source * @src: filled with virStorageSource object representing @path * - * Returns 0 on success and fills @src or -1 on error and reports appropri= ate - * error. + * Returns 0 on success, 1 if we could parse all location data but @path + * specified other data unrepresentable by libvirt (e.g. inline authentica= tion). + * In both cases @src is filled. On error -1 is returned @src is NULL and = an + * error is reported. */ int virStorageSourceNewFromBackingAbsolute(const char *path, virStorageSourcePtr *src) { const char *json; - int rc; + int rc =3D 0; VIR_AUTOUNREF(virStorageSourcePtr) def =3D NULL; *src =3D NULL; @@ -3687,7 +3696,7 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th, } VIR_STEAL_PTR(*src, def); - return 0; + return rc; } @@ -3701,7 +3710,11 @@ virStorageSourceNewFromBackingAbsolute(const char *p= ath, * and other data. Note that for local storage this function interrogates = the * actual type of the backing store. * - * Returns 0 and fills @backing, or -1 on error (with appropriate error re= ported). + * Returns 0 on success, 1 if we could parse all location data but the bac= kinig + * store specification contained other data unrepresentable by libvirt (e.= g. + * inline authentication). + * In both cases @src is filled. On error -1 is returned @src is NULL and = an + * error is reported. */ int virStorageSourceNewFromBacking(virStorageSourcePtr parent, @@ -3709,6 +3722,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr pa= rent, { struct stat st; VIR_AUTOUNREF(virStorageSourcePtr) def =3D NULL; + int rc =3D 0; *backing =3D NULL; @@ -3717,8 +3731,8 @@ virStorageSourceNewFromBacking(virStorageSourcePtr pa= rent, parent->backing= StoreRaw))) return -1; } else { - if (virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw, - &def) < 0) + if ((rc =3D virStorageSourceNewFromBackingAbsolute(parent->backing= StoreRaw, + &def)) < 0) return -1; } @@ -3742,7 +3756,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr pa= rent, def->detected =3D true; VIR_STEAL_PTR(*backing, def); - return 0; + return rc; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list