[Libvirt-cim] [PATCH] MigrationJob will write a migration mark to the infostore of the guest migrating

Richard Maciel rmaciel at linux.vnet.ibm.com
Mon Aug 10 16:52:49 UTC 2009


# HG changeset patch
# User Richard Maciel <rmaciel at linux.vnet.ibm.com>
# Date 1249923132 10800
# Node ID 411a3090c6a098de809144334edaa41f5d3007b0
# Parent  20528f913ec18441bf1ef2f812d110580fa01015
MigrationJob will write a migration mark to the infostore of the guest migrating

This allows ComputerSystem to know when its respective guest is being migrated

Signed-off-by: Richard Maciel <rmaciel at linux.vnet.ibm.com>

diff -r 20528f913ec1 -r 411a3090c6a0 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c	Tue Jun 16 14:25:50 2009 -0700
+++ b/src/Virt_VSMigrationService.c	Mon Aug 10 13:52:12 2009 -0300
@@ -48,6 +48,7 @@
 #include "Virt_ComputerSystem.h"
 #include "Virt_VSMigrationSettingData.h"
 #include "svpc_types.h"
+#include "libxkutil/infostore.h"
 
 #include "config.h"
 
@@ -1135,6 +1136,24 @@
         return s;
 }
 
+static void clear_infstore_migration_mark(virDomainPtr dom)
+{
+        struct infostore_ctx *infp;
+        bool ret = false;
+
+        infp = infostore_open(dom);
+        if (infp == NULL) {
+                CU_DEBUG("Unable to open domain information store."
+                          "Migration mark won't be cleared");
+                return;
+        }
+
+        ret = infostore_set_bool(infp, "migrating", false);
+        CU_DEBUG("Clearing infostore migrating flag");
+
+        infostore_close(infp);
+}
+
 static CMPIStatus migrate_vs(struct migration_job *job)
 {
         CMPIStatus s;
@@ -1210,6 +1229,7 @@
                          CMGetCharPtr(s.msg));
         }
  out:
+        clear_infstore_migration_mark(dom);
         raise_deleted_ind(job);
         
         free(uri);
@@ -1251,6 +1271,45 @@
         return NULL;
 }
 
+static bool set_infstore_migration_mark(const CMPIObjectPath *ref,
+                                        const char *domain)
+{
+        struct infostore_ctx *infp;
+        bool ret = false;
+        CMPIStatus s;
+        virConnectPtr conn = NULL;
+        virDomainPtr dom = NULL;
+        
+        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+        if (conn == NULL)
+                goto out;
+
+        dom = virDomainLookupByName(conn, domain);
+        if (dom == NULL) {
+                CU_DEBUG("No such domain");
+                goto out;
+        }
+
+
+        infp = infostore_open(dom);
+        if (infp == NULL) {
+                CU_DEBUG("Unable to open domain information store."
+                         "Migration mark won't be placed");
+                goto out;
+        }
+
+        ret = infostore_set_bool(infp, "migrating", true);
+        CU_DEBUG("Migration mark set");
+
+        infostore_close(infp);
+
+ out:
+        virDomainFree(dom);
+        virConnectClose(conn);
+
+        return ret;
+}
+
 static CMPIInstance *_migrate_job_new_instance(const char *cn,
                                                const char *ns)
 {
@@ -1411,6 +1470,10 @@
                 goto out;
         }
 
+        rc = set_infstore_migration_mark(ref, domain);
+        if (!rc)
+                CU_DEBUG("Failed to set migration mark in infostore");
+
         ind = prepare_indication(_BROKER, inst, job, MIG_CREATED, &s);
         rc = raise_indication(job->context, MIG_CREATED, job->ref_ns, 
                               inst, ind);




More information about the Libvirt-cim mailing list