From nobody Sat Nov 23 08:06:53 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=1732119332; cv=none; d=zohomail.com; s=zohoarc; b=hrJ/xct5O5Gkq5GDAFltWK2y6JR21FlLBAWaMcs1jaJZdmvyVX8OO3xy7aRxRm4rrOT2zYebEfB9f1vK1Q7sYI4QJ57XrXmr3TQIovFHGTGt+/XX5ZJpnCXvaEDzQWGXYFT82B8VLVS87X25EBv2gJoXf4Yx6a/l8+6vR3J5GCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119332; 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=0aZXOzfauhro0fW1dUXB/UVJtG79cgBKIIqi07OH+iY=; b=ByrDnqIKACnXEF2b9sLLGj3GQmMIIDMpdIaIxK1Z8owvxw8ErmMHq9CvgtkhI/SmX5KiCyb8/EmVrbVqfCffHV/fxL4iNk6Se1ADHu5+gdB0V9fApnE4tIDcezrcTb6AO+wIDCw5tEl7ffy5ynKsCqbhd1M+BBSZsy7uM6zLi5A= 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 1732119332444990.5994771954018; Wed, 20 Nov 2024 08:15:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6EACA1983; Wed, 20 Nov 2024 11:15:31 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DF3B51517; Wed, 20 Nov 2024 11:10:11 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9C91015F2; Wed, 20 Nov 2024 11:10:04 -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 D53BD1557 for ; Wed, 20 Nov 2024 11:09:47 -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 1tDn0V-0005yc-2s; Wed, 20 Nov 2024 16:52:43 +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=0+Jd78QPcCwfTRJknaLxrclYlNnRL7lOqZ34XHd5M/s=; b=EIvtxDShn00h 9tgOLnlzqzP7powfRPyQw3Gv4998ihVn5iqsg/HuIR7zyOQEyUDioqt/7pBVCHUdb3eIAtEEz4Hyn EQ1n9MzSEEKzzQKifin6jJD80iNmFYAYKRlyzvIkEFcxlcGzdt+sKyY+SDY1YGEK9CPPEiwchv2bu SijHHAApY+DtiEaYmGn79CUsAK6z5Y5aWM0xJNUzPepaX1UxT49p5EFMinVEac9Rfa6Ut5/RYHR8s xktXi18bDPC9ZINGz2+a2GeWwmxssg1wbDlgUISDhaaswAv+A/EXCk2gp8kLmne7A8kTylDXgPfYO xljSADeVk+3xE07NOPX2Fw==; To: devel@lists.libvirt.org Subject: [PATCH 01/15] conf: add data-file feature and related fields to virStorageSource Date: Wed, 20 Nov 2024 18:48:36 +0300 Message-ID: <20241120155229.1259-2-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: CVIJ23PRRI6WRECL4FSR4V3TZDDE24CL X-Message-ID-Hash: CVIJ23PRRI6WRECL4FSR4V3TZDDE24CL 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: 1732119333341116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/conf/storage_source_conf.c | 10 ++++++++++ src/conf/storage_source_conf.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 5b9a80f100..d4e39b9b57 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -829,6 +829,7 @@ virStorageSourceCopy(const virStorageSource *src, def->relPath =3D g_strdup(src->relPath); def->backingStoreRaw =3D g_strdup(src->backingStoreRaw); def->backingStoreRawFormat =3D src->backingStoreRawFormat; + def->dataFileRaw =3D g_strdup(src->dataFileRaw); def->snapshot =3D g_strdup(src->snapshot); def->configFile =3D g_strdup(src->configFile); def->nodenameformat =3D g_strdup(src->nodenameformat); @@ -894,6 +895,12 @@ virStorageSourceCopy(const virStorageSource *src, return NULL; } =20 + if (src->dataFileStore) { + if (!(def->dataFileStore =3D virStorageSourceCopy(src->dataFileSto= re, + false))) + return NULL; + } + if (src->fdtuple) def->fdtuple =3D g_object_ref(src->fdtuple); =20 @@ -1174,6 +1181,9 @@ virStorageSourceClear(virStorageSource *def) VIR_FREE(def->nodenamestorage); VIR_FREE(def->nodenameformat); =20 + VIR_FREE(def->dataFileRaw); + g_clear_pointer(&def->dataFileStore, virObjectUnref); + virStorageSourceBackingStoreClear(def); =20 VIR_FREE(def->tlsAlias); diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index a507116007..aa2aa680de 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -359,6 +359,9 @@ struct _virStorageSource { /* backing chain of the storage source */ virStorageSource *backingStore; =20 + /* qcow2 data file source */ + virStorageSource *dataFileStore; + /* metadata for storage driver access to remote and local volumes */ void *drv; =20 @@ -369,6 +372,7 @@ struct _virStorageSource { /* Name of the child backing store recorded in metadata of the * current file. */ char *backingStoreRaw; + char *dataFileRaw; virStorageFileFormat backingStoreRawFormat; =20 /* metadata that allows identifying given storage source */ --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119165; cv=none; d=zohomail.com; s=zohoarc; b=nxRDTmTXLVAqiCxbig9Orz5YtxxT1pZTN57T2Fy3VcfTAN0f9tzD+G1zZxYRsEwpk0o8isnqNLAClw5VgL7NJv3i0sHjUPDyXYHnqiKKP9qPWaGiy8508p5t827gEZ8OGISgnNVbfhVWuKhNOXqTFWQx0ngqx8n++7ovjzrxWWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119165; 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=arubILl+du+NMuyYGy0w0uuhEBazPPEYDefekzONR2Y=; b=E432AwMvWOi6vJyEGuNBmSDBFBOYbWBM0clqHvEuariJlwYxn/2XSRnjC6fZApcXwro9Tyy5X3G3R9DAGYB3KcAQvpySd2YD7gZ1OJ1ic+dY9L4nWIXlGy8SiARrABuNeUJhgnn0wZ6+4h8BdRa7WgyHavgak71fyokKC/EcBoM= 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 1732119165657301.28071325667815; Wed, 20 Nov 2024 08:12:45 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 90046149C; Wed, 20 Nov 2024 11:12:44 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 28A6D1565; Wed, 20 Nov 2024 11:09:59 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1161014CB; Wed, 20 Nov 2024 11:09:53 -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 DC0AE1561 for ; Wed, 20 Nov 2024 11:09:40 -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 1tDn0X-0005yc-1a; Wed, 20 Nov 2024 16:52:45 +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=sU9yXZaUySf02N06qQQcWFcf4ZjvYAR/o1rIoIsYLeE=; b=LHW2bjruRpdV /4S/bIfbrRA0nCm48Yc1OYO2P+fQr3SQh3dPCebithtqxnzLSlMoZAWBSB4+pWPjbUlgHDlkaMSRg EwNhS7GPoyffTmo2L0l2YSOkBiAndbc3eWg8S5cxCqub6m+cRBdFn7vNLKcbx+lqdHOlbn/rkvD/1 Lfr55KNBTBzSjZG6OVaALtF9fK+NeD1kHea2+GgpQLrYdU1KUYyZbYXuLl+CSaTvE82dafxaoTmP9 FOgQiSbIaTdq68CUI1iQ1sUN5ZvwrnVwSHyxr3JsB8LjrJBSYZpUy9SIQnhEyy63IKLBTAqnkjnu8 GrJAuaHCQpEwT91UP9pGHA==; To: devel@lists.libvirt.org Subject: [PATCH 02/15] Add VIR_STORAGE_FILE_FEATURE_DATA_FILE to virStorageFileFeature enum Date: Wed, 20 Nov 2024 18:48:37 +0300 Message-ID: <20241120155229.1259-3-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: FZ6WD6G6KR3OKH5KZUPMUKFWFUVRQLZ3 X-Message-ID-Hash: FZ6WD6G6KR3OKH5KZUPMUKFWFUVRQLZ3 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: 1732119166580116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/conf/storage_source_conf.c | 1 + src/conf/storage_source_conf.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index d4e39b9b57..2b658dd485 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -69,6 +69,7 @@ VIR_ENUM_IMPL(virStorageFileFeature, VIR_STORAGE_FILE_FEATURE_LAST, "lazy_refcounts", "extended_l2", + "data_file", ); =20 =20 diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index aa2aa680de..9463722518 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -88,6 +88,7 @@ VIR_ENUM_DECL(virStorageFileFormat); typedef enum { VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS =3D 0, VIR_STORAGE_FILE_FEATURE_EXTENDED_L2, + VIR_STORAGE_FILE_FEATURE_DATA_FILE, =20 VIR_STORAGE_FILE_FEATURE_LAST } virStorageFileFeature; --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732118997; cv=none; d=zohomail.com; s=zohoarc; b=Azc3QJFu2OTc7lF/i8WBaUGLzBQN1DfePgE3DLnPEJRr/rW8kSYA7TPX8zRorugymK9UZWDt5I5zXEQTCn9pD2r6mwT7rVsgqK51p6Jf1WLTbcA6h0RQ5Bxvb4K2hZH0axROILES9rGfwbd4d1akCriwWLXnxPp2JyDEcelmAaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732118997; 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=7X+jBnwHn2tOjpfVEaowoM+F/oBIywgIeSGjhFzqXUI=; b=Gs0edYgI0uK7Y2g5LiWpXvLOK0+Gj0N+/MqDi2NW+K+pY8XoWbncbaHXaq6ngVRmJMSSUGpsT0ngEIwlAZhI1daso2KtVoKkROPo54GlhELYeGYnlh4ZfN5r1U0uWG5P2kDkYMsm+Gu7POH3Mu3ikGk70frO7tlpf16FJ6nNXDA= 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 1732118997466761.4727686645826; Wed, 20 Nov 2024 08:09:57 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 59E971527; Wed, 20 Nov 2024 11:09:56 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B8AC51488; Wed, 20 Nov 2024 11:09:36 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C6449144F; Wed, 20 Nov 2024 11:09:33 -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 365A11461 for ; Wed, 20 Nov 2024 11:09:33 -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 1tDn0Y-0005yc-17; Wed, 20 Nov 2024 16:52:46 +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 X-Greylist: delayed 1016 seconds by postgrey-1.37 at lists.libvirt.org; Wed, 20 Nov 2024 11:09:33 EST 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=eVpPL2GTMsUAXhfPzP5MyB8bQnZNEMsM50jJgIlIxfk=; b=Szmt9V2k5TKr RmINp4NThKPhN4oOLlvLsjgEvCVFxEMLqEViEPj4R3UeDPvrN1eoqpZBblHW7j4KNnSavGCpVDOrY O9MbtwIKG7ebgB9PVywKDOXXl3LVYQNMzDrx1AJMqCsQWl/EbtxB34XnasxWNNGluGH3sdoHH4/6D apHFI4Sx2YH/vy8RR/K7D8OFKzo5Fy/ciS7JDqHPtqsZW/4+adaqUS0jTBm/tJ2HAwCRwjWxz2PAo Acn0rD6SqJAWGyz6CzZwgFr8sjuBe7SxZ0TauRZ90OlRmArA/sTMN4AMBxFFe2q9nTZvj3Q4+U5y6 ySe77q7ml3zX5SxayGrpvQ==; To: devel@lists.libvirt.org Subject: [PATCH 03/15] conf: schemas: add data-file store to domain rng schema Date: Wed, 20 Nov 2024 18:48:38 +0300 Message-ID: <20241120155229.1259-4-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: 2PEXN565JD3LCXUP5RSPEOO7HJ27OPPU X-Message-ID-Hash: 2PEXN565JD3LCXUP5RSPEOO7HJ27OPPU 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: 1732118998050116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin --- src/conf/schemas/domaincommon.rng | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index bfd0044805..e70896b7ef 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1783,6 +1783,9 @@ + + + =20 @@ -1803,6 +1806,18 @@ + + + + + + + + + + + + --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119382; cv=none; d=zohomail.com; s=zohoarc; b=FJsDhcxSHZ6/2JWb9lv81I884wiXDxdKAeah7EIMibcOXBm/I/bCuNmEkxKSK+BYe7DHqR7O6e4vd4AsfIN2r7gvOgJCEj09pw/IIWDdw6qUndTkxmyOmAaNgnl6UzULm+MPNHx2P4ncPO/lufYCNBkj79vr/LN5LWIjVOQt8H4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119382; 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=ENHeXpbwI0l/b8sduXyY8+CnRMgMom8Dwun9yYuTmEs=; b=Bm7T3uvUTrhvdW/CKyJkhjGW5PxyOsevUbC1bX8HlfRY9HlwD2co6yYdv3iBDNAeqA2CoFMLKR9Xd+5RHrH+OY5SIPgyggMnZkuBemgUbBBmc96qvtofcMiqtrdiFUmDg0lAfrpSwcuWhDZoH9C/+cjVGAkxADfnwJycwi7jEjI= 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 173211938283290.53361738932563; Wed, 20 Nov 2024 08:16:22 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id ABC3711D2; Wed, 20 Nov 2024 11:16:21 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B7AEA165; Wed, 20 Nov 2024 11:14:12 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 10D231085; Wed, 20 Nov 2024 11:14:08 -0500 (EST) Received: from mx1.osci.io (polly.osci.io [8.43.85.229]) (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 BE2131563 for ; Wed, 20 Nov 2024 11:13:34 -0500 (EST) Received: by mx1.osci.io (Postfix, from userid 995) id 7C73027A0B; Wed, 20 Nov 2024 11:13:34 -0500 (EST) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mx1.osci.io (Postfix) with ESMTPS id 7F3EA20E04 for ; Wed, 20 Nov 2024 11:13:33 -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 1tDn0Z-0005yc-0Q; Wed, 20 Nov 2024 16:52:47 +0100 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 1255 seconds by postgrey-1.37 at polly.osci.io; Wed, 20 Nov 2024 11:13:33 EST 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=iQgfyIq4F5B3WxNk6NRR7o41zYnjOEbDDF/8IS+71fM=; b=XJzGw/Evj2aJ NaaWE8I3mJQZB907NHFFJV2wvgRiYZw/WmBd4vgtPwJ85pemMTAgs/9L5XaF/uCDszanLwfIOTPN6 B6QejhTkhGKQHhCgFBZm4fPB7aVnaGMJEaJiRXWbw9xuXv7sEIABGIumnzXqaV7p1uBErRjIFE5xl LJJH4R6oRKA1q7U8KaedOziG8w3vX2VVUxlplZwK1RB6/wZyQiQxmNx8ql+Mj8MZSZktw79w0slW5 jvWHn52o4AKoyz1XVb22gMUY7X3Iq54N8ueo6JPspir6ptC/2ev8pgpi27dT+7w2hT8cwCmr2UaPh SQfgRdsXUcrj2yI4GhwoZA==; To: devel@lists.libvirt.org Subject: [PATCH 04/15] conf: implement XML parsing/formating for dataFileStore Date: Wed, 20 Nov 2024 18:48:39 +0300 Message-ID: <20241120155229.1259-5-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: 5ZX6ILLYQFML35PIMAKLDDT4BMUVZ2QY X-Message-ID-Hash: 5ZX6ILLYQFML35PIMAKLDDT4BMUVZ2QY X-MailFrom: SRS0=E946=SP=virtuozzo.com=nikolai.barybin@osci.io 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: 1732119383744116600 Content-Type: text/plain; charset="utf-8" Data files are simple raw images. Thus, we don't need to parse too much. The main objectives are: - allow only RAW format - forbid storage slices - include this parsing/formatting into backing chain parse/format as well as into top storage source parse/format because data file can belong to backing image Signed-off-by: Nikolai Barybin --- src/conf/domain_conf.c | 100 +++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 13 ++++++ 2 files changed, 113 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 295707ec1f..9348c12725 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7670,6 +7670,62 @@ virDomainStorageSourceParse(xmlNodePtr node, } =20 =20 +int +virDomainDiskDataFileStoreParse(xmlXPathContextPtr ctxt, + virStorageSource *src, + unsigned int flags, + virDomainXMLOption *xmlopt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt) + xmlNodePtr source; + g_autofree char *type =3D NULL; + g_autofree char *format =3D NULL; + g_autoptr(virStorageSource) dataFileStore =3D NULL; + + if (!(ctxt->node =3D virXPathNode("./dataFileStore", ctxt))) + return 0; + + if (!(type =3D virXMLPropStringRequired(ctxt->node, "type"))) + return -1; + + if (!(format =3D virXPathString("string(./format/@type)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing data file store format")); + return -1; + } + + if (!(source =3D virXPathNode("./source", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing disk data file store source")); + return -1; + } + + if (virStorageFileFormatTypeFromString(format) !=3D VIR_STORAGE_FILE_R= AW) { + virReportError(VIR_ERR_XML_ERROR, + _("unexpected disk data file format '%1$s', only ra= w format is supported"), + format); + return -1; + } + + if (!(dataFileStore =3D virDomainStorageSourceParseBase(type, format, = NULL))) + return -1; + + if (virDomainStorageSourceParse(source, ctxt, dataFileStore, flags, xm= lopt) < 0) + return -1; + + if (dataFileStore->sliceStorage) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("slices are not supported for fata file store sou= rce")); + return -1; + } + + dataFileStore->readonly =3D src->readonly; + src->dataFileStore =3D g_steal_pointer(&dataFileStore); + + return 0; +} + + int virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, virStorageSource *src, @@ -7720,6 +7776,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctx= t, backingStore->readonly =3D true; =20 if (virDomainStorageSourceParse(source, ctxt, backingStore, flags, xml= opt) < 0 || + virDomainDiskDataFileStoreParse(ctxt, backingStore, flags, xmlopt)= < 0 || virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) = < 0) return -1; =20 @@ -8112,6 +8169,9 @@ virDomainDiskDefParseSourceXML(virDomainXMLOption *xm= lopt, return NULL; } =20 + if (virDomainDiskDataFileStoreParse(ctxt, src, flags, xmlopt) < 0) + return NULL; + if (virDomainDiskBackingStoreParse(ctxt, src, flags, xmlopt) < 0) return NULL; =20 @@ -22885,6 +22945,38 @@ virDomainDiskSourceFormat(virBuffer *buf, return 0; } =20 +int +virDomainDiskDataFileStoreFormat(virBuffer *buf, + virStorageSource *src, + virDomainXMLOption *xmlopt, + unsigned int flags) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) formatAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + virStorageSource *dataFileStore =3D src->dataFileStore; + bool inactive =3D flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE; + + if (!dataFileStore) + return 0; + + /* don't write detected data file member to inactive xml */ + if (inactive && dataFileStore->detected) + return 0; + + virBufferAsprintf(&attrBuf, " type=3D'%s'", + virStorageTypeToString(dataFileStore->type)); + + virBufferAsprintf(&formatAttrBuf, " type=3D'%s'", "raw"); + virXMLFormatElement(&childBuf, "format", &formatAttrBuf, NULL); + + if (virDomainDiskSourceFormat(&childBuf, dataFileStore, "source", 0, f= alse, + flags, false, false, xmlopt) < 0) + return -1; + + virXMLFormatElement(buf, "dataFileStore", &attrBuf, &childBuf); + return 0; +} =20 int virDomainDiskBackingStoreFormat(virBuffer *buf, @@ -22943,6 +23035,10 @@ virDomainDiskBackingStoreFormat(virBuffer *buf, flags, false, false, xmlopt) < 0) return -1; =20 + if (backingStore->dataFileStore && + virDomainDiskDataFileStoreFormat(&childBuf, backingStore, xmlopt, = flags) < 0) + return -1; + if (virDomainDiskBackingStoreFormat(&childBuf, backingStore, xmlopt, f= lags) < 0) return -1; =20 @@ -23261,6 +23357,10 @@ virDomainDiskDefFormat(virBuffer *buf, if (virDomainDiskBackingStoreFormat(&childBuf, def->src, xmlopt, flags= ) < 0) return -1; =20 + if (def->src->dataFileStore && + virDomainDiskDataFileStoreFormat(&childBuf, def->src, xmlopt, flag= s) < 0) + return -1; + virBufferEscapeString(&childBuf, "\n", def= ->domain_name); =20 virDomainDiskGeometryDefFormat(&childBuf, def); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a187ab4083..4d1939aa1b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3909,6 +3909,12 @@ int virDomainDiskSourceFormat(virBuffer *buf, bool skipEnc, virDomainXMLOption *xmlopt); =20 +int +virDomainDiskDataFileStoreFormat(virBuffer *buf, + virStorageSource *src, + virDomainXMLOption *xmlopt, + unsigned int flags); + int virDomainDiskBackingStoreFormat(virBuffer *buf, virStorageSource *src, @@ -4426,6 +4432,13 @@ int virDomainStorageSourceParse(xmlNodePtr node, virDomainXMLOption *xmlopt) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 +int +virDomainDiskDataFileStoreParse(xmlXPathContextPtr ctxt, + virStorageSource *src, + unsigned int flags, + virDomainXMLOption *xmlopt) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; + int virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, virStorageSource *src, --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119148; cv=none; d=zohomail.com; s=zohoarc; b=fEYCumF4g8AA/zKSInf/b6wIhORy+Sha6QzYgzYdfSWJVnPncgysdh/PRpmJN9dUVHbD05TIzM4TX3sCUU0m2HkFSkTS7R8FhLqNje7nmCDqgRmLR6AaruE5Xpl5lkECfDYW88Xr1J5dISaFeQDiNB2VqGSY2Lw6gSeiC5O4YNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119148; 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=vIJcmnXfziu6HcIbz+hQYFqGjgf2Fw4Pc6Aswf4oCkc=; b=gi+3jYasdkASCy6v7qv08k4RLAmfaljK5uUFHwsnR8IyU38D3BE9Sj/rZfabnWd7mbKhDtzi3jxrQcM3+NCGE9ITHMEmFkveBX7sJaNGZe56MCsE+wiF20mIFHX9sG5HyjwC5z9I43LOyFzMibGklz3uXfefVoU6IpKW6I8vrTU= 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 1732119148581713.0038734055374; Wed, 20 Nov 2024 08:12:28 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A3301553; Wed, 20 Nov 2024 11:12:27 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 07F4A1591; Wed, 20 Nov 2024 11:09:57 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id D41601528; Wed, 20 Nov 2024 11:09:52 -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 BD36614C1 for ; Wed, 20 Nov 2024 11:09:39 -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 1tDn0Z-0005yc-37; Wed, 20 Nov 2024 16:52:48 +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=RbEQjpuT/nc0q5i/HWURggbkQGkUeN1fGhXqTWcVdPA=; b=nYNNiBt8wWDR 87KZOJ00ZFajAsILSqqs4Bhp+RbT2XQCje3+43ATtAIb46WqlpaA7g+LRi5rbcPfrZ8EWboRTshDg XhJNu5jXSztsQTJOKQkxZgs26VTACI6aeYWsuvDaqC+iumBvUSfNaWPk9mRCfDUQJHAr3WTkG8Yec 6OOSROMxq0PIAD1trHjgR4dQU6t5DsFWloPYN4Zeq5S71VP3EnP1Zfg68d//PPcI89NPEQLiQ7Fm5 DG9EFGQ97FxOLMkntZJzgNtUW73InUXT4nAXtYD7JKLFIiAChmF2FrOcpms9n64ldHaVSxRU268k2 wO0YUBF6xeScySyjy7F8Fw==; To: devel@lists.libvirt.org Subject: [PATCH 05/15] storage file: add getDataFile function to FileTypeInfo Date: Wed, 20 Nov 2024 18:48:40 +0300 Message-ID: <20241120155229.1259-6-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: CMAUUCC6247MTDXKVXIV7ADXV5KG2DMH X-Message-ID-Hash: CMAUUCC6247MTDXKVXIV7ADXV5KG2DMH 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: 1732119150497116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/storage_file/storage_file_probe.c | 34 ++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index 243927d50a..ad14350edc 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -93,6 +93,7 @@ struct FileTypeInfo { size_t buf_size); int (*getBackingStore)(char **res, int *format, const char *buf, size_t buf_size); + int (*getDataFile)(char **res, virBitmap *features, char *buf, size_t = buf_size); int (*getFeatures)(virBitmap **features, int format, char *buf, ssize_t len); }; @@ -238,18 +239,18 @@ static struct FileEncryptionInfo const qcow2Encryptio= nInfo[] =3D { =20 static struct FileTypeInfo const fileTypeInfo[] =3D { [VIR_STORAGE_FILE_NONE] =3D { 0, NULL, LV_LITTLE_ENDIAN, - -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NUL= L }, + -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NUL= L, NULL }, [VIR_STORAGE_FILE_RAW] =3D { 0, NULL, LV_LITTLE_ENDIAN, -1, 0, {0}, 0, 0, 0, luksEncryptionInfo, - NULL, NULL, NULL }, + NULL, NULL, NULL, NULL }, [VIR_STORAGE_FILE_DIR] =3D { 0, NULL, LV_LITTLE_ENDIAN, - -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL= }, + -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL= , NULL }, [VIR_STORAGE_FILE_BOCHS] =3D { /*"Bochs Virtual HD Image", */ /* Untested */ 0, NULL, LV_LITTLE_ENDIAN, 64, 4, {0x20000}, - 32+16+16+4+4+4+4+4, 8, 1, NULL, NULL, NULL, NULL + 32+16+16+4+4+4+4+4, 8, 1, NULL, NULL, NULL, NULL, NULL }, [VIR_STORAGE_FILE_CLOOP] =3D { /* #!/bin/sh @@ -258,7 +259,7 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { */ /* Untested */ 0, NULL, LV_LITTLE_ENDIAN, -1, 0, {0}, - -1, 0, 0, NULL, NULL, NULL, NULL + -1, 0, 0, NULL, NULL, NULL, NULL, NULL }, [VIR_STORAGE_FILE_DMG] =3D { /* XXX QEMU says there's no magic for dmg, @@ -266,45 +267,45 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { * would have to match) but then disables that check. */ 0, NULL, 0, -1, 0, {0}, - -1, 0, 0, NULL, NULL, NULL, NULL + -1, 0, 0, NULL, NULL, NULL, NULL, NULL }, [VIR_STORAGE_FILE_ISO] =3D { 32769, "CD001", LV_LITTLE_ENDIAN, -2, 0, {0}, - -1, 0, 0, NULL, NULL, NULL, NULL + -1, 0, 0, NULL, NULL, NULL, NULL, NULL }, [VIR_STORAGE_FILE_VPC] =3D { 0, "conectix", LV_BIG_ENDIAN, 12, 4, {0x10000}, - 8 + 4 + 4 + 8 + 4 + 4 + 2 + 2 + 4, 8, 1, NULL, NULL, NULL, NULL + 8 + 4 + 4 + 8 + 4 + 4 + 2 + 2 + 4, 8, 1, NULL, NULL, NULL, NULL, N= ULL }, /* TODO: add getBackingStore function */ [VIR_STORAGE_FILE_VDI] =3D { 64, "\x7f\x10\xda\xbe", LV_LITTLE_ENDIAN, 68, 4, {0x00010001}, - 64 + 5 * 4 + 256 + 7 * 4, 8, 1, NULL, NULL, NULL, NULL}, + 64 + 5 * 4 + 256 + 7 * 4, 8, 1, NULL, NULL, NULL, NULL, NULL}, =20 /* Not direct file formats, but used for various drivers */ [VIR_STORAGE_FILE_FAT] =3D { 0, NULL, LV_LITTLE_ENDIAN, - -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL= }, + -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL= , NULL }, [VIR_STORAGE_FILE_VHD] =3D { 0, NULL, LV_LITTLE_ENDIAN, - -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL= }, + -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL= , NULL }, [VIR_STORAGE_FILE_PLOOP] =3D { 0, "WithouFreSpacExt", LV_LITTLE_ENDIAN, -2, 0, {0}, PLOOP_IMAGE_SIZE_OFFSET, 8, - PLOOP_SIZE_MULTIPLIER, NULL, NULL, NULL, = NULL }, + PLOOP_SIZE_MULTIPLIER, NULL, NULL, NULL, = NULL, NULL }, =20 /* All formats with a backing store probe below here */ [VIR_STORAGE_FILE_COW] =3D { 0, "OOOM", LV_BIG_ENDIAN, 4, 4, {2}, - 4+4+1024+4, 8, 1, NULL, NULL, cowGetBackingStore, NULL + 4+4+1024+4, 8, 1, NULL, NULL, cowGetBackingStore, NULL, NULL }, [VIR_STORAGE_FILE_QCOW] =3D { 0, "QFI", LV_BIG_ENDIAN, 4, 4, {1}, QCOWX_HDR_IMAGE_SIZE, 8, 1, qcow1EncryptionInfo, - NULL, qcowXGetBackingStore, NULL + NULL, qcowXGetBackingStore, NULL, NULL }, [VIR_STORAGE_FILE_QCOW2] =3D { 0, "QFI", @@ -313,18 +314,19 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { qcow2EncryptionInfo, qcow2GetClusterSize, qcowXGetBackingStore, + NULL, qcow2GetFeatures }, [VIR_STORAGE_FILE_QED] =3D { /* https://wiki.qemu.org/Features/QED */ 0, "QED", LV_LITTLE_ENDIAN, -2, 0, {0}, - QED_HDR_IMAGE_SIZE, 8, 1, NULL, NULL, qedGetBackingStore, NULL + QED_HDR_IMAGE_SIZE, 8, 1, NULL, NULL, qedGetBackingStore, NULL, NU= LL }, [VIR_STORAGE_FILE_VMDK] =3D { 0, "KDMV", LV_LITTLE_ENDIAN, 4, 4, {1, 2, 3}, - 4+4+4, 8, 512, NULL, NULL, vmdk4GetBackingStore, NULL + 4+4+4, 8, 512, NULL, NULL, vmdk4GetBackingStore, NULL, NULL }, }; G_STATIC_ASSERT(G_N_ELEMENTS(fileTypeInfo) =3D=3D VIR_STORAGE_FILE_LAST); --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119293; cv=none; d=zohomail.com; s=zohoarc; b=ausUYOklMAxYj2HZvENZCAt4lJnR9hPYOhMTW1mIstgxHA6D1YWkMC1HtJhZEmh9iUNskkpnOqUl5acfZrQ4Ay0POpGfvHsFQ0Vqz6RlOP35otbIdCmFfl5woD8T/6AGp1gZJgLhCMVjz8dawVOIaMBIY6hR3oUp0kQHT6EDgGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119293; 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=MsbdWh3Um0Uleml3lLsVNmNNsDWpUBsuYgVvtWhm50U=; b=OJmY+oXk2eKXo9xcOdupJlOqQ02cQIyguRIpViSG+T7yn3lSIVUQWXti6JYAQmXdTDwtwY3Ocj9KejLQx8gZKWnQpQH0bPSx+U4GW6cjpgm0lWqJFkNWN/T70CeY+YRpDtk9g+ijtJIyHAjZBTh9D7i+XymRiFdBWuAsUihNiHY= 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 1732119293037600.802569923951; Wed, 20 Nov 2024 08:14:53 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E4FCA1259; Wed, 20 Nov 2024 11:14:51 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 875411509; Wed, 20 Nov 2024 11:10:07 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id BF8671503; Wed, 20 Nov 2024 11:09:57 -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 86DCE152E for ; Wed, 20 Nov 2024 11:09:45 -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 1tDn0a-0005yc-2a; Wed, 20 Nov 2024 16:52:48 +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=h5X0VthHXVSExXaOkRL8dbOiTr+PpcPkeVRL7/eT8Sg=; b=pj2IagI9dFUk RSZP9LS8ht2g9pKHnDLhSegxMBUOCvBdX0hZ9d3/U1ifNZWKx2MAVQhcFrTpi7cZlUR/tJcthQq5M cZAfzPdnSmnGXEYyVhYzAEJyoiI+RUgIwn621d5Qu31Aji+vmSsYkh+SVnAzxhIsj63+t1tl5SsFM Sj9pZVpqshU0lVfRp6AfgfLKubzGBOgpzfjhtdrhBqtFd8CsDXsePHyGFs9AvMt/JkTt5E99FKxWA TfUVzJlTNfJWe9iQlJxMVbenQrJt0rc9ouO4bPhSpx67Dd9lvmF9Lk49NN2NYkWGq7EVShaVlytWL uH4XkYMwUyaoFSi8jQ5Bwg==; To: devel@lists.libvirt.org Subject: [PATCH 06/15] storage file: add qcow2 data-file path parsing from header Date: Wed, 20 Nov 2024 18:48:41 +0300 Message-ID: <20241120155229.1259-7-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: DVYAF7Y572XJNRNOOBLHDGIFETJEAEDF X-Message-ID-Hash: DVYAF7Y572XJNRNOOBLHDGIFETJEAEDF 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: 1732119295234116600 Content-Type: text/plain; charset="utf-8" In qcow2 header data file is represented by incompitible feature bit and its path is saved to header extension table. Thus, we implement here the logic similar to backing file probing. Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/storage_file/storage_file_probe.c | 46 ++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index ad14350edc..06868f5355 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -106,6 +106,7 @@ qcow2GetClusterSize(const char *buf, size_t buf_size); static int qcowXGetBackingStore(char **, int *, const char *, size_t); +static int qcow2GetDataFile(char **, virBitmap *, char *, size_t); static int qcow2GetFeatures(virBitmap **features, int format, char *buf, ssize_t len); static int vmdk4GetBackingStore(char **, int *, @@ -127,6 +128,7 @@ qedGetBackingStore(char **, int *, const char *, size_t= ); =20 #define QCOW2_HDR_EXTENSION_END 0 #define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA +#define QCOW2_HDR_EXTENSION_DATA_FILE_NAME 0x44415441 =20 #define QCOW2v3_HDR_FEATURES_INCOMPATIBLE (QCOW2_HDR_TOTAL_SIZE) #define QCOW2v3_HDR_FEATURES_COMPATIBLE (QCOW2v3_HDR_FEATURES_INCOMPATIBLE= +8) @@ -314,7 +316,7 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { qcow2EncryptionInfo, qcow2GetClusterSize, qcowXGetBackingStore, - NULL, + qcow2GetDataFile, qcow2GetFeatures }, [VIR_STORAGE_FILE_QED] =3D { @@ -361,7 +363,7 @@ enum qcow2IncompatibleFeature { static const virStorageFileFeature qcow2IncompatibleFeatureArray[] =3D { VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_DIRTY */ VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_CORRUPT */ - VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_DATA_FILE= */ + VIR_STORAGE_FILE_FEATURE_DATA_FILE, /* QCOW2_INCOMPATIBLE_FEATURE_DATA= _FILE */ VIR_STORAGE_FILE_FEATURE_LAST, /* QCOW2_INCOMPATIBLE_FEATURE_COMPRESSI= ON */ VIR_STORAGE_FILE_FEATURE_EXTENDED_L2, /* QCOW2_INCOMPATIBLE_FEATURE_EX= TL2 */ }; @@ -393,7 +395,8 @@ cowGetBackingStore(char **res, static int qcow2GetExtensions(const char *buf, size_t buf_size, - int *backingFormat) + int *backingFormat, + char **dataFilePath) { size_t offset; size_t extension_start; @@ -488,6 +491,15 @@ qcow2GetExtensions(const char *buf, break; } =20 + case QCOW2_HDR_EXTENSION_DATA_FILE_NAME: { + if (!dataFilePath) + break; + + *dataFilePath =3D g_new0(char, len + 1); + memcpy(*dataFilePath, buf + offset, len); + break; + } + case QCOW2_HDR_EXTENSION_END: return 0; } @@ -554,13 +566,33 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] =3D '\0'; =20 - if (qcow2GetExtensions(buf, buf_size, format) < 0) + if (qcow2GetExtensions(buf, buf_size, format, NULL) < 0) return 0; =20 return 0; } =20 =20 +static int +qcow2GetDataFile(char **res, + virBitmap *features, + char *buf, + size_t buf_size) +{ + *res =3D NULL; + + if (buf_size < QCOW2v3_HDR_FEATURES_INCOMPATIBLE + 8) + return 0; + + if (features && virBitmapIsBitSet(features, VIR_STORAGE_FILE_FEATURE_D= ATA_FILE)) { + if (qcow2GetExtensions(buf, buf_size, NULL, res) < 0) + return 0; + } + + return 0; +} + + static int vmdk4GetBackingStore(char **res, int *format, @@ -968,6 +1000,12 @@ virStorageFileProbeGetMetadata(virStorageSource *meta, fileTypeInfo[meta->format].getFeatures(&meta->features, meta->form= at, buf, len) < 0) return -1; =20 + VIR_FREE(meta->dataFileRaw); + if (fileTypeInfo[meta->format].getDataFile !=3D NULL) { + fileTypeInfo[meta->format].getDataFile(&meta->dataFileRaw, meta->f= eatures, + buf, len); + } + VIR_FREE(meta->compat); if (meta->format =3D=3D VIR_STORAGE_FILE_QCOW2 && meta->features) meta->compat =3D g_strdup("1.1"); --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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 From nobody Sat Nov 23 08:06:53 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=1732119183; cv=none; d=zohomail.com; s=zohoarc; b=YfRtuX5NooKJZEJivGfdu3LAqzOi4b9Z9GolFf6UREqrs+5nSK5CLw9ykvQW3aiImO+Lb7QZfx6v475dSEWV5QuyBGb46F9tVjxO/stjvK3i0McbnRAMQrD/+8vY9IadfA+JhRX2AW6WlOogHJEGq2vET6LUhEI8tM5BQ97OGnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119183; 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=NXi8KS69D1/kKNd7/janq0Rfs/qCAwjuWF9V0VSMhY0=; b=Z2CQimiOu8+AgDcj+vsFs4NyKlBWKJIpa+7UmvmIJvI7jRySBCPGPKw2lSF46Amnx1M+cU+DDj9jgGclm5c0tfUrBmia/m4vtZ0IsyYcWADkHpdmSLZQeBkRCjoGi+yaLBwuHD71Y1HCj5OTe9dp82P4eoFdMfx6uS6FhDuOSkY= 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 1732119183919339.3938367835027; Wed, 20 Nov 2024 08:13:03 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C81D115AB; Wed, 20 Nov 2024 11:13:02 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A02A515A6; Wed, 20 Nov 2024 11:10:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C32FE1514; Wed, 20 Nov 2024 11:09:54 -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 44F8E1589 for ; Wed, 20 Nov 2024 11:09:43 -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 1tDn0u-0005yc-1n; Wed, 20 Nov 2024 16:53:08 +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=cCr58UpUPu9iphJ7RV+4U57orKDgcLGzagWycbokrIg=; b=Kj5JSM0gFJAT K1Wt0OZ5RQytaCAqub58GD4XY5eLdbTr17r0GBtKp7cFQSBQzGBovNrc4y5G1jP3OuCDvE+rjUXOi VpGwBKrt0kv43NhL1FeyAptlG0tqZrsxd33bhn56lq2kHOIb6sjPuijSfDWfp8vVtpyVKYBunBCt0 GkHca4lb3UN/bhbSr/8wIdmKKUwLbQgFN+MOdQ01Ovf/cRpHyr/Z5qt8jugCdBczLcbvel1qvkFiF azgpIhCVbmtbWiiNgMqQ9O496+eb6GoRo3Gqa+Q0NPpcFx5ttrX8vC9yjTbKet6s0Lm4zIcM9eGRV 9sD94y+pWBhIuJdT9qFYTg==; To: devel@lists.libvirt.org Subject: [PATCH 08/15] security: DAC: handle qcow2 data-file on image label set/restore Date: Wed, 20 Nov 2024 18:48:43 +0300 Message-ID: <20241120155229.1259-9-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: FAHDFU7TYKHLFMP6SD2755ZDD2I7KUPU X-Message-ID-Hash: FAHDFU7TYKHLFMP6SD2755ZDD2I7KUPU 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: 1732119184654116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/security/security_dac.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index a179378a78..0505f4e4a3 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -969,6 +969,13 @@ virSecurityDACSetImageLabel(virSecurityManager *mgr, def, n, parent, isChainTop= ) < 0) return -1; =20 + /* Unlike backing images, data files are not designed to be shared= by + * anyone. Thus, we always consider them as chain top. */ + if (n->dataFileStore && + virSecurityDACSetImageLabelInternal(mgr, sharedFilesystems, de= f, + n->dataFileStore, n, true)= < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; =20 @@ -1065,8 +1072,16 @@ virSecurityDACRestoreImageLabel(virSecurityManager *= mgr, virStorageSource *src, virSecurityDomainImageLabelFlags flags G_G= NUC_UNUSED) { - return virSecurityDACRestoreImageLabelInt(mgr, sharedFilesystems, - def, src, false); + if (virSecurityDACRestoreImageLabelInt(mgr, sharedFilesystems, + def, src, false) < 0) + return -1; + + if (src->dataFileStore && + virSecurityDACRestoreImageLabelInt(mgr, sharedFilesystems, + def, src->dataFileStore, false)= < 0) + return -1; + + return 0; } =20 =20 @@ -1946,6 +1961,14 @@ virSecurityDACRestoreAllLabel(virSecurityManager *mg= r, def->disks[i]->src, migrated) < 0) rc =3D -1; + + if (def->disks[i]->src->dataFileStore && + virSecurityDACRestoreImageLabelInt(mgr, + sharedFilesystems, + def, + def->disks[i]->src->dataFil= eStore, + migrated) < 0) + rc =3D -1; } =20 for (i =3D 0; i < def->ngraphics; i++) { --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119063; cv=none; d=zohomail.com; s=zohoarc; b=JcHcoJaXkZJNGc90v07Cqs3BPO1yX8u2fXCPwIWRfMNJxah7/cVE+bt0I21S0aUFrJyfepE07sVxYFWK4hM6uQuu3LN6n7OsPGdmkG+j4jBm3HrNFjwuNS4q/+/0NT/KCGa+1MUKt8INtOwyAGBwE7BOOH0Y2OdrD2G12lWOdFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119063; 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=zOYtrnvEvG83z5vRlbIcdGleYIJ5nDxz0RK7KgnrE1o=; b=CSUnz9ywhf0NmP6AUggSKsH2h+ioYdrsS7wf3TZLnqPV31yq9oPhNhgwpjoinJsI6oI+t58qw15eCsLxsdkO6WFvuHwLY51ZyM6cCZOBVu+4BxkP4PMxyaVqFnZjCp2vtX85WZ5Am52svi5ac0F9X/xMmKj6hePaAn3y6gENfSs= 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 1732119063302167.9608708413847; Wed, 20 Nov 2024 08:11:03 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3FDD8146C; Wed, 20 Nov 2024 11:11:02 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1455F1583; Wed, 20 Nov 2024 11:09:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0303C1461; Wed, 20 Nov 2024 11:09:36 -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 5E8961461 for ; Wed, 20 Nov 2024 11:09:36 -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 1tDn0w-0005yc-0T; Wed, 20 Nov 2024 16:53:10 +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=ziqxSOpMWgHjOZhMMLiwdGWktV9uvnHcjvos5dF0JpI=; b=Wrx8ZraaMf05 mcwPy2Lpm+9lCZLbcW5KmRKG1OG3XsMpxqz3TpcucGyJ+wnn+QnL1NPO7p5mF/+hBXsL6AvheudUU KuFpuK62TTJpEQ1nWXnWW0Pco9mKQfIeQJBsmQMTi7HxBCBw4+fpfQUpexlpPEl/N0CPBM5FVs2qz wkdjIihILFKVqU3D+XcUGuHz3FlIKR1oVbxb7e1oL/5m2o5w4/xh6n+d6lieOhBx8bjGkTJa/WoYB q+uFvT1bFGyMNSt/pwoX32QPaIijenVmPqAgllcTy1RLcbh5fv2aKfx24lWWFcsnneO4FK8Kv9wj+ YlvJ0Ak8vY4+FGiAfuYiag==; To: devel@lists.libvirt.org Subject: [PATCH 09/15] security: selinux: handle qcow2 data-file on image label set/restore Date: Wed, 20 Nov 2024 18:48:44 +0300 Message-ID: <20241120155229.1259-10-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: FQMBGTVAGTCZ4KMOPW3TGWMFTIIMWXJ6 X-Message-ID-Hash: FQMBGTVAGTCZ4KMOPW3TGWMFTIIMWXJ6 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: 1732119064286116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/security/security_selinux.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 18daa521d1..05e24ff11b 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1934,8 +1934,16 @@ virSecuritySELinuxRestoreImageLabel(virSecurityManag= er *mgr, virStorageSource *src, virSecurityDomainImageLabelFlags flags= G_GNUC_UNUSED) { - return virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, - def, src, false); + if (virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, + def, src, false) < 0) + return -1; + + if (src->dataFileStore && + virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, + def, src->dataFileStore, fa= lse) < 0) + return -1; + + return 0; } =20 =20 @@ -2067,6 +2075,14 @@ virSecuritySELinuxSetImageLabel(virSecurityManager *= mgr, isChainTop) < 0) return -1; =20 + /* Unlike backing images, data files are not designed to be shared= by + * anyone. Thus, we always consider them as chain top. */ + if (n->dataFileStore && + virSecuritySELinuxSetImageLabelInternal(mgr, sharedFilesystems, + def, n->dataFileStore,= parent, + true) < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; =20 @@ -2929,6 +2945,13 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManager= *mgr, def, disk->src, migrated) < 0) rc =3D -1; + + if (disk->src->dataFileStore && + virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, + def, disk->src->dataFil= eStore, + migrated) < 0) + rc =3D -1; + } =20 for (i =3D 0; i < def->nhostdevs; i++) { --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119042; cv=none; d=zohomail.com; s=zohoarc; b=MZBi2X2F0RU/WZR/CcXnXCURpfF80faIPS2RzTI3yCudTspRJt3awmpphGM6U00Ic86paGGHO3iAbKSWAfpqRhDjgieZRDWKLAOkMHeDfW3t+Z3BEoqeco+VkCnS72onbr6eJfSxi22rhRvBZ6pyQIE00B+tYPUHbx5Vak78ExU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119042; 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=j8POjTf5fLrv+dC1UWh/YfhGZ3+QUBjQ2RgTqJJscgk=; b=g/3sCAORGR23aD92c6fGz1zgMUPUBYdd98sQd7cYN42rKdsLTrP9wD1xr2Q7uPgBmA4ZtiMhWn6CDRSy+aMnZst2SCC+/XUVkKw3qzTNbmgC12rWzU6uDM4Jz6TZA2d/zuL401YzWIWXqug1aXtvNCax4u+izCWY9sZfTI4f53o= 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 1732119042588410.2523082675856; Wed, 20 Nov 2024 08:10:42 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 87F3815FE; Wed, 20 Nov 2024 11:10:41 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5AA301570; Wed, 20 Nov 2024 11:09:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E2ACF1463; Wed, 20 Nov 2024 11:09:35 -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 560D1144F for ; Wed, 20 Nov 2024 11:09:35 -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 1tDn0w-0005yc-2m; Wed, 20 Nov 2024 16:53:10 +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=jt1a552C/hF5joWzgd9R17MJNs8LJwtpyjKCW8NL4cM=; b=RwMkHfGseC3T leEyIS7liej2PsbdKKo6/Ew3mCx5Ci8K/DJ7498tEhLSYwHx/UU0g/WOeE3htLJW4zX1SXn+m7UxQ YGdTaBVaCFULMFs02p+T11hWc3Tlpqhhr2hNkzppWN86guWZV2Euk/Etrma5gXPNhjJUKeJ2LUxol Z/4UFXEjlYD7zrRlqVaKHh1P+L8AxA407LFYXMwK4WtYGil7lbn40hMR3IRtsHrc0aeKSm8lr2BGm r6mOUXekrBBCqemBc7jPCOcWSQA6jsQeurJkqu2Fc49bIRUp2PNPdhHVjcvMfcyPTat61z2eoqFCL f7fPOL6z3/8Z5Rcy3LquEQ==; To: devel@lists.libvirt.org Subject: [PATCH 10/15] security: apparmor: handle qcow2 data-file Date: Wed, 20 Nov 2024 18:48:45 +0300 Message-ID: <20241120155229.1259-11-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: PCDCLCTEDXWACPA52F2NVUEED6XC32JO X-Message-ID-Hash: PCDCLCTEDXWACPA52F2NVUEED6XC32JO 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: 1732119044145116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/security/virt-aa-helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 067a17f331..a2914f22b9 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -877,6 +877,10 @@ storage_source_add_files(virStorageSource *src, if (add_file_path(tmp, depth, buf) < 0) return -1; =20 + if (src->dataFileStore && + add_file_path(src->dataFileStore, buf, 0) < 0) + return -1; + depth++; } =20 --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119349; cv=none; d=zohomail.com; s=zohoarc; b=GTIsBgjA3PYdU9fNpmHkVr7DqSr6NPyKVAtrkU5mavy09TXHIpzGATkXR4icM4G1pEYKqtphwTf/kbXfdCsQ6nN5wbsvq19EgAhZ22Qw1qu9QV5zNxWl209gSYcOXy4K28jGlOUHYCnEVciLfJOmZJhjeCuIEDiUjehW80TQ1IY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119349; 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=Bzxd/3jCbB65ynzhto7ECdCOYUHXSBhOFBZ3r98RZ28=; b=CLx5NtpsyV4fhgk2WPWDRrVdGdizXRwzez4eHRfxoi9ejhEjNqDb01TNnYFccncNKSmKBrq+j3klv2WFzur4djD4NtIeuBIwcFSOgM6FhuczHVqsDF4Hb5pkZXNKNZUHqcezBwAn+/kdwI3WsZOj4zHMD84HxoWLLcFtapUyKg0= 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 1732119349026329.4828071615033; Wed, 20 Nov 2024 08:15:49 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BE861128D; Wed, 20 Nov 2024 11:15:47 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 97C0B151C; Wed, 20 Nov 2024 11:10:13 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 676021518; Wed, 20 Nov 2024 11:10:05 -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 F3ADC154F for ; Wed, 20 Nov 2024 11:09:48 -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 1tDn0x-0005yc-1S; Wed, 20 Nov 2024 16:53:11 +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=Vye28wu07v02JTRsB9t2kcR3+02Oo3DfeymOu1whKb8=; b=xFYd+wtMGPpD r61CHrAer/lipZNRLPXcA5xFcBvLX09JY9vHVXZoby45Ia8z83s3HrIDcnl108Oh88l47MQBuH1yj q78h8KN27Xfob0hviq0T9boApKLjXiYlNd9NhlVD8xscEFsQR/pkF6kbRM2l3dcBi5MhvDhZSgXxv aDZCUVkLFizvXIXKsRO10ZdLUb71m/tIFWZan9ITVEJFna4TrdhZQK7xH8MwejqxJNe8zXBOUJ9xx td+7hymlYVnToBXp+tEXbJYu+zymfSD90NAhBHAs3WNi7PGLk4KFTPteXBQDyb32QuEs97iInYLBk 7LwEifQfTLyA5F1Qb+hzgw==; To: devel@lists.libvirt.org Subject: [PATCH 11/15] qemu: put data-file path to VM's cgroup and namespace Date: Wed, 20 Nov 2024 18:48:46 +0300 Message-ID: <20241120155229.1259-12-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: NTK2KQSFOVDRNSPWXQCXLD7FOD3A4LTJ X-Message-ID-Hash: NTK2KQSFOVDRNSPWXQCXLD7FOD3A4LTJ 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: 1732119349385116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/qemu/qemu_cgroup.c | 13 ++++++++++++- src/qemu/qemu_namespace.c | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index be4b9a38ff..f3c85d65e8 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -232,7 +232,14 @@ int qemuSetupImageCgroup(virDomainObj *vm, virStorageSource *src) { - return qemuSetupImageCgroupInternal(vm, src, false); + if (qemuSetupImageCgroupInternal(vm, src, false) < 0) + return -1; + + if (src->dataFileStore && + qemuSetupImageCgroupInternal(vm, src->dataFileStore, false) < 0) + return -1; + + return 0; } =20 =20 @@ -321,6 +328,10 @@ qemuSetupImageChainCgroup(virDomainObj *vm, if (qemuSetupImageCgroupInternal(vm, next, forceReadonly) < 0) return -1; =20 + if (next->dataFileStore && + qemuSetupImageCgroupInternal(vm, next->dataFileStore, forceRea= donly) < 0) + return -1; + /* setup only the top level image for read-write */ forceReadonly =3D true; } diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 0ebc115524..9fc13ee759 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -272,6 +272,13 @@ qemuDomainSetupDisk(virStorageSource *src, } else { GSList *targetPaths =3D NULL; =20 + if (next->dataFileStore && + !virStorageSourceIsEmpty(next->dataFileStore) && + virStorageSourceIsLocalStorage(next->dataFileStore)) { + g_autofree char *dataFilePath =3D g_strdup(next->dataFileS= tore->path); + *paths =3D g_slist_prepend(*paths, g_steal_pointer(&dataFi= lePath)); + } + if (virStorageSourceIsEmpty(next) || !virStorageSourceIsLocalStorage(next)) { /* Not creating device. Just continue. */ --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119262; cv=none; d=zohomail.com; s=zohoarc; b=P5F9wl5tnvQqOTW8Inz77AodND2eTFUgJ9k2on/YeVtUsbCkW9wKnM+wd58ZzufmqbPlrEEZ1piczmBL2dYc4NNN8do5B7ZOkpWzVj00dTctwTUexO91Y11CSyTC9ilmszGdqBMkXY2q99CLXSLV97mrOWki8NvIiMDiBuUQSzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119262; 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=shtJReE7VZf9ETPkU7zPs2vC0VvaRDji5HnM6cFUrv8=; b=YJaSTo47EGAOwgsiXjx92tVgUi5MwQZLW/5EcTe5eB0QPeMrUDWS4Qipj/2d5h5ZscsOeCWNVjduoXBhX0o7+CnN66dMibzUSzCzZhrSR8m7Eon9h+CM+4nOvvVL11Y1+9sqqKlq/i6rCd3FhU3pZDF5wm36qzNa9yEPOW0auKk= 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 1732119261997346.27524460726033; Wed, 20 Nov 2024 08:14:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D0A2D15C6; Wed, 20 Nov 2024 11:14:20 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3204615F2; Wed, 20 Nov 2024 11:10:05 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 66F161503; Wed, 20 Nov 2024 11:09:57 -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 7046E1516 for ; Wed, 20 Nov 2024 11:09:44 -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 1tDn0x-0005yc-39; Wed, 20 Nov 2024 16:53:12 +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=Gx0t3INsyuvu2soodaLtTieLrxV6i0BbKjgWBnBnOV0=; b=mfQm4t5jyIrk 1BgUZMKBXwZaLZ55ewb+l422ZRkqiidysUNZIYBFPztw6cflFtHeTpPyRIqNUARPxh2f+GjHUeZle niqoVTvol+yRhIptPgnSwCISk/Od9WEf9W1qDvfdF30lPQyyaUOTgV6OORI+q8o/MSmakrm/JVVT+ R4cna6EiMBHScULayjLWyak8eY5c9nSK7EbvRy49kC7xlT21r5bVFWshoHL9LyYl1tVR9kna+ioxe Exh6A7l7XtJldTUekJZ1V40IaxJVhvBJQKfbVIRN0ihviIYgcu6zYyEAIsh0scfqX91Ut6ZAFB4+y fD69Ynu5fEloI7UaKLd+hg==; To: devel@lists.libvirt.org Subject: [PATCH 12/15] qemu: factor out qemuDomainPrepareStorageSource() Date: Wed, 20 Nov 2024 18:48:47 +0300 Message-ID: <20241120155229.1259-13-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: W4BJUUQ34KKMJVN62YTA7IZOKMIZPBAZ X-Message-ID-Hash: W4BJUUQ34KKMJVN62YTA7IZOKMIZPBAZ 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: 1732119262959116600 Content-Type: text/plain; charset="utf-8" This refactoring will simplify next changes. Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 66ab4baa8b..393c7dcac1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6114,6 +6114,32 @@ qemuDomainPrepareStorageSourceConfig(virStorageSourc= e *src, } =20 =20 +static int +qemuDomainPrepareStorageSource(virStorageSource *src, + virDomainObj *vm, + virDomainDiskDef *disk, + virQEMUDriverConfig *cfg) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + + /* convert detected ISO format to 'raw' as qemu would not understand i= t */ + if (src->format =3D=3D VIR_STORAGE_FILE_ISO) + src->format =3D VIR_STORAGE_FILE_RAW; + + if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0) + return -1; + + qemuDomainPrepareStorageSourceConfig(src, cfg); + qemuDomainPrepareDiskSourceData(disk, src); + + if (!qemuDiskBusIsSD(disk->bus) && + qemuDomainPrepareStorageSourceBlockdev(disk, src, priv, cfg) < 0) + return -1; + + return 0; +} + + /** * qemuDomainDetermineDiskChain: * @driver: qemu driver object @@ -6134,7 +6160,6 @@ qemuDomainDetermineDiskChain(virQEMUDriver *driver, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virStorageSource *src; /* iterator for the backing chain declared in X= ML */ virStorageSource *n; /* iterator for the backing chain detected from d= isk */ - qemuDomainObjPrivate *priv =3D vm->privateData; uid_t uid; gid_t gid; =20 @@ -6218,18 +6243,7 @@ qemuDomainDetermineDiskChain(virQEMUDriver *driver, return -1; =20 for (n =3D src->backingStore; virStorageSourceIsBacking(n); n =3D n->b= ackingStore) { - /* convert detected ISO format to 'raw' as qemu would not understa= nd it */ - if (n->format =3D=3D VIR_STORAGE_FILE_ISO) - n->format =3D VIR_STORAGE_FILE_RAW; - - if (qemuDomainValidateStorageSource(n, priv->qemuCaps) < 0) - return -1; - - qemuDomainPrepareStorageSourceConfig(n, cfg); - qemuDomainPrepareDiskSourceData(disk, n); - - if (!qemuDiskBusIsSD(disk->bus) && - qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0) + if (qemuDomainPrepareStorageSource(n, vm, disk, cfg) < 0) return -1; } =20 --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119121; cv=none; d=zohomail.com; s=zohoarc; b=graqzgQHLWC/p00NPcZ9l3ZPv9gdSV2RZaMkNO2fgs4TH0K6aQgRTPGlsH/Cu8hjbMFrO3GesdjBrXGGfnulglZiGuI05xeQMscyWRNgbVSt3wUx5hKSboEZGb/NGN9LTxBLO+UVLlltDJbHBnttNli4wLmR9nZuvgYv9ToUNyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119121; 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=JBMhEbApwpQ288uycpX6XW+fe6YSeD+VKbjcuNMUujw=; b=a0HUiJx/qkWsVfHvqcFRtBI8OFpsoqxZobGiNxJvYyoWtK4mjbZo1/heF1nkJgovxbopXrQ9fC4Lxhd0ce153L+9X3bQXp83I12ok/4mGperZALWA0nIFdrDwh0Fo4xr3SJ0gewWvpu5wTEi0liv5SQE+kEdhgyVmkXyFJcrJfg= 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 1732119121506673.5251198648284; Wed, 20 Nov 2024 08:12:01 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7AAF215A9; Wed, 20 Nov 2024 11:12:00 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2993E1541; Wed, 20 Nov 2024 11:09:52 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2473A1499; Wed, 20 Nov 2024 11:09:47 -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 A93601499 for ; Wed, 20 Nov 2024 11:09:38 -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 1tDn0y-0005yc-1k; Wed, 20 Nov 2024 16:53:12 +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=GUnelx5pY87qPOoCdgQBWXnyCoOC1UqqgEy9ECSE3/M=; b=NWI6UFUgW+mB qfAgVXdsRMtCVAwC9FRN6bFCGmeYMOOYsnJpRE4rm1tNr6Rpb4UwcjWhpg2Xyse2XX4vGsXyRMXdz azRHcOIvNQLKxXyjhMlWfKmOiqINLUsWN53Srvxd5dDSoQwk0d+UHgKGezEq7h3OEE+8ukuhubUUy YyhAKw/EVBkVbZCkxmDGuJJUEh7LHzcFAmjkvveLwH3Rn3gEUFyh1l+ju9CXB068MRiQRqO7qOEQ5 X8Cczy44/miLmz/QbNgCZV3XMYTBNXc3iFt/tkZhiBsRRM0OuhbGAa3P1GPzngZTn7iVjgjqL/MLn pa2oMVO3CcDyxgA33p2pOQ==; To: devel@lists.libvirt.org Subject: [PATCH 13/15] qemu: enable basic qcow2 data-file feature support Date: Wed, 20 Nov 2024 18:48:48 +0300 Message-ID: <20241120155229.1259-14-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: 6CJHE7WJRWATC2GDAIDBS6N6VKEV3GBO X-Message-ID-Hash: 6CJHE7WJRWATC2GDAIDBS6N6VKEV3GBO 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: 1732119122338116600 Content-Type: text/plain; charset="utf-8" - propogate data-file to cmdline - determine data-file within disk chain - enable live disk insertion Signed-off-by: Nikolai Barybin --- src/qemu/qemu_block.c | 14 ++++++++++++++ src/qemu/qemu_command.c | 5 +++++ src/qemu/qemu_domain.c | 14 +++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 3c1305ec84..1915d5f5fd 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1302,6 +1302,13 @@ qemuBlockStorageSourceGetFormatQcow2Props(virStorage= Source *src, NULL) < 0) return -1; =20 + if (src->dataFileStore) { + if (virJSONValueObjectAdd(&props, + "s:data-file", qemuBlockStorageSourceGet= EffectiveNodename(src->dataFileStore), + NULL) < 0) + return -1; + } + return 0; } =20 @@ -1859,6 +1866,13 @@ qemuBlockStorageSourceChainDetachPrepareBlockdev(vir= StorageSource *src) return NULL; =20 VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend); + + if (n->dataFileStore) { + if (!(backend =3D qemuBlockStorageSourceDetachPrepare(n->dataF= ileStore))) + return NULL; + + VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend); + } } =20 return g_steal_pointer(&data); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f4430275dc..cdc80cee73 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -11018,6 +11018,11 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(v= irStorageSource *top) if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, n, n->backing= Store) < 0) return NULL; + + if (n->dataFileStore && + qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, n->d= ataFileStore, + n->dataFil= eStore->backingStore) < 0) + return NULL; } =20 return g_steal_pointer(&data); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 393c7dcac1..d0700db3be 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6242,9 +6242,17 @@ qemuDomainDetermineDiskChain(virQEMUDriver *driver, true) < 0) return -1; =20 + if (src->dataFileStore && + qemuDomainPrepareStorageSource(src->dataFileStore, vm, disk, cfg) = < 0) + return -1; + for (n =3D src->backingStore; virStorageSourceIsBacking(n); n =3D n->b= ackingStore) { if (qemuDomainPrepareStorageSource(n, vm, disk, cfg) < 0) return -1; + + if (n->dataFileStore && + qemuDomainPrepareStorageSource(n->dataFileStore, vm, disk, cfg= ) < 0) + return -1; } =20 if (qemuDomainStorageSourceValidateDepth(disksrc, 0, disk->dst) < 0) @@ -9438,7 +9446,7 @@ qemuDomainPrepareDiskSourceData(virDomainDiskDef *dis= k, return; =20 /* transfer properties valid only for the top level image */ - if (src =3D=3D disk->src) + if (src =3D=3D disk->src || src =3D=3D disk->src->dataFileStore) src->detect_zeroes =3D disk->detect_zeroes; =20 /* transfer properties valid for the full chain */ @@ -9667,6 +9675,10 @@ qemuDomainPrepareDiskSourceBlockdev(virDomainDiskDef= *disk, for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { if (qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0) return -1; + + if (n->dataFileStore && + qemuDomainPrepareStorageSourceBlockdev(disk, n->dataFileStore,= priv, cfg) < 0) + return -1; } =20 return 0; --=20 2.43.5 From nobody Sat Nov 23 08:06:53 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=1732119240; cv=none; d=zohomail.com; s=zohoarc; b=fdQFCxKLxASkULNvWztZInKfhLJNsfwUW3B8wW7qw3Gy+YJkEEBirS/4G8rr9pOxqeRRhWXXQIv5eq3yBPrtLBjHcr3m5uzX6xlXjOulIfoYV1hZixku+rF7RemGJal5Kv3JnkCHGOUJwjO7C3CJ9TDB8VpCx8vkaVcmddGGWjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119240; 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=R17kxOatgE9uZ8TPyoka19b7e5modi3m52lvmemOntE=; b=fxQijgXO2Z8HsxdA4r4xa0gWZmoWS/ZGK0JErxFo9DDBpOgg8U/N/ELHxVGGOxhpNchDqVZFndWUJYidPd2xp5ZeW6X/mdj3vmeFMJKo0YJklqVPFaAoDRh71x4AxjnshUQ8q6YnL7VejcGGMAAjXObRS9sQgrbShQC/hPKcxhM= 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 1732119240476206.87964556332497; Wed, 20 Nov 2024 08:14:00 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6A884A41; Wed, 20 Nov 2024 11:13:59 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4F6471499; Wed, 20 Nov 2024 11:10:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E223A1526; Wed, 20 Nov 2024 11:09:55 -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 06E7F154E for ; Wed, 20 Nov 2024 11:09:42 -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 1tDn0z-0005yc-0V; Wed, 20 Nov 2024 16:53:13 +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=ewynCiEMNroPTYWXrTClsqDayBlLl7dj7WnLa1fIIo8=; b=I08W5+Ln6nGq tA7pImzsc0uL8A8HHeZSxuJjWO1m2DMeeqdC6gDvsimiiDiKDp6iWV+qKSVHfwmiuUvsRTX2XCQ26 aqgukqtcmWfiiG+PcU6MSuV4ShegJNVGyS1P/np0nnfU44XsYXTjPGP4rkZDhEtcDwluJ9xczdygJ mb9x4zwgEbe1voEMASmiyGIqKLJkraQ0t5lZ/K+LxyBV75H3p4m9yWqP/4torkKtlFEDqjxWIfm3z GJmRgrqakSROAnUYRsl0QZgIiQzFB71hFk+FQYANvVKTw/hOZSbJ2BAUqsq7R+RwuPUM9hhQJkADi 8FHmIqyr0lwZx0et2B27eg==; To: devel@lists.libvirt.org Subject: [PATCH 14/15] tests: add qcow2 data-file tests Date: Wed, 20 Nov 2024 18:48:49 +0300 Message-ID: <20241120155229.1259-15-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: IDFESQZDZ7WGUQPPQQM67GBMAQZFW65V X-Message-ID-Hash: IDFESQZDZ7WGUQPPQQM67GBMAQZFW65V 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: 1732119240881116600 Content-Type: text/plain; charset="utf-8" - qemuxmlconftest: check various xml definitions of dataFileStore: types file, block, network and the case when data-file belongs to qcow2 backing image - virstoragetest: create qcow2 image chains and check that data files are properly probed by metadata parser - qemuxmlactivetest: check that status files will contain data files' node names Signed-off-by: Nikolai Barybin --- .../qcow2-data-file-in.xml | 86 ++++++++++++++++ .../qcow2-data-file-out.xml | 86 ++++++++++++++++ tests/qemuxmlactivetest.c | 2 + ...sk-qcow2-datafile-store.x86_64-latest.args | 51 ++++++++++ ...isk-qcow2-datafile-store.x86_64-latest.xml | 81 +++++++++++++++ .../disk-qcow2-datafile-store.xml | 67 +++++++++++++ tests/qemuxmlconftest.c | 1 + tests/virstoragetest.c | 98 +++++++++++++++++++ tests/virstoragetestdata/out/qcow2-data_file | 20 ++++ .../out/qcow2-qcow2_qcow2-qcow2-data_file | 31 ++++++ 10 files changed, 523 insertions(+) create mode 100644 tests/qemustatusxml2xmldata/qcow2-data-file-in.xml create mode 100644 tests/qemustatusxml2xmldata/qcow2-data-file-out.xml create mode 100644 tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-= latest.args create mode 100644 tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-= latest.xml create mode 100644 tests/qemuxmlconfdata/disk-qcow2-datafile-store.xml create mode 100644 tests/virstoragetestdata/out/qcow2-data_file create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2-da= ta_file diff --git a/tests/qemustatusxml2xmldata/qcow2-data-file-in.xml b/tests/qem= ustatusxml2xmldata/qcow2-data-file-in.xml new file mode 100644 index 0000000000..40479dd3d6 --- /dev/null +++ b/tests/qemustatusxml2xmldata/qcow2-data-file-in.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + testtest + + + + + + + + + + + + + + + + -2 + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + +