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