[libvirt] [PATCH 5/9] virsh: add multi-thread migration option for live migrate command

ShaoHe Feng shaohe.feng at intel.com
Sun Jun 28 16:01:42 UTC 2015


Signed-off-by: Eli Qiao <liyong.qiao at intel.com>
Signed-off-by: ShaoHe Feng <shaohe.feng at intel.com>
---
 include/libvirt/libvirt-domain.h |  1 +
 tools/virsh-domain.c             | 54 ++++++++++++++++++++++++++++++++++++++++
 tools/virsh.pod                  | 22 +++++++++++-----
 3 files changed, 71 insertions(+), 6 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 1c6ab16..29b2b22 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -659,6 +659,7 @@ typedef enum {
     VIR_MIGRATE_ABORT_ON_ERROR    = (1 << 12), /* abort migration on I/O errors happened during migration */
     VIR_MIGRATE_AUTO_CONVERGE     = (1 << 13), /* force convergence */
     VIR_MIGRATE_RDMA_PIN_ALL      = (1 << 14), /* RDMA memory pinning */
+    VIR_MIGRATE_MT_COMPRESSED     = (1 << 15), /* multiple threads compression during migration */
 } virDomainMigrateFlags;
 
 
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 91a1ca2..b5713cc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9853,6 +9853,10 @@ static const vshCmdOptDef opts_migrate[] = {
      .type = VSH_OT_BOOL,
      .help = N_("compress repeated pages during live migration")
     },
+    {.name = "multi-thread-compress",
+     .type = VSH_OT_BOOL,
+     .help = N_("enable multi-thread compression during live migration")
+    },
     {.name = "auto-converge",
      .type = VSH_OT_BOOL,
      .help = N_("force convergence during live migration")
@@ -9889,6 +9893,21 @@ static const vshCmdOptDef opts_migrate[] = {
      .type = VSH_OT_STRING,
      .help = N_("filename containing updated XML for the target")
     },
+    {.name = "compress-level",
+     .type = VSH_OT_INT,
+     .help = N_("compres level, from 0-9, 0 means use default level. "
+                "'--multi-thread-compress' option will set as true with this option.")
+    },
+    {.name = "compress-threads",
+     .type = VSH_OT_INT,
+     .help = N_("compres thread count for multi-thread migration, from 0-255. "
+                "'--multi-thread-compress' option will set as true with this option.")
+    },
+    {.name = "decompress-threads",
+     .type = VSH_OT_INT,
+     .help = N_("decompres thread count for multi-thread migration, from 0-255. "
+                "'--multi-thread-compress' option will set as true with this option.")
+    },
     {.name = NULL}
 };
 
@@ -9907,6 +9926,8 @@ doMigrate(void *opaque)
     virTypedParameterPtr params = NULL;
     int nparams = 0;
     int maxparams = 0;
+    int value = 0;
+    int rv;
     virConnectPtr dconn = data->dconn;
 
     sigemptyset(&sigmask);
@@ -9948,6 +9969,36 @@ doMigrate(void *opaque)
                                 VIR_MIGRATE_PARAM_DEST_NAME, opt) < 0)
         goto save_error;
 
+    if ((rv = vshCommandOptInt(cmd, "compress-level", &value)) < 0) {
+        goto save_error;
+    } else if (rv > 0) {
+        if (virTypedParamsAddInt(&params, &nparams, &maxparams,
+                                 VIR_DOMAIN_MIRGRATE_COMPRESSION_LEVEL,
+                                 value) < 0)
+            goto save_error;
+        flags |= VIR_MIGRATE_MT_COMPRESSED;
+    }
+
+    if ((rv = vshCommandOptInt(cmd, "compress-threads", &value)) < 0) {
+        goto save_error;
+    } else if (rv > 0) {
+        if (virTypedParamsAddInt(&params, &nparams, &maxparams,
+                                 VIR_DOMAIN_MIRGRATE_COMPRESSION_THREADS,
+                                 value) < 0)
+            goto save_error;
+        flags |= VIR_MIGRATE_MT_COMPRESSED;
+    }
+
+    if ((rv = vshCommandOptInt(cmd, "decompress-threads", &value)) < 0) {
+        goto save_error;
+    } else if (rv > 0) {
+        if (virTypedParamsAddInt(&params, &nparams, &maxparams,
+                                 VIR_DOMAIN_MIRGRATE_DECOMPRESSION_THREADS,
+                                 value) < 0)
+            goto save_error;
+        flags |= VIR_MIGRATE_MT_COMPRESSED;
+    }
+
     if (vshCommandOptStringReq(ctl, cmd, "xml", &opt) < 0)
         goto out;
     if (opt) {
@@ -9996,6 +10047,9 @@ doMigrate(void *opaque)
     if (vshCommandOptBool(cmd, "compressed"))
         flags |= VIR_MIGRATE_COMPRESSED;
 
+    if (vshCommandOptBool(cmd, "multi-thread-compress"))
+        flags |= VIR_MIGRATE_MT_COMPRESSED;
+
     if (vshCommandOptBool(cmd, "auto-converge"))
         flags |= VIR_MIGRATE_AUTO_CONVERGE;
 
diff --git a/tools/virsh.pod b/tools/virsh.pod
index d588e5a..b81fd01 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1518,9 +1518,11 @@ to the I<uri> namespace is displayed instead of being modified.
 =item B<migrate> [I<--live>] [I<--offline>] [I<--direct>] [I<--p2p> [I<--tunnelled>]]
 [I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>]
 [I<--copy-storage-inc>] [I<--change-protection>] [I<--unsafe>] [I<--verbose>]
-[I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>]
-I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>] [I<listen-address>]
-[I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
+[I<--compressed>] [I<--multi-thread-compress>] [I<--abort-on-error>]
+[I<--auto-converge>] I<domain> I<desturi> [I<migrateuri>] [I<graphicsuri>]
+[I<listen-address>] [I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
+[I<--compress-level> B<number>] [I<--compress-threads> B<number>]
+[I<--decompress-threads> B<number>]
 
 Migrate domain to another host.  Add I<--live> for live migration; <--p2p>
 for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
@@ -1542,9 +1544,10 @@ is implicitly enabled when supported by the hypervisor, but can be explicitly
 used to reject the migration if the hypervisor lacks change protection
 support.  I<--verbose> displays the progress of migration.  I<--compressed>
 activates compression of memory pages that have to be transferred repeatedly
-during live migration. I<--abort-on-error> cancels the migration if a soft
-error (for example I/O error) happens during the migration. I<--auto-converge>
-forces convergence during live migration.
+during live migration. I<--multi-thread-compress> activates multi-thread
+compression during live migration. I<--abort-on-error> cancels the migration
+if a soft error (for example I/O error) happens during the migration.
+I<--auto-converge> forces convergence during live migration.
 
 B<Note>: Individual hypervisors usually do not support all possible types of
 migration. For example, QEMU does not support direct migration.
@@ -1564,6 +1567,13 @@ the destination to supply a larger set of changes to any host-specific
 portions of the domain XML, such as accounting for naming differences
 between source and destination in accessing underlying storage.
 
+I<--compress-level> is interpreted as an unsigned int value from 0-9. O means
+hypervisor choose an default value. Specifying a negative value results in an
+essentially unlimited value being provided to the hypervisor. The hypervisor
+can choose whether to reject the value or convert it to the maximum value
+allowed. I<--compress-threads> is interpreted as an unsigned int value.
+I<--decompress-threads> is interpreted as an unsigned int value.
+
 I<--timeout> B<seconds> forces guest to suspend when live migration exceeds
 that many seconds, and
 then the migration will complete offline. It can only be used with I<--live>.
-- 
2.1.4




More information about the libvir-list mailing list