[Libvirt-cim] [PATCH 1 of 2] Add calls into VSMigrationService to utilize new MigrationIndication provider

Jay Gagnon grendel at linux.vnet.ibm.com
Fri Feb 1 16:19:05 UTC 2008


# HG changeset patch
# User Jay Gagnon <grendel at linux.vnet.ibm.com>
# Date 1201882409 18000
# Node ID a17039d1b29cd5275ecd126782bb1757a415a0c0
# Parent  6d86529bbdce9eb68b26a7fc5339fd66a1f2fdd2
Add calls into VSMigrationService to utilize new MigrationIndication provider.

Signed-off-by: Jay Gagnon <grendel at linux.vnet.ibm.com>

diff -r 6d86529bbdce -r a17039d1b29c src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c	Fri Feb 01 11:13:26 2008 -0500
+++ b/src/Virt_VSMigrationService.c	Fri Feb 01 11:13:29 2008 -0500
@@ -34,6 +34,7 @@
 #include "misc_util.h"
 #include <libcmpiutil/std_instance.h>
 #include <libcmpiutil/std_invokemethod.h>
+#include <std_indication.h>
 
 #include "Virt_VSMigrationService.h"
 #include "Virt_HostSystem.h"
@@ -264,11 +265,32 @@ static CMPIStatus vs_migratable_system(C
         return vs_migratable(ref, name, dname, results, argsout);
 }
 
+static bool raise_indication(const CMPIContext *context,
+                             const char *base_type,
+                             const char *ns,
+                             const CMPIInstance *ind)
+{
+        char *type;
+        CMPIStatus s;
+
+        /* Seems like this shouldn't be hardcoded. */
+        type = get_typed_class("Xen", base_type);
+
+        s = stdi_raise_indication(_BROKER, context, type, ns, ind);
+
+        free(type);
+
+        return s.rc == CMPI_RC_OK;
+}
+
 static void migrate_job_set_state(struct migration_job *job,
                                   uint16_t state,
                                   const char *status)
 {
         CMPIInstance *inst;
+        CMPIInstance *prev_inst;
+        CMPIInstance *ind;
+        bool rc;
         CMPIStatus s;
         CMPIObjectPath *op;
 
@@ -297,12 +319,50 @@ static void migrate_job_set_state(struct
         CMSetProperty(inst, "Status",
                       (CMPIValue *)status, CMPI_chars);
 
+        CU_DEBUG("Creating indication.");
+        /* Prefix needs to be dynamic */
+        ind = get_typed_instance(_BROKER,
+                                 "Xen",
+                                 "ComputerSystemMigrationIndication",
+                                 job->ref_ns);
+        /* Prefix needs to be dynamic */
+        if (ind == NULL) {
+                CU_DEBUG("Failed to create ind, type '%s:%s_%s'", 
+                         job->ref_ns,
+                         "Xen",
+                         "ComputerSystemMigrationIndication");
+        }
+
+        /* Need to copy job inst before attaching as PreviousInstance because 
+           otherwise the changes we are about to make to job inst are made 
+           to PreviousInstance as well. */
+        s = cu_dup_instance(_BROKER, inst, &prev_inst);
+        if (s.rc != CMPI_RC_OK || prev_inst == NULL) {
+                CU_DEBUG("dup_instance failed (%i:%s)", s.rc, s.msg);
+                return;
+        }
+
+        CU_DEBUG("Setting PreviousInstance");
+        CMSetProperty(ind, "PreviousInstance", 
+                      (CMPIValue *)&prev_inst, CMPI_instance);
+
         CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status);
 
         s = CBModifyInstance(_BROKER, job->context, op, inst, NULL);
         if (s.rc != CMPI_RC_OK)
                 CU_DEBUG("Failed to update job instance: %s",
                          CMGetCharPtr(s.msg));
+
+        CU_DEBUG("Setting SourceInstance");
+        CMSetProperty(ind, "SourceInstance",
+                      (CMPIValue *)&inst, CMPI_instance);
+
+        rc = raise_indication(job->context,
+                              "ComputerSystemMigrationIndication",
+                              job->ref_ns,
+                              ind);
+        if (!rc)
+                CU_DEBUG("Failed to raise indication");
 }
 
 static CMPIStatus migrate_vs(struct migration_job *job)




More information about the Libvirt-cim mailing list