From nobody Wed Dec 4 09:10:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1732119022; cv=none; d=zohomail.com; s=zohoarc; b=lZatRX4KpPCaN1wf0QfBFc96g53ol9vJHx9TPNXzY7GdCGbBUmIKS+5v0c7VIebYCZMzxCS+4fvqtT38qX0w+0ivmwLiFexCO3sU9Wp8iDGMl/nUvMtW0goBAQnkA5Q+Fne0t+RZHyIIrWsYoxtOhwl3g3BIp9P9c/yXaVYJpiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119022; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=BNMikSbtt/Rf/F37JcZ7Y6mG1AFzBqWtsUKC5ER7ix0=; b=iXDSUXvnc6Xc+AY6VVxxVDdlDSqv/sODfyn/WmuRr+5irR81ueElrFYeLALH+pjV3hVCpuOgoIHgyvIYuVl0HWD9Qve1DFxmi81C2acHwjimL3/cqH7X2ECHuANOwRkaGxx2w/8Buf1lyUecxrZR480aNIMVL2n2cNqjkKXtKMs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732119022587702.7739605639114; Wed, 20 Nov 2024 08:10:22 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 746AF1527; Wed, 20 Nov 2024 11:10:21 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9EC70153D; Wed, 20 Nov 2024 11:09:38 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id D0610144F; Wed, 20 Nov 2024 11:09:34 -0500 (EST) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4372C1461 for ; Wed, 20 Nov 2024 11:09:34 -0500 (EST) Received: from [130.117.225.1] (helo=vz9-barybin-2.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1tDn0f-0005yc-01; Wed, 20 Nov 2024 16:52:53 +0100 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=GmOShsqKVm6M10HvWP9QQZrJIM4TRkY+3YVCkl+hDUk=; b=jTeAoeXP73SS T+WvehS/Ei0mmtn4LJuY9NUkI/8q+0wGx4SFJcGBR793Wf+fjkVmHPFRyThMgwkJdd0boe45kenvq Ajdy9gFNl/XH1oYQ3JOdwu+H+aoVAc35a9o7rMiXTSY91wXqlyLOffW9/I9ixZ4nkj+sKWmyqLApU IlAH2k7MY9qDw3F3ECdPegQ4crRJlMbxThtoiQS+CfwT7lt67EY3dg7GuCsajkXsI3Gk9hG/9nqeD /impyoWdy1Xotq5ESeeFR/64smjGB8l5rUJPvQ3VpBJDp9CTZCsTqPzKhrMqU3kP0Bo9PWrdhtWVq jEtdcNh6s6DZNgjU+49yQw==; To: devel@lists.libvirt.org Subject: [PATCH 07/15] storage file: fill in src->dataFileStore during file probe Date: Wed, 20 Nov 2024 18:48:42 +0300 Message-ID: <20241120155229.1259-8-nikolai.barybin@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241120155229.1259-1-nikolai.barybin@virtuozzo.com> References: <20241120155229.1259-1-nikolai.barybin@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ULI5BFMID2QYRJJO4NNVFOMBO7US7PQ7 X-Message-ID-Hash: ULI5BFMID2QYRJJO4NNVFOMBO7US7PQ7 X-MailFrom: nikolai.barybin@virtuozzo.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: den@openvz.org, Nikolai Barybin X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Nikolai Barybin via Devel Reply-To: Nikolai Barybin X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732119024055116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin --- src/storage_file/storage_source.c | 39 +++++++++++++++++++++++++++++++ src/storage_file/storage_source.h | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index 2cfe3bc325..b9d2d71aea 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -543,6 +543,33 @@ virStorageSourceNewFromBacking(virStorageSource *paren= t, } =20 =20 +/** + * virStorageSourceNewFromDataFile: + * @parent: storage source parent + * @dataFileSrc: returned data file source definition + * + * Creates a storage source which describes the data file image of @parent. + * Returned storage source format is VIR_STORAGE_FILE_RAW, and, unlike + * backing storage creation, readonly flag is copied from @parent. + * + * Return codes are the same as in virStorageSourceNewFromChild. + */ +int +virStorageSourceNewFromDataFile(virStorageSource *parent, + virStorageSource **dataFileSrc) +{ + if (virStorageSourceNewFromChild(parent, + parent->dataFileRaw, + dataFileSrc) < 0) + return -1; + + (*dataFileSrc)->format =3D VIR_STORAGE_FILE_RAW; + (*dataFileSrc)->readonly =3D parent->readonly; + + return 0; +} + + /** * @src: disk source definition structure * @fd: file descriptor @@ -1391,6 +1418,18 @@ virStorageSourceGetMetadataRecurse(virStorageSource = *src, } } =20 + if (src->dataFileRaw) { + g_autoptr(virStorageSource) dataFileStore =3D NULL; + if ((rv =3D virStorageSourceNewFromDataFile(src, &dataFileStore)) = < 0) + return -1; + + /* the data file would not be usable for VM usage */ + if (rv =3D=3D 1) + return 0; + + src->dataFileStore =3D g_steal_pointer(&dataFileStore); + } + if (src->backingStoreRaw) { if ((rv =3D virStorageSourceNewFromBacking(src, &backingStore)) < = 0) return -1; diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_s= ource.h index 63fefb6919..78b31e405a 100644 --- a/src/storage_file/storage_source.h +++ b/src/storage_file/storage_source.h @@ -72,6 +72,10 @@ int virStorageSourceNewFromBacking(virStorageSource *parent, virStorageSource **backing); =20 +int +virStorageSourceNewFromDataFile(virStorageSource *parent, + virStorageSource **dataFileSrc); + int virStorageSourceGetRelativeBackingPath(virStorageSource *top, virStorageSource *base, --=20 2.43.5