[Libvirt-cim] [PATCH 6 of 7] EAFP: adopt DevicePool interface changes

Heidi Eckhart heidieck at linux.vnet.ibm.com
Wed Mar 5 09:49:13 UTC 2008


# HG changeset patch
# User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
# Date 1204710377 -3600
# Node ID 2e9dc85abc269153ec38d1970b3e706168711f6c
# Parent  dfd9e623fef6ec927b06ab546857765b47482f87
EAFP: adopt DevicePool interface changes

- adopted changes to DevicePool interface
- updated resource types

Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>

diff -r dfd9e623fef6 -r 2e9dc85abc26 src/Virt_ElementAllocatedFromPool.c
--- a/src/Virt_ElementAllocatedFromPool.c	Wed Mar 05 10:33:38 2008 +0100
+++ b/src/Virt_ElementAllocatedFromPool.c	Wed Mar 05 10:46:17 2008 +0100
@@ -45,15 +45,15 @@ static uint16_t class_to_type(const CMPI
         uint16_t type;
 
         if (CMClassPathIsA(_BROKER, ref, "CIM_LogicalDisk", NULL))
-                type = CIM_RASD_TYPE_DISK;
+                type = CIM_RES_TYPE_DISK;
         else if (CMClassPathIsA(_BROKER, ref, "CIM_NetworkPort", NULL))
-                type = CIM_RASD_TYPE_NET;
+                type = CIM_RES_TYPE_NET;
         else if (CMClassPathIsA(_BROKER, ref, "CIM_Memory", NULL))
-                type = CIM_RASD_TYPE_MEM;
+                type = CIM_RES_TYPE_MEM;
         else if (CMClassPathIsA(_BROKER, ref, "CIM_Processor", NULL))
-                type = CIM_RASD_TYPE_PROC;
+                type = CIM_RES_TYPE_PROC;
         else
-                type = 0;
+                type = CIM_RES_TYPE_UNKNOWN;
 
         return type;
 }
@@ -66,12 +66,16 @@ static CMPIStatus vdev_to_pool(const CMP
         uint16_t type;
         const char *id = NULL;
         char *poolid = NULL;
-        virConnectPtr conn = NULL;
         CMPIInstance *pool = NULL;
+        CMPIInstance *inst = NULL;
 
         if (!match_hypervisor_prefix(ref, info))
                 return s;
 
+        s = get_device_by_ref(_BROKER, ref, &inst);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+
         type = class_to_type(ref);
         if (type == 0) {
                 cu_statusf(_BROKER, &s,
@@ -95,25 +99,14 @@ static CMPIStatus vdev_to_pool(const CMP
                 goto out;
         }
 
-        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
-        if (conn == NULL)
-                goto out;
-
-        pool = get_pool_by_id(_BROKER, conn, poolid, NAMESPACE(ref));
-        if (pool != NULL) {
-                inst_list_add(list, pool);
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_OK,
-                           "");
-        } else {
-                cu_statusf(_BROKER, &s,
-                           CMPI_RC_ERR_FAILED,
-                           "Unable to find pool `%s'", poolid);
-        }
+        s = get_pool_by_name(_BROKER, ref, poolid, &pool);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+
+        inst_list_add(list, pool);
 
  out:
         free(poolid);
-        virConnectClose(conn);
 
         return s;
 }
@@ -172,7 +165,6 @@ static int devs_from_pool(uint16_t type,
 
                 name = virDomainGetName(doms[i]);
 
-                /* FIXME: Get VIRT_DEV_ type here */
                 dom_devices(_BROKER, doms[i], ns, type, &tmp);
 
                 filter_by_pool(list, &tmp, type, poolid);
@@ -199,6 +191,10 @@ static CMPIStatus pool_to_vdev(const CMP
         if (!match_hypervisor_prefix(ref, info))
                 return s;
 
+        s = get_pool_by_ref(_BROKER, ref, &inst);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+
         if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
@@ -206,25 +202,16 @@ static CMPIStatus pool_to_vdev(const CMP
                 goto out;
         }
 
-        CU_DEBUG("Got %s\n", poolid);
-
         type = device_type_from_poolid(poolid);
-        if (type == VIRT_DEV_UNKNOWN) {
+        if (type == CIM_RES_TYPE_UNKNOWN) {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
                            "Invalid InstanceID or unsupported pool type");
                 goto out;
         }
 
-        s = get_pool_inst(_BROKER, ref, &inst);
-        if ((s.rc != CMPI_RC_OK) || (inst == NULL))
-                goto out;
-
         devs_from_pool(type, ref, poolid, list);
 
-        cu_statusf(_BROKER, &s,
-                   CMPI_RC_OK,
-                   "");
  out:
         return s;
 }




More information about the Libvirt-cim mailing list