[PATCH 2/3] virsh: Add migrate options to set parallel compress level

Jiang Jiacheng jiangjiacheng at huawei.com
Fri Feb 24 09:27:11 UTC 2023


Add migrate options: --compression-zlib-level
                     --compression-zstd-level
These options are used to set compress level for "zlib"
or "zstd" during parallel migration if the compress method
is specified.

Signed-off-by: Jiang Jiacheng <jiangjiacheng at huawei.com>
---
 docs/manpages/virsh.rst | 29 ++++++++++++++++++++---------
 tools/virsh-domain.c    | 26 ++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index d5b614dc03..ccad02bd94 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -3356,7 +3356,8 @@ migrate
       [--xml file] [--migrate-disks disk-list] [--disks-port port]
       [--compressed] [--comp-methods method-list]
       [--comp-mt-level] [--comp-mt-threads] [--comp-mt-dthreads]
-      [--comp-xbzrle-cache] [--auto-converge] [auto-converge-initial]
+      [--comp-xbzrle-cache] [--comp-zlib-level] [--comp-zstd-level]
+      [--auto-converge] [auto-converge-initial]
       [auto-converge-increment] [--persistent-xml file] [--tls]
       [--postcopy-bandwidth bandwidth]
       [--parallel [--parallel-connections connections]]
@@ -3463,14 +3464,24 @@ to post-copy upon timeout; migration has to be started with *--postcopy*
 option for this to work.
 
 *--compressed* activates compression, the compression method is chosen
-with *--comp-methods*. Supported methods are "mt" and "xbzrle" and
-can be used in any combination. When no methods are specified, a hypervisor
-default methods will be used. QEMU defaults to "xbzrle". Compression methods
-can be tuned further. *--comp-mt-level* sets compression level.
-Values are in range from 0 to 9, where 1 is maximum speed and 9 is maximum
-compression. *--comp-mt-threads* and *--comp-mt-dthreads* set the number
-of compress threads on source and the number of decompress threads on target
-respectively. *--comp-xbzrle-cache* sets size of page cache in bytes.
+with *--comp-methods*. Supported methods are "mt", "xbzrle", "zlib",
+and "zstd". The supported set of methods and their combinations depend
+on a hypervisor and migration options. QEMU only supports "zlib" and
+"zstd" methods when *--parallel* is used and they cannot be used at
+once. When no methods are specified, a hypervisor default methods will
+be used. QEMU defaults to no compression for *--parallel* migration and
+"xbzrle" otherwise. Compression methods can be tuned further.
+*--comp-mt-level* sets compression level for "mt" method. Values are in
+range from 0 to 9, where 1 is maximum speed and 9 is maximum compression.
+*--comp-mt-threads* and *--comp-mt-dthreads* set the number of compress
+threads on source and the number of decompress threads on target respectively.
+*--comp-xbzrle-cache* sets size of page cache in bytes.
+*--comp-zlib-level* sets the compression level when using "zlib" method.
+Values are in range from 0 to 9 and defaults to 1, where 0 is no compression,
+1 is maximum speed and 9 is maximum compression.
+*--comp-zstd-level* sets the compression level when using "zstd" method.
+Values are in range from 0 to 20 and defaults to 1, where 0 is no compression,
+1 is maximum speed and 20 is maximum compression.
 
 Providing *--tls* causes the migration to use the host configured TLS setup
 (see migrate_tls_x509_cert_dir in /etc/libvirt/qemu.conf) in order to perform
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a4abcb1b03..357f53c8e7 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -11097,6 +11097,14 @@ static const vshCmdOptDef opts_migrate[] = {
      .completer = virshCompleteEmpty,
      .help = N_("override the destination host name used for TLS verification")
     },
+    {.name = "comp-zlib-level",
+     .type = VSH_OT_INT,
+     .help = N_("compress level for zlib compression")
+    },
+    {.name = "comp-zstd-level",
+     .type = VSH_OT_INT,
+     .help = N_("compress level for zstd compression")
+    },
     {.name = NULL}
 };
 
@@ -11309,6 +11317,24 @@ doMigrate(void *opaque)
             goto save_error;
     }
 
+    if ((rv = vshCommandOptInt(ctl, cmd, "comp-zlib-level", &intOpt)) < 0) {
+        goto out;
+    } else if (rv > 0) {
+        if (virTypedParamsAddInt(&params, &nparams, &maxparams,
+                                 VIR_MIGRATE_PARAM_COMPRESSION_ZLIB_LEVEL,
+                                 intOpt) < 0)
+            goto save_error;
+    }
+
+    if ((rv = vshCommandOptInt(ctl, cmd, "comp-zstd-level", &intOpt)) < 0) {
+        goto out;
+    } else if (rv > 0) {
+        if (virTypedParamsAddInt(&params, &nparams, &maxparams,
+                                 VIR_MIGRATE_PARAM_COMPRESSION_ZSTD_LEVEL,
+                                 intOpt) < 0)
+            goto save_error;
+    }
+
     if ((rv = vshCommandOptULongLong(ctl, cmd, "bandwidth", &ullOpt)) < 0) {
         goto out;
     } else if (rv > 0) {
-- 
2.33.0



More information about the libvir-list mailing list