From nobody Fri Jan 3 03:57:57 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728915212102133.21746276315707; Mon, 14 Oct 2024 07:13:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 049FF12AF; Mon, 14 Oct 2024 10:13:30 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BDCAD12C8; Mon, 14 Oct 2024 10:13:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2262C12AF; Mon, 14 Oct 2024 10:13:13 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 A9ECD12AA for ; Mon, 14 Oct 2024 10:13:12 -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-6-fEG0RHixNluTAPTMYF6AfQ-1; Mon, 14 Oct 2024 10:13:10 -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 9868D1956064 for ; Mon, 14 Oct 2024 14:13:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A52BC3000198 for ; Mon, 14 Oct 2024 14:13:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: *** X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728915192; 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; bh=Xze25KUsG0NteQfx8UhREpHKKq/hRo2y7qOI2Lgv/Oo=; b=OjjNs28S3ErSN1LGOK6V6TCFlTDxMpqysQM6hCiF6wyCFCrm9D/AZLvznKEj/pPt30auOG 4ZLFTBKMGIQcngUGq6ZB7GGmYQxO5QLiGF7kj7L0plxlttKNZAE/eFYRPeTe2YPT0pNq5a T7bVDNBso3nBdnjcvRA/tD9fYP/nYG8= X-MC-Unique: fEG0RHixNluTAPTMYF6AfQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH] qemu: migration: Fix blockdev config with VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES Date: Mon, 14 Oct 2024 16:13:07 +0200 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VNRXT6ERNW4Y4VHYIFHEQNHAUNQKERY7 X-Message-ID-Hash: VNRXT6ERNW4Y4VHYIFHEQNHAUNQKERY7 X-MailFrom: pkrempa@redhat.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 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728915213968116600 Content-Type: text/plain; charset="utf-8" The idea of migration with VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES populated is to sparsify the image. The QEMU NBD client as it was configured in commit 621f879adf98e2c93ac5c8c869733a57f06cd9aa would signal to the destination to do thick allocation of holes which would result in a non-sparse image for any backend except a qcow2 image which I used to test it. Switch to VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP and VIR_DOMAIN_DISK_DISCARD_UNMAP which tells the NBD client (and that in turn the NBD server) to preserve the sparse blocks it detected from the image. Fixes: 621f879adf98e2c93ac5c8c869733a57f06cd9aa Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_migration.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 179e9d7c83..832b2946e0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1092,8 +1092,14 @@ qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(= virDomainDiskDef *disk, copysrc->protocol =3D VIR_STORAGE_NET_PROTOCOL_NBD; copysrc->format =3D VIR_STORAGE_FILE_RAW; - if (detect_zeroes) - copysrc->detect_zeroes =3D VIR_DOMAIN_DISK_DETECT_ZEROES_ON; + if (detect_zeroes) { + /* We need to use both VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP and + * VIR_DOMAIN_DISK_DISCARD_UNMAP as the qemu NBD client otherwise = singals + * to the server to fully allocate the zero blocks + */ + copysrc->detect_zeroes =3D VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP; + copysrc->discard =3D VIR_DOMAIN_DISK_DISCARD_UNMAP; + } copysrc->backingStore =3D virStorageSourceNew(); --=20 2.46.2