From nobody Sun Oct 5 01:49:25 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 --- 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