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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]