All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Yang Zhang <yang.z.zhang@intel.com>, Liang Li <liang.z.li@intel.com>
Subject: [Qemu-devel] [PULL 14/16] migration: Add hmp interface to set and query parameters
Date: Thu,  7 May 2015 13:50:42 +0200	[thread overview]
Message-ID: <1430999444-24315-15-git-send-email-quintela@redhat.com> (raw)
In-Reply-To: <1430999444-24315-1-git-send-email-quintela@redhat.com>

From: Liang Li <liang.z.li@intel.com>

Add the hmp interface to tune and query the parameters used in
live migration.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hmp-commands.hx | 17 +++++++++++++++
 hmp.c           | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hmp.h           |  4 ++++
 monitor.c       | 25 ++++++++++++++++++++++
 4 files changed, 111 insertions(+)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index a6de819..e864a6c 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -993,6 +993,21 @@ Enable/Disable the usage of a capability @var{capability} for migration.
 ETEXI

     {
+        .name       = "migrate_set_parameter",
+        .args_type  = "parameter:s,value:i",
+        .params     = "parameter value",
+        .help       = "Set the parameter for migration",
+        .mhandler.cmd = hmp_migrate_set_parameter,
+        .command_completion = migrate_set_parameter_completion,
+    },
+
+STEXI
+@item migrate_set_parameter @var{parameter} @var{value}
+@findex migrate_set_parameter
+Set the parameter @var{parameter} for migration.
+ETEXI
+
+    {
         .name       = "client_migrate_info",
         .args_type  = "protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?",
         .params     = "protocol hostname port tls-port cert-subject",
@@ -1761,6 +1776,8 @@ show user network stack connection states
 show migration status
 @item info migrate_capabilities
 show current migration capabilities
+@item info migrate_parameters
+show current migration parameters
 @item info migrate_cache_size
 show current migration XBZRLE cache size
 @item info balloon
diff --git a/hmp.c b/hmp.c
index 3010d04..e17852d 100644
--- a/hmp.c
+++ b/hmp.c
@@ -252,6 +252,29 @@ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict)
     qapi_free_MigrationCapabilityStatusList(caps);
 }

+void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
+{
+    MigrationParameters *params;
+
+    params = qmp_query_migrate_parameters(NULL);
+
+    if (params) {
+        monitor_printf(mon, "parameters:");
+        monitor_printf(mon, " %s: %" PRId64,
+            MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL],
+            params->compress_level);
+        monitor_printf(mon, " %s: %" PRId64,
+            MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS],
+            params->compress_threads);
+        monitor_printf(mon, " %s: %" PRId64,
+            MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS],
+            params->decompress_threads);
+        monitor_printf(mon, "\n");
+    }
+
+    qapi_free_MigrationParameters(params);
+}
+
 void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict)
 {
     monitor_printf(mon, "xbzrel cache size: %" PRId64 " kbytes\n",
@@ -1185,6 +1208,48 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
     }
 }

+void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
+{
+    const char *param = qdict_get_str(qdict, "parameter");
+    int value = qdict_get_int(qdict, "value");
+    Error *err = NULL;
+    bool has_compress_level = false;
+    bool has_compress_threads = false;
+    bool has_decompress_threads = false;
+    int i;
+
+    for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) {
+        if (strcmp(param, MigrationParameter_lookup[i]) == 0) {
+            switch (i) {
+            case MIGRATION_PARAMETER_COMPRESS_LEVEL:
+                has_compress_level = true;
+                break;
+            case MIGRATION_PARAMETER_COMPRESS_THREADS:
+                has_compress_threads = true;
+                break;
+            case MIGRATION_PARAMETER_DECOMPRESS_THREADS:
+                has_decompress_threads = true;
+                break;
+            }
+            qmp_migrate_set_parameters(has_compress_level, value,
+                                       has_compress_threads, value,
+                                       has_decompress_threads, value,
+                                       &err);
+            break;
+        }
+    }
+
+    if (i == MIGRATION_PARAMETER_MAX) {
+        error_set(&err, QERR_INVALID_PARAMETER, param);
+    }
+
+    if (err) {
+        monitor_printf(mon, "migrate_set_parameter: %s\n",
+                       error_get_pretty(err));
+        error_free(err);
+    }
+}
+
 void hmp_set_password(Monitor *mon, const QDict *qdict)
 {
     const char *protocol  = qdict_get_str(qdict, "protocol");
diff --git a/hmp.h b/hmp.h
index 12acb6d..a158e3f 100644
--- a/hmp.h
+++ b/hmp.h
@@ -28,6 +28,7 @@ void hmp_info_chardev(Monitor *mon, const QDict *qdict);
 void hmp_info_mice(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
+void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict);
 void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
 void hmp_info_cpus(Monitor *mon, const QDict *qdict);
 void hmp_info_block(Monitor *mon, const QDict *qdict);
@@ -64,6 +65,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict);
 void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict);
 void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict);
 void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict);
+void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict);
 void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict);
 void hmp_set_password(Monitor *mon, const QDict *qdict);
 void hmp_expire_password(Monitor *mon, const QDict *qdict);
@@ -113,6 +115,8 @@ void watchdog_action_completion(ReadLineState *rs, int nb_args,
                                 const char *str);
 void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
                                        const char *str);
+void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
+                                      const char *str);
 void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str);
 void host_net_remove_completion(ReadLineState *rs, int nb_args,
                                 const char *str);
diff --git a/monitor.c b/monitor.c
index d831d98..3952d64 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2859,6 +2859,13 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.cmd = hmp_info_migrate_capabilities,
     },
     {
+        .name       = "migrate_parameters",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show current migration parameters",
+        .mhandler.cmd = hmp_info_migrate_parameters,
+    },
+    {
         .name       = "migrate_cache_size",
         .args_type  = "",
         .params     = "",
@@ -4540,6 +4547,24 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
     }
 }

+void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
+                                      const char *str)
+{
+    size_t len;
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    if (nb_args == 2) {
+        int i;
+        for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) {
+            const char *name = MigrationParameter_lookup[i];
+            if (!strncmp(str, name, len)) {
+                readline_add_completion(rs, name);
+            }
+        }
+    }
+}
+
 void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str)
 {
     int i;
-- 
2.4.0

  parent reply	other threads:[~2015-05-07 11:51 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07 11:50 [Qemu-devel] [PULL 00/16] Migration pull request (v2) Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 01/16] docs: Add a doc about multiple thread compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 02/16] migration: Add the framework of multi-thread compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 03/16] migration: Add the framework of multi-thread decompression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 04/16] qemu-file: Add compression functions to QEMUFile Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 05/16] arch_init: Alloc and free data struct for compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 06/16] arch_init: Add and free data struct for decompression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 07/16] migration: Split save_zero_page from ram_save_page Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 08/16] migration: Add the core code of multi-thread compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 09/16] migration: Make compression co-work with xbzrle Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 10/16] migration: Add the core code for decompression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 11/16] migration: Add interface to control compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 12/16] migration: Use an array instead of 3 parameters Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 13/16] migration: Add qmp commands to set and query parameters Juan Quintela
2015-05-07 11:50 ` Juan Quintela [this message]
2015-05-07 11:50 ` [Qemu-devel] [PULL 15/16] migration: avoid divide by zero in xbzrle cache miss rate Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 16/16] migration: Fix migration state update issue Juan Quintela
2015-05-07 12:45 ` [Qemu-devel] [PULL 00/16] Migration pull request (v2) Peter Maydell
2015-05-07 14:43   ` Eric Blake
2015-05-07 14:56     ` Paolo Bonzini
2015-05-07 18:10   ` Amit Shah
2015-05-08  9:31     ` Stefan Hajnoczi
2015-05-11 11:04       ` Amit Shah
2015-05-11 11:37         ` Peter Maydell
2015-05-11 14:29           ` Dr. David Alan Gilbert
2015-05-11 11:47       ` Alex Bennée
2015-05-07 16:46 [Qemu-devel] [PULL 00/16] Migration pull requset (take 3) Juan Quintela
2015-05-07 16:46 ` [Qemu-devel] [PULL 14/16] migration: Add hmp interface to set and query parameters Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430999444-24315-15-git-send-email-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=liang.z.li@intel.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yang.z.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.