Patchwork [01/11] Add migration capabilities

login
register
mail settings
Submitter Orit Wasserman
Date July 29, 2012, 9:42 a.m.
Message ID <1343554983-4195-2-git-send-email-owasserm@redhat.com>
Download mbox | patch
Permalink /patch/173906/
State New
Headers show

Comments

Orit Wasserman - July 29, 2012, 9:42 a.m.
Add migration capabilities that can be queried by the management.
The management can query the source QEMU and the destination QEMU in order to
verify both support some migration capability (currently only XBZRLE).

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hmp-commands.hx  |    2 ++
 hmp.c            |   19 +++++++++++++++++++
 hmp.h            |    1 +
 migration.c      |   11 +++++++++++
 monitor.c        |    7 +++++++
 qapi-schema.json |   39 +++++++++++++++++++++++++++++++++++++++
 qmp-commands.hx  |   24 ++++++++++++++++++++++++
 7 files changed, 103 insertions(+), 0 deletions(-)
Luiz Capitulino - July 30, 2012, 5:24 p.m.
On Sun, 29 Jul 2012 12:42:53 +0300
Orit Wasserman <owasserm@redhat.com> wrote:

> Add migration capabilities that can be queried by the management.
> The management can query the source QEMU and the destination QEMU in order to
> verify both support some migration capability (currently only XBZRLE).
> 
> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hmp-commands.hx  |    2 ++
>  hmp.c            |   19 +++++++++++++++++++
>  hmp.h            |    1 +
>  migration.c      |   11 +++++++++++
>  monitor.c        |    7 +++++++
>  qapi-schema.json |   39 +++++++++++++++++++++++++++++++++++++++
>  qmp-commands.hx  |   24 ++++++++++++++++++++++++
>  7 files changed, 103 insertions(+), 0 deletions(-)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index eea8b32..8786148 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1417,6 +1417,8 @@ show CPU statistics
>  show user network stack connection states
>  @item info migrate
>  show migration status
> +@item info migration_capabilities
> +show migration capabilities
>  @item info balloon
>  show balloon information
>  @item info qtree
> diff --git a/hmp.c b/hmp.c
> index 6b72a64..5c7d0be 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -161,6 +161,25 @@ void hmp_info_migrate(Monitor *mon)
>      qapi_free_MigrationInfo(info);
>  }
>  
> +void hmp_info_migration_capabilities(Monitor *mon)
> +{
> +    MigrationCapabilityStatusList *caps_list, *cap;
> +
> +    caps_list = qmp_query_migration_capabilities(NULL);
> +    if (!caps_list) {
> +        monitor_printf(mon, "No migration capabilities found\n");
> +        return;
> +    }
> +
> +    for (cap = caps_list; cap; cap = cap->next) {
> +        monitor_printf(mon, "%s: %s ",
> +                       MigrationCapability_lookup[cap->value->capability],
> +                       cap->value->state ? "on" : "off");
> +    }
> +
> +    qapi_free_MigrationCapabilityStatusList(caps_list);
> +}
> +
>  void hmp_info_cpus(Monitor *mon)
>  {
>      CpuInfoList *cpu_list, *cpu;
> diff --git a/hmp.h b/hmp.h
> index 8d2b0d7..2fb44ca 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -25,6 +25,7 @@ void hmp_info_uuid(Monitor *mon);
>  void hmp_info_chardev(Monitor *mon);
>  void hmp_info_mice(Monitor *mon);
>  void hmp_info_migrate(Monitor *mon);
> +void hmp_info_migration_capabilities(Monitor *mon);
>  void hmp_info_cpus(Monitor *mon);
>  void hmp_info_block(Monitor *mon);
>  void hmp_info_blockstats(Monitor *mon);
> diff --git a/migration.c b/migration.c
> index 8db1b43..8c27347 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -166,6 +166,17 @@ MigrationInfo *qmp_query_migrate(Error **errp)
>      return info;
>  }
>  
> +MigrationCapabilityStatusList *qmp_query_migration_capabilities(Error **errp)
> +{
> +    MigrationCapabilityStatusList *caps_list = g_malloc0(sizeof(*caps_list));
> +
> +    caps_list->value = g_malloc(sizeof(*caps_list->value));
> +    caps_list->value->capability = MIGRATION_CAPABILITY_XBZRLE;
> +    caps_list->next = NULL;
> +
> +    return caps_list;
> +}

This is missing an entry in qmp-commands.hx, otherwise looks good.

> +
>  /* shared migration helpers */
>  
>  static int migrate_fd_cleanup(MigrationState *s)
> diff --git a/monitor.c b/monitor.c
> index 09aa3cd..fd57c5e 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2662,6 +2662,13 @@ static mon_cmd_t info_cmds[] = {
>          .mhandler.info = hmp_info_migrate,
>      },
>      {
> +        .name       = "migration-capabilities",
> +        .args_type  = "",
> +        .params     = "",
> +        .help       = "show migration capabilities",
> +        .mhandler.info = hmp_info_migration_capabilities,
> +    },
> +    {
>          .name       = "balloon",
>          .args_type  = "",
>          .params     = "",
> diff --git a/qapi-schema.json b/qapi-schema.json
> index a92adb1..b4d4dd6 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -306,6 +306,45 @@
>  { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
>  
>  ##
> +# @MigrationCapability
> +#
> +# Migration capabilities enumeration
> +#
> +# @xbzrle: Migration supports xbzrle (Xor Based Zero Length Encoding).
> +#          This feature allows us to minimize migration traffic for certain work
> +#          loads, by sending compressed difference of the pages
> +#
> +# Since: 1.2
> +##
> +{ 'enum': 'MigrationCapability',
> +  'data': ['xbzrle'] }
> +
> +##
> +# @MigrationCapabilityStatus
> +#
> +# Migration capability information
> +#
> +# @capability: capability enum
> +#
> +# @state: capability state bool
> +#
> +# Since: 1.2
> +##
> +{ 'type': 'MigrationCapabilityStatus',
> +  'data': { 'capability' : 'MigrationCapability', 'state' : 'bool' } }
> +
> +##
> +# @query-migration-capabilities
> +#
> +# Returns information about current migration process capabilities.
> +#
> +# Returns: @MigrationCapabilityStatus list
> +#
> +# Since: 1.2
> +##
> +{ 'command': 'query-migration-capabilities', 'returns': ['MigrationCapabilityStatus'] }
> +
> +##
>  # @MouseInfo:
>  #
>  # Information about a mouse device.
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index e3cf3c5..c0ed14c 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -2141,6 +2141,30 @@ EQMP
>      },
>  
>  SQMP
> +query-migration-capabilities
> +-------
> +
> +Query migration capabilities
> +
> +- "xbzrle": xbzrle support
> +
> +Arguments:
> +
> +Example:
> +
> +-> { "execute": "query-migration-capabilities"}
> +<- { "return": [ { "capability": "xbzrle", "state": true },
> +                 { "capability": "foobar", "state": false } ] }
> +
> +EQMP
> +
> +    {
> +        .name       = "query-migration-capabilities",
> +        .args_type  = "",
> +	.mhandler.cmd_new = qmp_marshal_input_query_migration_capabilities,
> +    },
> +
> +SQMP
>  query-balloon
>  -------------
>
Luiz Capitulino - July 30, 2012, 5:29 p.m.
On Mon, 30 Jul 2012 14:24:18 -0300
Luiz Capitulino <lcapitulino@redhat.com> wrote:

> On Sun, 29 Jul 2012 12:42:53 +0300
> Orit Wasserman <owasserm@redhat.com> wrote:
> 
> > Add migration capabilities that can be queried by the management.
> > The management can query the source QEMU and the destination QEMU in order to
> > verify both support some migration capability (currently only XBZRLE).
> > 
> > Signed-off-by: Orit Wasserman <owasserm@redhat.com>
> > Signed-off-by: Juan Quintela <quintela@redhat.com>
> > ---
> >  hmp-commands.hx  |    2 ++
> >  hmp.c            |   19 +++++++++++++++++++
> >  hmp.h            |    1 +
> >  migration.c      |   11 +++++++++++
> >  monitor.c        |    7 +++++++
> >  qapi-schema.json |   39 +++++++++++++++++++++++++++++++++++++++
> >  qmp-commands.hx  |   24 ++++++++++++++++++++++++
> >  7 files changed, 103 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hmp-commands.hx b/hmp-commands.hx
> > index eea8b32..8786148 100644
> > --- a/hmp-commands.hx
> > +++ b/hmp-commands.hx
> > @@ -1417,6 +1417,8 @@ show CPU statistics
> >  show user network stack connection states
> >  @item info migrate
> >  show migration status
> > +@item info migration_capabilities
> > +show migration capabilities
> >  @item info balloon
> >  show balloon information
> >  @item info qtree
> > diff --git a/hmp.c b/hmp.c
> > index 6b72a64..5c7d0be 100644
> > --- a/hmp.c
> > +++ b/hmp.c
> > @@ -161,6 +161,25 @@ void hmp_info_migrate(Monitor *mon)
> >      qapi_free_MigrationInfo(info);
> >  }
> >  
> > +void hmp_info_migration_capabilities(Monitor *mon)
> > +{
> > +    MigrationCapabilityStatusList *caps_list, *cap;
> > +
> > +    caps_list = qmp_query_migration_capabilities(NULL);
> > +    if (!caps_list) {
> > +        monitor_printf(mon, "No migration capabilities found\n");
> > +        return;
> > +    }
> > +
> > +    for (cap = caps_list; cap; cap = cap->next) {
> > +        monitor_printf(mon, "%s: %s ",
> > +                       MigrationCapability_lookup[cap->value->capability],
> > +                       cap->value->state ? "on" : "off");
> > +    }
> > +
> > +    qapi_free_MigrationCapabilityStatusList(caps_list);
> > +}
> > +
> >  void hmp_info_cpus(Monitor *mon)
> >  {
> >      CpuInfoList *cpu_list, *cpu;
> > diff --git a/hmp.h b/hmp.h
> > index 8d2b0d7..2fb44ca 100644
> > --- a/hmp.h
> > +++ b/hmp.h
> > @@ -25,6 +25,7 @@ void hmp_info_uuid(Monitor *mon);
> >  void hmp_info_chardev(Monitor *mon);
> >  void hmp_info_mice(Monitor *mon);
> >  void hmp_info_migrate(Monitor *mon);
> > +void hmp_info_migration_capabilities(Monitor *mon);
> >  void hmp_info_cpus(Monitor *mon);
> >  void hmp_info_block(Monitor *mon);
> >  void hmp_info_blockstats(Monitor *mon);
> > diff --git a/migration.c b/migration.c
> > index 8db1b43..8c27347 100644
> > --- a/migration.c
> > +++ b/migration.c
> > @@ -166,6 +166,17 @@ MigrationInfo *qmp_query_migrate(Error **errp)
> >      return info;
> >  }
> >  
> > +MigrationCapabilityStatusList *qmp_query_migration_capabilities(Error **errp)
> > +{
> > +    MigrationCapabilityStatusList *caps_list = g_malloc0(sizeof(*caps_list));
> > +
> > +    caps_list->value = g_malloc(sizeof(*caps_list->value));
> > +    caps_list->value->capability = MIGRATION_CAPABILITY_XBZRLE;
> > +    caps_list->next = NULL;
> > +
> > +    return caps_list;
> > +}
> 
> This is missing an entry in qmp-commands.hx, otherwise looks good.

It's actually there, so:

 Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

> 
> > +
> >  /* shared migration helpers */
> >  
> >  static int migrate_fd_cleanup(MigrationState *s)
> > diff --git a/monitor.c b/monitor.c
> > index 09aa3cd..fd57c5e 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -2662,6 +2662,13 @@ static mon_cmd_t info_cmds[] = {
> >          .mhandler.info = hmp_info_migrate,
> >      },
> >      {
> > +        .name       = "migration-capabilities",
> > +        .args_type  = "",
> > +        .params     = "",
> > +        .help       = "show migration capabilities",
> > +        .mhandler.info = hmp_info_migration_capabilities,
> > +    },
> > +    {
> >          .name       = "balloon",
> >          .args_type  = "",
> >          .params     = "",
> > diff --git a/qapi-schema.json b/qapi-schema.json
> > index a92adb1..b4d4dd6 100644
> > --- a/qapi-schema.json
> > +++ b/qapi-schema.json
> > @@ -306,6 +306,45 @@
> >  { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
> >  
> >  ##
> > +# @MigrationCapability
> > +#
> > +# Migration capabilities enumeration
> > +#
> > +# @xbzrle: Migration supports xbzrle (Xor Based Zero Length Encoding).
> > +#          This feature allows us to minimize migration traffic for certain work
> > +#          loads, by sending compressed difference of the pages
> > +#
> > +# Since: 1.2
> > +##
> > +{ 'enum': 'MigrationCapability',
> > +  'data': ['xbzrle'] }
> > +
> > +##
> > +# @MigrationCapabilityStatus
> > +#
> > +# Migration capability information
> > +#
> > +# @capability: capability enum
> > +#
> > +# @state: capability state bool
> > +#
> > +# Since: 1.2
> > +##
> > +{ 'type': 'MigrationCapabilityStatus',
> > +  'data': { 'capability' : 'MigrationCapability', 'state' : 'bool' } }
> > +
> > +##
> > +# @query-migration-capabilities
> > +#
> > +# Returns information about current migration process capabilities.
> > +#
> > +# Returns: @MigrationCapabilityStatus list
> > +#
> > +# Since: 1.2
> > +##
> > +{ 'command': 'query-migration-capabilities', 'returns': ['MigrationCapabilityStatus'] }
> > +
> > +##
> >  # @MouseInfo:
> >  #
> >  # Information about a mouse device.
> > diff --git a/qmp-commands.hx b/qmp-commands.hx
> > index e3cf3c5..c0ed14c 100644
> > --- a/qmp-commands.hx
> > +++ b/qmp-commands.hx
> > @@ -2141,6 +2141,30 @@ EQMP
> >      },
> >  
> >  SQMP
> > +query-migration-capabilities
> > +-------
> > +
> > +Query migration capabilities
> > +
> > +- "xbzrle": xbzrle support
> > +
> > +Arguments:
> > +
> > +Example:
> > +
> > +-> { "execute": "query-migration-capabilities"}
> > +<- { "return": [ { "capability": "xbzrle", "state": true },
> > +                 { "capability": "foobar", "state": false } ] }
> > +
> > +EQMP
> > +
> > +    {
> > +        .name       = "query-migration-capabilities",
> > +        .args_type  = "",
> > +	.mhandler.cmd_new = qmp_marshal_input_query_migration_capabilities,
> > +    },
> > +
> > +SQMP
> >  query-balloon
> >  -------------
> >  
>
Eric Blake - July 30, 2012, 5:45 p.m.
On 07/29/2012 03:42 AM, Orit Wasserman wrote:
> Add migration capabilities that can be queried by the management.
> The management can query the source QEMU and the destination QEMU in order to
> verify both support some migration capability (currently only XBZRLE).
> 
> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
> Signed-off-by: Juan Quintela <quintela@redhat.com>

> +++ b/qapi-schema.json
> @@ -306,6 +306,45 @@
>  { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
>  
>  ##
> +# @MigrationCapability
> +#
> +# Migration capabilities enumeration
> +#
> +# @xbzrle: Migration supports xbzrle (Xor Based Zero Length Encoding).

In patch 3/10, you named it:
XBZRLE (Xor Based Zero Run Length Encoding)

You are missing 'Run' here.

> +#          This feature allows us to minimize migration traffic for certain work
> +#          loads, by sending compressed difference of the pages
> +#
> +# Since: 1.2

We are inconsistent on whether this should be 'Since: 1.2.0' or 'Since:
1.2', but cleaning that up would be an independent patch since there are
pre-existing uses of both forms.

Other than that,

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index eea8b32..8786148 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1417,6 +1417,8 @@  show CPU statistics
 show user network stack connection states
 @item info migrate
 show migration status
+@item info migration_capabilities
+show migration capabilities
 @item info balloon
 show balloon information
 @item info qtree
diff --git a/hmp.c b/hmp.c
index 6b72a64..5c7d0be 100644
--- a/hmp.c
+++ b/hmp.c
@@ -161,6 +161,25 @@  void hmp_info_migrate(Monitor *mon)
     qapi_free_MigrationInfo(info);
 }
 
+void hmp_info_migration_capabilities(Monitor *mon)
+{
+    MigrationCapabilityStatusList *caps_list, *cap;
+
+    caps_list = qmp_query_migration_capabilities(NULL);
+    if (!caps_list) {
+        monitor_printf(mon, "No migration capabilities found\n");
+        return;
+    }
+
+    for (cap = caps_list; cap; cap = cap->next) {
+        monitor_printf(mon, "%s: %s ",
+                       MigrationCapability_lookup[cap->value->capability],
+                       cap->value->state ? "on" : "off");
+    }
+
+    qapi_free_MigrationCapabilityStatusList(caps_list);
+}
+
 void hmp_info_cpus(Monitor *mon)
 {
     CpuInfoList *cpu_list, *cpu;
diff --git a/hmp.h b/hmp.h
index 8d2b0d7..2fb44ca 100644
--- a/hmp.h
+++ b/hmp.h
@@ -25,6 +25,7 @@  void hmp_info_uuid(Monitor *mon);
 void hmp_info_chardev(Monitor *mon);
 void hmp_info_mice(Monitor *mon);
 void hmp_info_migrate(Monitor *mon);
+void hmp_info_migration_capabilities(Monitor *mon);
 void hmp_info_cpus(Monitor *mon);
 void hmp_info_block(Monitor *mon);
 void hmp_info_blockstats(Monitor *mon);
diff --git a/migration.c b/migration.c
index 8db1b43..8c27347 100644
--- a/migration.c
+++ b/migration.c
@@ -166,6 +166,17 @@  MigrationInfo *qmp_query_migrate(Error **errp)
     return info;
 }
 
+MigrationCapabilityStatusList *qmp_query_migration_capabilities(Error **errp)
+{
+    MigrationCapabilityStatusList *caps_list = g_malloc0(sizeof(*caps_list));
+
+    caps_list->value = g_malloc(sizeof(*caps_list->value));
+    caps_list->value->capability = MIGRATION_CAPABILITY_XBZRLE;
+    caps_list->next = NULL;
+
+    return caps_list;
+}
+
 /* shared migration helpers */
 
 static int migrate_fd_cleanup(MigrationState *s)
diff --git a/monitor.c b/monitor.c
index 09aa3cd..fd57c5e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2662,6 +2662,13 @@  static mon_cmd_t info_cmds[] = {
         .mhandler.info = hmp_info_migrate,
     },
     {
+        .name       = "migration-capabilities",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show migration capabilities",
+        .mhandler.info = hmp_info_migration_capabilities,
+    },
+    {
         .name       = "balloon",
         .args_type  = "",
         .params     = "",
diff --git a/qapi-schema.json b/qapi-schema.json
index a92adb1..b4d4dd6 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -306,6 +306,45 @@ 
 { 'command': 'query-migrate', 'returns': 'MigrationInfo' }
 
 ##
+# @MigrationCapability
+#
+# Migration capabilities enumeration
+#
+# @xbzrle: Migration supports xbzrle (Xor Based Zero Length Encoding).
+#          This feature allows us to minimize migration traffic for certain work
+#          loads, by sending compressed difference of the pages
+#
+# Since: 1.2
+##
+{ 'enum': 'MigrationCapability',
+  'data': ['xbzrle'] }
+
+##
+# @MigrationCapabilityStatus
+#
+# Migration capability information
+#
+# @capability: capability enum
+#
+# @state: capability state bool
+#
+# Since: 1.2
+##
+{ 'type': 'MigrationCapabilityStatus',
+  'data': { 'capability' : 'MigrationCapability', 'state' : 'bool' } }
+
+##
+# @query-migration-capabilities
+#
+# Returns information about current migration process capabilities.
+#
+# Returns: @MigrationCapabilityStatus list
+#
+# Since: 1.2
+##
+{ 'command': 'query-migration-capabilities', 'returns': ['MigrationCapabilityStatus'] }
+
+##
 # @MouseInfo:
 #
 # Information about a mouse device.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e3cf3c5..c0ed14c 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2141,6 +2141,30 @@  EQMP
     },
 
 SQMP
+query-migration-capabilities
+-------
+
+Query migration capabilities
+
+- "xbzrle": xbzrle support
+
+Arguments:
+
+Example:
+
+-> { "execute": "query-migration-capabilities"}
+<- { "return": [ { "capability": "xbzrle", "state": true },
+                 { "capability": "foobar", "state": false } ] }
+
+EQMP
+
+    {
+        .name       = "query-migration-capabilities",
+        .args_type  = "",
+	.mhandler.cmd_new = qmp_marshal_input_query_migration_capabilities,
+    },
+
+SQMP
 query-balloon
 -------------