From nobody Tue Dec 23 09:44:32 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 1727703388760795.3799409735353; Mon, 30 Sep 2024 06:36:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A0841C7C; Mon, 30 Sep 2024 09:36:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C6D051276; Mon, 30 Sep 2024 09:30:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 670CE12F7; Mon, 30 Sep 2024 09:30:13 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 9F2EA14A9 for ; Mon, 30 Sep 2024 09:29:56 -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-53-ZkKWa9BfOGGsAJVG8K8Ccg-1; Mon, 30 Sep 2024 09:29:55 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (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 3E86919772F6 for ; Mon, 30 Sep 2024 13:29:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5EDE819541A0 for ; Mon, 30 Sep 2024 13:29:53 +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=-0.5 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_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702996; 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=In3hccEDK9QM8lAz2ZknTsO9sgS84POIB3CPfMbz7oc=; b=PXqSS1x/sLbV4YHUK5F9taQGpXysGPcnmHCcm5/M1HxjvYeBWLlORUT5YlgkfNl+y7cPR9 aShR7/QEq7ZQ1cJlwR6XLqCMZSlhnlUFYAtRM0wcODEQelfs7PUtOO3TnXFjmrmMopzvuy masCyMaH6Q1VQ7aqnamfU3+n5xtQCsY= X-MC-Unique: ZkKWa9BfOGGsAJVG8K8Ccg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 13/13] virsh: Add support for VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES migration parameter Date: Mon, 30 Sep 2024 15:29:35 +0200 Message-ID: <89a495fabe2fabd2ce4cf0098bc17607e3014825.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: DKWJX77QJOS2PX47E5TO3JEALEZPXNPO X-Message-ID-Hash: DKWJX77QJOS2PX47E5TO3JEALEZPXNPO 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: 1727703390153116600 Content-Type: text/plain; charset="utf-8" Expose the new parameter as '--migrate-disks-detect-zeroes' option. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- docs/manpages/virsh.rst | 8 +++++++- tools/virsh-domain.c | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index f02a28156d..6665d46497 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3389,7 +3389,9 @@ migrate [--postcopy-after-precopy] [--postcopy-resume] [--zerocopy] domain desturi [migrateuri] [graphicsuri] [listen-address] [dname] [--timeout seconds [--timeout-suspend | --timeout-postcopy]] - [--xml file] [--migrate-disks disk-list] [--disks-port port] + [--xml file] + [--migrate-disks disk-list] [--migrate-disks-detect-zeroes disk-list] + [--disks-port port] [--compressed] [--comp-methods method-list] [--comp-mt-level] [--comp-mt-threads] [--comp-mt-dthreads] [--comp-xbzrle-cache] [--comp-zlib-level] [--comp-zstd-level] @@ -3420,6 +3422,10 @@ images on source host to the images found at the sam= e place on the destination host. By default only non-shared non-readonly images are transferred. Use *--migrate-disks* to explicitly specify a list of disk targets to transfer via the comma separated ``disk-list`` argument. +The *--migrate-disks-detect-zeroes* option which takes a comma separated l= ist of +disk target names enables zeroed block detection for the listed migrated d= isks. +These blocks are not transferred or allocated on destination, effectively +sparsifying the disk at the cost of CPU overhead. With *--copy-storage-synchronous-writes* flag used the disk data migration= will synchronously handle guest disk writes to both the original source and the destination to ensure that the disk migration converges at the price of po= ssibly diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 50e80689a2..e4923284af 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10691,6 +10691,11 @@ static const vshCmdOptDef opts_migrate[] =3D { .completer =3D virshDomainMigrateDisksCompleter, .help =3D N_("comma separated list of disks to be migrated") }, + {.name =3D "migrate-disks-detect-zeroes", + .type =3D VSH_OT_STRING, + .completer =3D virshDomainMigrateDisksCompleter, + .help =3D N_("comma separated list of disks to be migrated with zero = detection enabled") + }, {.name =3D "disks-port", .type =3D VSH_OT_INT, .unwanted_positional =3D true, @@ -10909,6 +10914,27 @@ doMigrate(void *opaque) } } + if (vshCommandOptString(ctl, cmd, "migrate-disks-detect-zeroes", &opt)= < 0) + goto out; + if (opt) { + g_autofree char **val =3D NULL; + + if (!(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARE= D_INC))) { + vshError(ctl, "'--migrate-disks-detect-zeroes' requires one of= '--copy-storage-all', '--copy-storage-inc'"); + goto out; + } + + val =3D g_strsplit(opt, ",", 0); + + if (virTypedParamsAddStringList(¶ms, + &nparams, + &maxparams, + VIR_MIGRATE_PARAM_MIGRATE_DISKS_DE= TECT_ZEROES, + (const char **)val) < 0) { + goto save_error; + } + } + if (vshCommandOptString(ctl, cmd, "comp-methods", &opt) < 0) goto out; if (opt) { --=20 2.46.0