[Libvirt-cim] [PATCH] (#2) Fix UUID in migration job lifecycle indications

Chip Vincent cvincent at linux.vnet.ibm.com
Fri May 6 01:25:36 UTC 2011


# HG changeset patch
# User Chip Vincent <cvincent at us.ibm.com>
# Date 1304034351 14400
# Node ID 2f8763c53407a186968adf1edc9a2f2a1adbc00e
# Parent  8b428df21c360d1eaedba7157b0dfd429d2db121
(#2) Fix UUID in migration job lifecycle indications.

Fixed the logic that fetches a VM UUID and adds it to the migration job's InstanceIdentifier property.

Siged-off-by: Chip Vincent <cvincent at us.ibm.com>

diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c
+++ b/src/Virt_VSMigrationService.c
@@ -812,15 +812,20 @@
         CMPIInstance *ind = NULL;
         CMPIInstance *prev_inst = NULL;
         const char *pfx = NULL;
+        virConnectPtr conn = NULL;
         virDomainPtr dom = NULL;
         char uuid[VIR_UUID_STRING_BUFLEN];
         CMPIDateTime *timestamp = NULL;
         
+        conn = connect_by_classname(_BROKER, job->ref_cn, s);
+        if(conn == NULL)
+                goto out;
+
         ind_name = ind_type_to_name(ind_type);
 
         CU_DEBUG("Creating indication.");
 
-        pfx = pfx_from_conn(job->conn);
+        pfx = pfx_from_conn(conn);
 
         ind = get_typed_instance(broker, 
                                  pfx, 
@@ -832,13 +837,15 @@
                 goto out;
         }
         
-        dom = virDomainLookupByName(job->conn, job->domain);
-        if(dom == NULL) {
-                CU_DEBUG("Failed to connect to domain %s", job->domain);
+        timestamp = CMNewDateTime(broker, s);
+        CMSetProperty(ind, "IndicationTime",
+                (CMPIValue *)&timestamp, CMPI_dateTime);
+        
+        dom = virDomainLookupByName(conn, job->domain);
+        if (dom == NULL)
                 goto out;
-        }
 
-        if(virDomainGetUUIDString(dom, uuid) != 0) {
+        if (virDomainGetUUIDString(dom, uuid) != 0) {
                 CU_DEBUG("Failed to get UUID from domain name");
                 goto out;
         }
@@ -846,10 +853,6 @@
         CMSetProperty(ind, "IndicationIdentifier",
                 (CMPIValue *)uuid, CMPI_chars);
 
-        timestamp = CMNewDateTime(broker, s);
-        CMSetProperty(ind, "IndicationTime",
-                (CMPIValue *)&timestamp, CMPI_dateTime);
-
         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
@@ -867,6 +870,7 @@
 
  out:
         virDomainFree(dom);
+        virConnectClose(conn);
         return ind;
 }
 




More information about the Libvirt-cim mailing list