From nobody Fri Nov 21 10:10:01 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=1763371362; cv=none; d=zohomail.com; s=zohoarc; b=lK/b0d2OHNK8U8fi+5ozQJp0bC05ByIOYusfDjT1Y85fylEQxZ/hxiXR3paLsb8x0WLJqQENGe9uK0fFkIwTiC0HhFVFYociq//lmeIbFue3crUD0Xh0a154DNzHPeR8jZm/UejdH772GAOJ/QzKTBMMQmXfCV+xl2u+vgyzQto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763371362; 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=x1Gm3PKzOnPljkjdtt3ibL1D8DKkSxwk5/sIHcAyZtE=; b=DSgXMbUO2fOBnDoU+1afKXXcyGOhyGPxY69x+E43VCz0IIF5nEcxzSMwUQlOXEnxCqDHLOpwoos/XdsrhN9Sk99QidJxidIp1q91e6WkyKCdIifXJMGR/uHGKucQaWu6dJulMYiJKT1IhShoj1J0kSuHWyZt7rWGUxLHeiukHEc= 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 1763371362912755.1388642272017; Mon, 17 Nov 2025 01:22:42 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1B6FA3F898; Mon, 17 Nov 2025 04:22:39 -0500 (EST) Received: from [172.19.199.36] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id E7A43417E1; Mon, 17 Nov 2025 04:19:51 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id C790C44EC2; Fri, 14 Nov 2025 10:53:35 -0500 (EST) 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 0953744EC0 for ; Fri, 14 Nov 2025 10:53:35 -0500 (EST) Received: from mx-prod-mc-01.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-597-kysP_RZOPJeQFY4L2XnkOQ-1; Fri, 14 Nov 2025 10:53:33 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3FC7B1953998 for ; Fri, 14 Nov 2025 15:53:32 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5FCF71955F1B for ; Fri, 14 Nov 2025 15:53:31 +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=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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=1763135614; 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=x1Gm3PKzOnPljkjdtt3ibL1D8DKkSxwk5/sIHcAyZtE=; b=T9PdCmBn8ZdWiy77cvnZ//DGZ3VaBZyNOfWSvIzktOW9ealQUcnqmXUmVcfF0lQGpTMLk2 gcege9MBYtXWzh6UTIS4Kw401JMidK7jMxGHb9YMtDFlKfmkt1/frg1wHVxhefEcLTK+8f Uo9IvcDX6zkQvdsL2BgjnYecJtc3C60= X-MC-Unique: kysP_RZOPJeQFY4L2XnkOQ-1 X-Mimecast-MFC-AGG-ID: kysP_RZOPJeQFY4L2XnkOQ_1763135612 To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemuDomainPrepareDiskSourceData: Setup 'detect_zeroes' for all layers Date: Fri, 14 Nov 2025 16:53:26 +0100 Message-ID: <44d1d15434408783a0b708f90b9677995fee785e.1763135037.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RmorOE-mm2mwXv7PQm68nN6JrtMYHXKA6WTw2UXYwMY_1763135612 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BC4AXIRW5RXKSKHBW6VI5QGOPM5SSOEB X-Message-ID-Hash: BC4AXIRW5RXKSKHBW6VI5QGOPM5SSOEB 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: 1763371364715153000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa While it may seem that zero detection is pointless for backing chain layers other than the top one, which is usually the only one gettin written to, with block operations such as active-layer commit the non-top layer may become active, in which case the VM wouldn't be configured in accordance to the XML any more. Similarly with snapshots a new image is introduced which would not get zero detection enabled, but next start of the VM would enable it. Fix this by propagating the zero detection setting for all layers. This problem partially addresses one of the issues reported in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D1120389 Fixes: 8a78f88a1a6 and a522c3044bd (effectively reverts them) Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 6 +----- .../xml2json/file-backing_basic-detect.json | 3 +++ .../xml2json/file-backing_basic-unmap-detect.json | 3 +++ .../xml2json/file-backing_basic-unmap-ignore.json | 3 +++ tests/qemuxmlconfdata/disk-detect-zeroes.x86_64-latest.args | 6 +++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a42721efad..0ac9ae0658 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9702,11 +9702,7 @@ qemuDomainPrepareDiskSourceData(virDomainDiskDef *di= sk, if (!disk) return; - /* transfer properties valid only for the top level image */ - if (src =3D=3D disk->src || src =3D=3D disk->src->dataFileStore) - src->detect_zeroes =3D disk->detect_zeroes; - - /* transfer properties valid for the full chain */ + src->detect_zeroes =3D disk->detect_zeroes; src->iomode =3D disk->iomode; src->cachemode =3D disk->cachemode; src->discard =3D disk->discard; diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-detect.jso= n b/tests/qemublocktestdata/xml2json/file-backing_basic-detect.json index c27233269b..773b7b3a02 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-detect.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-detect.json @@ -16,6 +16,7 @@ { "node-name": "node-b-f", "read-only": true, + "detect-zeroes": "on", "driver": "qed", "file": "node-b-s", "backing": "node-c-f" @@ -30,6 +31,7 @@ { "node-name": "node-c-f", "read-only": true, + "detect-zeroes": "on", "driver": "vmdk", "file": "node-c-s", "backing": "node-d-f" @@ -49,6 +51,7 @@ { "node-name": "node-d-f", "read-only": true, + "detect-zeroes": "on", "driver": "raw", "file": "node-d-s" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-dete= ct.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect.= json index 1ec0b8fffc..70faaa81de 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect.json @@ -18,6 +18,7 @@ "node-name": "node-b-f", "read-only": true, "discard": "unmap", + "detect-zeroes": "unmap", "driver": "qed", "file": "node-b-s", "backing": "node-c-f" @@ -33,6 +34,7 @@ "node-name": "node-c-f", "read-only": true, "discard": "unmap", + "detect-zeroes": "unmap", "driver": "vmdk", "file": "node-c-s", "backing": "node-d-f" @@ -53,6 +55,7 @@ "node-name": "node-d-f", "read-only": true, "discard": "unmap", + "detect-zeroes": "unmap", "driver": "raw", "file": "node-d-s" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-igno= re.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore.= json index 315a17323a..4bb964aaa4 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore.json @@ -18,6 +18,7 @@ "node-name": "node-b-f", "read-only": true, "discard": "ignore", + "detect-zeroes": "on", "driver": "qed", "file": "node-b-s", "backing": "node-c-f" @@ -33,6 +34,7 @@ "node-name": "node-c-f", "read-only": true, "discard": "ignore", + "detect-zeroes": "on", "driver": "vmdk", "file": "node-c-s", "backing": "node-d-f" @@ -53,6 +55,7 @@ "node-name": "node-d-f", "read-only": true, "discard": "ignore", + "detect-zeroes": "on", "driver": "raw", "file": "node-d-s" } diff --git a/tests/qemuxmlconfdata/disk-detect-zeroes.x86_64-latest.args b/= tests/qemuxmlconfdata/disk-detect-zeroes.x86_64-latest.args index d959d4a717..6284c082b1 100644 --- a/tests/qemuxmlconfdata/disk-detect-zeroes.x86_64-latest.args +++ b/tests/qemuxmlconfdata/disk-detect-zeroes.x86_64-latest.args @@ -28,17 +28,17 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-test/= .config \ -boot menu=3Don,strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/detect-zer= oes-unmap-back.img","node-name":"libvirt-7-storage","auto-read-only":true,"= discard":"unmap"}' \ --blockdev '{"node-name":"libvirt-7-format","read-only":true,"discard":"unm= ap","driver":"qcow2","file":"libvirt-7-storage","backing":null}' \ +-blockdev '{"node-name":"libvirt-7-format","read-only":true,"discard":"unm= ap","detect-zeroes":"unmap","driver":"qcow2","file":"libvirt-7-storage","ba= cking":null}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/detect-zer= oes-unmap.img","node-name":"libvirt-6-storage","auto-read-only":true,"disca= rd":"unmap"}' \ -blockdev '{"node-name":"libvirt-6-format","read-only":false,"discard":"un= map","detect-zeroes":"unmap","driver":"qcow2","file":"libvirt-6-storage","b= acking":"libvirt-7-format"}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"li= bvirt-6-format","id":"virtio-disk0","bootindex":2}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/detect-zer= oes-on-back.img","node-name":"libvirt-5-storage","auto-read-only":true,"dis= card":"unmap"}' \ --blockdev '{"node-name":"libvirt-5-format","read-only":true,"discard":"unm= ap","driver":"qcow2","file":"libvirt-5-storage","backing":null}' \ +-blockdev '{"node-name":"libvirt-5-format","read-only":true,"discard":"unm= ap","detect-zeroes":"on","driver":"qcow2","file":"libvirt-5-storage","backi= ng":null}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/detect-zer= oes-on.img","node-name":"libvirt-4-storage","auto-read-only":true,"discard"= :"unmap"}' \ -blockdev '{"node-name":"libvirt-4-format","read-only":false,"discard":"un= map","detect-zeroes":"on","driver":"qcow2","file":"libvirt-4-storage","back= ing":"libvirt-5-format"}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"li= bvirt-4-format","id":"virtio-disk1"}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/detect-zer= oes-off-back.img","node-name":"libvirt-3-storage","auto-read-only":true,"di= scard":"unmap"}' \ --blockdev '{"node-name":"libvirt-3-format","read-only":true,"discard":"unm= ap","driver":"qcow2","file":"libvirt-3-storage","backing":null}' \ +-blockdev '{"node-name":"libvirt-3-format","read-only":true,"discard":"unm= ap","detect-zeroes":"off","driver":"qcow2","file":"libvirt-3-storage","back= ing":null}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/detect-zer= oes-off.img","node-name":"libvirt-2-storage","auto-read-only":true,"discard= ":"unmap"}' \ -blockdev '{"node-name":"libvirt-2-format","read-only":false,"discard":"un= map","detect-zeroes":"off","driver":"qcow2","file":"libvirt-2-storage","bac= king":"libvirt-3-format"}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"li= bvirt-2-format","id":"virtio-disk2"}' \ --=20 2.51.1