diff mbox

[RFC,v3,02/27] migration: Introduce capability 'colo' to migration

Message ID 1423711034-5340-3-git-send-email-zhang.zhanghailiang@huawei.com
State New
Headers show

Commit Message

Zhanghailiang Feb. 12, 2015, 3:16 a.m. UTC
This capability allows Primary VM (PVM) to be continuously checkpointed
to secondary VM.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 include/migration/migration.h |  1 +
 migration/migration.c         | 15 +++++++++++++++
 qapi-schema.json              |  5 ++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

Comments

Eric Blake Feb. 16, 2015, 9:57 p.m. UTC | #1
On 02/11/2015 08:16 PM, zhanghailiang wrote:
> This capability allows Primary VM (PVM) to be continuously checkpointed
> to secondary VM.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
>  include/migration/migration.h |  1 +
>  migration/migration.c         | 15 +++++++++++++++
>  qapi-schema.json              |  5 ++++-
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 

> +++ b/migration/migration.c
> @@ -276,6 +276,15 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
>      }
>  
>      for (cap = params; cap; cap = cap->next) {
> +#ifndef CONFIG_COLO
> +        if (cap->value->capability == MIGRATION_CAPABILITY_COLO &&
> +            cap->value->state) {
> +            error_setg(errp, "COLO is not currently supported, please"
> +                             " configure with --enable-colo option in order to"
> +                             " support COLO feature");
> +            continue;
> +        }
> +#endif
>          s->enabled_capabilities[cap->value->capability] = cap->value->state;
>      }

Yuck.  This means that probing whether colo is supported requires a
usage test (try setting the capability with migrate-set-capabilities and
see if it fails) instead of a query test (list the current capabilities;
if colo is in the set then it is supported).  Can you figure out a way
to avoid exposing the colo capability if !CONFIG_COLO, so that
query-migate-capabilities is sufficient to learn if colo is supported?
Zhanghailiang Feb. 25, 2015, 9:19 a.m. UTC | #2
On 2015/2/17 5:57, Eric Blake wrote:
> On 02/11/2015 08:16 PM, zhanghailiang wrote:
>> This capability allows Primary VM (PVM) to be continuously checkpointed
>> to secondary VM.
>>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
>> ---
>>   include/migration/migration.h |  1 +
>>   migration/migration.c         | 15 +++++++++++++++
>>   qapi-schema.json              |  5 ++++-
>>   3 files changed, 20 insertions(+), 1 deletion(-)
>>
>
>> +++ b/migration/migration.c
>> @@ -276,6 +276,15 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
>>       }
>>
>>       for (cap = params; cap; cap = cap->next) {
>> +#ifndef CONFIG_COLO
>> +        if (cap->value->capability == MIGRATION_CAPABILITY_COLO &&
>> +            cap->value->state) {
>> +            error_setg(errp, "COLO is not currently supported, please"
>> +                             " configure with --enable-colo option in order to"
>> +                             " support COLO feature");
>> +            continue;
>> +        }
>> +#endif
>>           s->enabled_capabilities[cap->value->capability] = cap->value->state;
>>       }
>
> Yuck.  This means that probing whether colo is supported requires a
> usage test (try setting the capability with migrate-set-capabilities and
> see if it fails) instead of a query test (list the current capabilities;
> if colo is in the set then it is supported).  Can you figure out a way
> to avoid exposing the colo capability if !CONFIG_COLO, so that
> query-migate-capabilities is sufficient to learn if colo is supported?
>

What about using colo_supported() function to instead of compile macro ?
Like what we have done in v2 version:
in colo.c

bool colo_supported(void)
{
     return true;
}

in stubs/migration-colo.c
bool colo_supported(void)
{
     return false;
}

And then we call this function in qmp_migrate_set_capabilities
@@ -292,15 +295,13 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
      }

      for (cap = params; cap; cap = cap->next) {
-#ifndef CONFIG_COLO
          if (cap->value->capability == MIGRATION_CAPABILITY_COLO &&
-            cap->value->state) {
+            cap->value->state && !colo_supported()) {
              error_setg(errp, "COLO is not currently supported, please"
                               " configure with --enable-colo option in order to"
                               " support COLO feature");
              continue;
          }
-#endif
          s->enabled_capabilities[cap->value->capability] = cap->value->state;
      }
  }

For qmp_query_migrate_capabilities we call it like:

@@ -158,6 +158,9 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)

      caps = NULL; /* silence compiler warning */
      for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) {
+        if (i == MIGRATION_CAPABILITY_COLO && !colo_supported()) {
+            continue;
+        }

Thanks,
zhanghailiang
diff mbox

Patch

diff --git a/include/migration/migration.h b/include/migration/migration.h
index f37348b..3f5c705 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -154,6 +154,7 @@  int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
 
 int migrate_use_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);
+bool migrate_enable_colo(void);
 
 int64_t xbzrle_cache_resize(int64_t new_size);
 
diff --git a/migration/migration.c b/migration/migration.c
index b3adbc6..8403c8a 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -276,6 +276,15 @@  void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
     }
 
     for (cap = params; cap; cap = cap->next) {
+#ifndef CONFIG_COLO
+        if (cap->value->capability == MIGRATION_CAPABILITY_COLO &&
+            cap->value->state) {
+            error_setg(errp, "COLO is not currently supported, please"
+                             " configure with --enable-colo option in order to"
+                             " support COLO feature");
+            continue;
+        }
+#endif
         s->enabled_capabilities[cap->value->capability] = cap->value->state;
     }
 }
@@ -585,6 +594,12 @@  int64_t migrate_xbzrle_cache_size(void)
     return s->xbzrle_cache_size;
 }
 
+bool migrate_enable_colo(void)
+{
+    MigrationState *s = migrate_get_current();
+    return s->enabled_capabilities[MIGRATION_CAPABILITY_COLO];
+}
+
 /* migration thread support */
 
 static void *migration_thread(void *opaque)
diff --git a/qapi-schema.json b/qapi-schema.json
index e16f8eb..8c59e50 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -494,10 +494,13 @@ 
 # @auto-converge: If enabled, QEMU will automatically throttle down the guest
 #          to speed up convergence of RAM migration. (since 1.6)
 #
+# @colo: If enabled, the migration will never end, and the VM will instead be
+#          continuously checkpointed. (since 2.3)
+#
 # Since: 1.2
 ##
 { 'enum': 'MigrationCapability',
-  'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks'] }
+  'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', 'colo'] }
 
 ##
 # @MigrationCapabilityStatus