diff mbox

[v2,11/11] migration: check global caps for validity

Message ID 1500279971-13875-12-git-send-email-peterx@redhat.com
State New
Headers show

Commit Message

Peter Xu July 17, 2017, 8:26 a.m. UTC
Checks validity for all the capabilities that we enabled with command
line.  Stop the VM if detected anything wrong.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/migration.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Comments

Juan Quintela July 17, 2017, 7:48 p.m. UTC | #1
Peter Xu <peterx@redhat.com> wrote:
> Checks validity for all the capabilities that we enabled with command
> line.  Stop the VM if detected anything wrong.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>
diff mbox

Patch

diff --git a/migration/migration.c b/migration/migration.c
index 300f84d..b2667d0 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2142,6 +2142,9 @@  static void migration_instance_post_init(Object *obj)
 {
     MigrationState *ms = (MigrationState *)obj;
     Error *err = NULL;
+    MigrationCapabilityStatusList *head = NULL;
+    /* Assuming all off */
+    bool cap_list[MIGRATION_CAPABILITY__MAX] = { 0 };
     MigrationParameters params = {
         .has_compress_level = true,
         .compress_level = ms->parameters.compress_level,
@@ -2162,13 +2165,35 @@  static void migration_instance_post_init(Object *obj)
         .has_block_incremental = true,
         .block_incremental = ms->parameters.block_incremental,
     };
+    int i;
 
     /* We have applied all the migration properties... */
 
     if (!migrate_params_check(&params, &err)) {
+        goto error;
+    }
+
+    for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
+        if (ms->enabled_capabilities[i]) {
+            head = migrate_cap_add(head, i, true);
+        }
+    }
+
+    if (!migrate_caps_check(cap_list, head, &err)) {
+        goto error;
+    }
+
+    qapi_free_MigrationCapabilityStatusList(head);
+    return;
+
+error:
+    if (head) {
+        qapi_free_MigrationCapabilityStatusList(head);
+    }
+    if (err) {
         error_report_err(err);
-        exit(1);
     }
+    exit(1);
 }
 
 static const TypeInfo migration_type = {