# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1204892340 -3600
# Node ID d09896378f5dc5dfd70054a9c514682a23cd4fd3
# Parent 1488fea7392b76963e081ca5c638c8d89ce53860
EAFP: adopt DevicePool interface changes
- adopted changes to DevicePool interface
- updated resource types
- validate client given device ref
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 1488fea7392b -r d09896378f5d src/Virt_ElementAllocatedFromPool.c
--- a/src/Virt_ElementAllocatedFromPool.c Fri Mar 07 13:19:00 2008 +0100
+++ b/src/Virt_ElementAllocatedFromPool.c Fri Mar 07 13:19:00 2008 +0100
@@ -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) {
+ type = res_type_from_pool_id(poolid);
+ 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;
}