[libvirt] [PATCH 13/14] virsh: Add migrate-compcache command

Jiri Denemark jdenemar at redhat.com
Tue Feb 19 12:35:51 UTC 2013


This is a command wrapping virDomainMigrateGetCompressionCache and
virDomainMigrateSetCompressionCache.
---
 tools/virsh-domain.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/virsh.pod      | 12 ++++++++++
 2 files changed, 80 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index ba05fa7..83885df 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8734,6 +8734,68 @@ done:
 }
 
 /*
+ * "migrate-compcache" command
+ */
+static const vshCmdInfo info_migrate_compcache[] = {
+    {.name = "help",
+     .data = N_("get/set compression cache size")
+    },
+    {.name = "desc",
+     .data = N_("Get/set size of the cache (in bytes) used for compressing "
+                "repeatedly transferred memory pages during live migration.")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_migrate_compcache[] = {
+    {.name = "domain",
+     .type = VSH_OT_DATA,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("domain name, id or uuid")
+    },
+    {.name = "size",
+     .type = VSH_OT_INT,
+     .flags = VSH_OFLAG_REQ_OPT,
+     .help = N_("requested size of the cache (in bytes) used for compression")
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd)
+{
+    virDomainPtr dom = NULL;
+    unsigned long long size = 0;
+    bool ret = false;
+    const char *unit;
+    double value;
+    int rc;
+
+    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+        return false;
+
+    rc = vshCommandOptULongLong(cmd, "size", &size);
+    if (rc < 0) {
+        vshError(ctl, "%s", _("Unable to parse size parameter"));
+        goto cleanup;
+    } else if (rc != 0) {
+        if (virDomainMigrateSetCompressionCache(dom, size, 0) < 0)
+            goto cleanup;
+    }
+
+    if (virDomainMigrateGetCompressionCache(dom, &size, 0) < 0)
+        goto cleanup;
+
+    value = vshPrettyCapacity(size, &unit);
+    vshPrint(ctl, _("Compression cache: %.3lf %s"), value, unit);
+
+    ret = true;
+cleanup:
+    virDomainFree(dom);
+    return ret;
+}
+
+/*
  * "migrate-setspeed" command
  */
 static const vshCmdInfo info_migrate_setspeed[] = {
@@ -10677,6 +10739,12 @@ const vshCmdDef domManagementCmds[] = {
      .info = info_migrate_setmaxdowntime,
      .flags = 0
     },
+    {.name = "migrate-compcache",
+     .handler = cmdMigrateCompCache,
+     .opts = opts_migrate_compcache,
+     .info = info_migrate_compcache,
+     .flags = 0
+    },
     {.name = "migrate-setspeed",
      .handler = cmdMigrateSetMaxSpeed,
      .opts = opts_migrate_setspeed,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e675850..8f62378 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1114,6 +1114,18 @@ Set maximum tolerable downtime for a domain which is being live-migrated to
 another host.  The I<downtime> is a number of milliseconds the guest is allowed
 to be down at the end of live migration.
 
+=item B<migrate-compcache> I<domain> [I<--size> B<bytes>]
+
+Sets and/or gets size of the cache (in bytes) used for compressing repeatedly
+transferred memory pages during live migration. When called without I<size>,
+the command just prints current size of the compression cache. When I<size>
+is specified, the hypervisor is asked to change compression cache to I<size>
+bytes and then the current size is printed (the result may differ from the
+requested size due to rounding done by the hypervisor). With I<size> this
+command is supposed to be called while the domain is being live-migrated as
+a reaction to migration progress and increasing number of compression cache
+misses obtained from domjobinfo.
+
 =item B<migrate-setspeed> I<domain> I<bandwidth>
 
 Set the maximum migration bandwidth (in Mbps) for a domain which is being
-- 
1.8.1.2




More information about the libvir-list mailing list