459f93
From 20c1c86f96dd7293734888ef6f8b75c11cda5fae Mon Sep 17 00:00:00 2001
459f93
Message-Id: <20c1c86f96dd7293734888ef6f8b75c11cda5fae@dist-git>
459f93
From: Jiri Denemark <jdenemar@redhat.com>
459f93
Date: Wed, 22 Jun 2022 16:36:53 +0200
459f93
Subject: [PATCH] virsh: Add support for VIR_MIGRATE_ZEROCOPY flag
459f93
MIME-Version: 1.0
459f93
Content-Type: text/plain; charset=UTF-8
459f93
Content-Transfer-Encoding: 8bit
459f93
459f93
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
459f93
Reviewed-by: Ján Tomko <jtomko@redhat.com>
459f93
(cherry picked from commit efa3baeae70fbdf4ab032ca485cb9272ee96bd50)
459f93
459f93
https://bugzilla.redhat.com/show_bug.cgi?id=2089433
459f93
459f93
Conflicts:
459f93
	docs/manpages/virsh.rst
459f93
	tools/virsh-domain.c
459f93
            - post-copy recovery not backported
459f93
459f93
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
459f93
---
459f93
 docs/manpages/virsh.rst | 8 +++++++-
459f93
 tools/virsh-domain.c    | 7 +++++++
459f93
 2 files changed, 14 insertions(+), 1 deletion(-)
459f93
459f93
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
459f93
index dd534c10cb..d24e7774a6 100644
459f93
--- a/docs/manpages/virsh.rst
459f93
+++ b/docs/manpages/virsh.rst
459f93
@@ -3225,7 +3225,8 @@ migrate
459f93
    migrate [--live] [--offline] [--direct] [--p2p [--tunnelled]]
459f93
       [--persistent] [--undefinesource] [--suspend] [--copy-storage-all]
459f93
       [--copy-storage-inc] [--change-protection] [--unsafe] [--verbose]
459f93
-      [--rdma-pin-all] [--abort-on-error] [--postcopy] [--postcopy-after-precopy]
459f93
+      [--rdma-pin-all] [--abort-on-error] [--postcopy]
459f93
+      [--postcopy-after-precopy] [--zerocopy]
459f93
       domain desturi [migrateuri] [graphicsuri] [listen-address] [dname]
459f93
       [--timeout seconds [--timeout-suspend | --timeout-postcopy]]
459f93
       [--xml file] [--migrate-disks disk-list] [--disks-port port]
459f93
@@ -3298,6 +3299,11 @@ high (and thus allowing the domain to lock most of the host's memory). Doing so
459f93
 may be dangerous to both the domain and the host itself since the host's kernel
459f93
 may run out of memory.
459f93
 
459f93
+*--zerocopy* requests zero-copy mechanism to be used for migrating memory pages.
459f93
+For QEMU/KVM this means QEMU will be temporarily allowed to lock all guest
459f93
+pages in host's memory, although only those that are queued for transfer will
459f93
+be locked at the same time.
459f93
+
459f93
 ``Note``: Individual hypervisors usually do not support all possible types of
459f93
 migration. For example, QEMU does not support direct migration.
459f93
 
459f93
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
459f93
index b56f6a90f5..c5bade1dbf 100644
459f93
--- a/tools/virsh-domain.c
459f93
+++ b/tools/virsh-domain.c
459f93
@@ -10730,6 +10730,10 @@ static const vshCmdOptDef opts_migrate[] = {
459f93
      .type = VSH_OT_BOOL,
459f93
      .help = N_("automatically switch to post-copy migration after one pass of pre-copy")
459f93
     },
459f93
+    {.name = "zerocopy",
459f93
+     .type = VSH_OT_BOOL,
459f93
+     .help = N_("use zero-copy mechanism for migrating memory pages")
459f93
+    },
459f93
     {.name = "migrateuri",
459f93
      .type = VSH_OT_STRING,
459f93
      .completer = virshCompleteEmpty,
459f93
@@ -11133,6 +11137,9 @@ doMigrate(void *opaque)
459f93
     if (vshCommandOptBool(cmd, "postcopy"))
459f93
         flags |= VIR_MIGRATE_POSTCOPY;
459f93
 
459f93
+    if (vshCommandOptBool(cmd, "zerocopy"))
459f93
+        flags |= VIR_MIGRATE_ZEROCOPY;
459f93
+
459f93
     if (vshCommandOptBool(cmd, "tls"))
459f93
         flags |= VIR_MIGRATE_TLS;
459f93
 
459f93
-- 
459f93
2.35.1
459f93