From nobody Sun Oct 5 00:06:49 2025 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=1757512766; cv=none; d=zohomail.com; s=zohoarc; b=KVzt0LcVEtQmkJmxsvpMMY6xu/sFF0Lrrg4NU0T1GEW0Fve2FJ0fkH+ynYHFPt1ks9p+watA34Je4V4JhAOIa+N0Z1UnLbz3uLpXDeyQYB1bhA/cBXDxEK2ghLeu5cdCrPprloD+8TtO5f6TIXC6mZv5T3t25nHnczmE8/7jWpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757512766; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=24KEd5lSojYW/qLqKwrZO6FzCKQ8Txa3E3QIMANuK+A=; b=PH2Mj3qmeb+kCrjqzRw/hJtTRB7KeWSo9P7OdP6Pin+JBOOCl3091P5Aj5VauhO9anWHPYGr7458ur6nMf4Vhuf6Yym9q2Bxv5yFDmvUG34AraJGhB9RG9mzDx2vTX0bbnqf8NzaQcs8XKYW4EhbNlt6Z4AGBL2PrJM5+X94Zps= 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 1757512766970455.15626281222524; Wed, 10 Sep 2025 06:59:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 2275D418E2; Wed, 10 Sep 2025 09:59:26 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id A3F7741C73; Wed, 10 Sep 2025 09:57:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5232941B9B; Wed, 10 Sep 2025 09:57:49 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A531141B96 for ; Wed, 10 Sep 2025 09:57:48 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-NHv7YiZiOXeYIfdtuYNQgg-1; Wed, 10 Sep 2025 09:57:46 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5FCA219540FE for ; Wed, 10 Sep 2025 13:57:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E0C6300018D for ; Wed, 10 Sep 2025 13:57:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757512668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=24KEd5lSojYW/qLqKwrZO6FzCKQ8Txa3E3QIMANuK+A=; b=DBSByb/0HGfSKcUMKIR0F9ku8erK2c6M++dvHm73HXxXjsh70ikGUqBWoY0unQePMslKPK ksieDmiTbvVb7gUvInwU2sm4IMEOZ8bWkJNalQpW76oYw73JmcHlO21LeHIsVlmuYaTSXC TO8LkZ6lvCh33Hs4aJAiZFFtjZhbFG8= X-MC-Unique: NHv7YiZiOXeYIfdtuYNQgg-1 X-Mimecast-MFC-AGG-ID: NHv7YiZiOXeYIfdtuYNQgg_1757512665 To: devel@lists.libvirt.org Subject: [PATCH 1/6] qemuMigrationSrcIsSafe: Drop 'DEBUG' message about qemu supporting cache dropping Date: Wed, 10 Sep 2025 15:57:36 +0200 Message-ID: <437fd3f2fb505952ed485f07cfa4fa3958ba13f4.1757512552.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rDNQV63leeSJ18hUytFgy0DN5K6GfHjzAMXlaC0stZU_1757512665 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: P3UXAHCKRTILUDRB774ASUTO2PU5DUB2 X-Message-ID-Hash: P3UXAHCKRTILUDRB774ASUTO2PU5DUB2 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757512769248116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The feature exists for a long time, no need to add extra notice about it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a8f4dd489c..dd171f953c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1805,14 +1805,10 @@ qemuMigrationSrcIsSafe(virDomainObj *vm, * which case cache mode doesn't matter) or used with cache=3Dnone= or used with cache=3Ddirectsync */ if (disk->src->shared || disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DISABLE || - disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC) + disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATION_FILE_DROP_CACHE)) continue; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATION_FILE_DROP_CACHE))= { - VIR_DEBUG("QEMU supports flushing caches; migration is safe"); - continue; - } - virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", _("Migration may lead to data corruption if disks u= se cache other than none or directsync")); return false; --=20 2.51.0 From nobody Sun Oct 5 00:06:49 2025 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=1757512831; cv=none; d=zohomail.com; s=zohoarc; b=Wo0cf/RGO/QTK22BTWLYZ1rQ4DdMQMDZJfGv/Em7YnKh24xvRxSdROFb5Lvup4y79g2YVTLhG05Xpfaw9frs9HYa+cOuhr3Wens6bP1BMEmhxptj+7c9ZDq86oCKidxU2LqGNUHnr9zhzz5MZjmWWDzqlZFAmHJF0pl2hn2TQeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757512831; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=dhKC7sAh8rsvu9H3wWQ1xmh9eb3/5IBrqJFC8KjeY3w=; b=cfN8gP3kfwSbIiP1/ps7MsqU5RHWoth+Igdq/aEKi46Qchy+GOSpRj6tB5TadzA2uQ0Zt3avraL2v3DnPwaaTQxJzAazQ62CfmYM9tns4xMolEdiH7ex7Vir0cEiSAnvRsx2oTQ2/W62Auj3auTFrVUu2v4ntVnMh6aBk633RcI= 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 1757512831352856.8942373742649; Wed, 10 Sep 2025 07:00:31 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4959343DEA; Wed, 10 Sep 2025 10:00:30 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 749C841CA1; Wed, 10 Sep 2025 09:58:04 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C44E141B96; Wed, 10 Sep 2025 09:57:49 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0356441B9A for ; Wed, 10 Sep 2025 09:57:48 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-NZmeQzXhPteJ03pjaTTanQ-1; Wed, 10 Sep 2025 09:57:47 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 865D3180034D for ; Wed, 10 Sep 2025 13:57:46 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CBEEB300018D for ; Wed, 10 Sep 2025 13:57:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757512668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dhKC7sAh8rsvu9H3wWQ1xmh9eb3/5IBrqJFC8KjeY3w=; b=WjY2vCQS69/gVgeyV/sRTaxk6iM1nA3G0LDesZNaCFbMJ0FFhEygpFYDeK0EnkBo+qtF0I pxMHPv5VNuIK46zDayWKD9Uy8XW2hID98a44hqsz8815yQLQaly4QW5s1WQOdmtWQr1lpe JkGjsTglF4jSLJO3TS3i2Dt5cRplsHI= X-MC-Unique: NZmeQzXhPteJ03pjaTTanQ-1 X-Mimecast-MFC-AGG-ID: NZmeQzXhPteJ03pjaTTanQ_1757512666 To: devel@lists.libvirt.org Subject: [PATCH 2/6] qemuMigrationSrcIsSafe: Extract code for checking safe migrability of one disk Date: Wed, 10 Sep 2025 15:57:37 +0200 Message-ID: <367f2a92f8121dea6a94ada66be147d829c3f823.1757512552.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6AymPFa4o9RhXnSeyjcopzRo03dWrbu1Tgeh7k5-W9I_1757512666 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LLKS4NSR2WFODZDQNJWSX37RW7CWLTEZ X-Message-ID-Hash: LLKS4NSR2WFODZDQNJWSX37RW7CWLTEZ X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757512833328116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Extract the code which checks a source of a single disk for safe migratability into 'qemuMigrationSrcIsSafeDisk'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 132 ++++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index dd171f953c..96709dfcdd 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1732,6 +1732,74 @@ qemuMigrationSrcIsAllowed(virDomainObj *vm, return true; } + +static bool +qemuMigrationSrcIsSafeDisk(virDomainDiskDef *disk, + virQEMUCaps *qemuCaps, + virQEMUDriverConfig *cfg) +{ + virStorageType actualType =3D virStorageSourceGetActualType(disk->src); + bool unsafe =3D false; + int rc; + + /* Disks without any source (i.e. floppies and CD-ROMs) OR readonly ar= e safe. */ + if (virStorageSourceIsEmpty(disk->src) || + disk->src->readonly) + return true; + + /* However, disks on local FS (e.g. ext4) are not safe. */ + switch (actualType) { + case VIR_STORAGE_TYPE_FILE: + if ((rc =3D virFileIsSharedFS(disk->src->path, cfg->sharedFilesyst= ems)) < 0) { + return false; + } else if (rc =3D=3D 0) { + unsafe =3D true; + } + + if ((rc =3D virFileIsClusterFS(disk->src->path)) < 0) + return false; + else if (rc =3D=3D 1) + return true; + break; + + case VIR_STORAGE_TYPE_NETWORK: + return true; + + case VIR_STORAGE_TYPE_NVME: + unsafe =3D true; + break; + + case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_BLOCK: + case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_VOLUME: + case VIR_STORAGE_TYPE_LAST: + break; + } + + if (unsafe) { + virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", + _("Migration without shared storage is unsafe")); + return false; + } + + /* Our code elsewhere guarantees shared disks are either readonly (in + * which case cache mode doesn't matter) or used with cache=3Dnone or = used with cache=3Ddirectsync */ + if (!(disk->src->shared || + disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DISABLE || + disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATION_FILE_DROP_CACHE))) { + virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", + _("Migration may lead to data corruption if disks u= se cache other than none or directsync")); + return false; + } + + return true; +} + + static bool qemuMigrationSrcIsSafe(virDomainObj *vm, const char **migrate_disks, @@ -1739,79 +1807,21 @@ qemuMigrationSrcIsSafe(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; - virQEMUCaps *qemuCaps =3D priv->qemuCaps; - virQEMUDriver *driver =3D priv->driver; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); bool storagemigration =3D flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC); size_t i; - int rc; for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk =3D vm->def->disks[i]; - const char *src =3D virDomainDiskGetSource(disk); - virStorageType actualType =3D virStorageSourceGetActualType(disk->= src); - bool unsafe =3D false; - - /* Disks without any source (i.e. floppies and CD-ROMs) - * OR readonly are safe. */ - if (virStorageSourceIsEmpty(disk->src) || - disk->src->readonly) - continue; - /* Disks which are migrated by qemu are safe too. */ + /* Disks which are migrated by qemu are safe */ if (storagemigration && qemuMigrationAnyCopyDisk(disk, migrate_disks)) continue; - /* However, disks on local FS (e.g. ext4) are not safe. */ - switch (actualType) { - case VIR_STORAGE_TYPE_FILE: - if ((rc =3D virFileIsSharedFS(src, cfg->sharedFilesystems)) < = 0) { - return false; - } else if (rc =3D=3D 0) { - unsafe =3D true; - } - if ((rc =3D virFileIsClusterFS(src)) < 0) - return false; - else if (rc =3D=3D 1) - continue; - break; - case VIR_STORAGE_TYPE_NETWORK: - /* But network disks are safe again. */ - continue; - - case VIR_STORAGE_TYPE_NVME: - unsafe =3D true; - break; - - case VIR_STORAGE_TYPE_VHOST_USER: - case VIR_STORAGE_TYPE_VHOST_VDPA: - case VIR_STORAGE_TYPE_NONE: - case VIR_STORAGE_TYPE_BLOCK: - case VIR_STORAGE_TYPE_DIR: - case VIR_STORAGE_TYPE_VOLUME: - case VIR_STORAGE_TYPE_LAST: - break; - } - - if (unsafe) { - virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", - _("Migration without shared storage is unsafe")= ); + if (!qemuMigrationSrcIsSafeDisk(disk, priv->qemuCaps, cfg)) return false; - } - - /* Our code elsewhere guarantees shared disks are either readonly = (in - * which case cache mode doesn't matter) or used with cache=3Dnone= or used with cache=3Ddirectsync */ - if (disk->src->shared || - disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DISABLE || - disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATION_FILE_DROP_CACHE)) - continue; - - virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", - _("Migration may lead to data corruption if disks u= se cache other than none or directsync")); - return false; } return true; --=20 2.51.0 From nobody Sun Oct 5 00:06:49 2025 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=1757512902; cv=none; d=zohomail.com; s=zohoarc; b=kQBG8kcrbWDcwPEvQxYtRDBcAYQqOW1DOPGIwCM6q3ezuoPnLh2QfkbJDFTTFrHj62kxQzgpfjeeF7SBeWIiyAKoIU0G5PBjnVuqjX4r1bQlB266S96yjwe/Kc0UV4UOZ/HiYienJgL0i+4unvMb9hd2diwe6xoQXtr8LfupzBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757512902; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=et8cKSZ1UqIgBqG5AmI9CtVofv1T22XABOOUNmO78uk=; b=nDxvMfcGeDKKDSFYe5+k+QADDLctZk9S42SZqebRdrIoX3f6pCIsdTIZuV+6GbQYm0jk5wpWghwYeb8fzkc55csAy/U30NAeV1MBTjH5OCpLDrtdjAvTH9/laOlQ4pfLQpqy+ICJ1xeZhJa1mQOh+gXXQGpC3+7Cf66j8SlmfLo= 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 1757512901988393.87045025063117; Wed, 10 Sep 2025 07:01:41 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id DEC4241B94; Wed, 10 Sep 2025 10:01:40 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 8C78043DD2; Wed, 10 Sep 2025 09:58:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id AE11C41B9F; Wed, 10 Sep 2025 09:57:50 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id ECD5E41B94 for ; Wed, 10 Sep 2025 09:57:49 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-r3F49UhzM3eh_P7kGLblgA-1; Wed, 10 Sep 2025 09:57:48 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF3091800378 for ; Wed, 10 Sep 2025 13:57:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F265D300018D for ; Wed, 10 Sep 2025 13:57:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757512669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=et8cKSZ1UqIgBqG5AmI9CtVofv1T22XABOOUNmO78uk=; b=JEhnu31+UWpaFWPd3RkVmhMYjddUtGtgYxQ0xWLUJul1XOpRdhtQluR459Vwg9Mx82MmDy X6ipyQweFQH3JDPyXS14p6KM2J0fGwJrQlSJzza7ZJ4ktOP1dSE9B8zX6l2tHpiDHTpngG H7CF6z+YgRruJBHYR0Yf+2mlnXbJAFE= X-MC-Unique: r3F49UhzM3eh_P7kGLblgA-1 X-Mimecast-MFC-AGG-ID: r3F49UhzM3eh_P7kGLblgA_1757512667 To: devel@lists.libvirt.org Subject: [PATCH 3/6] qemuMigrationSrcIsSafeDisk: Extract safe migration checks for one storage source Date: Wed, 10 Sep 2025 15:57:38 +0200 Message-ID: <7a956459d85df5d7c35516806da88e19ab7996f8.1757512552.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qkkYaM4t5GVF6u6IE9bCukWReukMoSKF58ZEQKY0S8o_1757512667 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GJHCMEJ34QI3NPS3RJ7ZEG6ULHSWGWCY X-Message-ID-Hash: GJHCMEJ34QI3NPS3RJ7ZEG6ULHSWGWCY X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757512904371116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Further split up the code originally in 'qemuMigrationSrcIsSafe' to separate checks concerning a single storage source. The code will then be reused to check the safe migration state also for the data file (qcow2 feature that allows store of data separated from the qcow2 metadata). Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 71 ++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 96709dfcdd..ae26f74f8c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1733,40 +1733,34 @@ qemuMigrationSrcIsAllowed(virDomainObj *vm, } -static bool -qemuMigrationSrcIsSafeDisk(virDomainDiskDef *disk, - virQEMUCaps *qemuCaps, - virQEMUDriverConfig *cfg) +static int +qemuMigrationSrcCheckStorageSourceSafety(virStorageSource *src, + virQEMUDriverConfig *cfg, + bool *unsafe_storage, + bool *requires_safe_cache) { - virStorageType actualType =3D virStorageSourceGetActualType(disk->src); - bool unsafe =3D false; - int rc; + switch (virStorageSourceGetActualType(src)) { + case VIR_STORAGE_TYPE_FILE: { + int rc_cluster =3D virFileIsClusterFS(src->path); + int rc_shared =3D virFileIsSharedFS(src->path, cfg->sharedFilesyst= ems); - /* Disks without any source (i.e. floppies and CD-ROMs) OR readonly ar= e safe. */ - if (virStorageSourceIsEmpty(disk->src) || - disk->src->readonly) - return true; + if (rc_cluster < 0 || rc_shared < 0) + return -1; - /* However, disks on local FS (e.g. ext4) are not safe. */ - switch (actualType) { - case VIR_STORAGE_TYPE_FILE: - if ((rc =3D virFileIsSharedFS(disk->src->path, cfg->sharedFilesyst= ems)) < 0) { - return false; - } else if (rc =3D=3D 0) { - unsafe =3D true; - } + if (rc_cluster =3D=3D 0) { + *requires_safe_cache =3D true; - if ((rc =3D virFileIsClusterFS(disk->src->path)) < 0) - return false; - else if (rc =3D=3D 1) - return true; + if (rc_shared =3D=3D 0) + *unsafe_storage =3D true; + } + } break; case VIR_STORAGE_TYPE_NETWORK: - return true; + break; case VIR_STORAGE_TYPE_NVME: - unsafe =3D true; + *unsafe_storage =3D true; break; case VIR_STORAGE_TYPE_VHOST_USER: @@ -1776,10 +1770,32 @@ qemuMigrationSrcIsSafeDisk(virDomainDiskDef *disk, case VIR_STORAGE_TYPE_DIR: case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_LAST: + *requires_safe_cache =3D true; break; } - if (unsafe) { + return 0; +} + + +static bool +qemuMigrationSrcIsSafeDisk(virDomainDiskDef *disk, + virQEMUCaps *qemuCaps, + virQEMUDriverConfig *cfg) +{ + bool unsafe_storage =3D false; + bool requires_safe_cache =3D false; + + /* Disks without any source (i.e. floppies and CD-ROMs) OR readonly ar= e safe. */ + if (virStorageSourceIsEmpty(disk->src) || + disk->src->readonly) + return true; + + if (qemuMigrationSrcCheckStorageSourceSafety(disk->src, cfg, &unsafe_s= torage, + &requires_safe_cache) < 0) + return false; + + if (unsafe_storage) { virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", _("Migration without shared storage is unsafe")); return false; @@ -1787,7 +1803,8 @@ qemuMigrationSrcIsSafeDisk(virDomainDiskDef *disk, /* Our code elsewhere guarantees shared disks are either readonly (in * which case cache mode doesn't matter) or used with cache=3Dnone or = used with cache=3Ddirectsync */ - if (!(disk->src->shared || + if (requires_safe_cache && + !(disk->src->shared || disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DISABLE || disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC || virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATION_FILE_DROP_CACHE))) { --=20 2.51.0 From nobody Sun Oct 5 00:06:49 2025 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=1757512961; cv=none; d=zohomail.com; s=zohoarc; b=TUtWDlHkugg6IOyvDknqqfT4sXdLayMFDcB6Y9QeOQrLjkT116uOjsZDjdsnTUvBrpg/1j7+WtRM+EijCQ15B1AI2aDXkle4HbUQPLrxcIBZpBOiW75k1DqcQ99aCR+nezKJjfgyK2NOrC9N+KuuPhA6AZamh9HhEKCV0U/lD7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757512961; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=qLS+aXd99KEYW0qQdF6Qg5oMR4MEHNXuQbhhriSPvio=; b=STsBQPBhB2m0LYBMXNczcBycoHm4V5cUrcaCgXkT2FHZDIoJjB5rxaG5cW+e8fBsTltguvitqWBYQ7d+SvmQzX/aXQ2shnQQNSq27XZDAzBodbb3vI/L3l07B50IFMChfDMdX41GF+OiJEm39byo6KvdGIisZQ0wpuRZ2fsjntA= 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 1757512961270459.49979297927666; Wed, 10 Sep 2025 07:02:41 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id DE53B43EA9; Wed, 10 Sep 2025 10:02:36 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id B8B7443EC1; Wed, 10 Sep 2025 09:58:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 142D143E1E; Wed, 10 Sep 2025 09:57:59 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5406E41BB9 for ; Wed, 10 Sep 2025 09:57:51 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-147-AtX41W4XNz-ge6hkR8dDPg-1; Wed, 10 Sep 2025 09:57:49 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E7D2119541BE for ; Wed, 10 Sep 2025 13:57:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2E64C300018D for ; Wed, 10 Sep 2025 13:57:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757512670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qLS+aXd99KEYW0qQdF6Qg5oMR4MEHNXuQbhhriSPvio=; b=J7TLXXrglxtVsjEuhEgdrRMPHpHEBWSbbpmavX8DZT5j/kqUYhTdt/Hm0DwZFvf1dEj0LF Siav7Ko2D40YRv7g6hnU1gaNxUiTievxErVHqQw34N72scqHlzJInUPVZCORRSlXI0+ONC I1RKbdLAUer9FeYdNywLE5WIKMmwLHs= X-MC-Unique: AtX41W4XNz-ge6hkR8dDPg-1 X-Mimecast-MFC-AGG-ID: AtX41W4XNz-ge6hkR8dDPg_1757512669 To: devel@lists.libvirt.org Subject: [PATCH 4/6] qemuMigrationSrcIsSafeDisk: Check also data file propertiues for migrability Date: Wed, 10 Sep 2025 15:57:39 +0200 Message-ID: <55560fa7860583c70303b1b3c9a1f2b7bf52d520.1757512552.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WQTf3ZHeqpdBjsQY8KouUEFHpq9VmvZh-QmByt4-9e8_1757512669 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 653AN6CJC2KMMGAPEN4HYFMXZ72F5Y6F X-Message-ID-Hash: 653AN6CJC2KMMGAPEN4HYFMXZ72F5Y6F X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757512964909116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa If the qcow2 data file feature (which separates the data into a separate file from the metadata) is in use the migration safety check ought co consider both the metadata and the data file for safe migration. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index ae26f74f8c..2e52e73f48 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1795,6 +1795,12 @@ qemuMigrationSrcIsSafeDisk(virDomainDiskDef *disk, &requires_safe_cache) < 0) return false; + if (disk->src->dataFileStore && + qemuMigrationSrcCheckStorageSourceSafety(disk->src->dataFileStore, + cfg, &unsafe_storage, + &requires_safe_cache) < 0) + return false; + if (unsafe_storage) { virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", _("Migration without shared storage is unsafe")); --=20 2.51.0 From nobody Sun Oct 5 00:06:49 2025 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=1757513033; cv=none; d=zohomail.com; s=zohoarc; b=ZrcgIwiZ0UZyhL3uA+wUrnYH818xxn+0+4fvNItgehz0QkQ10v2/2UirQi8pptm8GayoH8BR/B1c39yEUmlVToYZIEeu3P5bVEjV3oWPqQ+Nbll4HdXtCAz4cGsvN+qt6+UIMVufaqEFLNPkgpgXoWEpXRgHUxhsY9paQKM4GMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757513033; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=9ComOTN9kK+1FNiwukuRbHKXCNJD1gW+yPpGczMhwd4=; b=LZDI2DilkExkarnxJGrsiGpkulzkHfcj7Bk7WzY3W9nd8zMQUhtKgDBPAuaF85pHhT5QKLjyQIm3iuVv6qB5zcIQDBD/vZ8iOOhhF/lJ3NquXn5Suer3xCdc23C15MHMBVfxR44404Q3qns8vPJdHr3+8D2/hAFW+ExnN3haV1A= 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 1757513032950546.743389539569; Wed, 10 Sep 2025 07:03:52 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9AD4A43E2F; Wed, 10 Sep 2025 10:03:51 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 31DD643EFE; Wed, 10 Sep 2025 09:58:19 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 3C3D243E59; Wed, 10 Sep 2025 09:58:02 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5FB8541C7C for ; Wed, 10 Sep 2025 09:57:52 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-604-8lcH6IYtMWeFRT_SPkYd9A-1; Wed, 10 Sep 2025 09:57:50 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 28B5819560B3 for ; Wed, 10 Sep 2025 13:57:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6D61230001B5 for ; Wed, 10 Sep 2025 13:57:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757512672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9ComOTN9kK+1FNiwukuRbHKXCNJD1gW+yPpGczMhwd4=; b=DNanjLA/feI6hTz2H0eTzF/RWBvHDs1xsKMJbYPYrOJayM1vGi38/9liL8zSEgb0alQ4UZ Le9Xr9iCpAGiMxjwzaVk6vUM3loKUEb7lraOQimhUbb/4J9ba55KGXZr1fXVUhapO88fT+ 0CB83WdN2Q2E/YKgjIVQkEJ62CLEwM8= X-MC-Unique: 8lcH6IYtMWeFRT_SPkYd9A-1 X-Mimecast-MFC-AGG-ID: 8lcH6IYtMWeFRT_SPkYd9A_1757512670 To: devel@lists.libvirt.org Subject: [PATCH 5/6] qemuBlockGetNamedNodeData: Extract 'data_file_raw' flag Date: Wed, 10 Sep 2025 15:57:40 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JTl4WTpTbXarMVmqsfbyYUflfWpMkMfMyQpG5viNJzg_1757512670 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GBCKT24MY2YOIOPIM5TUH6ZWROCFAZWG X-Message-ID-Hash: GBCKT24MY2YOIOPIM5TUH6ZWROCFAZWG X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757513034460116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The 'data_file_raw' flag of qcow2 notifies that all data inside the 'data_file' is a raw image so can be used standalone without the metadata without any problem (except for not updating the dirty bitmaps). Our migration safety checks will allow skipping the migration safety check for these files as during migration we know it's safe to re-create this on the destination in a location that isn't shared. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.h | 3 +++ src/qemu/qemu_monitor_json.c | 3 +++ tests/qemublocktest.c | 2 ++ tests/qemublocktestdata/bitmap/synthetic.json | 1 + tests/qemublocktestdata/bitmap/synthetic.out | 1 + 5 files changed, 10 insertions(+) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 750e7444fc..8ef85ceb0a 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -748,6 +748,9 @@ struct _qemuBlockNamedNodeData { /* qcow2 subcluster allocation -> extended_l2 */ bool qcow2extendedL2; + + /* qcow2 data file 'raw' feature is enabled */ + bool qcow2dataFileRaw; }; GHashTable * diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2c8ae5198c..9caade7bc9 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2775,6 +2775,9 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos= G_GNUC_UNUSED, ignore_value(virJSONValueObjectGetBoolean(qcow2props, "extende= d-l2", &ent->qcow2extendedL= 2)); + + ignore_value(virJSONValueObjectGetBoolean(qcow2props, "data-fi= le-raw", + &ent->qcow2dataFileR= aw)); } } diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 095a54e22c..47746207cc 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -589,6 +589,8 @@ testQemuDetectBitmapsWorker(GHashTable *nodedata, virBufferAsprintf(buf, "%s:\n", nodename); if (data->qcow2v2) virBufferAddLit(buf, " qcow2 v2\n"); + if (data->qcow2dataFileRaw) + virBufferAddLit(buf, " data-file-raw\n"); virBufferAdjustIndent(buf, 1); for (i =3D 0; i < data->nbitmaps; i++) { diff --git a/tests/qemublocktestdata/bitmap/synthetic.json b/tests/qemubloc= ktestdata/bitmap/synthetic.json index cd468a42a2..1753830f69 100644 --- a/tests/qemublocktestdata/bitmap/synthetic.json +++ b/tests/qemublocktestdata/bitmap/synthetic.json @@ -15,6 +15,7 @@ "compat": "0.10", "compression-type": "zlib", "lazy-refcounts": false, + "data-file-raw": true, "bitmaps": [ { "flags": [ diff --git a/tests/qemublocktestdata/bitmap/synthetic.out b/tests/qemublock= testdata/bitmap/synthetic.out index 2d9545fc9b..45423903a0 100644 --- a/tests/qemublocktestdata/bitmap/synthetic.out +++ b/tests/qemublocktestdata/bitmap/synthetic.out @@ -1,5 +1,6 @@ libvirt-1-format: qcow2 v2 + data-file-raw current: record:1 busy:0 persist:1 inconsist:1 gran:65536 dirty:0 top-ok: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 top-inactive: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0 --=20 2.51.0 From nobody Sun Oct 5 00:06:49 2025 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=1757513093; cv=none; d=zohomail.com; s=zohoarc; b=R2chfbtoh7MtTDbRbOb6mDePejbo/XhfRjwkbJSuUwVwGtc5GdmieKiYPnaZ82nacEoovEpg1dHq3nanbM4nGDY2uSunJQ+jXRbbrCbSxOcbRG6vN2tcqUcI5LTFZz8uB8FIc0FdHy/QMG86mUNYv4A3DXXkbTiBrUNENS1Bx68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757513093; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=QXmtdDjWTF26l7SbSuiegb+LdbFp/u45ulXmnsk0xvQ=; b=lXRYe5wKUoLk86ubm++n1my4eXzXk9bRdBQnSYM3W/QYxYXo13r8ux4T6MzOE0+juDMvU2/ZzO3JwDq2+eOSyo+Rt99xCpwGHJposipppCok3HD8ISqkEl3WfdNQFzgKFS2EaCeICfYHp/luWnq/hOQwktBGUZI+jn6/JLJKOKg= 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 1757513093032534.3189189658226; Wed, 10 Sep 2025 07:04:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 7915741905; Wed, 10 Sep 2025 10:04:51 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 8508D43F2E; Wed, 10 Sep 2025 09:58:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 01A9741CAF; Wed, 10 Sep 2025 09:58:05 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 83BDD41B9F for ; Wed, 10 Sep 2025 09:57:53 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-Tc5Ux5UdNR2MN1DgQD-Zag-1; Wed, 10 Sep 2025 09:57:52 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 52F0219560A1 for ; Wed, 10 Sep 2025 13:57:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.8]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9759C3000198 for ; Wed, 10 Sep 2025 13:57:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757512673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QXmtdDjWTF26l7SbSuiegb+LdbFp/u45ulXmnsk0xvQ=; b=EkOsZ1vKltjDQpvQucaXi7aISOjI0DxEemaX9p6YjbKOWkE+B5FPebfQR2lVUKHO16XKYr EKU4FHVYBxLLN5aJSdA1z51Je7nH0mxizu9i5u1ZyX7UHRgs+/uQXotqBmscb+aC7Y6pgM 6zKCTLcA4o7JDlWZyd+7XnYP2j3/+kY= X-MC-Unique: Tc5Ux5UdNR2MN1DgQD-Zag-1 X-Mimecast-MFC-AGG-ID: Tc5Ux5UdNR2MN1DgQD-Zag_1757512671 To: devel@lists.libvirt.org Subject: [PATCH 6/6] qemuMigrationSrcIsSafeDisk: Allow non-shared qcow2's with raw data file Date: Wed, 10 Sep 2025 15:57:41 +0200 Message-ID: <8b4cef73eed622332a56efeea96a6898dae1f16c.1757512552.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aY0gWvc6JNpiB8ytrd4_5pZp8ujCR76sOd_qPiwZ3wY_1757512671 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6WQ3ORGHLJAGE4NXAZ4BSIYH7AQBDST6 X-Message-ID-Hash: 6WQ3ORGHLJAGE4NXAZ4BSIYH7AQBDST6 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757513095654116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa A qcow2 image which uses a data file and the 'data_file_raw' flag is effectively a raw image with the qcow2 wrapper used only to store metadata (block dirty bitmaps). Since the dirty bitmaps are always migrated using the migration stream it's technically not required that the qcow2 overlay itself is shared between the destinations. Management tools like Kubevirt want to migrate VMs which have a qcow2 overlay with the above config stored in a location that is not shared, but the data file itself is. This patch adds code that skips the validation of the overlay since it's not needed to ensure data consistency in that very specific case. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2e52e73f48..7d87b3073b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1779,19 +1779,47 @@ qemuMigrationSrcCheckStorageSourceSafety(virStorage= Source *src, static bool -qemuMigrationSrcIsSafeDisk(virDomainDiskDef *disk, +qemuMigrationSrcIsSafeDisk(virDomainObj *vm, + virDomainDiskDef *disk, virQEMUCaps *qemuCaps, - virQEMUDriverConfig *cfg) + virQEMUDriverConfig *cfg, + GHashTable **blockNamedNodeData) { bool unsafe_storage =3D false; bool requires_safe_cache =3D false; + bool skip_overlay_check =3D false; /* Disks without any source (i.e. floppies and CD-ROMs) OR readonly ar= e safe. */ if (virStorageSourceIsEmpty(disk->src) || disk->src->readonly) return true; - if (qemuMigrationSrcCheckStorageSourceSafety(disk->src, cfg, &unsafe_s= torage, + if (disk->src->dataFileStore && + !virStorageSourceHasBacking(disk->src)) { + qemuBlockNamedNodeData *nodedata; + + /* As a special case if the topmost disk image is a qcow2 with a + * data_file and the 'data_file_raw' option enabled, the overlay i= tself + * contains no useful data. Kubevirt uses this setup for migrations + * where the qcow2 overlay is used for block dirty bitmaps which a= re + * migrated using migration stream and kubevirt thus pre-creates t= he + * overlay rather than putting it on shared storage */ + + if (!*blockNamedNodeData && + !(*blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, + VIR_ASYNC_JO= B_MIGRATION_OUT))) + return false; + + if ((nodedata =3D virHashLookup(*blockNamedNodeData, + qemuBlockStorageSourceGetFormatNoden= ame(disk->src)))) { + + if (nodedata->qcow2dataFileRaw) + skip_overlay_check =3D true; + } + } + + if (!skip_overlay_check && + qemuMigrationSrcCheckStorageSourceSafety(disk->src, cfg, &unsafe_s= torage, &requires_safe_cache) < 0) return false; @@ -1831,6 +1859,7 @@ qemuMigrationSrcIsSafe(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); + g_autoptr(GHashTable) blockNamedNodeData =3D NULL; bool storagemigration =3D flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC); size_t i; @@ -1843,7 +1872,7 @@ qemuMigrationSrcIsSafe(virDomainObj *vm, qemuMigrationAnyCopyDisk(disk, migrate_disks)) continue; - if (!qemuMigrationSrcIsSafeDisk(disk, priv->qemuCaps, cfg)) + if (!qemuMigrationSrcIsSafeDisk(vm, disk, priv->qemuCaps, cfg, &bl= ockNamedNodeData)) return false; } --=20 2.51.0