From nobody Tue Mar 24 01:19:20 2026 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=1773853749; cv=none; d=zohomail.com; s=zohoarc; b=EIS9iVPmjniEPhHZaG0mWT+sL4i5lm5qb7AAkAhntKyjuYFFGLPK+TaFzz2qQiXKxmDUJ3G3OfgR8rGi+FBDuTj1CFT7X//uzaxXaVnZ4U+gf0leoBToGEdpQlElEcEbtK+PR1t5RMEdzntDiSPcP1ZQGba9DlCi7DkKldJ4g/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773853749; 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=VGnbH5EzGgY5MBox9KieeE69ZbHW0+N0yOFEiGE41/c=; b=VAPELRBG/aVeig6gGnFXrpjsUyfbcxUEJCofpHe5S5FglE7w9l7hEiQSc2zLK67twW79gJrpSGyFltmqyEVBUpKFUHhDZVo2EiZRwAIVZJvZjZ4+51i3JKALLgFKRWPS4Lb3f3b29KVo7T20irTkq2WQ4RvOvQl938r/BOQuoVI= 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 1773853749799154.60889917035763; Wed, 18 Mar 2026 10:09:09 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 973FE41AF4; Wed, 18 Mar 2026 13:09:08 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 1DBD341CC4; Wed, 18 Mar 2026 13:05:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C5E9C41908; Wed, 18 Mar 2026 13:05:13 -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 98A2C41908 for ; Wed, 18 Mar 2026 13:05:04 -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-478-5IDYx_upPV65ANCqmPAnHg-1; Wed, 18 Mar 2026 13:05:03 -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 3A7A918005BB for ; Wed, 18 Mar 2026 17:05:02 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.5]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6BBC330001A1 for ; Wed, 18 Mar 2026 17:05:01 +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=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,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=1773853504; 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=VGnbH5EzGgY5MBox9KieeE69ZbHW0+N0yOFEiGE41/c=; b=QbJwNNAWwQJ7dC+CqdNeMw5clhS+gEXu98YHmSKdHDZBKvmqL3/IH18LIcM6kdMo0zzn4v ZleJNZW3MdcOfUSnOtvNOhwfFFlUJ7grfzyUSC6JjENyRDVcoRF2pzui8beG1hAjj1O+9m zcoCDPShWi8I1wDF3U56mNIERRTqxhM= X-MC-Unique: 5IDYx_upPV65ANCqmPAnHg-1 X-Mimecast-MFC-AGG-ID: 5IDYx_upPV65ANCqmPAnHg_1773853502 To: devel@lists.libvirt.org Subject: [PATCH 4/7] qemu: Add VIR_DOMAIN_BLOCK_COPY_TARGET_ZEROED flag for virDomainBlockCopy Date: Wed, 18 Mar 2026 18:04:52 +0100 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: ubHrt8QcgYfO7-Ow6ZnJRvJu1TIRDe0fp6QqP23XNzw_1773853502 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: H2JKZQJBISXTQJSRK2WMQEJNQQFACCKA X-Message-ID-Hash: H2JKZQJBISXTQJSRK2WMQEJNQQFACCKA 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: 1773853751394158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Allow the hypervisor to assume that the user already passed a zeroed-out image to optimize the copy. Implement the feature for the qemu driver. Signed-off-by: Peter Krempa --- include/libvirt/libvirt-domain.h | 7 +++++++ src/libvirt-domain.c | 4 ++++ src/qemu/qemu_driver.c | 16 +++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index ccc2c87ea8..a0e0b84eb9 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5004,6 +5004,13 @@ typedef enum { * Since: 8.0.0 */ VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES =3D 1 << 3, + + /* Destination of the copy is zeroed (any read returns only 0x00 bytes= ) so + * the hypervisor may optimize out clearing of the target image. + * + * Since: 12.2.0 */ + VIR_DOMAIN_BLOCK_COPY_TARGET_ZEROED =3D 1 << 4, + } virDomainBlockCopyFlags; /** diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 6b8783d57f..e1571cbda7 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11261,6 +11261,10 @@ virDomainBlockRebase(virDomainPtr dom, const char = *disk, * the destination storage is slower. This may impact performance of writes * while the blockjob is running. * + * If @flags contains VIR_DOMAIN_BLOCK_COPY_TARGET_ZEROED the hypervisor m= ay + * assume that the target image was already zeroed out (any read will retu= rn + * 0x00 bytes) and thus may skip this step. + * * The @disk parameter is either an unambiguous source name of the * block device (the sub-element, such as * "/path/to/image"), or the device target shorthand (the diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0ba40e0665..42d0f46405 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14285,13 +14285,15 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, virStorageSource *mirrorBacking =3D NULL; g_autoptr(GHashTable) blockNamedNodeData =3D NULL; bool syncWrites =3D !!(flags & VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITE= S); + bool targetIsZero =3D !!(flags & VIR_DOMAIN_BLOCK_COPY_TARGET_ZEROED); int rc =3D 0; /* Preliminaries: find the disk we are editing, sanity checks */ virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW | VIR_DOMAIN_BLOCK_COPY_REUSE_EXT | VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB | - VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES, -1); + VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES | + VIR_DOMAIN_BLOCK_COPY_TARGET_ZEROED, -1); if (virStorageSourceIsRelative(mirror)) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -14327,6 +14329,13 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, goto endjob; } + if (targetIsZero && + !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_MIRROR_TARGET_I= S_ZERO)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("this qemu doesn't support 'VIR_DOMAIN_BLOCK_COPY= _TARGET_ZEROED'")); + goto endjob; + } + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN && virDomainDiskDefSourceLUNValidate(mirror) < 0) goto endjob; @@ -14535,7 +14544,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, qemuBlockStorageSourceGetEffectiveNode= name(disk->src), bandwidth, granularity, buf_size, mirror_shallow, - syncWrites, false); + syncWrites, targetIsZero); virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >=3D 0); qemuDomainObjExitMonitor(vm); @@ -14670,7 +14679,8 @@ qemuDomainBlockCopy(virDomainPtr dom, virCheckFlags(VIR_DOMAIN_BLOCK_COPY_SHALLOW | VIR_DOMAIN_BLOCK_COPY_REUSE_EXT | VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB | - VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES, -1); + VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES | + VIR_DOMAIN_BLOCK_COPY_TARGET_ZEROED, -1); if (virTypedParamsValidate(params, nparams, VIR_DOMAIN_BLOCK_COPY_BANDWIDTH, --=20 2.53.0