[Libvirt-cim] [PATCH] Remove hardcoded Xen prefix from VSMigrationService

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Aug 15 16:23:15 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1218817830 25200
# Node ID 69b76cf7611d1878d13af3218142b927afd509ca
# Parent  86d7161daef682ba869fbae74133cfd811f1d306
Remove hardcoded Xen prefix from VSMigrationService

Also fix prefix of MigrationJob to be that of the virt type.

Removed unnecessary comments and fixed one comment that was over 80 chars in length.


Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 86d7161daef6 -r 69b76cf7611d schema/VSMigrationService.mof
--- a/schema/VSMigrationService.mof	Thu Aug 14 07:28:22 2008 -0700
+++ b/schema/VSMigrationService.mof	Fri Aug 15 09:30:30 2008 -0700
@@ -65,7 +65,7 @@
       );
 };
 
-class Virt_MigrationJob : CIM_ConcreteJob {
+class Xen_MigrationJob : CIM_ConcreteJob {
 };
 
 [Provider("cmpi::Virt_VSMigrationService")]
diff -r 86d7161daef6 -r 69b76cf7611d src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c	Thu Aug 14 07:28:22 2008 -0700
+++ b/src/Virt_VSMigrationService.c	Fri Aug 15 09:30:30 2008 -0700
@@ -722,8 +722,7 @@
 
         ind_name = ind_type_to_name(ind_type);
 
-        /* FIXME: This is a hack until we un-Xenify this provider */
-        ref = CMNewObjectPath(_BROKER, ns, "Xen_Foo", &s);
+        ref = CMGetObjectPath(inst, &s);
         if ((ref == NULL) || (s.rc != CMPI_RC_OK)) {
                 CU_DEBUG("Failed to get job reference");
         } else {
@@ -734,15 +733,7 @@
                 } else {
                         CU_DEBUG("Unable to get HostSystem properties");
                 }
-        }
 
-        /* FIXME: This should be merged with above once the job path is
-         *        properly typed
-         */
-        ref = CMGetObjectPath(inst, &s);
-        if ((ref == NULL) || (s.rc != CMPI_RC_OK)) {
-                CU_DEBUG("Failed to get job reference");
-        } else {
                 CMPIString *str;
 
                 str = CMObjectPathToString(ref, &s);
@@ -758,8 +749,7 @@
         CMSetProperty(ind, "SourceInstance",
                       (CMPIValue *)&inst, CMPI_instance);
 
-        /* Seems like this shouldn't be hardcoded. */
-        type = get_typed_class("Xen", ind_name);
+        type = get_typed_class(CLASSNAME(ref), ind_name);
 
         s = stdi_raise_indication(_BROKER, context, type, ns, ind);
 
@@ -770,33 +760,35 @@
 
 static CMPIInstance *prepare_indication(const CMPIBroker *broker,
                                         CMPIInstance *inst,
-                                        char *ns,
+                                        struct migration_job *job,
                                         int ind_type,
                                         CMPIStatus *s)
 {
         const char *ind_name = NULL;
         CMPIInstance *ind = NULL;
         CMPIInstance *prev_inst = NULL;
+        const char *pfx = NULL;
 
         ind_name = ind_type_to_name(ind_type);
 
         CU_DEBUG("Creating indication.");
-        /* Prefix needs to be dynamic */
+
+        pfx = pfx_from_conn(job->conn);
+
         ind = get_typed_instance(broker, 
-                                 "Xen", 
+                                 pfx, 
                                  ind_name, 
-                                 ns);
-        /* Prefix needs to be dynamic */
+                                 job->ref_ns);
         if (ind == NULL) {
                 CU_DEBUG("Failed to create ind, type '%s:%s_%s'", 
-                         ns, "Xen", ind_name);
+                         job->ref_ns, pfx, ind_name);
                 goto out;
         }
 
         if (ind_type == MIG_MODIFIED) {
-                /* 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. */
+                /* 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. */
                 prev_inst = cu_dup_instance(_BROKER, inst, s);
                 if (s->rc != CMPI_RC_OK || prev_inst == NULL) {
                         CU_DEBUG("dup_instance failed (%i:%s)", s->rc, s->msg);
@@ -816,15 +808,20 @@
                                     CMPIStatus *s)
 {
         CMPIObjectPath *ref = NULL;
+        char *type;
+        
+        type = get_typed_class(job->ref_cn, "MigrationJob");
         
         ref = CMNewObjectPath(_BROKER,
                               job->ref_ns,
-                              "Virt_MigrationJob",
+                              type,
                               s);
-        if (s->rc != CMPI_RC_OK) {
+        if (s->rc != CMPI_RC_OK) { 
                 CU_DEBUG("Failed to create job ref for update");
                 goto out;
         }
+
+        free(type);
 
         CMSetNameSpace(ref, job->ref_ns);
         CMAddKey(ref, "InstanceID", (CMPIValue *)job->uuid, CMPI_chars);
@@ -855,7 +852,7 @@
                 return;
         }
 
-        ind = prepare_indication(_BROKER, inst, job->ref_ns, MIG_DELETED, &s);
+        ind = prepare_indication(_BROKER, inst, job, MIG_DELETED, &s);
         
         rc = raise_indication(job->context, MIG_DELETED, job->ref_ns,
                               inst, ind);
@@ -886,7 +883,7 @@
                 return;
         }
 
-        ind = prepare_indication(_BROKER, inst, job->ref_ns, MIG_MODIFIED, &s);
+        ind = prepare_indication(_BROKER, inst, job, MIG_MODIFIED, &s);
 
         CMSetProperty(inst, "JobState",
                       (CMPIValue *)&state, CMPI_uint16);
@@ -1238,6 +1235,7 @@
         CMPIDateTime *start;
         CMPIBoolean autodelete = true;
         uint16_t state = CIM_JOBSTATE_STARTING;
+        char *type = NULL;
 
         start = CMNewDateTime(_BROKER, &s);
         if ((s.rc != CMPI_RC_OK) || CMIsNullObject(start)) {
@@ -1246,9 +1244,10 @@
                            "Failed to get job start time");
                 goto out;
         }
+        
+        type = get_typed_class(job->ref_cn, "MigrationJob");
 
-        jobinst = _migrate_job_new_instance("Virt_MigrationJob",
-                                            job->ref_ns);
+        jobinst = _migrate_job_new_instance(type, job->ref_ns);
         if (jobinst == NULL) {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
@@ -1291,6 +1290,8 @@
         CMSetNameSpace(*job_op, job->ref_ns);
 
  out:
+        free(type);
+
         return s;
 }
 
@@ -1362,7 +1363,7 @@
                 goto out;
         }
 
-        ind = prepare_indication(_BROKER, inst, job->ref_ns, MIG_CREATED, &s);
+        ind = prepare_indication(_BROKER, inst, job, MIG_CREATED, &s);
         rc = raise_indication(job->context, MIG_CREATED, job->ref_ns, 
                               inst, ind);
         if (!rc)




More information about the Libvirt-cim mailing list