[PATCH 00 of 10] #3 - Adopt get_() common look and feel to DevicePool and Adopted interface changes to assocs

Adopted the get_() function look and feel to the DevicePool provider. Updated the association providers that uses these functions. Diff to patch set 1: - patch #1 (svpc_types) - add Resource Pool types to svpc_types.h and map existing types to base resource types - patch #2 (DevicePool) - implement configurable enum_pools() function; adopt resource types - patch #6 (EAFP) - adopt resource types; validate client given device ref - patch #7 (AC) - adopt DevicePool interface changes; updated NOT_FOUND error message to be consistent with others Diff to patch set 2: - unified resource types to CIM_RES_TYPE_foo and adopted these changes to the providers - fixed some style issues

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204794319 -3600 # Node ID 4b2f3847b668b639473777171ec78263a2471c40 # Parent 58da2f9d92e39567b75d8537a833aba0da994f92 Add Resource Pool types to svpc_types.h This patch reorganizes the resource types. It defines common resource types for: - ALL - PROC - MEM - NET - DISK - UNKNOWN and maps the corresponding class specific resource types to these base types. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 58da2f9d92e3 -r 4b2f3847b668 libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Mon Mar 03 09:58:19 2008 -0800 +++ b/libxkutil/device_parsing.h Thu Mar 06 10:05:19 2008 +0100 @@ -64,11 +64,11 @@ struct graphics_device { struct virt_device { enum { - VIRT_DEV_NET = CIM_RASD_TYPE_NET, - VIRT_DEV_DISK = CIM_RASD_TYPE_DISK, - VIRT_DEV_MEM = CIM_RASD_TYPE_MEM, - VIRT_DEV_VCPU = CIM_RASD_TYPE_PROC, - VIRT_DEV_UNKNOWN = 1000, + VIRT_DEV_NET = CIM_RES_TYPE_NET, + VIRT_DEV_DISK = CIM_RES_TYPE_DISK, + VIRT_DEV_MEM = CIM_RES_TYPE_MEM, + VIRT_DEV_VCPU = CIM_RES_TYPE_PROC, + VIRT_DEV_UNKNOWN = CIM_RES_TYPE_UNKNOWN, VIRT_DEV_EMU, VIRT_DEV_GRAPHICS, } type; diff -r 58da2f9d92e3 -r 4b2f3847b668 src/svpc_types.h --- a/src/svpc_types.h Mon Mar 03 09:58:19 2008 -0800 +++ b/src/svpc_types.h Thu Mar 06 10:05:19 2008 +0100 @@ -22,10 +22,12 @@ #ifndef __SVPC_TYPES_H #define __SVPC_TYPES_H -#define CIM_RASD_TYPE_PROC 3 -#define CIM_RASD_TYPE_MEM 4 -#define CIM_RASD_TYPE_NET 10 -#define CIM_RASD_TYPE_DISK 17 +#define CIM_RES_TYPE_ALL 0 +#define CIM_RES_TYPE_PROC 3 +#define CIM_RES_TYPE_MEM 4 +#define CIM_RES_TYPE_NET 10 +#define CIM_RES_TYPE_DISK 17 +#define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_VSSD_RECOVERY_NONE 2 #define CIM_VSSD_RECOVERY_RESTART 3

HE> struct virt_device { HE> enum { HE> - VIRT_DEV_NET = CIM_RASD_TYPE_NET, HE> - VIRT_DEV_DISK = CIM_RASD_TYPE_DISK, HE> - VIRT_DEV_MEM = CIM_RASD_TYPE_MEM, HE> - VIRT_DEV_VCPU = CIM_RASD_TYPE_PROC, HE> - VIRT_DEV_UNKNOWN = 1000, HE> + VIRT_DEV_NET = CIM_RES_TYPE_NET, HE> + VIRT_DEV_DISK = CIM_RES_TYPE_DISK, HE> + VIRT_DEV_MEM = CIM_RES_TYPE_MEM, HE> + VIRT_DEV_VCPU = CIM_RES_TYPE_PROC, HE> + VIRT_DEV_UNKNOWN = CIM_RES_TYPE_UNKNOWN, HE> VIRT_DEV_EMU, HE> VIRT_DEV_GRAPHICS, HE> } type; Are the VIRT_DEV_foo constants used anywhere else? It looks to me that they are mostly stripped out, with the exception of maybe some of the device_parsing stuff. I don't think it's a good idea to set dev->type=A in device_parsing, but check for dev->type==B everywhere else, even though we know A==B. Do you mind if we try to make this a clean change instead of an incremental one? I think breaking out the first few patches into a separate set to do the switchover is appropriate. Anyone else have any thoughts about this? Sorry to drag this out, Heidi... :| -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
HE> struct virt_device { HE> enum { HE> - VIRT_DEV_NET = CIM_RASD_TYPE_NET, HE> - VIRT_DEV_DISK = CIM_RASD_TYPE_DISK, HE> - VIRT_DEV_MEM = CIM_RASD_TYPE_MEM, HE> - VIRT_DEV_VCPU = CIM_RASD_TYPE_PROC, HE> - VIRT_DEV_UNKNOWN = 1000, HE> + VIRT_DEV_NET = CIM_RES_TYPE_NET, HE> + VIRT_DEV_DISK = CIM_RES_TYPE_DISK, HE> + VIRT_DEV_MEM = CIM_RES_TYPE_MEM, HE> + VIRT_DEV_VCPU = CIM_RES_TYPE_PROC, HE> + VIRT_DEV_UNKNOWN = CIM_RES_TYPE_UNKNOWN, HE> VIRT_DEV_EMU, HE> VIRT_DEV_GRAPHICS, HE> } type;
Are the VIRT_DEV_foo constants used anywhere else? It looks to me that they are mostly stripped out, with the exception of maybe some of the device_parsing stuff.
I don't think it's a good idea to set dev->type=A in device_parsing, but check for dev->type==B everywhere else, even though we know A==B. Do you mind if we try to make this a clean change instead of an incremental one?
I think breaking out the first few patches into a separate set to do the switchover is appropriate.
It'll end up being one large set though, or several smaller sets all dependent on one another. The "#2 - Add configurable enum_devices() to Device provider and Adopt interface changes to SD & EAFP" also removes some of the VIRT_DEV_* types. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797484 -3600 # Node ID f5794941df79b894318965b235cb0b7b54050d3d # Parent 4b2f3847b668b639473777171ec78263a2471c40 RASD: update resource types to CIM_RES_TYPE_foo Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 4b2f3847b668 -r f5794941df79 src/Virt_RASD.c --- a/src/Virt_RASD.c Thu Mar 06 10:05:19 2008 +0100 +++ b/src/Virt_RASD.c Thu Mar 06 10:58:04 2008 +0100 @@ -292,17 +292,17 @@ static CMPIInstance *rasd_from_vdev(cons char *base; char *id; - if (dev->type == VIRT_DEV_DISK) { - type = CIM_RASD_TYPE_DISK; + if (dev->type == CIM_RES_TYPE_DISK) { + type = CIM_RES_TYPE_DISK; base = "DiskResourceAllocationSettingData"; - } else if (dev->type == VIRT_DEV_NET) { - type = CIM_RASD_TYPE_NET; + } else if (dev->type == CIM_RES_TYPE_NET) { + type = CIM_RES_TYPE_NET; base = "NetResourceAllocationSettingData"; - } else if (dev->type == VIRT_DEV_VCPU) { - type = CIM_RASD_TYPE_PROC; + } else if (dev->type == CIM_RES_TYPE_PROC) { + type = CIM_RES_TYPE_PROC; base = "ProcResourceAllocationSettingData"; - } else if (dev->type == VIRT_DEV_MEM) { - type = CIM_RASD_TYPE_MEM; + } else if (dev->type == CIM_RES_TYPE_MEM) { + type = CIM_RES_TYPE_MEM; base = "MemResourceAllocationSettingData"; } else { return NULL; @@ -329,7 +329,7 @@ static CMPIInstance *rasd_from_vdev(cons CMSetProperty(inst, "ResourceType", (CMPIValue *)&type, CMPI_uint16); - if (dev->type == VIRT_DEV_DISK) { + if (dev->type == CIM_RES_TYPE_DISK) { CMSetProperty(inst, "VirtualDevice", (CMPIValue *)dev->dev.disk.virtual_dev, @@ -338,12 +338,12 @@ static CMPIInstance *rasd_from_vdev(cons "Address", (CMPIValue *)dev->dev.disk.source, CMPI_chars); - } else if (dev->type == VIRT_DEV_NET) { + } else if (dev->type == CIM_RES_TYPE_NET) { CMSetProperty(inst, "NetworkType", (CMPIValue *)dev->dev.disk.type, CMPI_chars); - } else if (dev->type == VIRT_DEV_MEM) { + } else if (dev->type == CIM_RES_TYPE_MEM) { const char *units = "MegaBytes"; CMSetProperty(inst, "AllocationUnits", @@ -354,7 +354,7 @@ static CMPIInstance *rasd_from_vdev(cons (CMPIValue *)&dev->dev.mem.size, CMPI_uint64); CMSetProperty(inst, "Limit", (CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64); - } else if (dev->type == VIRT_DEV_VCPU) { + } else if (dev->type == CIM_RES_TYPE_PROC) { proc_rasd_from_vdev(broker, dev, host, ref, inst); } @@ -470,13 +470,13 @@ CMPIrc rasd_type_from_classname(const ch goto out; if (STREQ(base, "DiskResourceAllocationSettingData")) - *type = CIM_RASD_TYPE_DISK; + *type = CIM_RES_TYPE_DISK; else if (STREQ(base, "NetResourceAllocationSettingData")) - *type = CIM_RASD_TYPE_NET; + *type = CIM_RES_TYPE_NET; else if (STREQ(base, "ProcResourceAllocationSettingData")) - *type = CIM_RASD_TYPE_PROC; + *type = CIM_RES_TYPE_PROC; else if (STREQ(base, "MemResourceAllocationSettingData")) - *type = CIM_RASD_TYPE_MEM; + *type = CIM_RES_TYPE_MEM; else goto out; @@ -493,16 +493,16 @@ CMPIrc rasd_classname_from_type(uint16_t CMPIrc rc = CMPI_RC_OK; switch(type) { - case CIM_RASD_TYPE_MEM: + case CIM_RES_TYPE_MEM: *classname = "MemResourceAllocationSettingData"; break; - case CIM_RASD_TYPE_PROC: + case CIM_RES_TYPE_PROC: *classname = "ProcResourceAllocationSettingData"; break; - case CIM_RASD_TYPE_NET: + case CIM_RES_TYPE_NET: *classname = "NetResourceAllocationSettingData"; break; - case CIM_RASD_TYPE_DISK: + case CIM_RES_TYPE_DISK: *classname = "DiskResourceAllocationSettingData"; break; default: @@ -522,10 +522,10 @@ static CMPIStatus _enum_rasds(const CMPI int i, j; uint16_t type; CMPIStatus s; - uint16_t types[] = {CIM_RASD_TYPE_PROC, - CIM_RASD_TYPE_DISK, - CIM_RASD_TYPE_NET, - CIM_RASD_TYPE_MEM, + uint16_t types[] = {CIM_RES_TYPE_PROC, + CIM_RES_TYPE_DISK, + CIM_RES_TYPE_NET, + CIM_RES_TYPE_MEM, 0}; conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797484 -3600 # Node ID fe35567bbbb9af8ce77dac9dbd1148389aee9e06 # Parent f5794941df79b894318965b235cb0b7b54050d3d VSMS: update resource types to CIM_RES_TYPE_foo Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r f5794941df79 -r fe35567bbbb9 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Thu Mar 06 10:58:04 2008 +0100 +++ b/src/Virt_VirtualSystemManagementService.c Thu Mar 06 10:58:04 2008 +0100 @@ -231,7 +231,7 @@ static int rasd_to_vdev(CMPIInstance *in if (!parse_fq_devid(id, &name, &devid)) goto err; - if (type == VIRT_DEV_DISK) { + if (type == CIM_RES_TYPE_DISK) { free(dev->dev.disk.virtual_dev); dev->dev.disk.virtual_dev = devid; @@ -241,7 +241,7 @@ static int rasd_to_vdev(CMPIInstance *in free(dev->dev.disk.source); dev->dev.disk.source = strdup(val); dev->dev.disk.disk_type = disk_type_from_file(val); - } else if (type == VIRT_DEV_NET) { + } else if (type == CIM_RES_TYPE_NET) { free(dev->dev.net.mac); dev->dev.net.mac = devid; @@ -253,7 +253,7 @@ static int rasd_to_vdev(CMPIInstance *in CU_DEBUG("Unknown class type for net device: %s", CLASSNAME(op)); - } else if (type == VIRT_DEV_MEM) { + } else if (type == CIM_RES_TYPE_MEM) { cu_get_u64_prop(inst, "VirtualQuantity", &dev->dev.mem.size); cu_get_u64_prop(inst, "Reservation", &dev->dev.mem.size); dev->dev.mem.maxsize = dev->dev.mem.size; @@ -307,16 +307,16 @@ static int classify_resources(CMPIArray CMPI_RC_OK) return 0; - if (type == CIM_RASD_TYPE_PROC) + if (type == CIM_RES_TYPE_PROC) rasd_to_vdev(item.value.inst, &domain->dev_vcpu[domain->dev_vcpu_ct++]); - else if (type == CIM_RASD_TYPE_MEM) + else if (type == CIM_RES_TYPE_MEM) rasd_to_vdev(item.value.inst, &domain->dev_mem[domain->dev_mem_ct++]); - else if (type == CIM_RASD_TYPE_DISK) + else if (type == CIM_RES_TYPE_DISK) rasd_to_vdev(item.value.inst, &domain->dev_disk[domain->dev_disk_ct++]); - else if (type == CIM_RASD_TYPE_NET) + else if (type == CIM_RES_TYPE_NET) rasd_to_vdev(item.value.inst, &domain->dev_net[domain->dev_net_ct++]); } @@ -613,16 +613,16 @@ static struct virt_device **find_list(st { struct virt_device **list = NULL; - if (type == VIRT_DEV_NET) { + if (type == CIM_RES_TYPE_NET) { list = &dominfo->dev_net; *count = &dominfo->dev_net_ct; - } else if (type == VIRT_DEV_DISK) { + } else if (type == CIM_RES_TYPE_DISK) { list = &dominfo->dev_disk; *count = &dominfo->dev_disk_ct; - } else if (type == VIRT_DEV_VCPU) { + } else if (type == CIM_RES_TYPE_PROC) { list = &dominfo->dev_vcpu; *count = &dominfo->dev_vcpu_ct; - } else if (type == VIRT_DEV_MEM) { + } else if (type == CIM_RES_TYPE_MEM) { list = &dominfo->dev_mem; *count = &dominfo->dev_mem_ct; } @@ -713,7 +713,7 @@ static CMPIStatus resource_del(struct do goto out; _list = find_list(dominfo, type, &count); - if ((type == CIM_RASD_TYPE_MEM) || (_list != NULL)) + if ((type == CIM_RES_TYPE_MEM) || (_list != NULL)) list = *_list; else { cu_statusf(_BROKER, &s, @@ -734,7 +734,7 @@ static CMPIStatus resource_del(struct do dev, RESOURCE_DEL, CLASSNAME(op)); - dev->type = VIRT_DEV_UNKNOWN; + dev->type = CIM_RES_TYPE_UNKNOWN; break; } } @@ -760,7 +760,7 @@ static CMPIStatus resource_add(struct do goto out; _list = find_list(dominfo, type, &count); - if ((type == CIM_RASD_TYPE_MEM) || (_list == NULL)) { + if ((type == CIM_RES_TYPE_MEM) || (_list == NULL)) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Cannot add resources of type %" PRIu16, type);

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797486 -3600 # Node ID bcfdb432ac3a01af32dff70572a81e7c1823c038 # Parent fe35567bbbb9af8ce77dac9dbd1148389aee9e06 DevicePool: reorganize get and enum functions - the common look and feel of the get_..._by_name() and get_..._by_ref() is adopted - get_all_pools() is renamed to enum_pools and rewritten to be configurable dynamically - return either a specific or all resource pools. This also replaces get_pool_by_type(). - the device_pool_names array is removed and types are identified by the CIM_RES_TYPE_..., as defined in svpc_types.h - renamed device_type_by_poolid to res_type_by_pool_id Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r fe35567bbbb9 -r bcfdb432ac3a src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Thu Mar 06 10:58:04 2008 +0100 +++ b/src/Virt_DevicePool.c Thu Mar 06 10:58:06 2008 +0100 @@ -45,12 +45,6 @@ static const CMPIBroker *_BROKER; -char *device_pool_names[] = {"ProcessorPool", - "MemoryPool", - "DiskPool", - "NetworkPool", - NULL}; - struct disk_pool { char *tag; char *path; @@ -174,7 +168,7 @@ static char *diskpool_member_of(const CM if (dom == NULL) goto out; - count = get_devices(dom, &devs, VIRT_DEV_DISK); + count = get_devices(dom, &devs, CIM_RES_TYPE_DISK); for (i = 0; i < count; i++) { if (STREQ((devs[i].dev.disk.virtual_dev), dev)) { @@ -290,7 +284,7 @@ static char *netpool_member_of(const CMP if (dom == NULL) goto out; - count = get_devices(dom, &devs, VIRT_DEV_NET); + count = get_devices(dom, &devs, CIM_RES_TYPE_NET); for (i = 0; i < count; i++) { if (STREQ((devs[i].id), dev)) { @@ -318,13 +312,13 @@ char *pool_member_of(const CMPIBroker *b { char *poolid = NULL; - if (type == CIM_RASD_TYPE_PROC) + if (type == CIM_RES_TYPE_PROC) poolid = strdup("ProcessorPool/0"); - else if (type == CIM_RASD_TYPE_MEM) + else if (type == CIM_RES_TYPE_MEM) poolid = strdup("MemoryPool/0"); - else if (type == CIM_RASD_TYPE_NET) + else if (type == CIM_RES_TYPE_NET) poolid = netpool_member_of(broker, id, refcn); - else if (type == CIM_RASD_TYPE_DISK) + else if (type == CIM_RES_TYPE_DISK) poolid = diskpool_member_of(broker, id, refcn); else return NULL; @@ -332,18 +326,32 @@ char *pool_member_of(const CMPIBroker *b return poolid; } -uint16_t device_type_from_poolid(const char *id) +uint16_t res_type_from_pool_classname(const char *classname) +{ + if (strstr(classname, "NetworkPool")) + return CIM_RES_TYPE_NET; + else if (strstr(classname, "DiskPool")) + return CIM_RES_TYPE_DISK; + else if (strstr(classname, "MemoryPool")) + return CIM_RES_TYPE_MEM; + else if (strstr(classname, "ProcessorPool")) + return CIM_RES_TYPE_PROC; + else + return CIM_RES_TYPE_UNKNOWN; +} + +uint16_t res_type_from_pool_id(const char *id) { if (STARTS_WITH(id, "NetworkPool")) - return VIRT_DEV_NET; + return CIM_RES_TYPE_NET; else if (STARTS_WITH(id, "DiskPool")) - return VIRT_DEV_DISK; + return CIM_RES_TYPE_DISK; else if (STARTS_WITH(id, "MemoryPool")) - return VIRT_DEV_MEM; + return CIM_RES_TYPE_MEM; else if (STARTS_WITH(id, "ProcessorPool")) - return VIRT_DEV_VCPU; + return CIM_RES_TYPE_PROC; else - return VIRT_DEV_UNKNOWN; + return CIM_RES_TYPE_UNKNOWN; } static bool mempool_set_total(CMPIInstance *inst, virConnectPtr conn) @@ -412,7 +420,7 @@ static CMPIStatus mempool_instance(virCo const CMPIBroker *broker) { const char *id = "MemoryPool/0"; - uint16_t type = CIM_RASD_TYPE_MEM; + uint16_t type = CIM_RES_TYPE_MEM; CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -450,7 +458,7 @@ static CMPIStatus procpool_instance(virC const CMPIBroker *broker) { const char *id = "ProcessorPool/0"; - uint16_t type = CIM_RASD_TYPE_PROC; + uint16_t type = CIM_RES_TYPE_PROC; CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -489,7 +497,7 @@ static CMPIStatus _netpool_for_network(s { char *str = NULL; char *bridge = NULL; - uint16_t type = CIM_RASD_TYPE_NET; + uint16_t type = CIM_RES_TYPE_NET; CMPIInstance *inst; virNetworkPtr network = NULL; @@ -595,7 +603,7 @@ static CMPIInstance *diskpool_from_path( { CMPIInstance *inst; char *poolid = NULL; - const uint16_t type = CIM_RASD_TYPE_DISK; + const uint16_t type = CIM_RES_TYPE_DISK; struct statvfs vfs; uint64_t cap; uint64_t res; @@ -673,177 +681,190 @@ static CMPIStatus diskpool_instance(virC return s; } -static CMPIStatus _get_pool(const CMPIBroker *broker, - virConnectPtr conn, - const char *type, +static CMPIStatus _get_pools(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const uint16_t type, + const char *id, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; + + if ((type == CIM_RES_TYPE_PROC) || + (type == CIM_RES_TYPE_ALL)) + s = procpool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if ((type == CIM_RES_TYPE_MEM) || + (type == CIM_RES_TYPE_ALL)) + s = mempool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if ((type == CIM_RES_TYPE_NET) || + (type == CIM_RES_TYPE_ALL)) + s = netpool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if ((type == CIM_RES_TYPE_DISK) || + (type == CIM_RES_TYPE_ALL)) + s = diskpool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if (type == CIM_RES_TYPE_UNKNOWN) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance - resource pool type unknown"); + + if (id && list->cur == 0) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", id); + + out: + virConnectClose(conn); + return s; +} + +CMPIStatus get_pool_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, const char *id, - const char *ns, - struct inst_list *list) -{ - if (STARTS_WITH(type, "MemoryPool")) - return mempool_instance(conn, list, ns, id, broker); - else if (STARTS_WITH(type, "ProcessorPool")) - return procpool_instance(conn, list, ns, id, broker); - else if (STARTS_WITH(type, "NetworkPool")) - return netpool_instance(conn, list, ns, id, broker); - else if (STARTS_WITH(type, "DiskPool")) - return diskpool_instance(conn, list, ns, id, broker); - - return (CMPIStatus){CMPI_RC_ERR_NOT_FOUND, NULL}; -} - -CMPIStatus get_pool_by_type(const CMPIBroker *broker, - virConnectPtr conn, - const char *type, - const char *ns, - struct inst_list *list) -{ - return _get_pool(broker, conn, type, NULL, ns, list); -} - -CMPIInstance *get_pool_by_id(const CMPIBroker *broker, - virConnectPtr conn, - const char *id, - const char *ns) -{ - CMPIInstance *inst = NULL; - CMPIStatus s; - char *type = NULL; + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + struct inst_list list; char *poolid = NULL; int ret; - struct inst_list list; + uint16_t type; inst_list_init(&list); - ret = sscanf(id, "%a[^/]/%as", &type, &poolid); - if (ret != 2) - goto out; - - s = _get_pool(broker, conn, type, poolid, ns, &list); - if ((s.rc == CMPI_RC_OK) && (list.cur > 0)) - inst = list.list[0]; - - out: + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } + + type = res_type_from_pool_id(id); + + if (type == CIM_RES_TYPE_UNKNOWN) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s) - resource pool type mismatch", + id); + goto out; + } + + ret = sscanf(id, "%*[^/]/%as", &poolid); + if (ret != 1) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", + id); + goto out; + } + + s = _get_pools(broker, reference, type, poolid, &list); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = list.list[0]; + + out: + free(poolid); + virConnectClose(conn); inst_list_free(&list); - return inst; -} - -CMPIStatus get_all_pools(const CMPIBroker *broker, - virConnectPtr conn, - const char *ns, - struct inst_list *list) -{ - int i; + return s; +} + +CMPIStatus get_pool_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **instance) +{ CMPIStatus s = {CMPI_RC_OK}; - - for (i = 0; device_pool_names[i]; i++) { - s = get_pool_by_type(broker, - conn, - device_pool_names[i], - ns, - list); - if (s.rc != CMPI_RC_OK) - goto out; - } - + CMPIInstance *inst = NULL; + const char *id = NULL; + uint16_t type_cls; + uint16_t type_id; + + if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID"); + goto out; + } + + type_cls = res_type_from_pool_classname(CLASSNAME(reference)); + type_id = res_type_from_pool_id(id); + + if ((type_cls != type_id) || + (type_cls == CIM_RES_TYPE_UNKNOWN)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s) - resource pool type mismatch", + id); + goto out; + } + + s = get_pool_by_name(broker, reference, id, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *instance = inst; + out: return s; } -static void __return_pool(const CMPIResult *results, - struct inst_list *list, - bool name_only) -{ - if (name_only) - cu_return_instance_names(results, list); - else - cu_return_instances(results, list); +CMPIStatus enum_pools(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const uint16_t type, + struct inst_list *list) +{ + return _get_pools(broker, reference, type, NULL, list); } static CMPIStatus return_pool(const CMPIObjectPath *ref, const CMPIResult *results, - bool name_only, - bool single_only) -{ - CMPIStatus s; - char *type; - virConnectPtr conn; + bool names_only) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; struct inst_list list; if (!provider_is_responsible(_BROKER, ref, &s)) - return s; - - type = class_base_name(CLASSNAME(ref)); - if (type == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid classname `%s'", CLASSNAME(ref)); - return s; - } + goto out; inst_list_init(&list); - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - s = get_pool_by_type(_BROKER, - conn, - type, - NAMESPACE(ref), - &list); - if (s.rc == CMPI_RC_OK) { - __return_pool(results, &list, name_only); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - } else { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Pool type %s not found", type); - } - - out: - free(type); + s = enum_pools(_BROKER, + ref, + res_type_from_pool_classname(CLASSNAME(ref)), + &list); + if (s.rc != CMPI_RC_OK) + goto out; + + if (names_only) + cu_return_instance_names(results, &list); + else + cu_return_instances(results, &list); + + out: inst_list_free(&list); - - return s; -} - -CMPIStatus get_pool_inst(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance) -{ - CMPIStatus s; - CMPIInstance *inst = NULL; - virConnectPtr conn = NULL; - const char *id = NULL; - - if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Missing InstanceID"); - goto out; - } - - conn = connect_by_classname(broker, CLASSNAME(reference), &s); - if (conn == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance"); - goto out; - } - - inst = get_pool_by_id(broker, conn, id, NAMESPACE(reference)); - if (inst == NULL) - cu_statusf(broker, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", id); - - out: - virConnectClose(conn); - *instance = inst; return s; } @@ -853,7 +874,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_pool(reference, results, true, false); + return return_pool(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -862,7 +883,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return return_pool(reference, results, false, false); + return return_pool(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -871,13 +892,16 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK}; CMPIInstance *inst = NULL; - s = get_pool_inst(_BROKER, reference, &inst); - if ((s.rc == CMPI_RC_OK) && (inst != NULL)) - CMReturnInstance(results, inst); - + s = get_pool_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: return s; } diff -r fe35567bbbb9 -r bcfdb432ac3a src/Virt_DevicePool.h --- a/src/Virt_DevicePool.h Thu Mar 06 10:58:04 2008 +0100 +++ b/src/Virt_DevicePool.h Thu Mar 06 10:58:06 2008 +0100 @@ -26,20 +26,6 @@ #include <libcmpiutil/libcmpiutil.h> #include <stdint.h> -extern char *device_pool_names[]; - -CMPIStatus get_pool_by_type(const CMPIBroker *broker, - virConnectPtr conn, - const char *type, - const char *ns, - struct inst_list *list); - -CMPIInstance *get_pool_by_id(const CMPIBroker *broker, - virConnectPtr conn, - const char *id, - const char *ns); - - /** * Get the InstanceID of a pool that a given RASD id (for type) is in * @@ -56,24 +42,35 @@ char *pool_member_of(const CMPIBroker *b const char *id); /** - * Get the device type of a given pool from the pool's InstanceID + * Get the resource type of a given pool from the pool's classname + * + * @param classname The classname of the pool + * Returns the resource type + */ +uint16_t res_type_from_pool_classname(const char *classname); + +/** + * Get the resource type of a given pool from the pool's InstanceID * * @param id The InstanceID of the pool + * Returns the resource type */ -uint16_t device_type_from_poolid(const char *id); +uint16_t res_type_from_pool_id(const char *id); /** - * Get all device pools on the system for the given connection + * Get all device pools on the system for the given type + * * * @param broker The current Broker - * @param conn The libvirt connection to use - * @param ns Namespace for the pools - * @param list Return instances in this struct + * @param reference Defines the libvirt connection to use + * @param type The device pool type or CIM_RES_TYPE_ALL + * to get all resource pools + * @param list The list of returned instances */ -CMPIStatus get_all_pools(const CMPIBroker *broker, - virConnectPtr conn, - const char *ns, - struct inst_list *list); +CMPIStatus enum_pools(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const uint16_t type, + struct inst_list *list); /** * Get a device pools instance for the given reference @@ -82,9 +79,23 @@ CMPIStatus get_all_pools(const CMPIBroke * @param reference The reference passed to the CIMOM * @param instance Return corresponding instance */ -CMPIStatus get_pool_inst(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance); +CMPIStatus get_pool_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **instance); + +/** + * Get device pool instance specified by the id + * + * @param broker A pointer to the current broker + * @param ref The object path containing namespace and prefix info + * @param name The device pool id + * @param _inst In case of success the pointer to the instance + * @returns CMPIStatus + */ +CMPIStatus get_pool_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *id, + CMPIInstance **_inst); #endif

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797486 -3600 # Node ID 7bf83e55471f88bf78472f79b926a0573f80729a # Parent bcfdb432ac3a01af32dff70572a81e7c1823c038 AllocationCapabilities: adopt new DevicePool enum interface - adopted new DevicePool enum_pools() interface - updated NOT_FOUND error message to be consistent with others - updated resource type to CIM_RES_TYPE_foo Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r bcfdb432ac3a -r 7bf83e55471f src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Thu Mar 06 10:58:06 2008 +0100 +++ b/src/Virt_AllocationCapabilities.c Thu Mar 06 10:58:06 2008 +0100 @@ -33,6 +33,7 @@ #include "Virt_AllocationCapabilities.h" #include "Virt_DevicePool.h" +#include "svpc_types.h" const static CMPIBroker *_BROKER; @@ -95,11 +96,11 @@ CMPIStatus enum_alloc_cap_instances(cons if (id) cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, - "Requested Object could not be found."); - goto out; - } - - s = get_all_pools(broker, conn, NAMESPACE(ref), &device_pool_list); + "Instance not found."); + goto out; + } + + s = enum_pools(broker, ref, CIM_RES_TYPE_ALL, &device_pool_list); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -135,7 +136,7 @@ CMPIStatus enum_alloc_cap_instances(cons if (id && !inst_id) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, - "Requested Object could not be found."); + "Instance not found."); goto out; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797487 -3600 # Node ID 8eee311470e991e9ed8ebdef20e863c6f738ecf9 # Parent 7bf83e55471f88bf78472f79b926a0573f80729a SDC: adopt DevicePool interface change - adopted changes to DevicePool interface Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 7bf83e55471f -r 8eee311470e9 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Thu Mar 06 10:58:06 2008 +0100 +++ b/src/Virt_SettingsDefineCapabilities.c Thu Mar 06 10:58:07 2008 +0100 @@ -529,13 +529,9 @@ static struct sdc_rasd_prop *disk_max(co /* Getting the relevant resource pool directly finds the free space for us. It is in the Capacity field. */ - pool_inst = get_pool_by_id(_BROKER, conn, inst_id, NAMESPACE(ref)); - if (pool_inst == NULL) { - cu_statusf(_BROKER, s, - CMPI_RC_ERR_FAILED, - "Could not get pool instance"); - goto out; - } + *s = get_pool_by_name(_BROKER, ref, inst_id, &pool_inst); + if (s->rc != CMPI_RC_OK) + goto out; prop_ret = cu_get_u64_prop(pool_inst, "Capacity", &free_64); if (prop_ret != CMPI_RC_OK) { @@ -614,7 +610,7 @@ static struct sdc_rasd_prop *disk_inc(co } static struct sdc_rasd mem = { - .resource_type = CIM_RASD_TYPE_MEM, + .resource_type = CIM_RES_TYPE_MEM, .min = mem_min, .max = mem_max, .def = mem_def, @@ -622,7 +618,7 @@ static struct sdc_rasd mem = { }; static struct sdc_rasd processor = { - .resource_type = CIM_RASD_TYPE_PROC, + .resource_type = CIM_RES_TYPE_PROC, .min = proc_min, .max = proc_max, .def = proc_def, @@ -630,7 +626,7 @@ static struct sdc_rasd processor = { }; static struct sdc_rasd network = { - .resource_type = CIM_RASD_TYPE_NET, + .resource_type = CIM_RES_TYPE_NET, .min = net_min, .max = net_max, .def = net_def, @@ -638,7 +634,7 @@ static struct sdc_rasd network = { }; static struct sdc_rasd disk = { - .resource_type = CIM_RASD_TYPE_DISK, + .resource_type = CIM_RES_TYPE_DISK, .min = disk_min, .max = disk_max, .def = disk_def, @@ -794,8 +790,6 @@ static CMPIStatus alloc_cap_to_rasd(cons if (!match_hypervisor_prefix(ref, info)) return s; - CU_DEBUG("Getting ResourceType"); - if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -803,11 +797,9 @@ static CMPIStatus alloc_cap_to_rasd(cons goto out; } - type = device_type_from_poolid(id); - - CU_DEBUG("ResourceType: %hi", type); - - if (type == VIRT_DEV_UNKNOWN) { + type = res_type_from_pool_id(id); + + if (type == CIM_RES_TYPE_UNKNOWN) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Unable to determine resource type");

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797487 -3600 # Node ID ea35090f8613c2a6af6993bd02cbfed709792110 # Parent 8eee311470e991e9ed8ebdef20e863c6f738ecf9 HRP: adopt DevicePool interface change - adopted changes to DevicePool interface Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 8eee311470e9 -r ea35090f8613 src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Thu Mar 06 10:58:07 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Thu Mar 06 10:58:07 2008 +0100 @@ -34,6 +34,7 @@ #include "Virt_HostSystem.h" #include "Virt_DevicePool.h" +#include "svpc_types.h" static const CMPIBroker *_BROKER; @@ -47,8 +48,8 @@ static CMPIStatus pool_to_sys(const CMPI if (!match_hypervisor_prefix(ref, info)) goto out; - s = get_pool_inst(_BROKER, ref, &inst); - if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + s = get_pool_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; s = get_host(_BROKER, ref, &inst, false); @@ -67,26 +68,15 @@ static CMPIStatus sys_to_pool(const CMPI { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - int i; - virConnectPtr conn; if (!match_hypervisor_prefix(ref, info)) goto out; - + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - for (i = 0; device_pool_names[i]; i++) - get_pool_by_type(_BROKER, - conn, - device_pool_names[i], - NAMESPACE(ref), - list); + s = enum_pools(_BROKER, ref, CIM_RES_TYPE_ALL, list); out: return s;

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797488 -3600 # Node ID 91ac728ec7c9b5e68b73d90039aa75f293978dd3 # Parent ea35090f8613c2a6af6993bd02cbfed709792110 VSSDC: update resource types to CIM_RES_TYPE_foo Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r ea35090f8613 -r 91ac728ec7c9 src/Virt_VSSDComponent.c --- a/src/Virt_VSSDComponent.c Thu Mar 06 10:58:07 2008 +0100 +++ b/src/Virt_VSSDComponent.c Thu Mar 06 10:58:08 2008 +0100 @@ -45,10 +45,10 @@ static CMPIStatus vssd_to_rasd(const CMP char *name = NULL; int i = 0; int types[] = { - CIM_RASD_TYPE_PROC, - CIM_RASD_TYPE_NET, - CIM_RASD_TYPE_DISK, - CIM_RASD_TYPE_MEM, + CIM_RES_TYPE_PROC, + CIM_RES_TYPE_NET, + CIM_RES_TYPE_DISK, + CIM_RES_TYPE_MEM, -1 };

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797489 -3600 # Node ID 64e4b5f13878ff7b1ba59bea42709d0cac1c7bbc # Parent 91ac728ec7c9b5e68b73d90039aa75f293978dd3 RAFP: adopt DevicePool interface changes - adopted changes to DevicePool interface Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 91ac728ec7c9 -r 64e4b5f13878 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Thu Mar 06 10:58:08 2008 +0100 +++ b/src/Virt_ResourceAllocationFromPool.c Thu Mar 06 10:58:09 2008 +0100 @@ -45,7 +45,6 @@ static CMPIStatus rasd_to_pool(const CMP uint16_t type; const char *id = NULL; char *poolid = NULL; - virConnectPtr conn = NULL; CMPIInstance *pool = NULL; CMPIInstance *inst = NULL; @@ -78,28 +77,17 @@ static CMPIStatus rasd_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; } @@ -191,7 +179,11 @@ static CMPIStatus pool_to_rasd(const CMP CMPIInstance *inst; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + 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, @@ -200,17 +192,13 @@ static CMPIStatus pool_to_rasd(const CMP goto out; } - 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; rasds_from_pool(type, ref, @@ -218,9 +206,6 @@ static CMPIStatus pool_to_rasd(const CMP info->properties, list); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: return s; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204797490 -3600 # Node ID c342fe8a021484ae95e2ab48ca974ae2e7ca5e8e # Parent 64e4b5f13878ff7b1ba59bea42709d0cac1c7bbc EAFP: adopt DevicePool interface changes - adopted changes to DevicePool interface - updated resource types - validate client given device ref Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 64e4b5f13878 -r c342fe8a0214 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Thu Mar 06 10:58:09 2008 +0100 +++ b/src/Virt_ElementAllocatedFromPool.c Thu Mar 06 10:58:10 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) { + 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; }

Heidi Eckhart wrote:
Adopted the get_() function look and feel to the DevicePool provider. Updated the association providers that uses these functions.
Diff to patch set 1: - patch #1 (svpc_types) - add Resource Pool types to svpc_types.h and map existing types to base resource types - patch #2 (DevicePool) - implement configurable enum_pools() function; adopt resource types - patch #6 (EAFP) - adopt resource types; validate client given device ref - patch #7 (AC) - adopt DevicePool interface changes; updated NOT_FOUND error message to be consistent with others
Diff to patch set 2: - unified resource types to CIM_RES_TYPE_foo and adopted these changes to the providers - fixed some style issues
I've no complaints with this set. And it tested fine on my system. +1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Kaitlin Rupert