
From: Xu Wang <gesaint@linux.vnet.ibm.com> Support being able to convert the Controller RASD into a virtual device Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/Virt_VirtualSystemManagementService.c | 76 +++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 3e7785e..26de59d 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1838,6 +1838,53 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, return NULL; } +static const char *controller_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + const char *val = NULL; + const char *msg = NULL; + int ret; + + if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) { + msg = "ControllerRASD ResourceSubType field not valid"; + goto out; + } + dev->dev.controller.type = strdup(val); + + /* Required fields */ + if (cu_get_u64_prop(inst, "Index", + &dev->dev.controller.index) != CMPI_RC_OK) { + msg = "ControllerRASD Index field not valid"; + goto out; + } + + /* Formulate our instance id from controller, controller type, + * and index value. This should be unique enough. + */ + ret = asprintf(&dev->id, "controller:%s:" PRIu64, + dev->dev.controller.type, + dev->dev.controller.index); + if (ret == -1) { + msg = "Failed to create controller string"; + goto out; + } + + /* Optional fields */ + if (cu_get_str_prop(inst, "Model", &val) == CMPI_RC_OK) + dev->dev.controller.model = strdup(val); + if (cu_get_str_prop(inst, "Ports", &val) == CMPI_RC_OK) + dev->dev.controller.ports = strdup(val); + if (cu_get_str_prop(inst, "Vectors", &val) == CMPI_RC_OK) + dev->dev.controller.vectors = strdup(val); + if (cu_get_str_prop(inst, "Queues", &val) == CMPI_RC_OK) + dev->dev.controller.queues = strdup(val); + msg = rasd_to_device_address(inst, &dev->dev.controller.address); + + out: + + return msg; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -1858,6 +1905,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, return console_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform"; @@ -1878,6 +1927,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, return lxc_proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform"; @@ -1987,6 +2038,9 @@ static const char *classify_resources(CMPIArray *resources, if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) return "Failed to alloc input list"; + if (!make_space(&domain->dev_controller, domain->dev_controller_ct, count)) + return "Failed to alloc controller list"; + for (i = 0; i < count; i++) { CMPIObjectPath *op; CMPIData item; @@ -2101,7 +2155,23 @@ static const char *classify_resources(CMPIArray *resources, &domain->dev_input[0], ns, p_error); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + struct virt_device dev; + int dcount = count + domain->dev_controller_ct; + + memset(&dev, 0, sizeof(dev)); + msg = rasd_to_vdev(inst, + domain, + &dev, + ns, + p_error); + if (msg == NULL) + msg = add_device_nodup(&dev, + domain->dev_controller, + dcount, + &domain->dev_controller_ct); } + if (msg != NULL) return msg; @@ -2908,6 +2978,9 @@ static struct virt_device **find_list(struct domain *dominfo, } else if (type == CIM_RES_TYPE_INPUT) { list = &dominfo->dev_input; *count = &dominfo->dev_input_ct; + } else if (type == CIM_RES_TYPE_CONTROLLER) { + list = &dominfo->dev_controller; + *count = &dominfo->dev_controller_ct; } return list; @@ -3029,6 +3102,7 @@ static CMPIStatus resource_del(struct domain *dominfo, if (STREQ(dev->id, devid)) { if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_CONSOLE) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { @@ -3111,6 +3185,7 @@ static CMPIStatus resource_add(struct domain *dominfo, if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) { (*count)++; cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); @@ -3188,6 +3263,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { -- 1.8.5.3