From gesaint at linux.vnet.ibm.com Mon Mar 3 01:04:17 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 3 Mar 2014 09:04:17 +0800 Subject: [Libvirt-cim] [PATCH 0/2] Add rawio/sgio tag property support Message-ID: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> They are needed by virtio-scsi so add them into libvirt-cim support Xu Wang (2): Add rawio property support Add sgio property support libxkutil/device_parsing.c | 8 ++++++++ libxkutil/device_parsing.h | 2 ++ libxkutil/xmlgen.c | 4 ++++ schema/ResourceAllocationSettingData.mof | 6 ++++++ src/Virt_RASD.c | 12 ++++++++++++ src/Virt_VirtualSystemManagementService.c | 10 ++++++++++ 6 files changed, 42 insertions(+), 0 deletions(-) From gesaint at linux.vnet.ibm.com Mon Mar 3 01:04:18 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 3 Mar 2014 09:04:18 +0800 Subject: [Libvirt-cim] [PATCH 1/2] Add rawio property support In-Reply-To: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1393808659-3006-2-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 4 ++++ libxkutil/device_parsing.h | 1 + libxkutil/xmlgen.c | 2 ++ schema/ResourceAllocationSettingData.mof | 3 +++ src/Virt_RASD.c | 6 ++++++ src/Virt_VirtualSystemManagementService.c | 5 +++++ 6 files changed, 21 insertions(+), 0 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index c9ae886..6b29a2d 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -92,6 +92,7 @@ static void cleanup_disk_device(struct disk_device *dev) free(dev->source); free(dev->virtual_dev); free(dev->bus_type); + free(dev->rawio); free(dev->access_mode); cleanup_device_address(&dev->address); } @@ -512,6 +513,8 @@ static int parse_block_device(xmlNode *dnode, struct virt_device **vdevs) if (ddev->device == NULL) goto err; + ddev->rawio = get_attr_value(dnode, "rawio"); + for (child = dnode->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "driver")) { ddev->driver = get_attr_value(child, "name"); @@ -1315,6 +1318,7 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) DUP_FIELD(dev, _dev, dev.disk.device); DUP_FIELD(dev, _dev, dev.disk.driver); DUP_FIELD(dev, _dev, dev.disk.driver_type); + DUP_FIELD(dev, _dev, dev.disk.rawio); DUP_FIELD(dev, _dev, dev.disk.cache); DUP_FIELD(dev, _dev, dev.disk.source); DUP_FIELD(dev, _dev, dev.disk.virtual_dev); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 92427c1..a8cf7aa 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -56,6 +56,7 @@ struct disk_device { char *driver_type; char *source; char *virtual_dev; + char *rawio; enum {DISK_UNKNOWN, DISK_PHY, DISK_FILE, DISK_FS} disk_type; bool readonly; bool shareable; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 931f0c9..2f0f475 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -212,6 +212,8 @@ static char *disk_block_xml(xmlNodePtr root, struct disk_device *dev) xmlNewProp(disk, BAD_CAST "type", BAD_CAST "block"); if (dev->device) xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device); + if (dev->rawio) + xmlNewProp(disk, BAD_CAST "rawio", BAD_CAST dev->rawio); if (dev->driver) { tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL); diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index bf1fbb6..5228f4b 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -65,6 +65,9 @@ class KVM_DiskResourceAllocationSettingData : KVM_ResourceAllocationSettingData [Description ("filesystem access mode")] string AccessMode; + [Description ("rawio value of lun device")] + string rawio; + [Description ("if device is shareable")] boolean shareable; diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index df1e921..0800311 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -482,6 +482,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, (CMPIValue *)dev->dev.disk.access_mode, CMPI_chars); + if(dev->dev.disk.rawio) + CMSetProperty(inst, + "rawio", + (CMPIValue *)dev->dev.disk.rawio, + CMPI_chars); + if(dev->dev.disk.shareable) CMSetProperty(inst, "shareable", diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 3e7785e..a9f7ae0 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1184,6 +1184,11 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, else dev->dev.disk.access_mode = strdup(val); + if (cu_get_str_prop(inst, "rawio", &val) != CMPI_RC_OK) + dev->dev.disk.rawio = NULL; + else + dev->dev.disk.rawio = strdup(val); + if (cu_get_bool_prop(inst, "shareable", &shareable) != CMPI_RC_OK) dev->dev.disk.shareable = false; else -- 1.7.1 From gesaint at linux.vnet.ibm.com Mon Mar 3 01:04:19 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 3 Mar 2014 09:04:19 +0800 Subject: [Libvirt-cim] [PATCH 2/2] Add sgio property support In-Reply-To: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1393808659-3006-3-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 4 ++++ libxkutil/device_parsing.h | 1 + libxkutil/xmlgen.c | 2 ++ schema/ResourceAllocationSettingData.mof | 3 +++ src/Virt_RASD.c | 6 ++++++ src/Virt_VirtualSystemManagementService.c | 5 +++++ 6 files changed, 21 insertions(+), 0 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 6b29a2d..d2d3859 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -93,6 +93,7 @@ static void cleanup_disk_device(struct disk_device *dev) free(dev->virtual_dev); free(dev->bus_type); free(dev->rawio); + free(dev->sgio); free(dev->access_mode); cleanup_device_address(&dev->address); } @@ -515,6 +516,8 @@ static int parse_block_device(xmlNode *dnode, struct virt_device **vdevs) ddev->rawio = get_attr_value(dnode, "rawio"); + ddev->sgio = get_attr_value(dnode, "sgio"); + for (child = dnode->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "driver")) { ddev->driver = get_attr_value(child, "name"); @@ -1319,6 +1322,7 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) DUP_FIELD(dev, _dev, dev.disk.driver); DUP_FIELD(dev, _dev, dev.disk.driver_type); DUP_FIELD(dev, _dev, dev.disk.rawio); + DUP_FIELD(dev, _dev, dev.disk.sgio); DUP_FIELD(dev, _dev, dev.disk.cache); DUP_FIELD(dev, _dev, dev.disk.source); DUP_FIELD(dev, _dev, dev.disk.virtual_dev); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a8cf7aa..a92e223 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -57,6 +57,7 @@ struct disk_device { char *source; char *virtual_dev; char *rawio; + char *sgio; enum {DISK_UNKNOWN, DISK_PHY, DISK_FILE, DISK_FS} disk_type; bool readonly; bool shareable; diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 2f0f475..18c4765 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -214,6 +214,8 @@ static char *disk_block_xml(xmlNodePtr root, struct disk_device *dev) xmlNewProp(disk, BAD_CAST "device", BAD_CAST dev->device); if (dev->rawio) xmlNewProp(disk, BAD_CAST "rawio", BAD_CAST dev->rawio); + if (dev->sgio) + xmlNewProp(disk, BAD_CAST "sgio", BAD_CAST dev->sgio); if (dev->driver) { tmp = xmlNewChild(disk, NULL, BAD_CAST "driver", NULL); diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 5228f4b..6b649de 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -68,6 +68,9 @@ class KVM_DiskResourceAllocationSettingData : KVM_ResourceAllocationSettingData [Description ("rawio value of lun device")] string rawio; + [Description ("sgio value of lun device")] + string sgio; + [Description ("if device is shareable")] boolean shareable; diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 0800311..abfb09f 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -488,6 +488,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, (CMPIValue *)dev->dev.disk.rawio, CMPI_chars); + if(dev->dev.disk.sgio) + CMSetProperty(inst, + "sgio", + (CMPIValue *)dev->dev.disk.sgio, + CMPI_chars); + if(dev->dev.disk.shareable) CMSetProperty(inst, "shareable", diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index a9f7ae0..e146470 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1189,6 +1189,11 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, else dev->dev.disk.rawio = strdup(val); + if (cu_get_str_prop(inst, "sgio", &val) != CMPI_RC_OK) + dev->dev.disk.sgio = NULL; + else + dev->dev.disk.sgio = strdup(val); + if (cu_get_bool_prop(inst, "shareable", &shareable) != CMPI_RC_OK) dev->dev.disk.shareable = false; else -- 1.7.1 From gesaint at linux.vnet.ibm.com Mon Mar 3 07:38:35 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 3 Mar 2014 15:38:35 +0800 Subject: [Libvirt-cim] [PATCH 0/3] Add Controller Device Support Message-ID: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> Add Xen/KVM/LXC_ControllerResourceAllocationSettingData classes for controller device operation. So far there are two variables (type and model) could be operated by calling API. Xu Wang (3): libxutil: Controller Support RASD: Schema and Provider Support for Controller RASDs VSMS: Support for domains with controller devices libxkutil/device_parsing.c | 62 ++++++++++++++++++++- libxkutil/device_parsing.h | 9 +++ libxkutil/xmlgen.c | 28 +++++++++ schema/ResourceAllocationSettingData.mof | 27 +++++++++ schema/ResourceAllocationSettingData.registration | 3 + src/Virt_RASD.c | 24 ++++++++ src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++ src/svpc_types.h | 4 +- 8 files changed, 199 insertions(+), 2 deletions(-) From gesaint at linux.vnet.ibm.com Mon Mar 3 07:38:36 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 3 Mar 2014 15:38:36 +0800 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 ++++++ libxkutil/xmlgen.c | 28 ++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..1937132 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith @@ -49,6 +49,7 @@ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" #define DEFAULT_BRIDGE "xenbr0" #define DEFAULT_NETWORK "default" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); } +static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller); free(dev->id); @@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + + if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break; + case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); } + return dev; } @@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER); return ret; @@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); free(dom); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; }; +struct controller_device { + char *type; + char *model; +}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain { struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; }; struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..537238d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; } +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL }; diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 #define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 -#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.7.1 From gesaint at linux.vnet.ibm.com Mon Mar 3 07:38:37 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 3 Mar 2014 15:38:37 +0800 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; }; +[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..1142376 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index abfb09f..594fe83 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; } +static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, "Type", + (CMPIValue *)dev->dev.controller.type, CMPI_chars); + + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_CONTROLLER; + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(dev, inst); } /* FIXME: Put the HostResource in place */ @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out; @@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; } -- 1.7.1 From gesaint at linux.vnet.ibm.com Mon Mar 3 07:38:38 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Mon, 3 Mar 2014 15:38:38 +0800 Subject: [Libvirt-cim] [PATCH 3/3] VSMS: Support for domains with controller devices In-Reply-To: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1393832318-18310-4-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index e146470..1a34ff8 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1848,6 +1848,28 @@ 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; + + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Type field not valid"); + goto out; + } + dev->dev.controller.type = strdup(val); + + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { + CU_DEBUG("Invalid value for Model in ControllerRASD"); + goto out; + } + dev->dev.controller.model = strdup(val); + + out: + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -1868,6 +1890,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"; @@ -1888,6 +1912,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"; @@ -1997,6 +2023,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; @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray *resources, &domain->dev_input[0], ns, p_error); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_controller[domain->dev_controller_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_controller_ct += 1; } + if (msg != NULL) return msg; @@ -2918,6 +2956,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; @@ -3039,6 +3080,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 { @@ -3121,6 +3163,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, ""); @@ -3198,6 +3241,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.7.1 From jferlan at redhat.com Mon Mar 10 20:34:39 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 10 Mar 2014 16:34:39 -0400 Subject: [Libvirt-cim] [PATCH 0/2] Add rawio/sgio tag property support In-Reply-To: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <531E21DF.6020103@redhat.com> On 03/02/2014 08:04 PM, Xu Wang wrote: > They are needed by virtio-scsi so add them into libvirt-cim support > > Xu Wang (2): > Add rawio property support > Add sgio property support > > libxkutil/device_parsing.c | 8 ++++++++ > libxkutil/device_parsing.h | 2 ++ > libxkutil/xmlgen.c | 4 ++++ > schema/ResourceAllocationSettingData.mof | 6 ++++++ > src/Virt_RASD.c | 12 ++++++++++++ > src/Virt_VirtualSystemManagementService.c | 10 ++++++++++ > 6 files changed, 42 insertions(+), 0 deletions(-) > These look OK, but the existing cimtest had some new failures; however, I believe that those failures had to do with me running the latest git head and there is a new device to deal with (sigh), see: http://www.redhat.com/archives/libvir-list/2014-February/msg01058.html Although I'm OK with the changes - I would like to see a test to verify that this works. Whether that's a cimtest or even adjusting the checkin message to add new files and/or scripts to validate. I have to assume this is desired to be backported into RHEL6.next at some point. In order to do that - I really need a test. John From jferlan at redhat.com Mon Mar 10 20:45:52 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 10 Mar 2014 16:45:52 -0400 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <531E2480.2090808@redhat.com> Coverity points out two missing break;'s - see below... On 03/03/2014 02:38 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 9 ++++++ > libxkutil/xmlgen.c | 28 ++++++++++++++++++++ > src/svpc_types.h | 4 ++- > 4 files changed, 101 insertions(+), 2 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index d2d3859..1937132 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007, 2013 > + * Copyright IBM Corp. 2007, 2014 > * > * Authors: > * Dan Smith > @@ -49,6 +49,7 @@ > #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ > "/domain/devices/console" > #define INPUT_XPATH (xmlChar *)"/domain/devices/input" > +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" > > #define DEFAULT_BRIDGE "xenbr0" > #define DEFAULT_NETWORK "default" > @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) > free(dev->bus); > } > > +static void cleanup_controller_device(struct controller_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->type); > + free(dev->model); > +} > + > void cleanup_virt_device(struct virt_device *dev) > { > if (dev == NULL) > @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) > cleanup_input_device(&dev->dev.input); > else if (dev->type == CIM_RES_TYPE_CONSOLE) > cleanup_console_device(&dev->dev.console); > + else if (dev->type == CIM_RES_TYPE_CONTROLLER) > + cleanup_controller_device(&dev->dev.controller); > > free(dev->id); > > @@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) > return 0; > } > > +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) > +{ > + struct virt_device *vdev = NULL; > + struct controller_device *cdev = NULL; > + int ret; > + > + vdev = calloc(1, sizeof(*vdev)); > + if (vdev == NULL) > + goto err; > + > + cdev = &(vdev->dev.controller); > + > + cdev->type = get_attr_value(node, "type"); > + cdev->model = get_attr_value(node, "model"); > + > + if (cdev->type == NULL) > + goto err; > + > + vdev->type = CIM_RES_TYPE_CONTROLLER; > + > + ret = asprintf(&vdev->id, "%s", cdev->type); > + if (ret == -1) { > + CU_DEBUG("Failed to create controller id string"); > + goto err; > + } > + > + *vdevs = vdev; > + > + return 1; > + err: > + cleanup_controller_device(cdev); > + free(vdev); > + > + return 0; > +} > + > static bool resize_devlist(struct virt_device **list, int newsize) > { > struct virt_device *_list; > @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) > func = &parse_input_device; > break; > > + case CIM_RES_TYPE_CONTROLLER: > + xpathstr = CONTROLLER_XPATH; > + func = &parse_controller_device; > + Missing a break; > default: > CU_DEBUG("Unrecognized device type. Returning."); > goto err1; > @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) > } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > console_device_dup(&dev->dev.console, > &_dev->dev.console); > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + DUP_FIELD(dev, _dev, dev.controller.type); > + DUP_FIELD(dev, _dev, dev.controller.model); > } > + > return dev; > } > > @@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) > (*dominfo)->dev_vcpu_ct = parse_devices(xml, > &(*dominfo)->dev_vcpu, > CIM_RES_TYPE_PROC); > + (*dominfo)->dev_controller_ct = parse_devices(xml, > + &(*dominfo)->dev_controller, > + CIM_RES_TYPE_CONTROLLER); > > return ret; > > @@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) > cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); > cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); > cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); > + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); > > free(dom); > > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index a92e223..cc58970 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -163,6 +163,11 @@ struct input_device { > char *bus; > }; > > +struct controller_device { > + char *type; > + char *model; > +}; > + > struct virt_device { > uint16_t type; > union { > @@ -174,6 +179,7 @@ struct virt_device { > struct graphics_device graphics; > struct console_device console; > struct input_device input; > + struct controller_device controller; > } dev; > char *id; > }; > @@ -249,6 +255,9 @@ struct domain { > > struct virt_device *dev_vcpu; > int dev_vcpu_ct; > + > + struct virt_device *dev_controller; > + int dev_controller_ct; > }; > > struct virt_device *virt_device_dup(struct virt_device *dev); > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 18c4765..537238d 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) > return NULL; > } > > +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) > +{ > + int i; > + > + for (i = 0; i < dominfo->dev_controller_ct; i++) { > + xmlNodePtr tmp; > + struct virt_device *_dev = &dominfo->dev_controller[i]; > + if (_dev->type == CIM_RES_TYPE_UNKNOWN) > + continue; > + > + struct controller_device *dev = &_dev->dev.controller; > + > + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); > + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); > + } > + > + return NULL; > +} > + > static char *system_xml(xmlNodePtr root, struct domain *domain) > { > xmlNodePtr tmp; > @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) > dominfo->dev_input_ct = 1; > dominfo->dev_input = dev; > break; > + case CIM_RES_TYPE_CONTROLLER: > + func = controller_xml; > + dominfo->dev_controller_ct = 1; > + dominfo->dev_controller = dev; Missing a break; > default: > cleanup_virt_devices(&dev, 1); > goto out; > @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) > &console_xml, > &graphics_xml, > &emu_xml, > + &controller_xml, > NULL > }; > > diff --git a/src/svpc_types.h b/src/svpc_types.h > index 404e428..d76097c 100644 > --- a/src/svpc_types.h > +++ b/src/svpc_types.h > @@ -32,12 +32,13 @@ > #define CIM_RES_TYPE_DISK 17 > #define CIM_RES_TYPE_GRAPHICS 24 > #define CIM_RES_TYPE_INPUT 13 > +#define CIM_RES_TYPE_CONTROLLER 33 > #define CIM_RES_TYPE_UNKNOWN 1000 > #define CIM_RES_TYPE_IMAGE 32768 > #define CIM_RES_TYPE_CONSOLE 32769 > #define CIM_RES_TYPE_EMU 32770 > > -#define CIM_RES_TYPE_COUNT 7 > +#define CIM_RES_TYPE_COUNT 8 > const static int cim_res_types[CIM_RES_TYPE_COUNT] = > {CIM_RES_TYPE_NET, > CIM_RES_TYPE_DISK, > @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = > CIM_RES_TYPE_GRAPHICS, > CIM_RES_TYPE_INPUT, > CIM_RES_TYPE_CONSOLE, > + CIM_RES_TYPE_CONTROLLER, > }; > > #define CIM_VSSD_RECOVERY_NONE 2 > From jferlan at redhat.com Mon Mar 10 21:07:51 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 10 Mar 2014 17:07:51 -0400 Subject: [Libvirt-cim] [PATCH 0/3] Add Controller Device Support In-Reply-To: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <531E29A7.9020605@redhat.com> On 03/03/2014 02:38 AM, Xu Wang wrote: > Add Xen/KVM/LXC_ControllerResourceAllocationSettingData classes for > controller device operation. So far there are two variables (type and > model) could be operated by calling API. > > Xu Wang (3): > libxutil: Controller Support > RASD: Schema and Provider Support for Controller RASDs > VSMS: Support for domains with controller devices > > libxkutil/device_parsing.c | 62 ++++++++++++++++++++- > libxkutil/device_parsing.h | 9 +++ > libxkutil/xmlgen.c | 28 +++++++++ > schema/ResourceAllocationSettingData.mof | 27 +++++++++ > schema/ResourceAllocationSettingData.registration | 3 + > src/Virt_RASD.c | 24 ++++++++ > src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++ > src/svpc_types.h | 4 +- > 8 files changed, 199 insertions(+), 2 deletions(-) > Again, like the rawio/sgio patches - I'd like to see a test here. I think this one certainly deserves some sort of cimtest as well. My cimtest is failing in multiple places. Did you run cimtest before and after these changes? John From fiuczy at linux.vnet.ibm.com Wed Mar 12 16:36:35 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Wed, 12 Mar 2014 17:36:35 +0100 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <53208D13.1070303@linux.vnet.ibm.com> On 03/03/2014 08:38 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 9 ++++++ > libxkutil/xmlgen.c | 28 ++++++++++++++++++++ > src/svpc_types.h | 4 ++- > 4 files changed, 101 insertions(+), 2 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index d2d3859..1937132 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007, 2013 > + * Copyright IBM Corp. 2007, 2014 > * > * Authors: > * Dan Smith > @@ -49,6 +49,7 @@ > #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ > "/domain/devices/console" > #define INPUT_XPATH (xmlChar *)"/domain/devices/input" > +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" > > #define DEFAULT_BRIDGE "xenbr0" > #define DEFAULT_NETWORK "default" > @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) > free(dev->bus); > } > > +static void cleanup_controller_device(struct controller_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->type); > + free(dev->model); > +} > + > void cleanup_virt_device(struct virt_device *dev) > { > if (dev == NULL) > @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) > cleanup_input_device(&dev->dev.input); > else if (dev->type == CIM_RES_TYPE_CONSOLE) > cleanup_console_device(&dev->dev.console); > + else if (dev->type == CIM_RES_TYPE_CONTROLLER) > + cleanup_controller_device(&dev->dev.controller); > > free(dev->id); > > @@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) > return 0; > } > > +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) > +{ > + struct virt_device *vdev = NULL; > + struct controller_device *cdev = NULL; > + int ret; > + > + vdev = calloc(1, sizeof(*vdev)); > + if (vdev == NULL) > + goto err; > + > + cdev = &(vdev->dev.controller); > + > + cdev->type = get_attr_value(node, "type"); > + cdev->model = get_attr_value(node, "model"); > + > + if (cdev->type == NULL) > + goto err; > + > + vdev->type = CIM_RES_TYPE_CONTROLLER; > + > + ret = asprintf(&vdev->id, "%s", cdev->type); What is going to happen if you have more than one instance of the same type of controller? In other words, I do not think that type is unique to be the ID. To make it unique you also need the index which is also a mandatory attribute. > + if (ret == -1) { > + CU_DEBUG("Failed to create controller id string"); > + goto err; > + } > + > + *vdevs = vdev; > + > + return 1; > + err: > + cleanup_controller_device(cdev); > + free(vdev); > + > + return 0; > +} > + > static bool resize_devlist(struct virt_device **list, int newsize) > { > struct virt_device *_list; > @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) > func = &parse_input_device; > break; > > + case CIM_RES_TYPE_CONTROLLER: > + xpathstr = CONTROLLER_XPATH; > + func = &parse_controller_device; > + > default: > CU_DEBUG("Unrecognized device type. Returning."); > goto err1; > @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) > } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > console_device_dup(&dev->dev.console, > &_dev->dev.console); > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + DUP_FIELD(dev, _dev, dev.controller.type); > + DUP_FIELD(dev, _dev, dev.controller.model); > } > + > return dev; > } > > @@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) > (*dominfo)->dev_vcpu_ct = parse_devices(xml, > &(*dominfo)->dev_vcpu, > CIM_RES_TYPE_PROC); > + (*dominfo)->dev_controller_ct = parse_devices(xml, > + &(*dominfo)->dev_controller, > + CIM_RES_TYPE_CONTROLLER); > > return ret; > > @@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) > cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); > cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); > cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); > + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); > > free(dom); > > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index a92e223..cc58970 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -163,6 +163,11 @@ struct input_device { > char *bus; > }; > > +struct controller_device { > + char *type; > + char *model; > +}; > + > struct virt_device { > uint16_t type; > union { > @@ -174,6 +179,7 @@ struct virt_device { > struct graphics_device graphics; > struct console_device console; > struct input_device input; > + struct controller_device controller; > } dev; > char *id; > }; > @@ -249,6 +255,9 @@ struct domain { > > struct virt_device *dev_vcpu; > int dev_vcpu_ct; > + > + struct virt_device *dev_controller; > + int dev_controller_ct; > }; > > struct virt_device *virt_device_dup(struct virt_device *dev); > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 18c4765..537238d 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) > return NULL; > } > > +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) > +{ > + int i; > + > + for (i = 0; i < dominfo->dev_controller_ct; i++) { > + xmlNodePtr tmp; > + struct virt_device *_dev = &dominfo->dev_controller[i]; > + if (_dev->type == CIM_RES_TYPE_UNKNOWN) > + continue; > + > + struct controller_device *dev = &_dev->dev.controller; > + > + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); > + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); Model is an optional attribute. So if I read this correctly dev->model might be NULL and you create a new property with it. I am not sure what libvirt is going to do about it. > + } > + > + return NULL; > +} > + > static char *system_xml(xmlNodePtr root, struct domain *domain) > { > xmlNodePtr tmp; > @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) > dominfo->dev_input_ct = 1; > dominfo->dev_input = dev; > break; > + case CIM_RES_TYPE_CONTROLLER: > + func = controller_xml; > + dominfo->dev_controller_ct = 1; > + dominfo->dev_controller = dev; > default: > cleanup_virt_devices(&dev, 1); > goto out; > @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) > &console_xml, > &graphics_xml, > &emu_xml, > + &controller_xml, > NULL > }; > > diff --git a/src/svpc_types.h b/src/svpc_types.h > index 404e428..d76097c 100644 > --- a/src/svpc_types.h > +++ b/src/svpc_types.h > @@ -32,12 +32,13 @@ > #define CIM_RES_TYPE_DISK 17 > #define CIM_RES_TYPE_GRAPHICS 24 > #define CIM_RES_TYPE_INPUT 13 > +#define CIM_RES_TYPE_CONTROLLER 33 33 is DMTF reserved as an Ethernet Connection the next logical number in libvirt-cim terms would be 32771 (see below) > #define CIM_RES_TYPE_UNKNOWN 1000 > #define CIM_RES_TYPE_IMAGE 32768 > #define CIM_RES_TYPE_CONSOLE 32769 > #define CIM_RES_TYPE_EMU 32770 > > -#define CIM_RES_TYPE_COUNT 7 > +#define CIM_RES_TYPE_COUNT 8 > const static int cim_res_types[CIM_RES_TYPE_COUNT] = > {CIM_RES_TYPE_NET, > CIM_RES_TYPE_DISK, > @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = > CIM_RES_TYPE_GRAPHICS, > CIM_RES_TYPE_INPUT, > CIM_RES_TYPE_CONSOLE, > + CIM_RES_TYPE_CONTROLLER, > }; > > #define CIM_VSSD_RECOVERY_NONE 2 > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Thu Mar 13 10:13:05 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 11:13:05 +0100 Subject: [Libvirt-cim] [PATCH 3/3] VSMS: Support for domains with controller devices In-Reply-To: <1393832318-18310-4-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-4-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <532184B1.2080109@linux.vnet.ibm.com> On 03/03/2014 08:38 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++ > 1 files changed, 44 insertions(+), 0 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index e146470..1a34ff8 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1848,6 +1848,28 @@ 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; > + > + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { > + CU_DEBUG("ControllerRASD Type field not valid"); > + goto out; > + } > + dev->dev.controller.type = strdup(val); > + > + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { > + CU_DEBUG("Invalid value for Model in ControllerRASD"); > + goto out; > + } > + dev->dev.controller.model = strdup(val); I have already written before that the CIM instance uniqueness is with the current code not guaranteed. I suggest the following schema for the instanceID: /controller:: To accomplish this you need to set dev->id here to (abbreviated) "controller:"+dev->dev.controller.type+":"dev->dev.controller.index btw. this is also needed to be set in method parse_controller_device in libxkutil/device_parsing.c I might have missed that before. > + > + out: > + > + return NULL; > +} > + > static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev, > uint16_t type, > @@ -1868,6 +1890,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"; > @@ -1888,6 +1912,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"; > @@ -1997,6 +2023,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; > @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray *resources, > &domain->dev_input[0], > ns, > p_error); > + } else if (type == CIM_RES_TYPE_CONTROLLER) { > + msg = rasd_to_vdev(inst, > + domain, > + &domain->dev_controller[domain->dev_controller_ct], > + ns, > + p_error); > + if (msg == NULL) > + domain->dev_controller_ct += 1; > } > + > if (msg != NULL) > return msg; > > @@ -2918,6 +2956,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; > @@ -3039,6 +3080,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) || In libvirt controller can be dynamically added and deleted (hotplug and hotunplug). If I am not mistaken you prevent this here and also below (resource_add & resource_mod). > (type == CIM_RES_TYPE_INPUT)) > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > else { > @@ -3121,6 +3163,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, ""); > @@ -3198,6 +3241,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 { > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Thu Mar 13 10:00:01 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 11:00:01 +0100 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <532181A1.6070400@linux.vnet.ibm.com> On 03/03/2014 08:38 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ > schema/ResourceAllocationSettingData.registration | 3 ++ > src/Virt_RASD.c | 24 ++++++++++++++++++ > 3 files changed, 54 insertions(+), 0 deletions(-) > > diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof > index 6b649de..3512170 100644 > --- a/schema/ResourceAllocationSettingData.mof > +++ b/schema/ResourceAllocationSettingData.mof > @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData > string BusType; > }; > > +[Description ("Xen virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData > +{ > + string Type; > + string Model; > +}; > + > +[Description ("KVM virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData > +{ > + string Type; The class CIM_ResourceAllocationSettingData has an attribute ResourceSubType. I think there is no need to introduce this new attribute here. > + string Model; I think that there should at least be some minimum documentation of the attributes in the mof as well. e.g. [Description ("Order in which the bus controller is encountered. " "The order is controller type scoped.")] uint64 Index; > +}; As already said in patch 1/3 I think that you need to add the index. > + > +[Description ("LXC virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData > +{ > + string Type; > + string Model; > +}; > + > [Description ("Xen virtual network pool settings"), > Provider("cmpi::Virt_RASD") > ] > diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration > index b969bfe..1142376 100644 > --- a/schema/ResourceAllocationSettingData.registration > +++ b/schema/ResourceAllocationSettingData.registration > @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > index abfb09f..594fe83 100644 > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, > return s; > } > > +static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, > + CMPIInstance *inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + > + CMSetProperty(inst, "Type", > + (CMPIValue *)dev->dev.controller.type, CMPI_chars); > + > + CMSetProperty(inst, "Model", > + (CMPIValue *)dev->dev.controller.model, CMPI_chars); > + > + return s; > +} > + > CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > struct virt_device *dev, > const char *host, > @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > } else if (dev->type == CIM_RES_TYPE_INPUT) { > type = CIM_RES_TYPE_INPUT; > base = "InputResourceAllocationSettingData"; > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + type = CIM_RES_TYPE_CONTROLLER; Setting the attribute ResourceType to CIM_RES_TYPE_OTHER since there is no value in the DMTF defined space that would fit a generic controller. By setting it to "Other" or "1" you should specify attributes OtherResourceType and ResourceSubType. I suggest to set OtherResourceType to "Controller" and as mentioned above set the ResourceSubType according to the controller type specified. You need to set these in method set_controller_rasd_params. > + base = "ControllerResourceAllocationSettingData"; > } else { > return NULL; > } > @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > s = set_input_rasd_params(dev, inst); > } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > s = set_console_rasd_params(dev, inst); > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + s = set_controller_rasd_params(dev, inst); > } > > /* FIXME: Put the HostResource in place */ > @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) > *type = CIM_RES_TYPE_IMAGE; > else if (STREQ(base, "ConsoleResourceAllocationSettingData")) > *type = CIM_RES_TYPE_CONSOLE; > + else if (STREQ(base, "ControllerResourceAllocationSettingData")) > + *type = CIM_RES_TYPE_CONTROLLER; > else > goto out; > > @@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) > case CIM_RES_TYPE_INPUT: > *classname = "InputResourceAllocationSettingData"; > break; > + case CIM_RES_TYPE_CONTROLLER: > + *classname = "ControllerResourceAllocationSettingData"; > + break; > default: > rc = CMPI_RC_ERR_FAILED; > } > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Mar 13 12:02:32 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 08:02:32 -0400 Subject: [Libvirt-cim] [PATCH 0/3] Add Controller Device Support In-Reply-To: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <53219E58.4060503@redhat.com> On 03/03/2014 02:38 AM, Xu Wang wrote: > Add Xen/KVM/LXC_ControllerResourceAllocationSettingData classes for > controller device operation. So far there are two variables (type and > model) could be operated by calling API. > > Xu Wang (3): > libxutil: Controller Support > RASD: Schema and Provider Support for Controller RASDs > VSMS: Support for domains with controller devices > > libxkutil/device_parsing.c | 62 ++++++++++++++++++++- > libxkutil/device_parsing.h | 9 +++ > libxkutil/xmlgen.c | 28 +++++++++ > schema/ResourceAllocationSettingData.mof | 27 +++++++++ > schema/ResourceAllocationSettingData.registration | 3 + > src/Virt_RASD.c | 24 ++++++++ > src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++ > src/svpc_types.h | 4 +- > 8 files changed, 199 insertions(+), 2 deletions(-) > The "need" for this just ratcheted up a bit since for RHEL7 the PCI controller must be defined for "new" or "changed" XML. There is a BZ assigned to me now - https://bugzilla.redhat.com/show_bug.cgi?id=1075874 Of course the window of opportunity to get changes in is very small. Hopefully we can come to a resolution on this set of changes rather quickly - I don't mind jumping in to assist if you are time constrained since at least work is started. John From jferlan at redhat.com Thu Mar 13 12:45:23 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 08:45:23 -0400 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <53208D13.1070303@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> <53208D13.1070303@linux.vnet.ibm.com> Message-ID: <5321A863.50800@redhat.com> On 03/12/2014 12:36 PM, Boris Fiuczynski wrote: >> diff --git a/src/svpc_types.h b/src/svpc_types.h >> index 404e428..d76097c 100644 >> --- a/src/svpc_types.h >> +++ b/src/svpc_types.h >> @@ -32,12 +32,13 @@ >> #define CIM_RES_TYPE_DISK 17 >> #define CIM_RES_TYPE_GRAPHICS 24 >> #define CIM_RES_TYPE_INPUT 13 >> +#define CIM_RES_TYPE_CONTROLLER 33 > 33 is DMTF reserved as an Ethernet Connection the next logical number in > libvirt-cim terms would be 32771 (see below) Do you have a link handy to the specification that describes the numbers? I know I used to have a link, but I cannot find it any more. tks, John >> #define CIM_RES_TYPE_UNKNOWN 1000 >> #define CIM_RES_TYPE_IMAGE 32768 >> #define CIM_RES_TYPE_CONSOLE 32769 >> #define CIM_RES_TYPE_EMU 32770 >> >> -#define CIM_RES_TYPE_COUNT 7 >> +#define CIM_RES_TYPE_COUNT 8 >> const static int cim_res_types[CIM_RES_TYPE_COUNT] = >> {CIM_RES_TYPE_NET, >> CIM_RES_TYPE_DISK, >> @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = >> CIM_RES_TYPE_GRAPHICS, >> CIM_RES_TYPE_INPUT, >> CIM_RES_TYPE_CONSOLE, >> + CIM_RES_TYPE_CONTROLLER, >> }; >> >> #define CIM_VSSD_RECOVERY_NONE 2 >> > > From fiuczy at linux.vnet.ibm.com Thu Mar 13 13:25:28 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 14:25:28 +0100 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <532181A1.6070400@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> <532181A1.6070400@linux.vnet.ibm.com> Message-ID: <5321B1C8.3090905@linux.vnet.ibm.com> On 03/13/2014 11:00 AM, Boris Fiuczynski wrote: > On 03/03/2014 08:38 AM, Xu Wang wrote: >> Signed-off-by: Xu Wang >> --- >> schema/ResourceAllocationSettingData.mof | 27 >> +++++++++++++++++++++ >> schema/ResourceAllocationSettingData.registration | 3 ++ >> src/Virt_RASD.c | 24 >> ++++++++++++++++++ >> 3 files changed, 54 insertions(+), 0 deletions(-) >> >> diff --git a/schema/ResourceAllocationSettingData.mof >> b/schema/ResourceAllocationSettingData.mof >> index 6b649de..3512170 100644 >> --- a/schema/ResourceAllocationSettingData.mof >> +++ b/schema/ResourceAllocationSettingData.mof >> @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : >> LXC_ResourceAllocationSettingData >> string BusType; >> }; >> >> +[Description ("Xen virtual controller device"), >> + Provider("cmpi::Virt_RASD") >> +] >> +class Xen_ControllerResourceAllocationSettingData : >> Xen_ResourceAllocationSettingData >> +{ >> + string Type; >> + string Model; >> +}; >> + >> +[Description ("KVM virtual controller device"), >> + Provider("cmpi::Virt_RASD") >> +] >> +class KVM_ControllerResourceAllocationSettingData : >> KVM_ResourceAllocationSettingData >> +{ >> + string Type; > The class CIM_ResourceAllocationSettingData has an attribute > ResourceSubType. I think there is no need to introduce this new > attribute here. >> + string Model; > I think that there should at least be some minimum documentation of the > attributes in the mof as well. e.g. > [Description ("Order in which the bus controller is encountered. " > "The order is controller type scoped.")] > uint64 Index; > >> +}; > As already said in patch 1/3 I think that you need to add the index. After reading John's mail about the BZ, I would suggest to also add [Description ("Device address property names")] string AddressProperties[]; [Description ("Device address property values")] string AddressValues[]; These attributes already exist on the Disk and Net. The provider code for this is reusable and generic. See below... Below I added some code snippets for support and also will do that for hopefully most of the other spots. > >> + >> +[Description ("LXC virtual controller device"), >> + Provider("cmpi::Virt_RASD") >> +] >> +class LXC_ControllerResourceAllocationSettingData : >> LXC_ResourceAllocationSettingData >> +{ >> + string Type; >> + string Model; >> +}; >> + >> [Description ("Xen virtual network pool settings"), >> Provider("cmpi::Virt_RASD") >> ] >> diff --git a/schema/ResourceAllocationSettingData.registration >> b/schema/ResourceAllocationSettingData.registration >> index b969bfe..1142376 100644 >> --- a/schema/ResourceAllocationSettingData.registration >> +++ b/schema/ResourceAllocationSettingData.registration >> @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt >> Virt_RASD Virt_RASD instance >> Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt >> Virt_RASD Virt_RASD instance >> KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD >> instance >> LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD >> Virt_RASD instance >> diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c >> index abfb09f..594fe83 100644 >> --- a/src/Virt_RASD.c >> +++ b/src/Virt_RASD.c >> @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const >> struct virt_device *dev, >> return s; >> } >> >> +static CMPIStatus set_controller_rasd_params(const struct virt_device >> *dev, >> + CMPIInstance *inst) static CMPIStatus set_controller_rasd_params(const CMPIBroker *broker, const CMPIObjectPath *ref, const struct virt_device *vdev, CMPIInstance *inst) >> +{ >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> + >> + CMSetProperty(inst, "Type", >> + (CMPIValue *)dev->dev.controller.type, >> CMPI_chars); >> + >> + CMSetProperty(inst, "Model", >> + (CMPIValue *)dev->dev.controller.model, >> CMPI_chars); if (dev->dev.controller.address.ct > 0) set_rasd_device_address(broker, ref, &dev->dev.controller.address, inst); >> + >> + return s; >> +} >> + >> CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, >> struct virt_device *dev, >> const char *host, >> @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker >> *broker, >> } else if (dev->type == CIM_RES_TYPE_INPUT) { >> type = CIM_RES_TYPE_INPUT; >> base = "InputResourceAllocationSettingData"; >> + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { >> + type = CIM_RES_TYPE_CONTROLLER; > Setting the attribute ResourceType to CIM_RES_TYPE_OTHER since there is > no value in the DMTF defined space that would fit a generic controller. > By setting it to "Other" or "1" you should specify attributes > OtherResourceType and ResourceSubType. > I suggest to set OtherResourceType to "Controller" and as mentioned > above set the ResourceSubType according to the controller type > specified. You need to set these in method set_controller_rasd_params. >> + base = "ControllerResourceAllocationSettingData"; >> } else { >> return NULL; >> } >> @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker >> *broker, >> s = set_input_rasd_params(dev, inst); >> } else if (dev->type == CIM_RES_TYPE_CONSOLE) { >> s = set_console_rasd_params(dev, inst); >> + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { >> + s = set_controller_rasd_params(dev, inst); s = set_controller_rasd_params(broker, rev, dev, inst); >> } >> >> /* FIXME: Put the HostResource in place */ >> @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char >> *cn, uint16_t *type) >> *type = CIM_RES_TYPE_IMAGE; >> else if (STREQ(base, "ConsoleResourceAllocationSettingData")) >> *type = CIM_RES_TYPE_CONSOLE; >> + else if (STREQ(base, "ControllerResourceAllocationSettingData")) >> + *type = CIM_RES_TYPE_CONTROLLER; >> else >> goto out; >> >> @@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, >> const char **classname) >> case CIM_RES_TYPE_INPUT: >> *classname = "InputResourceAllocationSettingData"; >> break; >> + case CIM_RES_TYPE_CONTROLLER: >> + *classname = "ControllerResourceAllocationSettingData"; >> + break; >> default: >> rc = CMPI_RC_ERR_FAILED; >> } >> > > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Thu Mar 13 13:46:11 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 14:46:11 +0100 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <53208D13.1070303@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> <53208D13.1070303@linux.vnet.ibm.com> Message-ID: <5321B6A3.8040907@linux.vnet.ibm.com> Here the other address stuff On 03/12/2014 05:36 PM, Boris Fiuczynski wrote: > On 03/03/2014 08:38 AM, Xu Wang wrote: >> Signed-off-by: Xu Wang >> --- >> libxkutil/device_parsing.c | 62 >> +++++++++++++++++++++++++++++++++++++++++++- >> libxkutil/device_parsing.h | 9 ++++++ >> libxkutil/xmlgen.c | 28 ++++++++++++++++++++ >> src/svpc_types.h | 4 ++- >> 4 files changed, 101 insertions(+), 2 deletions(-) >> >> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c >> index d2d3859..1937132 100644 >> --- a/libxkutil/device_parsing.c >> +++ b/libxkutil/device_parsing.c >> @@ -1,5 +1,5 @@ >> /* >> - * Copyright IBM Corp. 2007, 2013 >> + * Copyright IBM Corp. 2007, 2014 >> * >> * Authors: >> * Dan Smith >> @@ -49,6 +49,7 @@ >> #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ >> "/domain/devices/console" >> #define INPUT_XPATH (xmlChar *)"/domain/devices/input" >> +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" >> >> #define DEFAULT_BRIDGE "xenbr0" >> #define DEFAULT_NETWORK "default" >> @@ -308,6 +309,15 @@ static void cleanup_input_device(struct >> input_device *dev) >> free(dev->bus); >> } >> >> +static void cleanup_controller_device(struct controller_device *dev) >> +{ >> + if (dev == NULL) >> + return; >> + >> + free(dev->type); >> + free(dev->model); cleanup_device_address(&dev->address); >> +} >> + >> void cleanup_virt_device(struct virt_device *dev) >> { >> if (dev == NULL) >> @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) >> cleanup_input_device(&dev->dev.input); >> else if (dev->type == CIM_RES_TYPE_CONSOLE) >> cleanup_console_device(&dev->dev.console); >> + else if (dev->type == CIM_RES_TYPE_CONTROLLER) >> + cleanup_controller_device(&dev->dev.controller); >> >> free(dev->id); >> >> @@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, >> struct virt_device **vdevs) >> return 0; >> } >> >> +static int parse_controller_device(xmlNode *node, struct virt_device >> **vdevs) >> +{ >> + struct virt_device *vdev = NULL; >> + struct controller_device *cdev = NULL; >> + int ret; >> + >> + vdev = calloc(1, sizeof(*vdev)); >> + if (vdev == NULL) >> + goto err; >> + >> + cdev = &(vdev->dev.controller); >> + >> + cdev->type = get_attr_value(node, "type"); >> + cdev->model = get_attr_value(node, "model"); >> + for (child = node->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "address")) { parse_device_address(child, &cdev->address); } } >> + if (cdev->type == NULL) >> + goto err; >> + >> + vdev->type = CIM_RES_TYPE_CONTROLLER; >> + >> + ret = asprintf(&vdev->id, "%s", cdev->type); > What is going to happen if you have more than one instance of the same > type of controller? In other words, I do not think that type is unique > to be the ID. To make it unique you also need the index which is also a > mandatory attribute. >> + if (ret == -1) { >> + CU_DEBUG("Failed to create controller id string"); >> + goto err; >> + } >> + >> + *vdevs = vdev; >> + >> + return 1; >> + err: >> + cleanup_controller_device(cdev); >> + free(vdev); >> + >> + return 0; >> +} >> + >> static bool resize_devlist(struct virt_device **list, int newsize) >> { >> struct virt_device *_list; >> @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, >> struct virt_device **_list, int type) >> func = &parse_input_device; >> break; >> >> + case CIM_RES_TYPE_CONTROLLER: >> + xpathstr = CONTROLLER_XPATH; >> + func = &parse_controller_device; >> + >> default: >> CU_DEBUG("Unrecognized device type. Returning."); >> goto err1; >> @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct >> virt_device *_dev) >> } else if (dev->type == CIM_RES_TYPE_CONSOLE) { >> console_device_dup(&dev->dev.console, >> &_dev->dev.console); >> + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { >> + DUP_FIELD(dev, _dev, dev.controller.type); >> + DUP_FIELD(dev, _dev, dev.controller.model); duplicate_device_address(&dev->dev.controller.address, &_dev->dev.controller.address); >> } >> + >> return dev; >> } >> >> @@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct >> domain **dominfo) >> (*dominfo)->dev_vcpu_ct = parse_devices(xml, >> &(*dominfo)->dev_vcpu, >> CIM_RES_TYPE_PROC); >> + (*dominfo)->dev_controller_ct = parse_devices(xml, >> + >> &(*dominfo)->dev_controller, >> + >> CIM_RES_TYPE_CONTROLLER); >> >> return ret; >> >> @@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) >> cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); >> cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); >> cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); >> + cleanup_virt_devices(&dom->dev_controller, >> dom->dev_controller_ct); >> >> free(dom); >> >> diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h >> index a92e223..cc58970 100644 >> --- a/libxkutil/device_parsing.h >> +++ b/libxkutil/device_parsing.h >> @@ -163,6 +163,11 @@ struct input_device { >> char *bus; >> }; >> >> +struct controller_device { >> + char *type; >> + char *model; struct device_address address; >> +}; >> + >> struct virt_device { >> uint16_t type; >> union { >> @@ -174,6 +179,7 @@ struct virt_device { >> struct graphics_device graphics; >> struct console_device console; >> struct input_device input; >> + struct controller_device controller; >> } dev; >> char *id; >> }; >> @@ -249,6 +255,9 @@ struct domain { >> >> struct virt_device *dev_vcpu; >> int dev_vcpu_ct; >> + >> + struct virt_device *dev_controller; >> + int dev_controller_ct; >> }; >> >> struct virt_device *virt_device_dup(struct virt_device *dev); >> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >> index 18c4765..537238d 100644 >> --- a/libxkutil/xmlgen.c >> +++ b/libxkutil/xmlgen.c >> @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, >> struct domain *dominfo) >> return NULL; >> } >> >> +static const char *controller_xml(xmlNodePtr root, struct domain >> *dominfo) >> +{ >> + int i; >> + >> + for (i = 0; i < dominfo->dev_controller_ct; i++) { >> + xmlNodePtr tmp; >> + struct virt_device *_dev = &dominfo->dev_controller[i]; >> + if (_dev->type == CIM_RES_TYPE_UNKNOWN) >> + continue; >> + >> + struct controller_device *dev = &_dev->dev.controller; >> + >> + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", >> NULL); >> + if (tmp == NULL) >> + return XML_ERROR; >> + >> + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); >> + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); > Model is an optional attribute. So if I read this correctly dev->model > might be NULL and you create a new property with it. I am not sure what > libvirt is going to do about it. if (dev->address.ct > 0) return device_address_xml(tmp, &dev->address); -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Mar 13 14:07:06 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 10:07:06 -0400 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <5321B6A3.8040907@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> <53208D13.1070303@linux.vnet.ibm.com> <5321B6A3.8040907@linux.vnet.ibm.com> Message-ID: <5321BB8A.1020409@redhat.com> On 03/13/2014 09:46 AM, Boris Fiuczynski wrote: > Here the other address stuff > > On 03/12/2014 05:36 PM, Boris Fiuczynski wrote: >> On 03/03/2014 08:38 AM, Xu Wang wrote: >>> Signed-off-by: Xu Wang >>> --- >>> libxkutil/device_parsing.c | 62 >>> +++++++++++++++++++++++++++++++++++++++++++- >>> libxkutil/device_parsing.h | 9 ++++++ >>> libxkutil/xmlgen.c | 28 ++++++++++++++++++++ >>> src/svpc_types.h | 4 ++- >>> 4 files changed, 101 insertions(+), 2 deletions(-) >>> >>> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c >>> index d2d3859..1937132 100644 >>> --- a/libxkutil/device_parsing.c >>> +++ b/libxkutil/device_parsing.c >>> @@ -1,5 +1,5 @@ >>> /* >>> - * Copyright IBM Corp. 2007, 2013 >>> + * Copyright IBM Corp. 2007, 2014 >>> * >>> * Authors: >>> * Dan Smith >>> @@ -49,6 +49,7 @@ >>> #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ >>> "/domain/devices/console" >>> #define INPUT_XPATH (xmlChar *)"/domain/devices/input" >>> +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" >>> >>> #define DEFAULT_BRIDGE "xenbr0" >>> #define DEFAULT_NETWORK "default" >>> @@ -308,6 +309,15 @@ static void cleanup_input_device(struct >>> input_device *dev) >>> free(dev->bus); >>> } >>> >>> +static void cleanup_controller_device(struct controller_device *dev) >>> +{ >>> + if (dev == NULL) >>> + return; >>> + >>> + free(dev->type); >>> + free(dev->model); > cleanup_device_address(&dev->address); > >>> +} >>> + >>> void cleanup_virt_device(struct virt_device *dev) >>> { >>> if (dev == NULL) >>> @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) >>> cleanup_input_device(&dev->dev.input); >>> else if (dev->type == CIM_RES_TYPE_CONSOLE) >>> cleanup_console_device(&dev->dev.console); >>> + else if (dev->type == CIM_RES_TYPE_CONTROLLER) >>> + cleanup_controller_device(&dev->dev.controller); >>> >>> free(dev->id); >>> >>> @@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, >>> struct virt_device **vdevs) >>> return 0; >>> } >>> >>> +static int parse_controller_device(xmlNode *node, struct virt_device >>> **vdevs) >>> +{ >>> + struct virt_device *vdev = NULL; >>> + struct controller_device *cdev = NULL; >>> + int ret; >>> + >>> + vdev = calloc(1, sizeof(*vdev)); >>> + if (vdev == NULL) >>> + goto err; >>> + >>> + cdev = &(vdev->dev.controller); >>> + >>> + cdev->type = get_attr_value(node, "type"); >>> + cdev->model = get_attr_value(node, "model"); >>> + > for (child = node->children; child != NULL; child = child->next) { > if (XSTREQ(child->name, "address")) { > parse_device_address(child, &cdev->address); > } > } > >>> + if (cdev->type == NULL) >>> + goto err; >>> + >>> + vdev->type = CIM_RES_TYPE_CONTROLLER; >>> + >>> + ret = asprintf(&vdev->id, "%s", cdev->type); >> What is going to happen if you have more than one instance of the same >> type of controller? In other words, I do not think that type is unique >> to be the ID. To make it unique you also need the index which is also a >> mandatory attribute. >>> + if (ret == -1) { >>> + CU_DEBUG("Failed to create controller id string"); >>> + goto err; >>> + } >>> + >>> + *vdevs = vdev; >>> + >>> + return 1; >>> + err: >>> + cleanup_controller_device(cdev); >>> + free(vdev); >>> + >>> + return 0; >>> +} >>> + >>> static bool resize_devlist(struct virt_device **list, int newsize) >>> { >>> struct virt_device *_list; >>> @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, >>> struct virt_device **_list, int type) >>> func = &parse_input_device; >>> break; >>> >>> + case CIM_RES_TYPE_CONTROLLER: >>> + xpathstr = CONTROLLER_XPATH; >>> + func = &parse_controller_device; >>> + >>> default: >>> CU_DEBUG("Unrecognized device type. Returning."); >>> goto err1; >>> @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct >>> virt_device *_dev) >>> } else if (dev->type == CIM_RES_TYPE_CONSOLE) { >>> console_device_dup(&dev->dev.console, >>> &_dev->dev.console); >>> + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { >>> + DUP_FIELD(dev, _dev, dev.controller.type); >>> + DUP_FIELD(dev, _dev, dev.controller.model); > duplicate_device_address(&dev->dev.controller.address, > &_dev->dev.controller.address); > And I naturally missed this ... I've since adjusted my changes (here's a cut-n-paste): } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.index); DUP_FIELD(dev, _dev, dev.controller.model); + DUP_FIELD(dev, _dev, dev.controller.ports); + DUP_FIELD(dev, _dev, dev.controller.vectors); + DUP_FIELD(dev, _dev, dev.controller.queues); + duplicate_device_address(&dev->dev.master.address, + &_dev->dev.master.address); + duplicate_device_address(&dev->dev.controller.address, + &_dev->dev.controller.address); } >>> } >>> + >>> return dev; >>> } >>> >>> @@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct >>> domain **dominfo) >>> (*dominfo)->dev_vcpu_ct = parse_devices(xml, >>> &(*dominfo)->dev_vcpu, >>> CIM_RES_TYPE_PROC); >>> + (*dominfo)->dev_controller_ct = parse_devices(xml, >>> + >>> &(*dominfo)->dev_controller, >>> + >>> CIM_RES_TYPE_CONTROLLER); >>> >>> return ret; >>> >>> @@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) >>> cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); >>> cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); >>> cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); >>> + cleanup_virt_devices(&dom->dev_controller, >>> dom->dev_controller_ct); >>> >>> free(dom); >>> >>> diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h >>> index a92e223..cc58970 100644 >>> --- a/libxkutil/device_parsing.h >>> +++ b/libxkutil/device_parsing.h >>> @@ -163,6 +163,11 @@ struct input_device { >>> char *bus; >>> }; >>> >>> +struct controller_device { >>> + char *type; >>> + char *model; > struct device_address address; > >>> +}; >>> + >>> struct virt_device { >>> uint16_t type; >>> union { >>> @@ -174,6 +179,7 @@ struct virt_device { >>> struct graphics_device graphics; >>> struct console_device console; >>> struct input_device input; >>> + struct controller_device controller; >>> } dev; >>> char *id; >>> }; >>> @@ -249,6 +255,9 @@ struct domain { >>> >>> struct virt_device *dev_vcpu; >>> int dev_vcpu_ct; >>> + >>> + struct virt_device *dev_controller; >>> + int dev_controller_ct; >>> }; >>> >>> struct virt_device *virt_device_dup(struct virt_device *dev); >>> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >>> index 18c4765..537238d 100644 >>> --- a/libxkutil/xmlgen.c >>> +++ b/libxkutil/xmlgen.c >>> @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, >>> struct domain *dominfo) >>> return NULL; >>> } >>> >>> +static const char *controller_xml(xmlNodePtr root, struct domain >>> *dominfo) >>> +{ >>> + int i; >>> + >>> + for (i = 0; i < dominfo->dev_controller_ct; i++) { >>> + xmlNodePtr tmp; >>> + struct virt_device *_dev = &dominfo->dev_controller[i]; >>> + if (_dev->type == CIM_RES_TYPE_UNKNOWN) >>> + continue; >>> + >>> + struct controller_device *dev = &_dev->dev.controller; >>> + >>> + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", >>> NULL); >>> + if (tmp == NULL) >>> + return XML_ERROR; >>> + >>> + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); >>> + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); >> Model is an optional attribute. So if I read this correctly dev->model >> might be NULL and you create a new property with it. I am not sure what >> libvirt is going to do about it. > > if (dev->address.ct > 0) > return device_address_xml(tmp, &dev->address); > > > From fiuczy at linux.vnet.ibm.com Thu Mar 13 14:10:59 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 15:10:59 +0100 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <5321A863.50800@redhat.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> <53208D13.1070303@linux.vnet.ibm.com> <5321A863.50800@redhat.com> Message-ID: <5321BC73.8060305@linux.vnet.ibm.com> On 03/13/2014 01:45 PM, John Ferlan wrote: > > > On 03/12/2014 12:36 PM, Boris Fiuczynski wrote: >>> diff --git a/src/svpc_types.h b/src/svpc_types.h >>> index 404e428..d76097c 100644 >>> --- a/src/svpc_types.h >>> +++ b/src/svpc_types.h >>> @@ -32,12 +32,13 @@ >>> #define CIM_RES_TYPE_DISK 17 >>> #define CIM_RES_TYPE_GRAPHICS 24 >>> #define CIM_RES_TYPE_INPUT 13 >>> +#define CIM_RES_TYPE_CONTROLLER 33 >> 33 is DMTF reserved as an Ethernet Connection the next logical number in >> libvirt-cim terms would be 32771 (see below) > > > Do you have a link handy to the specification that describes the > numbers? I know I used to have a link, but I cannot find it any more. > > tks, > > John John, sure! http://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_ResourceAllocationSettingData.html I suggested #define CIM_RES_TYPE_CONTROLLER 32771 that is for provider pluming but when generating the CIM instance I suggested to set CIM_ResourceAllocationSettingData.ResourceType as Other or 1 to make use of CIM_ResourceAllocationSettingData.OtherResourceType and CIM_ResourceAllocationSettingData.ResourceSubType as explained in my response to Patch 2/3 >>> #define CIM_RES_TYPE_UNKNOWN 1000 >>> #define CIM_RES_TYPE_IMAGE 32768 >>> #define CIM_RES_TYPE_CONSOLE 32769 >>> #define CIM_RES_TYPE_EMU 32770 >>> >>> -#define CIM_RES_TYPE_COUNT 7 >>> +#define CIM_RES_TYPE_COUNT 8 >>> const static int cim_res_types[CIM_RES_TYPE_COUNT] = >>> {CIM_RES_TYPE_NET, >>> CIM_RES_TYPE_DISK, >>> @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = >>> CIM_RES_TYPE_GRAPHICS, >>> CIM_RES_TYPE_INPUT, >>> CIM_RES_TYPE_CONSOLE, >>> + CIM_RES_TYPE_CONTROLLER, >>> }; >>> >>> #define CIM_VSSD_RECOVERY_NONE 2 >>> >> >> > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Thu Mar 13 14:00:52 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 15:00:52 +0100 Subject: [Libvirt-cim] [PATCH 3/3] VSMS: Support for domains with controller devices In-Reply-To: <532184B1.2080109@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-4-git-send-email-gesaint@linux.vnet.ibm.com> <532184B1.2080109@linux.vnet.ibm.com> Message-ID: <5321BA14.70000@linux.vnet.ibm.com> Here is the rest of the address code On 03/13/2014 11:13 AM, Boris Fiuczynski wrote: > On 03/03/2014 08:38 AM, Xu Wang wrote: >> Signed-off-by: Xu Wang >> --- >> src/Virt_VirtualSystemManagementService.c | 44 >> +++++++++++++++++++++++++++++ >> 1 files changed, 44 insertions(+), 0 deletions(-) >> >> diff --git a/src/Virt_VirtualSystemManagementService.c >> b/src/Virt_VirtualSystemManagementService.c >> index e146470..1a34ff8 100644 >> --- a/src/Virt_VirtualSystemManagementService.c >> +++ b/src/Virt_VirtualSystemManagementService.c >> @@ -1848,6 +1848,28 @@ 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 *msg = NULL; >> + const char *val; >> + >> + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { >> + CU_DEBUG("ControllerRASD Type field not valid"); >> + goto out; >> + } >> + dev->dev.controller.type = strdup(val); >> + >> + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { >> + CU_DEBUG("Invalid value for Model in ControllerRASD"); >> + goto out; >> + } >> + dev->dev.controller.model = strdup(val); > I have already written before that the CIM instance uniqueness is with > the current code not guaranteed. I suggest the following schema for the > instanceID: /controller:: > To accomplish this you need to set dev->id here to (abbreviated) > "controller:"+dev->dev.controller.type+":"dev->dev.controller.index > btw. this is also needed to be set in method parse_controller_device in > libxkutil/device_parsing.c > I might have missed that before. > msg = rasd_to_device_address(inst, &dev->dev.controller.address); >> + >> + out: >> + >> + return msg; >> + return NULL; >> +} >> + >> static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, >> struct virt_device *dev, >> uint16_t type, >> @@ -1868,6 +1890,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"; >> @@ -1888,6 +1912,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"; >> @@ -1997,6 +2023,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; >> @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray >> *resources, >> &domain->dev_input[0], >> ns, >> p_error); >> + } else if (type == CIM_RES_TYPE_CONTROLLER) { >> + msg = rasd_to_vdev(inst, >> + domain, >> + >> &domain->dev_controller[domain->dev_controller_ct], >> + ns, >> + p_error); >> + if (msg == NULL) >> + domain->dev_controller_ct += 1; May I suggest this implementation? 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; >> >> @@ -2918,6 +2956,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; >> @@ -3039,6 +3080,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) || > In libvirt controller can be dynamically added and deleted (hotplug and > hotunplug). If I am not mistaken you prevent this here and also below > (resource_add & resource_mod). >> (type == CIM_RES_TYPE_INPUT)) >> cu_statusf(_BROKER, &s, CMPI_RC_OK, >> ""); >> else { >> @@ -3121,6 +3163,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, ""); >> @@ -3198,6 +3241,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 { >> > > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Mar 13 14:00:35 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 10:00:35 -0400 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <53208D13.1070303@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> <53208D13.1070303@linux.vnet.ibm.com> Message-ID: <5321BA03.7020502@redhat.com> On 03/12/2014 12:36 PM, Boris Fiuczynski wrote: > On 03/03/2014 08:38 AM, Xu Wang wrote: >> Signed-off-by: Xu Wang >> --- >> libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- >> libxkutil/device_parsing.h | 9 ++++++ >> libxkutil/xmlgen.c | 28 ++++++++++++++++++++ >> src/svpc_types.h | 4 ++- >> 4 files changed, 101 insertions(+), 2 deletions(-) >> >> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c >> index d2d3859..1937132 100644 >> --- a/libxkutil/device_parsing.c >> +++ b/libxkutil/device_parsing.c >> @@ -1,5 +1,5 @@ >> /* >> - * Copyright IBM Corp. 2007, 2013 >> + * Copyright IBM Corp. 2007, 2014 >> * >> * Authors: >> * Dan Smith >> @@ -49,6 +49,7 @@ >> #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ >> "/domain/devices/console" >> #define INPUT_XPATH (xmlChar *)"/domain/devices/input" >> +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" >> >> #define DEFAULT_BRIDGE "xenbr0" >> #define DEFAULT_NETWORK "default" >> @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) >> free(dev->bus); >> } >> >> +static void cleanup_controller_device(struct controller_device *dev) >> +{ >> + if (dev == NULL) >> + return; >> + >> + free(dev->type); >> + free(dev->model); >> +} >> + >> void cleanup_virt_device(struct virt_device *dev) >> { >> if (dev == NULL) >> @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) >> cleanup_input_device(&dev->dev.input); >> else if (dev->type == CIM_RES_TYPE_CONSOLE) >> cleanup_console_device(&dev->dev.console); >> + else if (dev->type == CIM_RES_TYPE_CONTROLLER) >> + cleanup_controller_device(&dev->dev.controller); >> >> free(dev->id); >> >> @@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) >> return 0; >> } >> >> +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) >> +{ >> + struct virt_device *vdev = NULL; >> + struct controller_device *cdev = NULL; >> + int ret; >> + >> + vdev = calloc(1, sizeof(*vdev)); >> + if (vdev == NULL) >> + goto err; >> + >> + cdev = &(vdev->dev.controller); >> + >> + cdev->type = get_attr_value(node, "type"); >> + cdev->model = get_attr_value(node, "model"); >> + >> + if (cdev->type == NULL) >> + goto err; >> + >> + vdev->type = CIM_RES_TYPE_CONTROLLER; >> + >> + ret = asprintf(&vdev->id, "%s", cdev->type); > What is going to happen if you have more than one instance of the same > type of controller? In other words, I do not think that type is unique > to be the ID. To make it unique you also need the index which is also a > mandatory attribute. >> + if (ret == -1) { >> + CU_DEBUG("Failed to create controller id string"); >> + goto err; >> + } >> + >> + *vdevs = vdev; >> + >> + return 1; >> + err: >> + cleanup_controller_device(cdev); >> + free(vdev); >> + >> + return 0; >> +} >> + >> static bool resize_devlist(struct virt_device **list, int newsize) >> { >> struct virt_device *_list; >> @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) >> func = &parse_input_device; >> break; >> >> + case CIM_RES_TYPE_CONTROLLER: >> + xpathstr = CONTROLLER_XPATH; >> + func = &parse_controller_device; >> + >> default: >> CU_DEBUG("Unrecognized device type. Returning."); >> goto err1; >> @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) >> } else if (dev->type == CIM_RES_TYPE_CONSOLE) { >> console_device_dup(&dev->dev.console, >> &_dev->dev.console); >> + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { >> + DUP_FIELD(dev, _dev, dev.controller.type); >> + DUP_FIELD(dev, _dev, dev.controller.model); >> } >> + >> return dev; >> } >> >> @@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) >> (*dominfo)->dev_vcpu_ct = parse_devices(xml, >> &(*dominfo)->dev_vcpu, >> CIM_RES_TYPE_PROC); >> + (*dominfo)->dev_controller_ct = parse_devices(xml, >> + &(*dominfo)->dev_controller, >> + CIM_RES_TYPE_CONTROLLER); >> >> return ret; >> >> @@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) >> cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); >> cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); >> cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); >> + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); >> >> free(dom); >> >> diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h >> index a92e223..cc58970 100644 >> --- a/libxkutil/device_parsing.h >> +++ b/libxkutil/device_parsing.h >> @@ -163,6 +163,11 @@ struct input_device { >> char *bus; >> }; >> >> +struct controller_device { >> + char *type; >> + char *model; >> +}; >> + >> struct virt_device { >> uint16_t type; >> union { >> @@ -174,6 +179,7 @@ struct virt_device { >> struct graphics_device graphics; >> struct console_device console; >> struct input_device input; >> + struct controller_device controller; >> } dev; >> char *id; >> }; >> @@ -249,6 +255,9 @@ struct domain { >> >> struct virt_device *dev_vcpu; >> int dev_vcpu_ct; >> + >> + struct virt_device *dev_controller; >> + int dev_controller_ct; >> }; >> >> struct virt_device *virt_device_dup(struct virt_device *dev); >> diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c >> index 18c4765..537238d 100644 >> --- a/libxkutil/xmlgen.c >> +++ b/libxkutil/xmlgen.c >> @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) >> return NULL; >> } >> >> +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) >> +{ >> + int i; >> + >> + for (i = 0; i < dominfo->dev_controller_ct; i++) { >> + xmlNodePtr tmp; >> + struct virt_device *_dev = &dominfo->dev_controller[i]; >> + if (_dev->type == CIM_RES_TYPE_UNKNOWN) >> + continue; >> + >> + struct controller_device *dev = &_dev->dev.controller; >> + >> + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); >> + if (tmp == NULL) >> + return XML_ERROR; >> + >> + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); >> + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); > Model is an optional attribute. So if I read this correctly dev->model > might be NULL and you create a new property with it. I am not sure what > libvirt is going to do about it. >> + } >> + >> + return NULL; >> +} >> + >> static char *system_xml(xmlNodePtr root, struct domain *domain) >> { >> xmlNodePtr tmp; >> @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) >> dominfo->dev_input_ct = 1; >> dominfo->dev_input = dev; >> break; >> + case CIM_RES_TYPE_CONTROLLER: >> + func = controller_xml; >> + dominfo->dev_controller_ct = 1; >> + dominfo->dev_controller = dev; >> default: >> cleanup_virt_devices(&dev, 1); >> goto out; >> @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) >> &console_xml, >> &graphics_xml, >> &emu_xml, >> + &controller_xml, >> NULL >> }; >> >> diff --git a/src/svpc_types.h b/src/svpc_types.h >> index 404e428..d76097c 100644 >> --- a/src/svpc_types.h >> +++ b/src/svpc_types.h >> @@ -32,12 +32,13 @@ >> #define CIM_RES_TYPE_DISK 17 >> #define CIM_RES_TYPE_GRAPHICS 24 >> #define CIM_RES_TYPE_INPUT 13 >> +#define CIM_RES_TYPE_CONTROLLER 33 > 33 is DMTF reserved as an Ethernet Connection the next logical number in > libvirt-cim terms would be 32771 (see below) >> #define CIM_RES_TYPE_UNKNOWN 1000 >> #define CIM_RES_TYPE_IMAGE 32768 >> #define CIM_RES_TYPE_CONSOLE 32769 >> #define CIM_RES_TYPE_EMU 32770 >> >> -#define CIM_RES_TYPE_COUNT 7 >> +#define CIM_RES_TYPE_COUNT 8 >> const static int cim_res_types[CIM_RES_TYPE_COUNT] = >> {CIM_RES_TYPE_NET, >> CIM_RES_TYPE_DISK, >> @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = >> CIM_RES_TYPE_GRAPHICS, >> CIM_RES_TYPE_INPUT, >> CIM_RES_TYPE_CONSOLE, >> + CIM_RES_TYPE_CONTROLLER, >> }; >> >> #define CIM_VSSD_RECOVERY_NONE 2 >> > > Because the "importance" of this ratcheted up a bit, I've gone ahead and started trying to add the missing parts myself. I probably have gone overboard, but I added the index, ports, queues, vectors, address, and master fields as described in the controller section of the domain. The "master" inside libvirt is parsed similarly to the address as a list of pairs that we don't care what the contents are - just that we copy them over. Taking the 1/3 changes, I've attached the adjustments. I've run *just* this pair of changes thru cimtest without any new failures than I found with the rawio/sgio changes. You should be able to just "git am" them to the existing 1/3 changes. John -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Adjustments-to-patch-1-3.patch Type: text/x-patch Size: 6583 bytes Desc: not available URL: From fiuczy at linux.vnet.ibm.com Thu Mar 13 15:16:11 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 16:16:11 +0100 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5321CBBB.4030800@linux.vnet.ibm.com> Just revisiting the mof again. I am aware what KVM supports regarding controllers nut does LXC really support controllers? Looking below at the mof... it apparently does! If it does not than the class LXC_ControllerResourceAllocationSettingData should be deleted! Also I am not aware to what extend Xen supports controllers. Any ideas? On 03/03/2014 08:38 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ > schema/ResourceAllocationSettingData.registration | 3 ++ > src/Virt_RASD.c | 24 ++++++++++++++++++ > 3 files changed, 54 insertions(+), 0 deletions(-) > > diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof > index 6b649de..3512170 100644 > --- a/schema/ResourceAllocationSettingData.mof > +++ b/schema/ResourceAllocationSettingData.mof > @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData > string BusType; > }; > > +[Description ("Xen virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData > +{ > + string Type; > + string Model; > +}; > + > +[Description ("KVM virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData > +{ > + string Type; > + string Model; > +}; > + > +[Description ("LXC virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData > +{ > + string Type; > + string Model; > +}; > + > [Description ("Xen virtual network pool settings"), > Provider("cmpi::Virt_RASD") > ] -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Mar 13 15:20:14 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 11:20:14 -0400 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <5321BC73.8060305@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> <53208D13.1070303@linux.vnet.ibm.com> <5321A863.50800@redhat.com> <5321BC73.8060305@linux.vnet.ibm.com> Message-ID: <5321CCAE.3030904@redhat.com> On 03/13/2014 10:10 AM, Boris Fiuczynski wrote: > On 03/13/2014 01:45 PM, John Ferlan wrote: >> >> >> On 03/12/2014 12:36 PM, Boris Fiuczynski wrote: >>>> diff --git a/src/svpc_types.h b/src/svpc_types.h >>>> index 404e428..d76097c 100644 >>>> --- a/src/svpc_types.h >>>> +++ b/src/svpc_types.h >>>> @@ -32,12 +32,13 @@ >>>> #define CIM_RES_TYPE_DISK 17 >>>> #define CIM_RES_TYPE_GRAPHICS 24 >>>> #define CIM_RES_TYPE_INPUT 13 >>>> +#define CIM_RES_TYPE_CONTROLLER 33 >>> 33 is DMTF reserved as an Ethernet Connection the next logical number in >>> libvirt-cim terms would be 32771 (see below) >> >> >> Do you have a link handy to the specification that describes the >> numbers? I know I used to have a link, but I cannot find it any more. >> >> tks, >> >> John > John, sure! > http://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_ResourceAllocationSettingData.html > I was thinking more along the lines of a link where the "33" is being defined since as you pointed out it was reserved. John From fiuczy at linux.vnet.ibm.com Thu Mar 13 15:29:09 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 16:29:09 +0100 Subject: [Libvirt-cim] [PATCH 1/3] libxutil: Controller Support In-Reply-To: <5321CCAE.3030904@redhat.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-2-git-send-email-gesaint@linux.vnet.ibm.com> <53208D13.1070303@linux.vnet.ibm.com> <5321A863.50800@redhat.com> <5321BC73.8060305@linux.vnet.ibm.com> <5321CCAE.3030904@redhat.com> Message-ID: <5321CEC5.2030101@linux.vnet.ibm.com> ResourceType uint16 Description string The type of resource this allocation setting represents. ModelCorrespondence string CIM_ResourceAllocationSettingData.OtherResourceType, CIM_ResourceAllocationSettingData.ResourceSubType ValueMap string 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, .., 0x8000..0xFFFF Values string Other, Computer System, Processor, Memory, IDE Controller, Parallel SCSI HBA, FC HBA, iSCSI HBA, IB HCA, Ethernet Adapter, Other Network Adapter, I/O Slot, I/O Device, Floppy Drive, CD Drive, DVD drive, Disk Drive, Tape Drive, Storage Extent, Other storage device, Serial port, Parallel port, USB Controller, Graphics controller, IEEE 1394 Controller, Partitionable Unit, Base Partitionable Unit, Power, Cooling Capacity, Ethernet Switch Port, Logical Disk, Storage Volume, Ethernet Connection, DMTF reserved, Vendor Reserved That is included in the ValueMap! On 03/13/2014 04:20 PM, John Ferlan wrote: > > > On 03/13/2014 10:10 AM, Boris Fiuczynski wrote: >> On 03/13/2014 01:45 PM, John Ferlan wrote: >>> >>> >>> On 03/12/2014 12:36 PM, Boris Fiuczynski wrote: >>>>> diff --git a/src/svpc_types.h b/src/svpc_types.h >>>>> index 404e428..d76097c 100644 >>>>> --- a/src/svpc_types.h >>>>> +++ b/src/svpc_types.h >>>>> @@ -32,12 +32,13 @@ >>>>> #define CIM_RES_TYPE_DISK 17 >>>>> #define CIM_RES_TYPE_GRAPHICS 24 >>>>> #define CIM_RES_TYPE_INPUT 13 >>>>> +#define CIM_RES_TYPE_CONTROLLER 33 >>>> 33 is DMTF reserved as an Ethernet Connection the next logical number in >>>> libvirt-cim terms would be 32771 (see below) >>> >>> >>> Do you have a link handy to the specification that describes the >>> numbers? I know I used to have a link, but I cannot find it any more. >>> >>> tks, >>> >>> John >> John, sure! >> http://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_ResourceAllocationSettingData.html >> > > I was thinking more along the lines of a link where the "33" is being > defined since as you pointed out it was reserved. > > > John > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Mar 13 15:41:36 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 11:41:36 -0400 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <5321CBBB.4030800@linux.vnet.ibm.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> <5321CBBB.4030800@linux.vnet.ibm.com> Message-ID: <5321D1B0.5060003@redhat.com> On 03/13/2014 11:16 AM, Boris Fiuczynski wrote: > Just revisiting the mof again. > I am aware what KVM supports regarding controllers nut does LXC really > support controllers? Looking below at the mof... it apparently does! If > it does not than the class LXC_ControllerResourceAllocationSettingData > should be deleted! > Also I am not aware to what extend Xen supports controllers. Any ideas? > No idea about Xen, but in looking through the libvirt source code there is no reference to virDomainControllerDefPtr in any Xen driver, although are references to say virDomainDiskDefPtr, which is the libvirt corollary to disk definitions... And I believe you're right about LXC as well. It seems this change should be "constricted" to the KVM controller. I assume that would then also remove the Xen_* and LXC_* controller defs in the registration file too? Or we keep it there, but just empty? John > On 03/03/2014 08:38 AM, Xu Wang wrote: >> Signed-off-by: Xu Wang >> --- >> schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ >> schema/ResourceAllocationSettingData.registration | 3 ++ >> src/Virt_RASD.c | 24 ++++++++++++++++++ >> 3 files changed, 54 insertions(+), 0 deletions(-) >> >> diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof >> index 6b649de..3512170 100644 >> --- a/schema/ResourceAllocationSettingData.mof >> +++ b/schema/ResourceAllocationSettingData.mof >> @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData >> string BusType; >> }; >> >> +[Description ("Xen virtual controller device"), >> + Provider("cmpi::Virt_RASD") >> +] >> +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData >> +{ >> + string Type; >> + string Model; >> +}; >> + >> +[Description ("KVM virtual controller device"), >> + Provider("cmpi::Virt_RASD") >> +] >> +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData >> +{ >> + string Type; >> + string Model; >> +}; >> + >> +[Description ("LXC virtual controller device"), >> + Provider("cmpi::Virt_RASD") >> +] >> +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData >> +{ >> + string Type; >> + string Model; >> +}; >> + >> [Description ("Xen virtual network pool settings"), >> Provider("cmpi::Virt_RASD") >> ] > > > From fiuczy at linux.vnet.ibm.com Thu Mar 13 16:41:04 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Thu, 13 Mar 2014 17:41:04 +0100 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <5321D1B0.5060003@redhat.com> References: <1393832318-18310-1-git-send-email-gesaint@linux.vnet.ibm.com> <1393832318-18310-3-git-send-email-gesaint@linux.vnet.ibm.com> <5321CBBB.4030800@linux.vnet.ibm.com> <5321D1B0.5060003@redhat.com> Message-ID: <5321DFA0.5070003@linux.vnet.ibm.com> On 03/13/2014 04:41 PM, John Ferlan wrote: > > > On 03/13/2014 11:16 AM, Boris Fiuczynski wrote: >> Just revisiting the mof again. >> I am aware what KVM supports regarding controllers nut does LXC really >> support controllers? Looking below at the mof... it apparently does! If >> it does not than the class LXC_ControllerResourceAllocationSettingData >> should be deleted! >> Also I am not aware to what extend Xen supports controllers. Any ideas? >> > > No idea about Xen, but in looking through the libvirt source code there > is no reference to virDomainControllerDefPtr in any Xen driver, although > are references to say virDomainDiskDefPtr, which is the libvirt > corollary to disk definitions... > > And I believe you're right about LXC as well. > > It seems this change should be "constricted" to the KVM controller. I > assume that would then also remove the Xen_* and LXC_* controller defs > in the registration file too? Or we keep it there, but just empty? > > John I would suggest to remove the classes as well as the registration. > > >> On 03/03/2014 08:38 AM, Xu Wang wrote: >>> Signed-off-by: Xu Wang >>> --- >>> schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ >>> schema/ResourceAllocationSettingData.registration | 3 ++ >>> src/Virt_RASD.c | 24 ++++++++++++++++++ >>> 3 files changed, 54 insertions(+), 0 deletions(-) >>> >>> diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof >>> index 6b649de..3512170 100644 >>> --- a/schema/ResourceAllocationSettingData.mof >>> +++ b/schema/ResourceAllocationSettingData.mof >>> @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData >>> string BusType; >>> }; >>> >>> +[Description ("Xen virtual controller device"), >>> + Provider("cmpi::Virt_RASD") >>> +] >>> +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData >>> +{ >>> + string Type; >>> + string Model; >>> +}; >>> + >>> +[Description ("KVM virtual controller device"), >>> + Provider("cmpi::Virt_RASD") >>> +] >>> +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData >>> +{ >>> + string Type; >>> + string Model; >>> +}; >>> + >>> +[Description ("LXC virtual controller device"), >>> + Provider("cmpi::Virt_RASD") >>> +] >>> +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData >>> +{ >>> + string Type; >>> + string Model; >>> +}; >>> + >>> [Description ("Xen virtual network pool settings"), >>> Provider("cmpi::Virt_RASD") >>> ] >> >> >> > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Thu Mar 13 22:26:59 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:26:59 -0400 Subject: [Libvirt-cim] [REWORK 0/7] Rework the controller patch series Message-ID: <1394749626-22498-1-git-send-email-jferlan@redhat.com> I took the "liberty" of making some adjustments based on the base series. I have left the base code "as is" in patches 1, 3, and 6. If I simply apply 1 & 2 and more specifically - if I modify patch 1 to just add the "break;"'s in 'do_parse()' and 'device_to_xml()', then cimtest has "new" failures, such as: -------------------------------------------------------------------- ComputerSystem - 41_cs_to_settingdefinestate.py: FAIL ERROR - Exception details: KVM_SystemDevice returned 0 Logical Devices objects ERROR - Exception details is Failed to get SystemDevice information CIM_ERR_FAILED: Couldn't get device instances -------------------------------------------------------------------- Memory - 02_defgetmem.py: FAIL ERROR - No devices returned ERROR - Exception: 'int' object is not iterable CIM_ERR_FAILED: Couldn't get device instances -------------------------------------------------------------------- Processor - 02_definesys_get_procs.py: FAIL ERROR - No devices returned ERROR - Exception: 'int' object is not iterable CIM_ERR_FAILED: Couldn't get device instances -------------------------------------------------------------------- RASD - 03_rasd_errs.py: FAIL ERROR - Expected 6 RASDs, got 7 -------------------------------------------------------------------- ResourceAllocationFromPool - 01_forward.py: FAIL ERROR - 7 RASD insts != 6 pool insts -------------------------------------------------------------------- ResourceAllocationFromPool - 02_reverse.py: FAIL ERROR - 7 RASD insts != 6 pool insts -------------------------------------------------------------------- SettingsDefine - 01_forward.py: FAIL ERROR - 6 device insts != 7 RASD insts -------------------------------------------------------------------- SettingsDefine - 02_reverse.py: FAIL ERROR - Got 9 RASDs, expected 7 ERROR - Failed to verify RASDs -------------------------------------------------------------------- VirtualSystemManagementService - 16_removeresource.py: FAIL ERROR - No devices returned ERROR - UnboundLocalError : local variable 'ccn' referenced before assignment Traceback (most recent call last): File "/home/jferlan/git/cimtest.work/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "16_removeresource.py", line 95, in main if ccn == input: UnboundLocalError: local variable 'ccn' referenced before assignment ERROR - None CIM_ERR_FAILED: Couldn't get device instances -------------------------------------------------------------------- VirtualSystemManagementService - 31_unset_netrasd.py: FAIL ERROR - CIMError : (1, u"CIM_ERR_FAILED: Couldn't get device instances") Traceback (most recent call last): ... assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class) ... CIMError: (1, u"CIM_ERR_FAILED: Couldn't get device instances") ERROR - None -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL ERROR - CIMError : (1, u"CIM_ERR_FAILED: Couldn't get device instances") Traceback (most recent call last): ... assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class) ... CIMError: (1, u"CIM_ERR_FAILED: Couldn't get device instances") ERROR - None -------------------------------------------------------------------- I haven't dug in too deeply but there's some disconnect between the new 'controller' device and other parts. It took a bit of time to just get things where there are now - I can continue with this, but I wanted to "share" in hopes that someone else can also look and give me some hints. I'm hoping it's something simple and not that I have to have something else - although I'm beginning to think I need a logical device... I have not completed the 3 of 3 changes to manage all the new fields. I figured I could add those eventually, but I did want to make sure I was setting up the instance id correctly as described in the code reviews thus far. John Ferlan (4): Adjustments to patch 1/3 Rename set_rasd_device_address Changes to 2/3 to support more fields Changes to 3 of 3 from code review Xu Wang (3): libxutil: Controller Support RASD: Schema and Provider Support for Controller RASDs VSMS: Support for domains with controller devices libxkutil/device_parsing.c | 99 ++++++++++++++++++++++- libxkutil/device_parsing.h | 15 ++++ libxkutil/xmlgen.c | 47 +++++++++++ schema/ResourceAllocationSettingData.mof | 45 +++++++++++ schema/ResourceAllocationSettingData.registration | 1 + src/Virt_ElementSettingData.c | 1 + src/Virt_RASD.c | 81 +++++++++++++++++-- src/Virt_SettingsDefineState.c | 1 + src/Virt_VSSDComponent.c | 1 + src/Virt_VirtualSystemManagementService.c | 70 ++++++++++++++++ src/svpc_types.h | 4 +- 11 files changed, 355 insertions(+), 10 deletions(-) -- 1.8.5.3 From jferlan at redhat.com Thu Mar 13 22:27:00 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:27:00 -0400 Subject: [Libvirt-cim] [PATCH 1/7] libxutil: Controller Support In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <1394749626-22498-2-git-send-email-jferlan@redhat.com> From: Xu Wang Signed-off-by: Xu Wang Signed-off-by: John Ferlan --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 +++++++ libxkutil/xmlgen.c | 28 +++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index c9ae886..12c52dc 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith @@ -49,6 +49,7 @@ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" #define DEFAULT_BRIDGE "xenbr0" #define DEFAULT_NETWORK "default" @@ -306,6 +307,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); } +static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -323,6 +333,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller); free(dev->id); @@ -1101,6 +1113,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + + if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1224,6 +1272,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break; + case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1343,7 +1395,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); } + return dev; } @@ -1723,6 +1779,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER); return ret; @@ -1811,6 +1870,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); free(dom); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 92427c1..556b9f2 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -161,6 +161,11 @@ struct input_device { char *bus; }; +struct controller_device { + char *type; + char *model; +}; + struct virt_device { uint16_t type; union { @@ -172,6 +177,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -247,6 +253,9 @@ struct domain { struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; }; struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 931f0c9..96e1c28 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -794,6 +794,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; } +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1125,6 +1148,10 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1163,6 +1190,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL }; diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 #define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 -#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.8.5.3 From jferlan at redhat.com Thu Mar 13 22:27:01 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:27:01 -0400 Subject: [Libvirt-cim] [PATCH 2/7] Adjustments to patch 1/3 In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <1394749626-22498-3-git-send-email-jferlan@redhat.com> Based on review comments - I've made a few adjustments to the initial patch. This change would be merged with 1/3 once we ensure things work as expected. Differences to 1/3: 1. Add "break;" in appropriate spots as found by Coverity 2. Add controller fields for : index - Required property of ports - Optional property of vectors - Optional property of queues - Optional property of optional child of master - Optional child of with paired list of properties address - Optional child of with paired list of properties 3. Adjust the 'cdev->id' to be "controller:" + "type" + ":" + "index" where type, index is sourced from the 4. Change the CIM_RES_TYPE_CONTROLLER to 32771 Signed-off-by: John Ferlan --- libxkutil/device_parsing.c | 51 +++++++++++++++++++++++++++++++++++++++------- libxkutil/device_parsing.h | 6 ++++++ libxkutil/xmlgen.c | 27 ++++++++++++++++++++---- src/svpc_types.h | 2 +- 4 files changed, 74 insertions(+), 12 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 12c52dc..41d75b8 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -313,7 +313,13 @@ static void cleanup_controller_device(struct controller_device *dev) return; free(dev->type); + free(dev->index); free(dev->model); + free(dev->queues); + free(dev->ports); + free(dev->vectors); + cleanup_device_address(&dev->address); + cleanup_device_address(&dev->master); } void cleanup_virt_device(struct virt_device *dev) @@ -1113,10 +1119,11 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } -static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +static int parse_controller_device(xmlNode *cnode, struct virt_device **vdevs) { struct virt_device *vdev = NULL; struct controller_device *cdev = NULL; + xmlNode *child = NULL; int ret; vdev = calloc(1, sizeof(*vdev)); @@ -1125,15 +1132,36 @@ static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) cdev = &(vdev->dev.controller); - cdev->type = get_attr_value(node, "type"); - cdev->model = get_attr_value(node, "model"); - - if (cdev->type == NULL) + cdev->type = get_attr_value(cnode, "type"); + if (cdev->type == NULL) { + CU_DEBUG("No type"); goto err; - + } + cdev->index = get_attr_value(cnode, "index"); + if (cdev->index == NULL) { + CU_DEBUG("No index"); + goto err; + } + cdev->model = get_attr_value(cnode, "model"); + cdev->ports = get_attr_value(cnode, "ports"); + cdev->vectors = get_attr_value(cnode, "vectors"); + + for (child = cnode->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "address")) { + parse_device_address(child, &cdev->address); + } else if (XSTREQ(child->name, "master")) { + /* Although technically not an address it is similar + * insomuch as it's a paired list of attributes that + * we're just going to save and write out later + */ + parse_device_address(child, &cdev->master); + } else if (XSTREQ(child->name, "driver")) { + cdev->queues = get_attr_value(child, "queues"); + } + } vdev->type = CIM_RES_TYPE_CONTROLLER; - ret = asprintf(&vdev->id, "%s", cdev->type); + ret = asprintf(&vdev->id, "controller:%s:%s", cdev->type, cdev->index); if (ret == -1) { CU_DEBUG("Failed to create controller id string"); goto err; @@ -1275,6 +1303,7 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) case CIM_RES_TYPE_CONTROLLER: xpathstr = CONTROLLER_XPATH; func = &parse_controller_device; + break; default: CU_DEBUG("Unrecognized device type. Returning."); @@ -1397,7 +1426,15 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) &_dev->dev.console); } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.index); DUP_FIELD(dev, _dev, dev.controller.model); + DUP_FIELD(dev, _dev, dev.controller.ports); + DUP_FIELD(dev, _dev, dev.controller.vectors); + DUP_FIELD(dev, _dev, dev.controller.queues); + duplicate_device_address(&dev->dev.controller.master, + &_dev->dev.controller.master); + duplicate_device_address(&dev->dev.controller.address, + &_dev->dev.controller.address); } return dev; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 556b9f2..e3d5616 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,7 +163,13 @@ struct input_device { struct controller_device { char *type; + char *index; char *model; + char *ports; + char *vectors; + char *queues; + struct device_address address; + struct device_address master; }; struct virt_device { diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 96e1c28..2326b1f 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -799,6 +799,7 @@ static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) int i; for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr ctlr; xmlNodePtr tmp; struct virt_device *_dev = &dominfo->dev_controller[i]; if (_dev->type == CIM_RES_TYPE_UNKNOWN) @@ -806,12 +807,29 @@ static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) struct controller_device *dev = &_dev->dev.controller; - tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); - if (tmp == NULL) + ctlr = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (ctlr == NULL) return XML_ERROR; - xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); - xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); + /* Required */ + xmlNewProp(ctlr, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(ctlr, BAD_CAST "index", BAD_CAST dev->index); + + /* Optional */ + if (dev->model) + xmlNewProp(ctlr, BAD_CAST "model", BAD_CAST dev->model); + if (dev->ports) + xmlNewProp(ctlr, BAD_CAST "ports", BAD_CAST dev->ports); + if (dev->vectors) + xmlNewProp(ctlr, BAD_CAST "vectors", BAD_CAST dev->vectors); + if (dev->queues) { + tmp = xmlNewChild(ctlr, NULL, BAD_CAST "driver", NULL); + xmlNewProp(tmp, BAD_CAST "queueus", BAD_CAST dev->queues); + } + if (dev->master.ct > 0) + return device_address_xml(ctlr, &dev->master); + if (dev->address.ct > 0) + return device_address_xml(ctlr, &dev->address); } return NULL; @@ -1152,6 +1170,7 @@ char *device_to_xml(struct virt_device *_dev) func = controller_xml; dominfo->dev_controller_ct = 1; dominfo->dev_controller = dev; + break; default: cleanup_virt_devices(&dev, 1); goto out; diff --git a/src/svpc_types.h b/src/svpc_types.h index d76097c..7a2b653 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,11 +32,11 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 -#define CIM_RES_TYPE_CONTROLLER 33 #define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 +#define CIM_RES_TYPE_CONTROLLER 32771 #define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = -- 1.8.5.3 From jferlan at redhat.com Thu Mar 13 22:27:02 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:27:02 -0400 Subject: [Libvirt-cim] [PATCH 3/7] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <1394749626-22498-4-git-send-email-jferlan@redhat.com> From: Xu Wang Signed-off-by: Xu Wang Signed-off-by: John Ferlan --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 +++ src/Virt_RASD.c | 24 ++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index bf1fbb6..5c76a1c 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -322,6 +322,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; }; +[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..1142376 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index df1e921..f75027e 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -903,6 +903,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; } +static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, "Type", + (CMPIValue *)dev->dev.controller.type, CMPI_chars); + + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -937,6 +951,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_CONTROLLER; + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -992,6 +1009,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(dev, inst); } /* FIXME: Put the HostResource in place */ @@ -1126,6 +1145,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out; @@ -1163,6 +1184,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; } -- 1.8.5.3 From jferlan at redhat.com Thu Mar 13 22:27:03 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:27:03 -0400 Subject: [Libvirt-cim] [PATCH 4/7] Rename set_rasd_device_address In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <1394749626-22498-5-git-send-email-jferlan@redhat.com> It's about to become multi-purpose and having AddressProperties and AddressValues static is problematic. Signed-off-by: John Ferlan --- src/Virt_RASD.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index f75027e..249e6e5 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -289,10 +289,12 @@ static bool get_vol_size(const CMPIBroker *broker, } #endif -static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, +static CMPIStatus set_rasd_property_value(const CMPIBroker *broker, const CMPIObjectPath *ref, const struct device_address *addr, - CMPIInstance *inst) + CMPIInstance *inst, + const char *property_name, + const char *property_value) { int i; CMPIArray *arr_key; @@ -338,11 +340,11 @@ static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, CMPI_string); } - CMSetProperty(inst, "AddressProperties", + CMSetProperty(inst, property_name, (CMPIValue *)&arr_key, CMPI_stringA); - CMSetProperty(inst, "AddressValues", + CMSetProperty(inst, property_value, (CMPIValue *)&arr_value, CMPI_stringA); @@ -489,10 +491,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, CMPI_boolean); if (dev->dev.disk.address.ct > 0) - set_rasd_device_address(broker, + set_rasd_property_value(broker, ref, &dev->dev.disk.address, - inst); + inst, + "AddressProperties", + "AddressValues"); virStoragePoolFree(pool); virStorageVolFree(vol); @@ -658,10 +662,12 @@ static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, CMPI_chars); if (dev->dev.net.address.ct > 0) - set_rasd_device_address(broker, + set_rasd_property_value(broker, ref, &dev->dev.net.address, - inst); + inst, + "AddressProperties", + "AddressValues"); #if LIBVIR_VERSION_NUMBER < 9000 out: -- 1.8.5.3 From jferlan at redhat.com Thu Mar 13 22:27:04 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:27:04 -0400 Subject: [Libvirt-cim] [PATCH 5/7] Changes to 2/3 to support more fields In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <1394749626-22498-6-git-send-email-jferlan@redhat.com> Signed-off-by: John Ferlan --- schema/ResourceAllocationSettingData.mof | 48 +++++++++++++++------- schema/ResourceAllocationSettingData.registration | 2 - src/Virt_ElementSettingData.c | 1 + src/Virt_RASD.c | 49 +++++++++++++++++++---- src/Virt_SettingsDefineState.c | 1 + src/Virt_VSSDComponent.c | 1 + 6 files changed, 78 insertions(+), 24 deletions(-) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 5c76a1c..bec49b8 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -322,31 +322,49 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; }; -[Description ("Xen virtual controller device"), - Provider("cmpi::Virt_RASD") -] class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData { - string Type; - string Model; }; -[Description ("KVM virtual controller device"), +[Description ("KVM virtual controller device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ('Other'), " + "CIM_ResourceAllocationSettingData.OtherResourceType='controller'" + " and CIM_ResourceAllocationSettingData.ResourceSubType set to " + "one of 'ide', 'fdc', 'scsi', 'sata', 'ccid', 'virtio-serial', " + "or 'pci'."), Provider("cmpi::Virt_RASD") ] class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData { - string Type; - string Model; -}; + [Description ("Order in which the bus controller is encountered. " + "The order is controller type scoped.")] + uint64 Index; -[Description ("LXC virtual controller device"), - Provider("cmpi::Virt_RASD") -] -class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData -{ - string Type; + [Description ("Optional string providing a specific model " + "information based on the controller type.")] string Model; + + [Description ("The 'virtio-serial' controller uses the Ports and " + "Vectors to control how many devices can be connected " + "through the controller.")] + sint64 Ports; + sint64 Vectors; + + [Description ("")] + uint64 Queues; + + [Description ("Device master property names")] + string MasterProperties[]; + + [Description ("Device master property values")] + string MasterValues[]; + + [Description ("For controllers that are themselves devices on a " + "PCI or USB bus an optional element to specify the " + "exact relationship of the controller to its master " + "bus. Stored in the property and value arrays.")] + string AddressProperties[]; + string AddressValues[]; }; [Description ("Xen virtual network pool settings"), diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index 1142376..da0b7d9 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -7,7 +7,6 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance -Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -22,4 +21,3 @@ LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance -LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c index c088e49..1fa81f2 100644 --- a/src/Virt_ElementSettingData.c +++ b/src/Virt_ElementSettingData.c @@ -137,6 +137,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 249e6e5..d3922cf 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -909,16 +909,51 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; } -static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, +static CMPIStatus set_controller_rasd_params(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const struct virt_device *dev, CMPIInstance *inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMSetProperty(inst, "Type", + CMSetProperty(inst, "OtherResourceType", "controller", CMPI_chars); + CMSetProperty(inst, "ResourceSubType", (CMPIValue *)dev->dev.controller.type, CMPI_chars); - - CMSetProperty(inst, "Model", - (CMPIValue *)dev->dev.controller.model, CMPI_chars); + CMSetProperty(inst, "Index", + (CMPIValue *)dev->dev.controller.index, CMPI_uint32); + + if (dev->dev.controller.model) + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + if (dev->dev.controller.ports) + CMSetProperty(inst, "Ports", + (CMPIValue *)dev->dev.controller.ports, CMPI_uint32); + + if (dev->dev.controller.vectors) + CMSetProperty(inst, "Vectors", + (CMPIValue *)dev->dev.controller.vectors, + CMPI_uint32); + + if (dev->dev.controller.queues) + CMSetProperty(inst, "Queues", + (CMPIValue *)dev->dev.controller.queues, CMPI_uint32); + + if (dev->dev.controller.master.ct > 0) + set_rasd_property_value(broker, + ref, + &dev->dev.controller.address, + inst, + "MasterProperties", + "MasterValues"); + + if (dev->dev.controller.address.ct > 0) + set_rasd_property_value(broker, + ref, + &dev->dev.controller.address, + inst, + "AddressProperties", + "AddressValues"); return s; } @@ -958,7 +993,7 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { - type = CIM_RES_TYPE_CONTROLLER; + type = CIM_RES_TYPE_OTHER; base = "ControllerResourceAllocationSettingData"; } else { return NULL; @@ -1016,7 +1051,7 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { - s = set_controller_rasd_params(dev, inst); + s = set_controller_rasd_params(broker, ref, dev, inst); } /* FIXME: Put the HostResource in place */ diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c index c8cda97..d5c6726 100644 --- a/src/Virt_SettingsDefineState.c +++ b/src/Virt_SettingsDefineState.c @@ -361,6 +361,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c index 35bffde..734271c 100644 --- a/src/Virt_VSSDComponent.c +++ b/src/Virt_VSSDComponent.c @@ -141,6 +141,7 @@ static char* part_component[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", -- 1.8.5.3 From jferlan at redhat.com Thu Mar 13 22:27:05 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:27:05 -0400 Subject: [Libvirt-cim] [PATCH 6/7] VSMS: Support for domains with controller devices In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <1394749626-22498-7-git-send-email-jferlan@redhat.com> From: Xu Wang Signed-off-by: Xu Wang Signed-off-by: John Ferlan --- src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 3e7785e..9634481 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1838,6 +1838,28 @@ 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; + + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Type field not valid"); + goto out; + } + dev->dev.controller.type = strdup(val); + + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { + CU_DEBUG("Invalid value for Model in ControllerRASD"); + goto out; + } + dev->dev.controller.model = strdup(val); + + out: + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -1858,6 +1880,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 +1902,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 +2013,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 +2130,16 @@ static const char *classify_resources(CMPIArray *resources, &domain->dev_input[0], ns, p_error); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_controller[domain->dev_controller_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_controller_ct += 1; } + if (msg != NULL) return msg; @@ -2908,6 +2946,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 +3070,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 +3153,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 +3231,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 From jferlan at redhat.com Thu Mar 13 22:27:06 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 13 Mar 2014 18:27:06 -0400 Subject: [Libvirt-cim] [PATCH 7/7] Changes to 3 of 3 from code review In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <1394749626-22498-8-git-send-email-jferlan@redhat.com> Signed-off-by: John Ferlan --- src/Virt_VirtualSystemManagementService.c | 38 ++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 9634481..b478d41 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1841,23 +1841,42 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, static const char *controller_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { - const char *val; + const char *val = NULL; + const char *msg = NULL; + int ret; - if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { - CU_DEBUG("ControllerRASD Type field not valid"); + if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD ResourceSubType field not valid"); goto out; } dev->dev.controller.type = strdup(val); + if (cu_get_u32_prop(inst, "Index", + &dev->dev.controller.index) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Index field not valid"); + goto out; + } + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { CU_DEBUG("Invalid value for Model in ControllerRASD"); goto out; } dev->dev.controller.model = strdup(val); + ret = asprintf(&dev->id, "controller:%s:%s", + dev->dev.controller.type, + dev->dev.controller.index); + if (ret == -1) { + msg = "Failed to create controller string"; + goto out; + } + + msg = rasd_to_device_address(inst, &dev->dev.controller.address); + + out: - return NULL; + return ; } static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, @@ -2131,13 +2150,20 @@ static const char *classify_resources(CMPIArray *resources, 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, - &domain->dev_controller[domain->dev_controller_ct], + &dev, ns, p_error); if (msg == NULL) - domain->dev_controller_ct += 1; + msg = add_device_nodup(&dev, + domain->dev_controller, + dcount, + &domain->dev_controller_ct); } if (msg != NULL) -- 1.8.5.3 From jmiao at redhat.com Fri Mar 14 02:45:44 2014 From: jmiao at redhat.com (Jincheng Miao) Date: Thu, 13 Mar 2014 22:45:44 -0400 (EDT) Subject: [Libvirt-cim] [PATCH 7/7] Changes to 3 of 3 from code review In-Reply-To: <1394749626-22498-8-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> <1394749626-22498-8-git-send-email-jferlan@redhat.com> Message-ID: <1821110959.20382203.1394765144610.JavaMail.zimbra@redhat.com> ----- Original Message ----- > Signed-off-by: John Ferlan > --- > src/Virt_VirtualSystemManagementService.c | 38 > ++++++++++++++++++++++++++----- > 1 file changed, 32 insertions(+), 6 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c > b/src/Virt_VirtualSystemManagementService.c > index 9634481..b478d41 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1841,23 +1841,42 @@ static const char *input_rasd_to_vdev(CMPIInstance > *inst, > static const char *controller_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev) > { > - const char *val; > + const char *val = NULL; > + const char *msg = NULL; > + int ret; > > - if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { > - CU_DEBUG("ControllerRASD Type field not valid"); > + if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) { > + CU_DEBUG("ControllerRASD ResourceSubType field not valid"); > goto out; > } > dev->dev.controller.type = strdup(val); > > + if (cu_get_u32_prop(inst, "Index", > + &dev->dev.controller.index) != CMPI_RC_OK) { > + CU_DEBUG("ControllerRASD Index field not valid"); > + goto out; > + } > + > if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { > CU_DEBUG("Invalid value for Model in ControllerRASD"); > goto out; > } > dev->dev.controller.model = strdup(val); > > + ret = asprintf(&dev->id, "controller:%s:%s", > + dev->dev.controller.type, > + dev->dev.controller.index); > + if (ret == -1) { > + msg = "Failed to create controller string"; > + goto out; > + } > + > + msg = rasd_to_device_address(inst, &dev->dev.controller.address); > + > + > out: > > - return NULL; > + return ; I am not clear why here is just 'return' ? IMHO, if this function doesn't return anything, should it be defined returning void? Otherwise return NULL is more safe, that is because if someone wanna reference this return value, 'return' will give him a ramdom value(from a place of stack), That will be SEGV. > } > > static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > @@ -2131,13 +2150,20 @@ static const char *classify_resources(CMPIArray > *resources, > 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, > - > &domain->dev_controller[domain->dev_controller_ct], > + &dev, > ns, > p_error); > if (msg == NULL) > - domain->dev_controller_ct += 1; > + msg = add_device_nodup(&dev, > + domain->dev_controller, > + dcount, > + > &domain->dev_controller_ct); > } > > if (msg != NULL) > -- > 1.8.5.3 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > From fiuczy at linux.vnet.ibm.com Fri Mar 14 08:14:44 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 14 Mar 2014 09:14:44 +0100 Subject: [Libvirt-cim] [PATCH 5/7] Changes to 2/3 to support more fields In-Reply-To: <1394749626-22498-6-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> <1394749626-22498-6-git-send-email-jferlan@redhat.com> Message-ID: <5322BA74.50806@linux.vnet.ibm.com> On 03/13/2014 11:27 PM, John Ferlan wrote: > Signed-off-by: John Ferlan > --- > schema/ResourceAllocationSettingData.mof | 48 +++++++++++++++------- > schema/ResourceAllocationSettingData.registration | 2 - > src/Virt_ElementSettingData.c | 1 + > src/Virt_RASD.c | 49 +++++++++++++++++++---- > src/Virt_SettingsDefineState.c | 1 + > src/Virt_VSSDComponent.c | 1 + > 6 files changed, 78 insertions(+), 24 deletions(-) > > diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof > index 5c76a1c..bec49b8 100644 > --- a/schema/ResourceAllocationSettingData.mof > +++ b/schema/ResourceAllocationSettingData.mof > @@ -322,31 +322,49 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData > string BusType; > }; > > -[Description ("Xen virtual controller device"), > - Provider("cmpi::Virt_RASD") > -] > class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData > { > - string Type; > - string Model; > }; If you do not register the class why do you leave the class defined? > > -[Description ("KVM virtual controller device"), > +[Description ("KVM virtual controller device. It is identified by: " > + "CIM_ResourceAllocationSettingData.ResourceType=1 ('Other'), " > + "CIM_ResourceAllocationSettingData.OtherResourceType='controller'" > + " and CIM_ResourceAllocationSettingData.ResourceSubType set to " > + "one of 'ide', 'fdc', 'scsi', 'sata', 'ccid', 'virtio-serial', " > + "or 'pci'."), > Provider("cmpi::Virt_RASD") > ] > class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData > { > - string Type; > - string Model; > -}; > + [Description ("Order in which the bus controller is encountered. " > + "The order is controller type scoped.")] > + uint64 Index; > > -[Description ("LXC virtual controller device"), > - Provider("cmpi::Virt_RASD") > -] > -class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData > -{ > - string Type; > + [Description ("Optional string providing a specific model " > + "information based on the controller type.")] > string Model; > + > + [Description ("The 'virtio-serial' controller uses the Ports and " > + "Vectors to control how many devices can be connected " > + "through the controller.")] > + sint64 Ports; > + sint64 Vectors; Why are you using signed 64-bit integers and not unsigned ones? I do not think that negative numbers are making sense! > + > + [Description ("")] that is very brief :-) ("Number of queues for the controller.") > + uint64 Queues; > + > + [Description ("Device master property names")] > + string MasterProperties[]; > + > + [Description ("Device master property values")] > + string MasterValues[]; > + > + [Description ("For controllers that are themselves devices on a " > + "PCI or USB bus an optional element to specify the " "PCI or USB" should be removed to remain generic or you simply write the description as above for Master... [Description ("Device address property names")] ... [Description ("Device address property values")] > + "exact relationship of the controller to its master " > + "bus. Stored in the property and value arrays.")] > + string AddressProperties[]; > + string AddressValues[]; > }; > > [Description ("Xen virtual network pool settings"), > diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration > index 1142376..da0b7d9 100644 > --- a/schema/ResourceAllocationSettingData.registration > +++ b/schema/ResourceAllocationSettingData.registration > @@ -7,7 +7,6 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > -Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > @@ -22,4 +21,3 @@ LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > -LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c > index c088e49..1fa81f2 100644 > --- a/src/Virt_ElementSettingData.c > +++ b/src/Virt_ElementSettingData.c > @@ -137,6 +137,7 @@ static char* resource_allocation_setting_data[] = { > "KVM_GraphicsResourceAllocationSettingData", > "KVM_ConsoleResourceAllocationSettingData", > "KVM_InputResourceAllocationSettingData", > + "KVM_ControllerResourceAllocationSettingData", > "LXC_DiskResourceAllocationSettingData", > "LXC_MemResourceAllocationSettingData", > "LXC_NetResourceAllocationSettingData", -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Fri Mar 14 08:32:11 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 14 Mar 2014 09:32:11 +0100 Subject: [Libvirt-cim] [REWORK 0/7] Rework the controller patch series In-Reply-To: <1394749626-22498-1-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> Message-ID: <5322BE8B.6040302@linux.vnet.ibm.com> On 03/13/2014 11:26 PM, John Ferlan wrote: > I took the "liberty" of making some adjustments based on the base > series. I have left the base code "as is" in patches 1, 3, and 6. Just my observation: In leaving these untouched it makes it more difficult to review this overall but I understand that you, John, want to preserve the credits for the initial version of Xu Wang. My preference would be to have a patch series that contains the bare required changes without the history of how it evolved. John and Xu, would that be OK for both of you? -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Fri Mar 14 09:45:51 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 14 Mar 2014 10:45:51 +0100 Subject: [Libvirt-cim] [PATCH 2/7] Adjustments to patch 1/3 In-Reply-To: <1394749626-22498-3-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> <1394749626-22498-3-git-send-email-jferlan@redhat.com> Message-ID: <5322CFCF.9000504@linux.vnet.ibm.com> On 03/13/2014 11:27 PM, John Ferlan wrote: > Based on review comments - I've made a few adjustments to the initial > patch. This change would be merged with 1/3 once we ensure things work > as expected. > > Differences to 1/3: > > 1. Add "break;" in appropriate spots as found by Coverity > 2. Add controller fields for : > index - Required property of > ports - Optional property of > vectors - Optional property of > queues - Optional property of optional child of > master - Optional child of with paired list of properties > address - Optional child of with paired list of properties > 3. Adjust the 'cdev->id' to be "controller:" + "type" + ":" + "index" where > type, index is sourced from the > 4. Change the CIM_RES_TYPE_CONTROLLER to 32771 > > Signed-off-by: John Ferlan > --- > libxkutil/device_parsing.c | 51 +++++++++++++++++++++++++++++++++++++++------- > libxkutil/device_parsing.h | 6 ++++++ > libxkutil/xmlgen.c | 27 ++++++++++++++++++++---- > src/svpc_types.h | 2 +- > 4 files changed, 74 insertions(+), 12 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index 12c52dc..41d75b8 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -313,7 +313,13 @@ static void cleanup_controller_device(struct controller_device *dev) > return; > > free(dev->type); > + free(dev->index); not needed if of type uint64_t > free(dev->model); > + free(dev->queues); > + free(dev->ports); > + free(dev->vectors); > + cleanup_device_address(&dev->address); > + cleanup_device_address(&dev->master); > } > > void cleanup_virt_device(struct virt_device *dev) > @@ -1113,10 +1119,11 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) > return 0; > } > > -static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) > +static int parse_controller_device(xmlNode *cnode, struct virt_device **vdevs) > { > struct virt_device *vdev = NULL; > struct controller_device *cdev = NULL; > + xmlNode *child = NULL; char *index = NULL; > int ret; > > vdev = calloc(1, sizeof(*vdev)); > @@ -1125,15 +1132,36 @@ static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) > > cdev = &(vdev->dev.controller); > > - cdev->type = get_attr_value(node, "type"); > - cdev->model = get_attr_value(node, "model"); > - > - if (cdev->type == NULL) > + cdev->type = get_attr_value(cnode, "type"); > + if (cdev->type == NULL) { > + CU_DEBUG("No type"); > goto err; > - > + } > + cdev->index = get_attr_value(cnode, "index"); > + if (cdev->index == NULL) { > + CU_DEBUG("No index"); > + goto err; > + } index = get_attr_value(cnode, "index"); if (index != NULL) { sscanf(index, "%" PRIu64, &cdev->index); free(index); } else { CU_DEBUG("No index"); goto err; } > + cdev->model = get_attr_value(cnode, "model"); > + cdev->ports = get_attr_value(cnode, "ports"); > + cdev->vectors = get_attr_value(cnode, "vectors"); > + > + for (child = cnode->children; child != NULL; child = child->next) { > + if (XSTREQ(child->name, "address")) { > + parse_device_address(child, &cdev->address); > + } else if (XSTREQ(child->name, "master")) { > + /* Although technically not an address it is similar > + * insomuch as it's a paired list of attributes that > + * we're just going to save and write out later > + */ > + parse_device_address(child, &cdev->master); > + } else if (XSTREQ(child->name, "driver")) { > + cdev->queues = get_attr_value(child, "queues"); > + } > + } > vdev->type = CIM_RES_TYPE_CONTROLLER; > > - ret = asprintf(&vdev->id, "%s", cdev->type); > + ret = asprintf(&vdev->id, "controller:%s:%s", cdev->type, cdev->index); > if (ret == -1) { > CU_DEBUG("Failed to create controller id string"); > goto err; > @@ -1275,6 +1303,7 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) > case CIM_RES_TYPE_CONTROLLER: > xpathstr = CONTROLLER_XPATH; > func = &parse_controller_device; > + break; > > default: > CU_DEBUG("Unrecognized device type. Returning."); > @@ -1397,7 +1426,15 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) > &_dev->dev.console); > } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > DUP_FIELD(dev, _dev, dev.controller.type); > + DUP_FIELD(dev, _dev, dev.controller.index); dev->dev.controller.index = _dev->dev.controller.index; > DUP_FIELD(dev, _dev, dev.controller.model); > + DUP_FIELD(dev, _dev, dev.controller.ports); > + DUP_FIELD(dev, _dev, dev.controller.vectors); > + DUP_FIELD(dev, _dev, dev.controller.queues); > + duplicate_device_address(&dev->dev.controller.master, > + &_dev->dev.controller.master); > + duplicate_device_address(&dev->dev.controller.address, > + &_dev->dev.controller.address); > } > > return dev; > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 556b9f2..e3d5616 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -163,7 +163,13 @@ struct input_device { #define CONTROLLER_INDEX_NOT_SET -1 > > struct controller_device { > char *type; > + char *index; this is an uint64 in the mof and I would suggest to at least for the index use uint64_t since it is good to have a number when things like hostdev are to be support in the future. The numbers for ports, vectors and queues are just handed from RASDs into xml and vice versa. > char *model; > + char *ports; > + char *vectors; > + char *queues; > + struct device_address address; > + struct device_address master; > }; > > struct virt_device { > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 96e1c28..2326b1f 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -799,6 +799,7 @@ static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) > int i; > > for (i = 0; i < dominfo->dev_controller_ct; i++) { > + xmlNodePtr ctlr; > xmlNodePtr tmp; > struct virt_device *_dev = &dominfo->dev_controller[i]; > if (_dev->type == CIM_RES_TYPE_UNKNOWN) > @@ -806,12 +807,29 @@ static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) > > struct controller_device *dev = &_dev->dev.controller; > > - tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); > - if (tmp == NULL) > + ctlr = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); > + if (ctlr == NULL) > return XML_ERROR; > > - xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); > - xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); > + /* Required */ > + xmlNewProp(ctlr, BAD_CAST "type", BAD_CAST dev->type); > + xmlNewProp(ctlr, BAD_CAST "index", BAD_CAST dev->index); if (cdev->index != CONTROLLER_INDEX_NOT_SET) { char *string = NULL; if (asprintf(&string, "%" PRIu64, cdev->index) == -1) return XML_ERROR; xmlNewProp(ctlr, BAD_CAST "index", BAD_CAST string); free(string); } > + > + /* Optional */ > + if (dev->model) > + xmlNewProp(ctlr, BAD_CAST "model", BAD_CAST dev->model); > + if (dev->ports) > + xmlNewProp(ctlr, BAD_CAST "ports", BAD_CAST dev->ports); > + if (dev->vectors) > + xmlNewProp(ctlr, BAD_CAST "vectors", BAD_CAST dev->vectors); > + if (dev->queues) { > + tmp = xmlNewChild(ctlr, NULL, BAD_CAST "driver", NULL); > + xmlNewProp(tmp, BAD_CAST "queueus", BAD_CAST dev->queues); > + } > + if (dev->master.ct > 0) > + return device_address_xml(ctlr, &dev->master); > + if (dev->address.ct > 0) > + return device_address_xml(ctlr, &dev->address); > } > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Fri Mar 14 09:45:49 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 14 Mar 2014 10:45:49 +0100 Subject: [Libvirt-cim] [PATCH 7/7] Changes to 3 of 3 from code review In-Reply-To: <1394749626-22498-8-git-send-email-jferlan@redhat.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> <1394749626-22498-8-git-send-email-jferlan@redhat.com> Message-ID: <5322CFCD.1010303@linux.vnet.ibm.com> On 03/13/2014 11:27 PM, John Ferlan wrote: > Signed-off-by: John Ferlan > --- > src/Virt_VirtualSystemManagementService.c | 38 ++++++++++++++++++++++++++----- > 1 file changed, 32 insertions(+), 6 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 9634481..b478d41 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1841,23 +1841,42 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, > static const char *controller_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev) > { > - const char *val; > + const char *val = NULL; > + const char *msg = NULL; > + int ret; > > - if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { > - CU_DEBUG("ControllerRASD Type field not valid"); > + if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) { > + CU_DEBUG("ControllerRASD ResourceSubType field not valid"); > goto out; > } > dev->dev.controller.type = strdup(val); > cu_get_u64_prop if Index is of type uint64 > + if (cu_get_u32_prop(inst, "Index", > + &dev->dev.controller.index) != CMPI_RC_OK) { CU_DEBUG("ControllerRASD Index not set - DEFAULT"); dev->dev.controller.index = CONTROLLER_INDEX_NOT_SET; } else { if (asprintf(&dev->id, "controller:%s:%" PRIu64, dev->dev.controller.type, dev->dev.controller.index) == -1) { CU_DEBUG("Failed to create controller id string"); msg = "Failed to create controller id string"; goto out; } } It is possible that index during the creation of domain is not specified and than libvirt will define the index itself. > + CU_DEBUG("ControllerRASD Index field not valid"); > + goto out; > + } > + > if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { > CU_DEBUG("Invalid value for Model in ControllerRASD"); > goto out; > } > dev->dev.controller.model = strdup(val); > ---- snip ---- > + ret = asprintf(&dev->id, "controller:%s:%s", > + dev->dev.controller.type, > + dev->dev.controller.index); > + if (ret == -1) { > + msg = "Failed to create controller string"; > + goto out; > + } ---- snap ---- the above block could be deleted > + > + msg = rasd_to_device_address(inst, &dev->dev.controller.address); > + > + > out: > > - return NULL; > + return ; This should probably be return msg; > } > > static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > @@ -2131,13 +2150,20 @@ static const char *classify_resources(CMPIArray *resources, > 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, > - &domain->dev_controller[domain->dev_controller_ct], > + &dev, > ns, > p_error); > if (msg == NULL) > - domain->dev_controller_ct += 1; > + msg = add_device_nodup(&dev, > + domain->dev_controller, > + dcount, > + &domain->dev_controller_ct); > } > > if (msg != NULL) > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Fri Mar 14 10:17:32 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 06:17:32 -0400 Subject: [Libvirt-cim] [REWORK 0/7] Rework the controller patch series In-Reply-To: <5322BE8B.6040302@linux.vnet.ibm.com> References: <1394749626-22498-1-git-send-email-jferlan@redhat.com> <5322BE8B.6040302@linux.vnet.ibm.com> Message-ID: <5322D73C.7070903@redhat.com> On 03/14/2014 04:32 AM, Boris Fiuczynski wrote: > On 03/13/2014 11:26 PM, John Ferlan wrote: >> I took the "liberty" of making some adjustments based on the base >> series. I have left the base code "as is" in patches 1, 3, and 6. > Just my observation: In leaving these untouched it makes it more > difficult to review this overall but I understand that you, John, want > to preserve the credits for the initial version of Xu Wang. > My preference would be to have a patch series that contains the bare > required changes without the history of how it evolved. > John and Xu, would that be OK for both of you? > > I can merge the pieces - no problem. Author/attribution for me is not that important. I was trying to show what I added. If you pulled the series into your own git branch and rebased/merged 1/2, 3/4/5, and 6/7 - then you'd have pretty much what I'll be doing. Give me a bit of time for the coffee to start coursing through my veins and the sleep cobwebs to clear and I'll repost. John From jferlan at redhat.com Fri Mar 14 12:56:03 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 08:56:03 -0400 Subject: [Libvirt-cim] [REPOST MERGED PATCH 0/3] Repost controller series merged Message-ID: <1394801766-31755-1-git-send-email-jferlan@redhat.com> Changes since last time - 1. Address review comments 2. I did not add CONTROLLER_INDEX_NOT_SET. Since that's a -1 value and the index is an unsigned value - it just didn't seem right. Furthermore, if libvirt doesn't find the 'index' value, it defaults to using 0 when parsing the XML - so I think following that model is better. I have yet to chase down all the libvirt paths to see what happens, but I think if someone adds a controller without defining an index and that index conflicts with something already there for that named/type of controller, then libvirt will reject the xml for the guest to start requiring the "user" to fix it. 3. I didn't yet do it, but I think the 'master' may need to be removed. The libvirt documented example is:
... This examples shows that the type is 'usb' and the 'index' is 0 for both which would violate our namespace rule. The 'model' is the same too. So unless we incorporate the address into the name, then there's a conflict. I'll have to think about this one some more and of course take advice! 4. Just realized I forgot to switch the mof values for queues, ports, and vectors back to string types... I'll do that, but didn't want to lose my current cover letter. Xu Wang (3): libxutil, xmlgen: Add Controller Support RASD: Schema and Provider Support for Controller RASDs VSMS: Support for domains with controller devices libxkutil/device_parsing.c | 105 +++++++++++++++++++++- libxkutil/device_parsing.h | 15 ++++ libxkutil/xmlgen.c | 52 +++++++++++ schema/ResourceAllocationSettingData.mof | 41 +++++++++ schema/ResourceAllocationSettingData.registration | 1 + src/Virt_ElementSettingData.c | 1 + src/Virt_RASD.c | 81 +++++++++++++++-- src/Virt_SettingsDefineState.c | 1 + src/Virt_VSSDComponent.c | 1 + src/Virt_VirtualSystemManagementService.c | 76 ++++++++++++++++ src/svpc_types.h | 4 +- 11 files changed, 368 insertions(+), 10 deletions(-) -- 1.8.5.3 From jferlan at redhat.com Fri Mar 14 12:56:04 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 08:56:04 -0400 Subject: [Libvirt-cim] [PATCH 1/3] libxutil, xmlgen: Add Controller Support In-Reply-To: <1394801766-31755-1-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> Message-ID: <1394801766-31755-2-git-send-email-jferlan@redhat.com> From: Xu Wang Add support to define and save a controller found in the XML. A controller will have an "OTHER" RASD ResourceType value and make use of the CIM ResourceSubType property as the XML "type" of controller Signed-off-by: Xu Wang Signed-off-by: John Ferlan --- libxkutil/device_parsing.c | 105 ++++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 15 +++++++ libxkutil/xmlgen.c | 52 ++++++++++++++++++++++ src/svpc_types.h | 4 +- 4 files changed, 174 insertions(+), 2 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index c9ae886..f35df39 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith @@ -49,6 +49,7 @@ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" #define DEFAULT_BRIDGE "xenbr0" #define DEFAULT_NETWORK "default" @@ -306,6 +307,20 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); } +static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); + free(dev->queues); + free(dev->ports); + free(dev->vectors); + cleanup_device_address(&dev->address); + cleanup_device_address(&dev->master); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -323,6 +338,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller); free(dev->id); @@ -1101,6 +1118,71 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } +static int parse_controller_device(xmlNode *cnode, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + xmlNode *child = NULL; + char *index = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(cnode, "type"); + if (cdev->type == NULL) { + CU_DEBUG("No type"); + goto err; + } + + index = get_attr_value(cnode, "index"); + if (index != NULL) { + sscanf(index, "%" PRIu64, &cdev->index); + free(index); + } else { + CU_DEBUG("No index"); + goto err; + } + + cdev->model = get_attr_value(cnode, "model"); + cdev->ports = get_attr_value(cnode, "ports"); + cdev->vectors = get_attr_value(cnode, "vectors"); + + for (child = cnode->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "address")) { + parse_device_address(child, &cdev->address); + } else if (XSTREQ(child->name, "master")) { + /* Although technically not an address it is similar + * insomuch as it's a paired list of attributes that + * we're just going to save and write out later + */ + parse_device_address(child, &cdev->master); + } else if (XSTREQ(child->name, "driver")) { + cdev->queues = get_attr_value(child, "queues"); + } + } + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "controller:%s:%" PRIu64, + cdev->type, cdev->index); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1224,6 +1306,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break; + case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + break; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1343,7 +1430,19 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + dev->dev.controller.index = _dev->dev.controller.index; + DUP_FIELD(dev, _dev, dev.controller.model); + DUP_FIELD(dev, _dev, dev.controller.ports); + DUP_FIELD(dev, _dev, dev.controller.vectors); + DUP_FIELD(dev, _dev, dev.controller.queues); + duplicate_device_address(&dev->dev.controller.master, + &_dev->dev.controller.master); + duplicate_device_address(&dev->dev.controller.address, + &_dev->dev.controller.address); } + return dev; } @@ -1723,6 +1822,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER); return ret; @@ -1811,6 +1913,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); free(dom); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 92427c1..8072f51 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -161,6 +161,17 @@ struct input_device { char *bus; }; +struct controller_device { + char *type; + uint64_t index; + char *model; + char *ports; + char *vectors; + char *queues; + struct device_address address; + struct device_address master; +}; + struct virt_device { uint16_t type; union { @@ -172,6 +183,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -247,6 +259,9 @@ struct domain { struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; }; struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 931f0c9..6418974 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -794,6 +794,52 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; } +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr ctlr; + xmlNodePtr tmp; + char *index; + + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + ctlr = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (ctlr == NULL) + return XML_ERROR; + + /* Required */ + xmlNewProp(ctlr, BAD_CAST "type", BAD_CAST dev->type); + if (asprintf(&index, "%" PRIu64, dev->index) == -1) + return XML_ERROR; + xmlNewProp(ctlr, BAD_CAST "index", BAD_CAST index); + free(index); + + /* Optional */ + if (dev->model) + xmlNewProp(ctlr, BAD_CAST "model", BAD_CAST dev->model); + if (dev->ports) + xmlNewProp(ctlr, BAD_CAST "ports", BAD_CAST dev->ports); + if (dev->vectors) + xmlNewProp(ctlr, BAD_CAST "vectors", BAD_CAST dev->vectors); + if (dev->queues) { + tmp = xmlNewChild(ctlr, NULL, BAD_CAST "driver", NULL); + xmlNewProp(tmp, BAD_CAST "queueus", BAD_CAST dev->queues); + } + if (dev->master.ct > 0) + return device_address_xml(ctlr, &dev->master); + if (dev->address.ct > 0) + return device_address_xml(ctlr, &dev->address); + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1125,6 +1171,11 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; + break; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1163,6 +1214,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL }; diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..7a2b653 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -36,8 +36,9 @@ #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 +#define CIM_RES_TYPE_CONTROLLER 32771 -#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.8.5.3 From jferlan at redhat.com Fri Mar 14 12:56:05 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 08:56:05 -0400 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1394801766-31755-1-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> Message-ID: <1394801766-31755-3-git-send-email-jferlan@redhat.com> From: Xu Wang Add the various controller fields and support for RASDs Signed-off-by: Xu Wang Signed-off-by: John Ferlan --- schema/ResourceAllocationSettingData.mof | 41 ++++++++++++ schema/ResourceAllocationSettingData.registration | 1 + src/Virt_ElementSettingData.c | 1 + src/Virt_RASD.c | 81 ++++++++++++++++++++--- src/Virt_SettingsDefineState.c | 1 + src/Virt_VSSDComponent.c | 1 + 6 files changed, 118 insertions(+), 8 deletions(-) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index bf1fbb6..30e62c4 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -322,6 +322,47 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; }; +[Description ("KVM virtual controller device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ('Other'), " + "CIM_ResourceAllocationSettingData.OtherResourceType='controller'" + " and CIM_ResourceAllocationSettingData.ResourceSubType set to " + "one of 'ide', 'fdc', 'scsi', 'sata', 'ccid', 'virtio-serial', " + "or 'pci'."), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + [Description ("Order in which the bus controller is encountered. " + "The order is controller type scoped.")] + uint64 Index; + + [Description ("Optional string providing a specific model " + "information based on the controller type.")] + string Model; + + [Description ("The 'virtio-serial' controller uses the Ports and " + "Vectors to control how many devices can be connected " + "through the controller.")] + uint64 Ports; + uint64 Vectors; + + [Description ("Number of queues for the controller.")] + uint64 Queues; + + [Description ("Device master property names")] + string MasterProperties[]; + + [Description ("Device master property values")] + string MasterValues[]; + + [Description ("For controllers that are themselves devices on a " + "bus an optional element to specify the exact " + "relationship of the controller to its master bus. " + "Stored in the property and value arrays.")] + string AddressProperties[]; + string AddressValues[]; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..da0b7d9 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -14,6 +14,7 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c index c088e49..1fa81f2 100644 --- a/src/Virt_ElementSettingData.c +++ b/src/Virt_ElementSettingData.c @@ -137,6 +137,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index df1e921..d3922cf 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -289,10 +289,12 @@ static bool get_vol_size(const CMPIBroker *broker, } #endif -static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, +static CMPIStatus set_rasd_property_value(const CMPIBroker *broker, const CMPIObjectPath *ref, const struct device_address *addr, - CMPIInstance *inst) + CMPIInstance *inst, + const char *property_name, + const char *property_value) { int i; CMPIArray *arr_key; @@ -338,11 +340,11 @@ static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, CMPI_string); } - CMSetProperty(inst, "AddressProperties", + CMSetProperty(inst, property_name, (CMPIValue *)&arr_key, CMPI_stringA); - CMSetProperty(inst, "AddressValues", + CMSetProperty(inst, property_value, (CMPIValue *)&arr_value, CMPI_stringA); @@ -489,10 +491,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, CMPI_boolean); if (dev->dev.disk.address.ct > 0) - set_rasd_device_address(broker, + set_rasd_property_value(broker, ref, &dev->dev.disk.address, - inst); + inst, + "AddressProperties", + "AddressValues"); virStoragePoolFree(pool); virStorageVolFree(vol); @@ -658,10 +662,12 @@ static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, CMPI_chars); if (dev->dev.net.address.ct > 0) - set_rasd_device_address(broker, + set_rasd_property_value(broker, ref, &dev->dev.net.address, - inst); + inst, + "AddressProperties", + "AddressValues"); #if LIBVIR_VERSION_NUMBER < 9000 out: @@ -903,6 +909,55 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; } +static CMPIStatus set_controller_rasd_params(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, "OtherResourceType", "controller", CMPI_chars); + CMSetProperty(inst, "ResourceSubType", + (CMPIValue *)dev->dev.controller.type, CMPI_chars); + CMSetProperty(inst, "Index", + (CMPIValue *)dev->dev.controller.index, CMPI_uint32); + + if (dev->dev.controller.model) + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + if (dev->dev.controller.ports) + CMSetProperty(inst, "Ports", + (CMPIValue *)dev->dev.controller.ports, CMPI_uint32); + + if (dev->dev.controller.vectors) + CMSetProperty(inst, "Vectors", + (CMPIValue *)dev->dev.controller.vectors, + CMPI_uint32); + + if (dev->dev.controller.queues) + CMSetProperty(inst, "Queues", + (CMPIValue *)dev->dev.controller.queues, CMPI_uint32); + + if (dev->dev.controller.master.ct > 0) + set_rasd_property_value(broker, + ref, + &dev->dev.controller.address, + inst, + "MasterProperties", + "MasterValues"); + + if (dev->dev.controller.address.ct > 0) + set_rasd_property_value(broker, + ref, + &dev->dev.controller.address, + inst, + "AddressProperties", + "AddressValues"); + + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -937,6 +992,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_OTHER; + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -992,6 +1050,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(broker, ref, dev, inst); } /* FIXME: Put the HostResource in place */ @@ -1126,6 +1186,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out; @@ -1163,6 +1225,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; } diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c index c8cda97..d5c6726 100644 --- a/src/Virt_SettingsDefineState.c +++ b/src/Virt_SettingsDefineState.c @@ -361,6 +361,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c index 35bffde..734271c 100644 --- a/src/Virt_VSSDComponent.c +++ b/src/Virt_VSSDComponent.c @@ -141,6 +141,7 @@ static char* part_component[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", -- 1.8.5.3 From jferlan at redhat.com Fri Mar 14 12:56:06 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 08:56:06 -0400 Subject: [Libvirt-cim] [PATCH 3/3] VSMS: Support for domains with controller devices In-Reply-To: <1394801766-31755-1-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> Message-ID: <1394801766-31755-4-git-send-email-jferlan@redhat.com> From: Xu Wang Support being able to convert the Controller RASD into a virtual device Signed-off-by: Xu Wang Signed-off-by: John Ferlan --- 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 From fiuczy at linux.vnet.ibm.com Fri Mar 14 14:20:52 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 14 Mar 2014 15:20:52 +0100 Subject: [Libvirt-cim] [REPOST MERGED PATCH 0/3] Repost controller series merged In-Reply-To: <1394801766-31755-1-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> Message-ID: <53231044.5090300@linux.vnet.ibm.com> On 03/14/2014 01:56 PM, John Ferlan wrote: > Changes since last time - > > 1. Address review comments > 2. I did not add CONTROLLER_INDEX_NOT_SET. Since that's a -1 value and > the index is an unsigned value - it just didn't seem right. Furthermore, > if libvirt doesn't find the 'index' value, it defaults to using 0 when > parsing the XML - so I think following that model is better. I have yet > to chase down all the libvirt paths to see what happens, but I think if > someone adds a controller without defining an index and that index > conflicts with something already there for that named/type of controller, > then libvirt will reject the xml for the guest to start requiring the > "user" to fix it. If I remember correctly libvirt has a mechanism to look for the next free index available. Defaulting the index when not specified to 0 would prevent libvirt-cim users from exploiting the mechanism. > 3. I didn't yet do it, but I think the 'master' may need to be removed. The > libvirt documented example is: > > > >
> > > >
> > ... > > > This examples shows that the type is 'usb' and the 'index' is 0 for both > which would violate our namespace rule. The 'model' is the same too. So > unless we incorporate the address into the name, then there's a conflict. Yes, that is a correct observation and I agree with you that removing the master and restricting the support for master is a feasible way. If at some later point this special case really becomes a requirement than it would still be possible to extend the InstanceID for these cases, I guess. > > I'll have to think about this one some more and of course take advice! > > 4. Just realized I forgot to switch the mof values for queues, ports, and > vectors back to string types... I'll do that, but didn't want to lose > my current cover letter. > > Xu Wang (3): > libxutil, xmlgen: Add Controller Support > RASD: Schema and Provider Support for Controller RASDs > VSMS: Support for domains with controller devices > > libxkutil/device_parsing.c | 105 +++++++++++++++++++++- > libxkutil/device_parsing.h | 15 ++++ > libxkutil/xmlgen.c | 52 +++++++++++ > schema/ResourceAllocationSettingData.mof | 41 +++++++++ > schema/ResourceAllocationSettingData.registration | 1 + > src/Virt_ElementSettingData.c | 1 + > src/Virt_RASD.c | 81 +++++++++++++++-- > src/Virt_SettingsDefineState.c | 1 + > src/Virt_VSSDComponent.c | 1 + > src/Virt_VirtualSystemManagementService.c | 76 ++++++++++++++++ > src/svpc_types.h | 4 +- > 11 files changed, 368 insertions(+), 10 deletions(-) > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Fri Mar 14 14:23:30 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 14 Mar 2014 15:23:30 +0100 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1394801766-31755-3-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> <1394801766-31755-3-git-send-email-jferlan@redhat.com> Message-ID: <532310E2.4020806@linux.vnet.ibm.com> On 03/14/2014 01:56 PM, John Ferlan wrote: > From: Xu Wang > > Add the various controller fields and support for RASDs > > Signed-off-by: Xu Wang > Signed-off-by: John Ferlan > --- > schema/ResourceAllocationSettingData.mof | 41 ++++++++++++ > schema/ResourceAllocationSettingData.registration | 1 + > src/Virt_ElementSettingData.c | 1 + > src/Virt_RASD.c | 81 ++++++++++++++++++++--- > src/Virt_SettingsDefineState.c | 1 + > src/Virt_VSSDComponent.c | 1 + > 6 files changed, 118 insertions(+), 8 deletions(-) > > diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof > index bf1fbb6..30e62c4 100644 > --- a/schema/ResourceAllocationSettingData.mof > +++ b/schema/ResourceAllocationSettingData.mof > @@ -322,6 +322,47 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData > string BusType; > }; > > +[Description ("KVM virtual controller device. It is identified by: " > + "CIM_ResourceAllocationSettingData.ResourceType=1 ('Other'), " > + "CIM_ResourceAllocationSettingData.OtherResourceType='controller'" > + " and CIM_ResourceAllocationSettingData.ResourceSubType set to " > + "one of 'ide', 'fdc', 'scsi', 'sata', 'ccid', 'virtio-serial', " > + "or 'pci'."), > + Provider("cmpi::Virt_RASD") > +] > +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData > +{ > + [Description ("Order in which the bus controller is encountered. " > + "The order is controller type scoped.")] > + uint64 Index; > + > + [Description ("Optional string providing a specific model " > + "information based on the controller type.")] > + string Model; > + > + [Description ("The 'virtio-serial' controller uses the Ports and " > + "Vectors to control how many devices can be connected " > + "through the controller.")] > + uint64 Ports; > + uint64 Vectors; > + > + [Description ("Number of queues for the controller.")] > + uint64 Queues; > + > + [Description ("Device master property names")] > + string MasterProperties[]; > + > + [Description ("Device master property values")] > + string MasterValues[]; > + > + [Description ("For controllers that are themselves devices on a " > + "bus an optional element to specify the exact " > + "relationship of the controller to its master bus. " > + "Stored in the property and value arrays.")] > + string AddressProperties[]; > + string AddressValues[]; > +}; > + > [Description ("Xen virtual network pool settings"), > Provider("cmpi::Virt_RASD") > ] > diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration > index b969bfe..da0b7d9 100644 > --- a/schema/ResourceAllocationSettingData.registration > +++ b/schema/ResourceAllocationSettingData.registration > @@ -14,6 +14,7 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c > index c088e49..1fa81f2 100644 > --- a/src/Virt_ElementSettingData.c > +++ b/src/Virt_ElementSettingData.c > @@ -137,6 +137,7 @@ static char* resource_allocation_setting_data[] = { > "KVM_GraphicsResourceAllocationSettingData", > "KVM_ConsoleResourceAllocationSettingData", > "KVM_InputResourceAllocationSettingData", > + "KVM_ControllerResourceAllocationSettingData", > "LXC_DiskResourceAllocationSettingData", > "LXC_MemResourceAllocationSettingData", > "LXC_NetResourceAllocationSettingData", > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > index df1e921..d3922cf 100644 > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -289,10 +289,12 @@ static bool get_vol_size(const CMPIBroker *broker, > } > #endif > > -static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, > +static CMPIStatus set_rasd_property_value(const CMPIBroker *broker, > const CMPIObjectPath *ref, > const struct device_address *addr, > - CMPIInstance *inst) > + CMPIInstance *inst, > + const char *property_name, > + const char *property_value) > { > int i; > CMPIArray *arr_key; > @@ -338,11 +340,11 @@ static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, > CMPI_string); > } > > - CMSetProperty(inst, "AddressProperties", > + CMSetProperty(inst, property_name, > (CMPIValue *)&arr_key, > CMPI_stringA); > > - CMSetProperty(inst, "AddressValues", > + CMSetProperty(inst, property_value, > (CMPIValue *)&arr_value, > CMPI_stringA); > > @@ -489,10 +491,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, > CMPI_boolean); > > if (dev->dev.disk.address.ct > 0) > - set_rasd_device_address(broker, > + set_rasd_property_value(broker, > ref, > &dev->dev.disk.address, > - inst); > + inst, > + "AddressProperties", > + "AddressValues"); > > virStoragePoolFree(pool); > virStorageVolFree(vol); > @@ -658,10 +662,12 @@ static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, > CMPI_chars); > > if (dev->dev.net.address.ct > 0) > - set_rasd_device_address(broker, > + set_rasd_property_value(broker, > ref, > &dev->dev.net.address, > - inst); > + inst, > + "AddressProperties", > + "AddressValues"); > > #if LIBVIR_VERSION_NUMBER < 9000 > out: > @@ -903,6 +909,55 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, > return s; > } > > +static CMPIStatus set_controller_rasd_params(const CMPIBroker *broker, > + const CMPIObjectPath *ref, > + const struct virt_device *dev, > + CMPIInstance *inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + > + CMSetProperty(inst, "OtherResourceType", "controller", CMPI_chars); > + CMSetProperty(inst, "ResourceSubType", > + (CMPIValue *)dev->dev.controller.type, CMPI_chars); > + CMSetProperty(inst, "Index", > + (CMPIValue *)dev->dev.controller.index, CMPI_uint32); (CMPIValue *)dev->dev.controller.index, CMPI_uint64); > + > + if (dev->dev.controller.model) > + CMSetProperty(inst, "Model", > + (CMPIValue *)dev->dev.controller.model, CMPI_chars); > + > + if (dev->dev.controller.ports) > + CMSetProperty(inst, "Ports", > + (CMPIValue *)dev->dev.controller.ports, CMPI_uint32); I leave these undocumented since you are going to change according to the cover letter back to chars. > + > + if (dev->dev.controller.vectors) > + CMSetProperty(inst, "Vectors", > + (CMPIValue *)dev->dev.controller.vectors, > + CMPI_uint32); > + > + if (dev->dev.controller.queues) > + CMSetProperty(inst, "Queues", > + (CMPIValue *)dev->dev.controller.queues, CMPI_uint32); > + > + if (dev->dev.controller.master.ct > 0) > + set_rasd_property_value(broker, > + ref, > + &dev->dev.controller.address, > + inst, > + "MasterProperties", > + "MasterValues"); > + > + if (dev->dev.controller.address.ct > 0) > + set_rasd_property_value(broker, > + ref, > + &dev->dev.controller.address, > + inst, > + "AddressProperties", > + "AddressValues"); > + > + return s; > +} > + > CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > struct virt_device *dev, > const char *host, > @@ -937,6 +992,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > } else if (dev->type == CIM_RES_TYPE_INPUT) { > type = CIM_RES_TYPE_INPUT; > base = "InputResourceAllocationSettingData"; > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + type = CIM_RES_TYPE_OTHER; > + base = "ControllerResourceAllocationSettingData"; > } else { > return NULL; > } > @@ -992,6 +1050,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > s = set_input_rasd_params(dev, inst); > } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > s = set_console_rasd_params(dev, inst); > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + s = set_controller_rasd_params(broker, ref, dev, inst); > } > > /* FIXME: Put the HostResource in place */ > @@ -1126,6 +1186,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) > *type = CIM_RES_TYPE_IMAGE; > else if (STREQ(base, "ConsoleResourceAllocationSettingData")) > *type = CIM_RES_TYPE_CONSOLE; > + else if (STREQ(base, "ControllerResourceAllocationSettingData")) > + *type = CIM_RES_TYPE_CONTROLLER; > else > goto out; > > @@ -1163,6 +1225,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) > case CIM_RES_TYPE_INPUT: > *classname = "InputResourceAllocationSettingData"; > break; > + case CIM_RES_TYPE_CONTROLLER: > + *classname = "ControllerResourceAllocationSettingData"; > + break; > default: > rc = CMPI_RC_ERR_FAILED; > } > diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c > index c8cda97..d5c6726 100644 > --- a/src/Virt_SettingsDefineState.c > +++ b/src/Virt_SettingsDefineState.c > @@ -361,6 +361,7 @@ static char* resource_allocation_setting_data[] = { > "KVM_GraphicsResourceAllocationSettingData", > "KVM_InputResourceAllocationSettingData", > "KVM_ConsoleResourceAllocationSettingData", > + "KVM_ControllerResourceAllocationSettingData", > "LXC_DiskResourceAllocationSettingData", > "LXC_MemResourceAllocationSettingData", > "LXC_NetResourceAllocationSettingData", > diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c > index 35bffde..734271c 100644 > --- a/src/Virt_VSSDComponent.c > +++ b/src/Virt_VSSDComponent.c > @@ -141,6 +141,7 @@ static char* part_component[] = { > "KVM_GraphicsResourceAllocationSettingData", > "KVM_InputResourceAllocationSettingData", > "KVM_ConsoleResourceAllocationSettingData", > + "KVM_ControllerResourceAllocationSettingData", > "LXC_DiskResourceAllocationSettingData", > "LXC_MemResourceAllocationSettingData", > "LXC_NetResourceAllocationSettingData", > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From fiuczy at linux.vnet.ibm.com Fri Mar 14 14:40:24 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 14 Mar 2014 15:40:24 +0100 Subject: [Libvirt-cim] [PATCH 3/3] VSMS: Support for domains with controller devices In-Reply-To: <1394801766-31755-4-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> <1394801766-31755-4-git-send-email-jferlan@redhat.com> Message-ID: <532314D8.9010302@linux.vnet.ibm.com> On 03/14/2014 01:56 PM, John Ferlan wrote: > From: Xu Wang > > Support being able to convert the Controller RASD into a virtual device > Signed-off-by: Xu Wang > > Signed-off-by: John Ferlan > --- > 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; > + } As I wrote elsewhere this is going to prevent the libvirt-cim user from using the libvirt auto assignment for the index. > + > + /* Formulate our instance id from controller, controller type, > + * and index value. This should be unique enough. > + */ ... > @@ -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) || What is the reason for adding the controller here? > (type == CIM_RES_TYPE_INPUT)) > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > else { > @@ -3111,6 +3185,7 @@ static CMPIStatus resource_add(struct domain *dominfo, > Why is the controller instance not added to a running domain? Instead of restricting it in the if statement below all I think should be done is this (before the if in the patch below.) if (type == CIM_RES_TYPE_CONTROLLER && dev != NULL && dev->id == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Add resource failed: Index property is required."); goto out; } > 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) || What is the reason for adding the controller here? > (type == CIM_RES_TYPE_CONSOLE)) > cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); > else { > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Fri Mar 14 15:12:53 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 11:12:53 -0400 Subject: [Libvirt-cim] [REPOST MERGED PATCH 0/3] Repost controller series merged In-Reply-To: <53231044.5090300@linux.vnet.ibm.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> <53231044.5090300@linux.vnet.ibm.com> Message-ID: <53231C75.6090006@redhat.com> On 03/14/2014 10:20 AM, Boris Fiuczynski wrote: > On 03/14/2014 01:56 PM, John Ferlan wrote: >> Changes since last time - >> >> 1. Address review comments >> 2. I did not add CONTROLLER_INDEX_NOT_SET. Since that's a -1 value and >> the index is an unsigned value - it just didn't seem right. Furthermore, >> if libvirt doesn't find the 'index' value, it defaults to using 0 when >> parsing the XML - so I think following that model is better. I have yet >> to chase down all the libvirt paths to see what happens, but I think if >> someone adds a controller without defining an index and that index >> conflicts with something already there for that named/type of controller, >> then libvirt will reject the xml for the guest to start requiring the >> "user" to fix it. > If I remember correctly libvirt has a mechanism to look for the next > free index available. Defaulting the index when not specified to 0 would > prevent libvirt-cim users from exploiting the mechanism. OK - I guess it's the -1 into the unsigned value that really caught my attention. Now that things are "merged" into one change it may be easier for my brain to comprehend where things are. I assume this would be the 'create' path where we'd have to allow that -1 value. The problem I have is how then is then the dev->id thing. I'm trying to get the "big picture" of how that will be generated then. I'll go back and look at the change in the context of your previous review. Once libvirt creates the guest, it will be assigned a number and thus the next read of the XML would have it. > >> 3. I didn't yet do it, but I think the 'master' may need to be removed. The >> libvirt documented example is: >> >> >> >>
>> >> >> >>
>> >> ... >> >> >> This examples shows that the type is 'usb' and the 'index' is 0 for both >> which would violate our namespace rule. The 'model' is the same too. So >> unless we incorporate the address into the name, then there's a conflict. > Yes, that is a correct observation and I agree with you that removing > the master and restricting the support for master is a feasible way. > If at some later point this special case really becomes a requirement > than it would still be possible to extend the InstanceID for these > cases, I guess. I'll work on removing it then. Not all good intentions work out... John >> >> I'll have to think about this one some more and of course take advice! >> >> 4. Just realized I forgot to switch the mof values for queues, ports, and >> vectors back to string types... I'll do that, but didn't want to lose >> my current cover letter. >> >> Xu Wang (3): >> libxutil, xmlgen: Add Controller Support >> RASD: Schema and Provider Support for Controller RASDs >> VSMS: Support for domains with controller devices >> >> libxkutil/device_parsing.c | 105 +++++++++++++++++++++- >> libxkutil/device_parsing.h | 15 ++++ >> libxkutil/xmlgen.c | 52 +++++++++++ >> schema/ResourceAllocationSettingData.mof | 41 +++++++++ >> schema/ResourceAllocationSettingData.registration | 1 + >> src/Virt_ElementSettingData.c | 1 + >> src/Virt_RASD.c | 81 +++++++++++++++-- >> src/Virt_SettingsDefineState.c | 1 + >> src/Virt_VSSDComponent.c | 1 + >> src/Virt_VirtualSystemManagementService.c | 76 ++++++++++++++++ >> src/svpc_types.h | 4 +- >> 11 files changed, 368 insertions(+), 10 deletions(-) >> > > From jferlan at redhat.com Fri Mar 14 15:14:13 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 11:14:13 -0400 Subject: [Libvirt-cim] [PATCH 2/3] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <532310E2.4020806@linux.vnet.ibm.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> <1394801766-31755-3-git-send-email-jferlan@redhat.com> <532310E2.4020806@linux.vnet.ibm.com> Message-ID: <53231CC5.4090508@redhat.com> On 03/14/2014 10:23 AM, Boris Fiuczynski wrote: > On 03/14/2014 01:56 PM, John Ferlan wrote: >> From: Xu Wang >> >> Add the various controller fields and support for RASDs >> >> Signed-off-by: Xu Wang >> Signed-off-by: John Ferlan >> --- >> schema/ResourceAllocationSettingData.mof | 41 ++++++++++++ >> schema/ResourceAllocationSettingData.registration | 1 + >> src/Virt_ElementSettingData.c | 1 + >> src/Virt_RASD.c | 81 ++++++++++++++++++++--- >> src/Virt_SettingsDefineState.c | 1 + >> src/Virt_VSSDComponent.c | 1 + >> 6 files changed, 118 insertions(+), 8 deletions(-) >> >> diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof >> index bf1fbb6..30e62c4 100644 >> --- a/schema/ResourceAllocationSettingData.mof >> +++ b/schema/ResourceAllocationSettingData.mof >> @@ -322,6 +322,47 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData >> string BusType; >> }; >> >> +[Description ("KVM virtual controller device. It is identified by: " >> + "CIM_ResourceAllocationSettingData.ResourceType=1 ('Other'), " >> + "CIM_ResourceAllocationSettingData.OtherResourceType='controller'" >> + " and CIM_ResourceAllocationSettingData.ResourceSubType set to " >> + "one of 'ide', 'fdc', 'scsi', 'sata', 'ccid', 'virtio-serial', " >> + "or 'pci'."), >> + Provider("cmpi::Virt_RASD") >> +] >> +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData >> +{ >> + [Description ("Order in which the bus controller is encountered. " >> + "The order is controller type scoped.")] >> + uint64 Index; >> + >> + [Description ("Optional string providing a specific model " >> + "information based on the controller type.")] >> + string Model; >> + >> + [Description ("The 'virtio-serial' controller uses the Ports and " >> + "Vectors to control how many devices can be connected " >> + "through the controller.")] >> + uint64 Ports; >> + uint64 Vectors; >> + >> + [Description ("Number of queues for the controller.")] >> + uint64 Queues; >> + >> + [Description ("Device master property names")] >> + string MasterProperties[]; >> + >> + [Description ("Device master property values")] >> + string MasterValues[]; >> + >> + [Description ("For controllers that are themselves devices on a " >> + "bus an optional element to specify the exact " >> + "relationship of the controller to its master bus. " >> + "Stored in the property and value arrays.")] >> + string AddressProperties[]; >> + string AddressValues[]; >> +}; >> + >> [Description ("Xen virtual network pool settings"), >> Provider("cmpi::Virt_RASD") >> ] >> diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration >> index b969bfe..da0b7d9 100644 >> --- a/schema/ResourceAllocationSettingData.registration >> +++ b/schema/ResourceAllocationSettingData.registration >> @@ -14,6 +14,7 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance >> diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c >> index c088e49..1fa81f2 100644 >> --- a/src/Virt_ElementSettingData.c >> +++ b/src/Virt_ElementSettingData.c >> @@ -137,6 +137,7 @@ static char* resource_allocation_setting_data[] = { >> "KVM_GraphicsResourceAllocationSettingData", >> "KVM_ConsoleResourceAllocationSettingData", >> "KVM_InputResourceAllocationSettingData", >> + "KVM_ControllerResourceAllocationSettingData", >> "LXC_DiskResourceAllocationSettingData", >> "LXC_MemResourceAllocationSettingData", >> "LXC_NetResourceAllocationSettingData", >> diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c >> index df1e921..d3922cf 100644 >> --- a/src/Virt_RASD.c >> +++ b/src/Virt_RASD.c >> @@ -289,10 +289,12 @@ static bool get_vol_size(const CMPIBroker *broker, >> } >> #endif >> >> -static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, >> +static CMPIStatus set_rasd_property_value(const CMPIBroker *broker, >> const CMPIObjectPath *ref, >> const struct device_address *addr, >> - CMPIInstance *inst) >> + CMPIInstance *inst, >> + const char *property_name, >> + const char *property_value) >> { >> int i; >> CMPIArray *arr_key; >> @@ -338,11 +340,11 @@ static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, >> CMPI_string); >> } >> >> - CMSetProperty(inst, "AddressProperties", >> + CMSetProperty(inst, property_name, >> (CMPIValue *)&arr_key, >> CMPI_stringA); >> >> - CMSetProperty(inst, "AddressValues", >> + CMSetProperty(inst, property_value, >> (CMPIValue *)&arr_value, >> CMPI_stringA); >> >> @@ -489,10 +491,12 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, >> CMPI_boolean); >> >> if (dev->dev.disk.address.ct > 0) >> - set_rasd_device_address(broker, >> + set_rasd_property_value(broker, >> ref, >> &dev->dev.disk.address, >> - inst); >> + inst, >> + "AddressProperties", >> + "AddressValues"); >> >> virStoragePoolFree(pool); >> virStorageVolFree(vol); >> @@ -658,10 +662,12 @@ static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, >> CMPI_chars); >> >> if (dev->dev.net.address.ct > 0) >> - set_rasd_device_address(broker, >> + set_rasd_property_value(broker, >> ref, >> &dev->dev.net.address, >> - inst); >> + inst, >> + "AddressProperties", >> + "AddressValues"); >> >> #if LIBVIR_VERSION_NUMBER < 9000 >> out: >> @@ -903,6 +909,55 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, >> return s; >> } >> >> +static CMPIStatus set_controller_rasd_params(const CMPIBroker *broker, >> + const CMPIObjectPath *ref, >> + const struct virt_device *dev, >> + CMPIInstance *inst) >> +{ >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> + >> + CMSetProperty(inst, "OtherResourceType", "controller", CMPI_chars); >> + CMSetProperty(inst, "ResourceSubType", >> + (CMPIValue *)dev->dev.controller.type, CMPI_chars); >> + CMSetProperty(inst, "Index", >> + (CMPIValue *)dev->dev.controller.index, CMPI_uint32); > (CMPIValue *)dev->dev.controller.index, CMPI_uint64); yep - saw that too when I went back to change the others back to chars John >> + >> + if (dev->dev.controller.model) >> + CMSetProperty(inst, "Model", >> + (CMPIValue *)dev->dev.controller.model, CMPI_chars); >> + >> + if (dev->dev.controller.ports) >> + CMSetProperty(inst, "Ports", >> + (CMPIValue *)dev->dev.controller.ports, CMPI_uint32); > I leave these undocumented since you are going to change according to > the cover letter back to chars. >> + >> + if (dev->dev.controller.vectors) >> + CMSetProperty(inst, "Vectors", >> + (CMPIValue *)dev->dev.controller.vectors, >> + CMPI_uint32); >> + >> + if (dev->dev.controller.queues) >> + CMSetProperty(inst, "Queues", >> + (CMPIValue *)dev->dev.controller.queues, CMPI_uint32); >> + >> + if (dev->dev.controller.master.ct > 0) >> + set_rasd_property_value(broker, >> + ref, >> + &dev->dev.controller.address, >> + inst, >> + "MasterProperties", >> + "MasterValues"); >> + >> + if (dev->dev.controller.address.ct > 0) >> + set_rasd_property_value(broker, >> + ref, >> + &dev->dev.controller.address, >> + inst, >> + "AddressProperties", >> + "AddressValues"); >> + >> + return s; >> +} >> + >> CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, >> struct virt_device *dev, >> const char *host, >> @@ -937,6 +992,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, >> } else if (dev->type == CIM_RES_TYPE_INPUT) { >> type = CIM_RES_TYPE_INPUT; >> base = "InputResourceAllocationSettingData"; >> + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { >> + type = CIM_RES_TYPE_OTHER; >> + base = "ControllerResourceAllocationSettingData"; >> } else { >> return NULL; >> } >> @@ -992,6 +1050,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, >> s = set_input_rasd_params(dev, inst); >> } else if (dev->type == CIM_RES_TYPE_CONSOLE) { >> s = set_console_rasd_params(dev, inst); >> + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { >> + s = set_controller_rasd_params(broker, ref, dev, inst); >> } >> >> /* FIXME: Put the HostResource in place */ >> @@ -1126,6 +1186,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) >> *type = CIM_RES_TYPE_IMAGE; >> else if (STREQ(base, "ConsoleResourceAllocationSettingData")) >> *type = CIM_RES_TYPE_CONSOLE; >> + else if (STREQ(base, "ControllerResourceAllocationSettingData")) >> + *type = CIM_RES_TYPE_CONTROLLER; >> else >> goto out; >> >> @@ -1163,6 +1225,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) >> case CIM_RES_TYPE_INPUT: >> *classname = "InputResourceAllocationSettingData"; >> break; >> + case CIM_RES_TYPE_CONTROLLER: >> + *classname = "ControllerResourceAllocationSettingData"; >> + break; >> default: >> rc = CMPI_RC_ERR_FAILED; >> } >> diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c >> index c8cda97..d5c6726 100644 >> --- a/src/Virt_SettingsDefineState.c >> +++ b/src/Virt_SettingsDefineState.c >> @@ -361,6 +361,7 @@ static char* resource_allocation_setting_data[] = { >> "KVM_GraphicsResourceAllocationSettingData", >> "KVM_InputResourceAllocationSettingData", >> "KVM_ConsoleResourceAllocationSettingData", >> + "KVM_ControllerResourceAllocationSettingData", >> "LXC_DiskResourceAllocationSettingData", >> "LXC_MemResourceAllocationSettingData", >> "LXC_NetResourceAllocationSettingData", >> diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c >> index 35bffde..734271c 100644 >> --- a/src/Virt_VSSDComponent.c >> +++ b/src/Virt_VSSDComponent.c >> @@ -141,6 +141,7 @@ static char* part_component[] = { >> "KVM_GraphicsResourceAllocationSettingData", >> "KVM_InputResourceAllocationSettingData", >> "KVM_ConsoleResourceAllocationSettingData", >> + "KVM_ControllerResourceAllocationSettingData", >> "LXC_DiskResourceAllocationSettingData", >> "LXC_MemResourceAllocationSettingData", >> "LXC_NetResourceAllocationSettingData", >> > > From jferlan at redhat.com Fri Mar 14 15:16:40 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 11:16:40 -0400 Subject: [Libvirt-cim] [PATCH 3/3] VSMS: Support for domains with controller devices In-Reply-To: <532314D8.9010302@linux.vnet.ibm.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> <1394801766-31755-4-git-send-email-jferlan@redhat.com> <532314D8.9010302@linux.vnet.ibm.com> Message-ID: <53231D58.6030700@redhat.com> On 03/14/2014 10:40 AM, Boris Fiuczynski wrote: > On 03/14/2014 01:56 PM, John Ferlan wrote: >> From: Xu Wang >> >> Support being able to convert the Controller RASD into a virtual device >> Signed-off-by: Xu Wang >> >> Signed-off-by: John Ferlan >> --- >> 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; >> + } > As I wrote elsewhere this is going to prevent the libvirt-cim user from > using the libvirt auto assignment for the index. > OK - I'll rework this.. >> + >> + /* Formulate our instance id from controller, controller type, >> + * and index value. This should be unique enough. >> + */ > > ... > >> @@ -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) || > What is the reason for adding the controller here? > That's original code that I haven't touched, thought about, or I guess knew what to do with... I guess I just hadn't got this far yet. I'll work through the remaining comments... Xu if you have the time to provide some feedback it would be most welcome... John >> (type == CIM_RES_TYPE_INPUT)) >> cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); >> else { >> @@ -3111,6 +3185,7 @@ static CMPIStatus resource_add(struct domain *dominfo, >> > > Why is the controller instance not added to a running domain? > Instead of restricting it in the if statement below all I think should > be done is this (before the if in the patch below.) > if (type == CIM_RES_TYPE_CONTROLLER && > dev != NULL && dev->id == NULL) { > cu_statusf(_BROKER, &s, > CMPI_RC_ERR_FAILED, > "Add resource failed: Index property is > required."); > goto out; > } > >> 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) || > What is the reason for adding the controller here? > >> (type == CIM_RES_TYPE_CONSOLE)) >> cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); >> else { >> > > From jferlan at redhat.com Fri Mar 14 15:20:50 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 14 Mar 2014 11:20:50 -0400 Subject: [Libvirt-cim] [PATCH 1/3] libxutil, xmlgen: Add Controller Support In-Reply-To: <1394801766-31755-2-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> <1394801766-31755-2-git-send-email-jferlan@redhat.com> Message-ID: <53231E52.1020504@redhat.com> On 03/14/2014 08:56 AM, John Ferlan wrote: > From: Xu Wang > > Add support to define and save a controller found in the XML. A controller > will have an "OTHER" RASD ResourceType value and make use of the CIM > ResourceSubType property as the XML "type" of controller > > Signed-off-by: Xu Wang > Signed-off-by: John Ferlan > --- > libxkutil/device_parsing.c | 105 ++++++++++++++++++++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 15 +++++++ > libxkutil/xmlgen.c | 52 ++++++++++++++++++++++ > src/svpc_types.h | 4 +- > 4 files changed, 174 insertions(+), 2 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index c9ae886..f35df39 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007, 2013 > + * Copyright IBM Corp. 2007, 2014 > * > * Authors: > * Dan Smith > @@ -49,6 +49,7 @@ > #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ > "/domain/devices/console" > #define INPUT_XPATH (xmlChar *)"/domain/devices/input" > +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" > > #define DEFAULT_BRIDGE "xenbr0" > #define DEFAULT_NETWORK "default" > @@ -306,6 +307,20 @@ static void cleanup_input_device(struct input_device *dev) > free(dev->bus); > } > > +static void cleanup_controller_device(struct controller_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->type); > + free(dev->model); > + free(dev->queues); > + free(dev->ports); > + free(dev->vectors); > + cleanup_device_address(&dev->address); > + cleanup_device_address(&dev->master); > +} > + > void cleanup_virt_device(struct virt_device *dev) > { > if (dev == NULL) > @@ -323,6 +338,8 @@ void cleanup_virt_device(struct virt_device *dev) > cleanup_input_device(&dev->dev.input); > else if (dev->type == CIM_RES_TYPE_CONSOLE) > cleanup_console_device(&dev->dev.console); > + else if (dev->type == CIM_RES_TYPE_CONTROLLER) > + cleanup_controller_device(&dev->dev.controller); > > free(dev->id); > > @@ -1101,6 +1118,71 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) > return 0; > } > > +static int parse_controller_device(xmlNode *cnode, struct virt_device **vdevs) > +{ > + struct virt_device *vdev = NULL; > + struct controller_device *cdev = NULL; > + xmlNode *child = NULL; > + char *index = NULL; > + int ret; > + > + vdev = calloc(1, sizeof(*vdev)); > + if (vdev == NULL) > + goto err; > + > + cdev = &(vdev->dev.controller); > + > + cdev->type = get_attr_value(cnode, "type"); > + if (cdev->type == NULL) { > + CU_DEBUG("No type"); > + goto err; > + } > + > + index = get_attr_value(cnode, "index"); > + if (index != NULL) { > + sscanf(index, "%" PRIu64, &cdev->index); > + free(index); > + } else { > + CU_DEBUG("No index"); > + goto err; > + } > + > + cdev->model = get_attr_value(cnode, "model"); > + cdev->ports = get_attr_value(cnode, "ports"); > + cdev->vectors = get_attr_value(cnode, "vectors"); > + > + for (child = cnode->children; child != NULL; child = child->next) { > + if (XSTREQ(child->name, "address")) { > + parse_device_address(child, &cdev->address); > + } else if (XSTREQ(child->name, "master")) { > + /* Although technically not an address it is similar > + * insomuch as it's a paired list of attributes that > + * we're just going to save and write out later > + */ > + parse_device_address(child, &cdev->master); > + } else if (XSTREQ(child->name, "driver")) { > + cdev->queues = get_attr_value(child, "queues"); > + } > + } > + vdev->type = CIM_RES_TYPE_CONTROLLER; > + > + ret = asprintf(&vdev->id, "controller:%s:%" PRIu64, > + cdev->type, cdev->index); > + if (ret == -1) { > + CU_DEBUG("Failed to create controller id string"); > + goto err; > + } > + > + *vdevs = vdev; > + > + return 1; > + err: > + cleanup_controller_device(cdev); > + free(vdev); > + > + return 0; > +} > + > static bool resize_devlist(struct virt_device **list, int newsize) > { > struct virt_device *_list; > @@ -1224,6 +1306,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) > func = &parse_input_device; > break; > > + case CIM_RES_TYPE_CONTROLLER: > + xpathstr = CONTROLLER_XPATH; > + func = &parse_controller_device; > + break; > + I really would like some guidance in this area to in order to understand what other kinds of changes are going to be necessary considering this particular "break;" causes quite a few cimtest failures. It's as if there needs to be some other place that has to know about the controller device. Perhaps in CIM parlance - some Association that's missing. John > default: > CU_DEBUG("Unrecognized device type. Returning."); > goto err1; > @@ -1343,7 +1430,19 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) > } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > console_device_dup(&dev->dev.console, > &_dev->dev.console); > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + DUP_FIELD(dev, _dev, dev.controller.type); > + dev->dev.controller.index = _dev->dev.controller.index; > + DUP_FIELD(dev, _dev, dev.controller.model); > + DUP_FIELD(dev, _dev, dev.controller.ports); > + DUP_FIELD(dev, _dev, dev.controller.vectors); > + DUP_FIELD(dev, _dev, dev.controller.queues); > + duplicate_device_address(&dev->dev.controller.master, > + &_dev->dev.controller.master); > + duplicate_device_address(&dev->dev.controller.address, > + &_dev->dev.controller.address); > } > + > return dev; > } > > @@ -1723,6 +1822,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) > (*dominfo)->dev_vcpu_ct = parse_devices(xml, > &(*dominfo)->dev_vcpu, > CIM_RES_TYPE_PROC); > + (*dominfo)->dev_controller_ct = parse_devices(xml, > + &(*dominfo)->dev_controller, > + CIM_RES_TYPE_CONTROLLER); > > return ret; > > @@ -1811,6 +1913,7 @@ void cleanup_dominfo(struct domain **dominfo) > cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); > cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); > cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); > + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); > > free(dom); > > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index 92427c1..8072f51 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -161,6 +161,17 @@ struct input_device { > char *bus; > }; > > +struct controller_device { > + char *type; > + uint64_t index; > + char *model; > + char *ports; > + char *vectors; > + char *queues; > + struct device_address address; > + struct device_address master; > +}; > + > struct virt_device { > uint16_t type; > union { > @@ -172,6 +183,7 @@ struct virt_device { > struct graphics_device graphics; > struct console_device console; > struct input_device input; > + struct controller_device controller; > } dev; > char *id; > }; > @@ -247,6 +259,9 @@ struct domain { > > struct virt_device *dev_vcpu; > int dev_vcpu_ct; > + > + struct virt_device *dev_controller; > + int dev_controller_ct; > }; > > struct virt_device *virt_device_dup(struct virt_device *dev); > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 931f0c9..6418974 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -794,6 +794,52 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) > return NULL; > } > > +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) > +{ > + int i; > + > + for (i = 0; i < dominfo->dev_controller_ct; i++) { > + xmlNodePtr ctlr; > + xmlNodePtr tmp; > + char *index; > + > + struct virt_device *_dev = &dominfo->dev_controller[i]; > + if (_dev->type == CIM_RES_TYPE_UNKNOWN) > + continue; > + > + struct controller_device *dev = &_dev->dev.controller; > + > + ctlr = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); > + if (ctlr == NULL) > + return XML_ERROR; > + > + /* Required */ > + xmlNewProp(ctlr, BAD_CAST "type", BAD_CAST dev->type); > + if (asprintf(&index, "%" PRIu64, dev->index) == -1) > + return XML_ERROR; > + xmlNewProp(ctlr, BAD_CAST "index", BAD_CAST index); > + free(index); > + > + /* Optional */ > + if (dev->model) > + xmlNewProp(ctlr, BAD_CAST "model", BAD_CAST dev->model); > + if (dev->ports) > + xmlNewProp(ctlr, BAD_CAST "ports", BAD_CAST dev->ports); > + if (dev->vectors) > + xmlNewProp(ctlr, BAD_CAST "vectors", BAD_CAST dev->vectors); > + if (dev->queues) { > + tmp = xmlNewChild(ctlr, NULL, BAD_CAST "driver", NULL); > + xmlNewProp(tmp, BAD_CAST "queueus", BAD_CAST dev->queues); > + } > + if (dev->master.ct > 0) > + return device_address_xml(ctlr, &dev->master); > + if (dev->address.ct > 0) > + return device_address_xml(ctlr, &dev->address); > + } > + > + return NULL; > +} > + > static char *system_xml(xmlNodePtr root, struct domain *domain) > { > xmlNodePtr tmp; > @@ -1125,6 +1171,11 @@ char *device_to_xml(struct virt_device *_dev) > dominfo->dev_input_ct = 1; > dominfo->dev_input = dev; > break; > + case CIM_RES_TYPE_CONTROLLER: > + func = controller_xml; > + dominfo->dev_controller_ct = 1; > + dominfo->dev_controller = dev; > + break; > default: > cleanup_virt_devices(&dev, 1); > goto out; > @@ -1163,6 +1214,7 @@ char *system_to_xml(struct domain *dominfo) > &console_xml, > &graphics_xml, > &emu_xml, > + &controller_xml, > NULL > }; > > diff --git a/src/svpc_types.h b/src/svpc_types.h > index 404e428..7a2b653 100644 > --- a/src/svpc_types.h > +++ b/src/svpc_types.h > @@ -36,8 +36,9 @@ > #define CIM_RES_TYPE_IMAGE 32768 > #define CIM_RES_TYPE_CONSOLE 32769 > #define CIM_RES_TYPE_EMU 32770 > +#define CIM_RES_TYPE_CONTROLLER 32771 > > -#define CIM_RES_TYPE_COUNT 7 > +#define CIM_RES_TYPE_COUNT 8 > const static int cim_res_types[CIM_RES_TYPE_COUNT] = > {CIM_RES_TYPE_NET, > CIM_RES_TYPE_DISK, > @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = > CIM_RES_TYPE_GRAPHICS, > CIM_RES_TYPE_INPUT, > CIM_RES_TYPE_CONSOLE, > + CIM_RES_TYPE_CONTROLLER, > }; > > #define CIM_VSSD_RECOVERY_NONE 2 > From jferlan at redhat.com Mon Mar 17 15:01:06 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 17 Mar 2014 11:01:06 -0400 Subject: [Libvirt-cim] [REPOST MERGED PATCH 0/3] Repost controller series merged In-Reply-To: <1394801766-31755-1-git-send-email-jferlan@redhat.com> References: <1394801766-31755-1-git-send-email-jferlan@redhat.com> Message-ID: <53270E32.9050206@redhat.com> While thinking during idle moments this past weekend (a 2+ hour each way drive) I was thinking perhaps some of the issues I'm facing with cimtest and associating this ControllerRASD is that there's no logical device Controller like there is for Input, Graphics, Console, etc. devices. Additionally, there's a pools and rasds association which I just haven't quite got right. So, I started looking into CIM_Controller and thought well - isn't that more of what we're talking about for a libvirt controller device? Other than a 'ccid' and 'virtio-serial' types the other types in the libvirt list can be correlated to a CIM_Controller "ProtocolSupported" value: ide == IDE fdc == Flexbile Diskette scsi == [one of the] SCSI * types sata == Serial ATA ccid == ?Our own value? virtio-serial == Our own value usb = Universal Serial Bus So I'm headed off in that direction, but before going to far - I wanted to be sure I wasn't off in the weeds too far. Still trying to nail down some minor particulars such as where is the DeviceID value set (eg dev->id), but "so far" for the most part things seem to be better 'cimtest' wise than going with the RASD type. Given that this is the right direction - I'm not sure a ControllerRASD is necessary, is it? The one thing that does seem to be necessary is when a bus is provided for some device, we have to "find" or "ensure" that KVM/CIM_Controller device exists. How the association there will work I haven't yet figured out, but theoretically it seems to be the right path. John From jferlan at redhat.com Wed Mar 19 02:49:04 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Mar 2014 22:49:04 -0400 Subject: [Libvirt-cim] [PATCH 0/6] Add Virtual Controller Device Message-ID: <1395197350-8552-1-git-send-email-jferlan@redhat.com> This is rework of the Controller patch series submitted by Xu Wang. I have built upon the constructs put in place by Xu with respect to reading and writing the XML, but for the remainder of the code I changed where the virtual controller lives. Xu's patches made a Controller RASD which had some issues regarding associations with other devices and pools. Rather than go with a RASD model, I have chosen to make a KVM_Controller virtual device to mimic a CIM_Controller device. This solution keeps things at a lower level and has been able to pass the cimtest as well as the update a defined domain with a changed value test. This second test is what fails for RHEL7. As it turns out, it seems as long as a 'pci' device with model 'pci-root' is created, then things seem to work. The code relies on the previous patch code Xu created to read/write the XML file with some adjustments. Perhaps the only controversial patch (for me at least) is 6/6. I figured that after we've read everything and just before we go to create or update the guest that we need to make sure that at least the 'pci' device with model 'pci-root' exists. This is similar to the add_default_devs() code, except that it's run after all that code prior to any add or update of the guest just before the "system_to_xml()" call is made. I figure this is the last gasp to ensure that at least the 'pci' device is there which seems to be used by a number of "silently added" libvirt devices. John Ferlan (4): Add virtual controller object defs Change static API to global API Controller Device Details VSMS: Determine if default controller exists for KVM Xu Wang (2): Add virtual controller device types Parse/Store controller XML tags Makefile.am | 2 + libvirt-cim.spec.in | 2 + libxkutil/device_parsing.c | 119 +++++++++++++++++++++++++++- libxkutil/device_parsing.h | 15 ++++ libxkutil/xmlgen.c | 72 +++++++++++++++++ schema/Controller.mof | 47 +++++++++++ schema/Controller.registration | 19 +++++ src/Virt_Device.c | 84 ++++++++++++++++++++ src/Virt_RASD.c | 21 +++-- src/Virt_RASD.h | 4 + src/Virt_VirtualSystemManagementService.c | 106 ++++++++++++++++++++++++- src/svpc_types.h | 127 ++++++++++++++++++++++++++++++ 12 files changed, 602 insertions(+), 16 deletions(-) create mode 100644 schema/Controller.mof create mode 100644 schema/Controller.registration -- 1.8.5.3 From jferlan at redhat.com Wed Mar 19 02:49:05 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Mar 2014 22:49:05 -0400 Subject: [Libvirt-cim] [PATCH 1/6] Add virtual controller device types In-Reply-To: <1395197350-8552-1-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> Message-ID: <1395197350-8552-2-git-send-email-jferlan@redhat.com> From: Xu Wang Add data and strutures for a virtual controller device Signed-off-by: John Ferlan --- libxkutil/device_parsing.h | 15 ++++++ src/svpc_types.h | 127 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 92427c1..545b46c 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -161,6 +161,17 @@ struct input_device { char *bus; }; +#define CONTROLLER_INDEX_NOT_SET -1 +struct controller_device { + uint16_t type; + uint64_t index; + char *model; + char *ports; + char *vectors; + char *queues; + struct device_address address; +}; + struct virt_device { uint16_t type; union { @@ -172,6 +183,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -247,6 +259,9 @@ struct domain { struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; }; struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..b1add52 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -24,6 +24,9 @@ #define CIM_OPERATIONAL_STATUS 2 +/* From the ResourceType list for CIM_ResourceAllocationSettingData.html + * Found on http://schemas.dmtf.org/wbem/cim-html/2.31.0 + */ #define CIM_RES_TYPE_ALL 0 #define CIM_RES_TYPE_OTHER 1 #define CIM_RES_TYPE_PROC 3 @@ -33,9 +36,11 @@ #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 #define CIM_RES_TYPE_UNKNOWN 1000 +/* libvirt-cim specific values can start here */ #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 +#define CIM_RES_TYPE_CONTROLLER 32771 #define CIM_RES_TYPE_COUNT 7 const static int cim_res_types[CIM_RES_TYPE_COUNT] = @@ -266,4 +271,126 @@ static inline const char* chardev_source_type_IDToStr(int type) return type_str; } +/* enum for Controller ProtocolSupported values + * + * From the ProtocolSupported list for CIM_Controller.html + * Found on http://schemas.dmtf.org/wbem/cim-html/2.31.0 + */ +enum CIM_controller_protocol_type { + CIM_CONTROLLER_PROTOCOL_TYPE_OTHER = 1, + CIM_CONTROLLER_PROTOCOL_TYPE_UNKNOWN = 2, + CIM_CONTROLLER_PROTOCOL_TYPE_EISA = 3, + CIM_CONTROLLER_PROTOCOL_TYPE_ISA = 4, + CIM_CONTROLLER_PROTOCOL_TYPE_PCI = 5, + CIM_CONTROLLER_PROTOCOL_TYPE_ATA = 6, + CIM_CONTROLLER_PROTOCOL_TYPE_FD = 7, + CIM_CONTROLLER_PROTOCOL_TYPE_1496 = 8, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_PI = 9, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_FC = 10, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SB = 11, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SB2 = 12, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SSA = 13, + CIM_CONTROLLER_PROTOCOL_TYPE_VESA = 14, + CIM_CONTROLLER_PROTOCOL_TYPE_PCMCIA = 15, + CIM_CONTROLLER_PROTOCOL_TYPE_USB = 16, + CIM_CONTROLLER_PROTOCOL_TYPE_PP = 17, + CIM_CONTROLLER_PROTOCOL_TYPE_ESCON = 18, + CIM_CONTROLLER_PROTOCOL_TYPE_DIAG = 19, + CIM_CONTROLLER_PROTOCOL_TYPE_I2C = 20, + CIM_CONTROLLER_PROTOCOL_TYPE_POWER = 21, + CIM_CONTROLLER_PROTOCOL_TYPE_HIPPI = 22, + CIM_CONTROLLER_PROTOCOL_TYPE_MULTIBUS = 23, + CIM_CONTROLLER_PROTOCOL_TYPE_VME = 24, + CIM_CONTROLLER_PROTOCOL_TYPE_IPI = 25, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE488 = 26, + CIM_CONTROLLER_PROTOCOL_TYPE_RS232 = 27, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_10BASE5 = 28, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_10BASE2 = 29, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_1BASE5 = 30, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_10BROAD36 = 31, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_100BASEVG = 32, + CIM_CONTROLLER_PROTOCOL_TYPE_TOKENRING = 33, + CIM_CONTROLLER_PROTOCOL_TYPE_ANSIX3T9 = 34, + CIM_CONTROLLER_PROTOCOL_TYPE_MCA = 35, + CIM_CONTROLLER_PROTOCOL_TYPE_ESDI = 36, + CIM_CONTROLLER_PROTOCOL_TYPE_IDE = 37, + CIM_CONTROLLER_PROTOCOL_TYPE_CMD = 38, + CIM_CONTROLLER_PROTOCOL_TYPE_ST506 = 39, + CIM_CONTROLLER_PROTOCOL_TYPE_DSSI = 40, + CIM_CONTROLLER_PROTOCOL_TYPE_QIC2 = 41, + CIM_CONTROLLER_PROTOCOL_TYPE_ENH_ATA = 42, + CIM_CONTROLLER_PROTOCOL_TYPE_AGP = 43, + CIM_CONTROLLER_PROTOCOL_TYPE_TWIRP = 44, + CIM_CONTROLLER_PROTOCOL_TYPE_FIR = 45, + CIM_CONTROLLER_PROTOCOL_TYPE_SIR = 46, + CIM_CONTROLLER_PROTOCOL_TYPE_IRBUS = 47, + CIM_CONTROLLER_PROTOCOL_TYPE_SATA = 48, + /* libvirt specific */ + CIM_CONTROLLER_PROTOCOL_TYPE_CCID = 32678, + CIM_CONTROLLER_PROTOCOL_TYPE_VIRTIO_SERIAL = 32769, +}; + +static inline int controller_protocol_type_StrToID(const char *type_str) +{ + int rc = CIM_CONTROLLER_PROTOCOL_TYPE_UNKNOWN; + + if (type_str == NULL) + return rc; + + if (STREQC(type_str, "ide")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_IDE; + else if (STREQC(type_str, "fdc")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_FD; + else if (STREQC(type_str, "scsi")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SSA; /* REVISIT */ + else if (STREQC(type_str, "sata")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_SATA; + else if (STREQC(type_str, "ccid")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_CCID; + else if (STREQC(type_str, "virtio-serial")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_VIRTIO_SERIAL; + else if (STREQC(type_str, "pci")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_PCI; + else if (STREQC(type_str, "usb")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_USB; + + return rc; +} + +static inline const char* controller_protocol_type_IDToStr(int type) +{ + char *type_str = NULL; + + switch (type) + { + case CIM_CONTROLLER_PROTOCOL_TYPE_IDE: + type_str = "ide"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_FD: + type_str = "fdc"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SSA: + type_str = "scsi"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_SATA: + type_str = "sata"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_CCID: + type_str = "ccid"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_VIRTIO_SERIAL: + type_str = "virtio-serial"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_PCI: + type_str = "pci"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_USB: + type_str = "usb"; + break; + default: + break; + } + return type_str; +} + #endif -- 1.8.5.3 From jferlan at redhat.com Wed Mar 19 02:49:06 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Mar 2014 22:49:06 -0400 Subject: [Libvirt-cim] [PATCH 2/6] Add virtual controller object defs In-Reply-To: <1395197350-8552-1-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> Message-ID: <1395197350-8552-3-git-send-email-jferlan@redhat.com> Add the mofs and registration of the new virtual contoller device, which will be a subclass of the CIM_Controller class. Signed-off-by: John Ferlan --- Makefile.am | 2 ++ libvirt-cim.spec.in | 2 ++ schema/Controller.mof | 47 ++++++++++++++++++++++++++++++++++++++++++ schema/Controller.registration | 19 +++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 schema/Controller.mof create mode 100644 schema/Controller.registration diff --git a/Makefile.am b/Makefile.am index 69b65cf..864047c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,7 @@ MOFS = \ $(top_srcdir)/schema/KVMRedirectionSAP.mof \ $(top_srcdir)/schema/DisplayController.mof \ $(top_srcdir)/schema/PointingDevice.mof \ + $(top_srcdir)/schema/Controller.mof \ $(top_srcdir)/schema/GraphicsPool.mof \ $(top_srcdir)/schema/InputPool.mof \ $(top_srcdir)/schema/HostedAccessPoint.mof \ @@ -143,6 +144,7 @@ REGS = \ $(top_srcdir)/schema/KVMRedirectionSAP.registration \ $(top_srcdir)/schema/DisplayController.registration \ $(top_srcdir)/schema/PointingDevice.registration \ + $(top_srcdir)/schema/Controller.registration \ $(top_srcdir)/schema/GraphicsPool.registration \ $(top_srcdir)/schema/InputPool.registration \ $(top_srcdir)/schema/HostedAccessPoint.registration \ diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index 01ee329..4e331d9 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -111,6 +111,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/KVMRedirectionSAP.registration \\\ %{_datadir}/%{name}/DisplayController.registration \\\ %{_datadir}/%{name}/PointingDevice.registration \\\ + %{_datadir}/%{name}/Controller.registration \\\ %{_datadir}/%{name}/GraphicsPool.registration \\\ %{_datadir}/%{name}/InputPool.registration \\\ %{_datadir}/%{name}/HostedAccessPoint.registration \\\ @@ -172,6 +173,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/KVMRedirectionSAP.mof \\\ %{_datadir}/%{name}/DisplayController.mof \\\ %{_datadir}/%{name}/PointingDevice.mof \\\ + %{_datadir}/%{name}/Controller.mof \\\ %{_datadir}/%{name}/GraphicsPool.mof \\\ %{_datadir}/%{name}/InputPool.mof \\\ %{_datadir}/%{name}/HostedAccessPoint.mof \\\ diff --git a/schema/Controller.mof b/schema/Controller.mof new file mode 100644 index 0000000..a8cb06a --- /dev/null +++ b/schema/Controller.mof @@ -0,0 +1,47 @@ + +// Copyright Red Hat Corp. 2014 +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library. If not, see +// . +// + +[Description ("KVM virtual controller device. It is identified by: " + "CIM_Controller.ProtocolSupported which is set to the " + "libvirt controller 'type' value converted to an uint16. " + "Additionally, the libvirt 'model' field will be used to " + "set the CIM_Controller.ProtocolDescription."), + Provider("cmpi::Virt_Device") +] +class KVM_Controller : CIM_Controller +{ + [Description ("Order in which the bus controller is encountered. " + "The order is controller type scoped.")] + uint64 Index; + + [Description ("The 'virtio-serial' controller optionally uses the Ports " + "and Vectors to control how many devices can be connected " + "through the controller.")] + string Ports; + string Vectors; + + [Description ("Optional number of queues for the controller.")] + string Queues; + + [Description ("For controllers that are themselves devices on a " + "bus an optional element to specify the exact " + "relationship of the controller to its master bus. " + "Stored in the property and value arrays.")] + string AddressProperties[]; + string AddressValues[]; +}; diff --git a/schema/Controller.registration b/schema/Controller.registration new file mode 100644 index 0000000..7e06331 --- /dev/null +++ b/schema/Controller.registration @@ -0,0 +1,19 @@ +# Copyright Red Hat Corp. 2014 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see +# . +# + +# Classname Namespace ProviderName ProviderModule ProviderTypes +KVM_Controller root/virt Virt_Device Virt_Device instance -- 1.8.5.3 From jferlan at redhat.com Wed Mar 19 02:49:07 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Mar 2014 22:49:07 -0400 Subject: [Libvirt-cim] [PATCH 3/6] Parse/Store controller XML tags In-Reply-To: <1395197350-8552-1-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> Message-ID: <1395197350-8552-4-git-send-email-jferlan@redhat.com> From: Xu Wang Parse and store the XML tags. The generated DeviceID will be a combination of "controller" + XML device "name" + XML Index "value". This should be unique enough now and generates "controller:pci:0" or "controller:usb:0" DeviceID's. In the future, if support is added for the "" XML child a new mechanism will need to be put in place since one of those controllers is designed to have the same name and index - what changes is the function for the device. Signed-off-by: John Ferlan --- libxkutil/device_parsing.c | 119 ++++++++++++++++++++++++++++++++++++++++++++- libxkutil/xmlgen.c | 72 +++++++++++++++++++++++++++ 2 files changed, 190 insertions(+), 1 deletion(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index c9ae886..e68a950 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith @@ -49,6 +49,7 @@ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" #define DEFAULT_BRIDGE "xenbr0" #define DEFAULT_NETWORK "default" @@ -69,6 +70,7 @@ static void cleanup_device_address(struct device_address *addr) if (addr == NULL) return; + CU_DEBUG("Cleanup %d addresses", addr->ct); for (i = 0; i < addr->ct; i++) { free(addr->key[i]); free(addr->value[i]); @@ -84,6 +86,7 @@ static void cleanup_disk_device(struct disk_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean Disk type %s", dev->type); free(dev->type); free(dev->device); free(dev->driver); @@ -101,6 +104,7 @@ static void cleanup_vsi_device(struct vsi_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean VSI type %s", dev->vsi_type); free(dev->vsi_type); free(dev->manager_id); free(dev->type_id); @@ -115,6 +119,7 @@ static void cleanup_net_device(struct net_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean net type %s", dev->type); free(dev->type); free(dev->mac); free(dev->source); @@ -132,6 +137,7 @@ static void cleanup_emu_device(struct emu_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean emu %s", dev->path); free(dev->path); } @@ -155,6 +161,7 @@ static void cleanup_graphics_device(struct graphics_device *dev) if (dev == NULL || dev->type == NULL) return; + CU_DEBUG("Clean graphics type %s", dev->type); if (STREQC(dev->type, "sdl")) cleanup_sdl_device(dev); else @@ -168,6 +175,7 @@ static void cleanup_path_device(struct path_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean path device %s", dev->path); free(dev->path); } @@ -177,6 +185,7 @@ static void cleanup_unixsock_device(struct unixsock_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean unixsock device"); free(dev->path); free(dev->mode); @@ -187,6 +196,7 @@ static void cleanup_tcp_device(struct tcp_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean tcp device"); free(dev->mode); free(dev->protocol); free(dev->host); @@ -199,6 +209,7 @@ static void cleanup_udp_device(struct udp_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean udb bind device"); free(dev->bind_host); free(dev->bind_service); free(dev->connect_host); @@ -210,6 +221,7 @@ static void cleanup_console_device(struct console_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean console source_type %d", dev->source_type); switch (dev->source_type) { case CIM_CHARDEV_SOURCE_TYPE_PTY: @@ -302,10 +314,24 @@ static void cleanup_input_device(struct input_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean input device %s", dev->type); free(dev->type); free(dev->bus); } +static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + CU_DEBUG("Clean controller device %d", dev->type); + free(dev->model); + free(dev->queues); + free(dev->ports); + free(dev->vectors); + cleanup_device_address(&dev->address); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -323,6 +349,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller); free(dev->id); @@ -337,6 +365,7 @@ void cleanup_virt_devices(struct virt_device **_devs, int count) for (i = 0; i < count; i++) cleanup_virt_device(&devs[i]); + CU_DEBUG("All devices cleaned"); free(devs); *_devs = NULL; } @@ -1101,6 +1130,75 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } +static int parse_controller_device(xmlNode *cnode, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + char *type_str = NULL; + xmlNode *child = NULL; + char *index = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + type_str = get_attr_value(cnode, "type"); + if (type_str == NULL) { + CU_DEBUG("No type"); + goto err; + } + CU_DEBUG("controller device type = %s", type_str); + cdev->type = controller_protocol_type_StrToID(type_str); + if (cdev->type == CIM_CONTROLLER_PROTOCOL_TYPE_UNKNOWN) { + CU_DEBUG("Unknown controller protocol type (%d)", cdev->type); + goto err; + } + + index = get_attr_value(cnode, "index"); + if (index != NULL) { + sscanf(index, "%" PRIu64, &cdev->index); + free(index); + } else { + CU_DEBUG("No index"); + goto err; + } + + cdev->model = get_attr_value(cnode, "model"); + cdev->ports = get_attr_value(cnode, "ports"); + cdev->vectors = get_attr_value(cnode, "vectors"); + + for (child = cnode->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "address")) { + parse_device_address(child, &cdev->address); + } else if (XSTREQ(child->name, "driver")) { + cdev->queues = get_attr_value(child, "queues"); + } + } + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "controller:%s:%" PRIu64, + type_str, cdev->index); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + CU_DEBUG("Controller id is %s", vdev->id); + free(type_str); + + *vdevs = vdev; + + return 1; + err: + free(type_str); + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1224,6 +1322,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break; + case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + break; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1343,7 +1446,17 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + dev->dev.controller.type = _dev->dev.controller.type; + dev->dev.controller.index = _dev->dev.controller.index; + DUP_FIELD(dev, _dev, dev.controller.model); + DUP_FIELD(dev, _dev, dev.controller.ports); + DUP_FIELD(dev, _dev, dev.controller.vectors); + DUP_FIELD(dev, _dev, dev.controller.queues); + duplicate_device_address(&dev->dev.controller.address, + &_dev->dev.controller.address); } + return dev; } @@ -1723,6 +1836,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER); return ret; @@ -1811,6 +1927,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); free(dom); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 931f0c9..a8a00ad 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -794,6 +794,72 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; } +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + const char *msg = NULL; + + CU_DEBUG("Found %d controllers", dominfo->dev_controller_ct); + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr ctlr; + xmlNodePtr tmp; + char *type_str; + + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *cdev = &_dev->dev.controller; + + ctlr = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (ctlr == NULL) + return XML_ERROR; + + + type_str = controller_protocol_type_IDToStr(cdev->type); + if (type_str == NULL) + return XML_ERROR; + + CU_DEBUG("Type=%s Index=%" PRIu64, type_str, cdev->index); + xmlNewProp(ctlr, BAD_CAST "type", + BAD_CAST type_str); + + /* If index is missing, let libvirt generate it */ + if (cdev->index != CONTROLLER_INDEX_NOT_SET) { + char *index; + if (asprintf(&index, "%" PRIu64, cdev->index) == -1) + return XML_ERROR; + xmlNewProp(ctlr, BAD_CAST "index", BAD_CAST index); + free(index); + } + + /* Optional */ + if (cdev->model) + xmlNewProp(ctlr, BAD_CAST "model", + BAD_CAST cdev->model); + if (cdev->ports) + xmlNewProp(ctlr, BAD_CAST "ports", + BAD_CAST cdev->ports); + if (cdev->vectors) + xmlNewProp(ctlr, BAD_CAST "vectors", + BAD_CAST cdev->vectors); + if (cdev->queues) { + tmp = xmlNewChild(ctlr, NULL, BAD_CAST "driver", NULL); + xmlNewProp(tmp, BAD_CAST "queueus", + BAD_CAST cdev->queues); + } + if (cdev->address.ct > 0) { + msg = device_address_xml(ctlr, &cdev->address); + if (msg != NULL) { + CU_DEBUG("Failed to set the address"); + return msg; + } + } + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1125,6 +1191,11 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; + break; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1163,6 +1234,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL }; -- 1.8.5.3 From jferlan at redhat.com Wed Mar 19 02:49:08 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Mar 2014 22:49:08 -0400 Subject: [Libvirt-cim] [PATCH 4/6] Change static API to global API In-Reply-To: <1395197350-8552-1-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> Message-ID: <1395197350-8552-5-git-send-email-jferlan@redhat.com> Change and rename the static set_rasd_device_address() to a global set_device_address() which can be shared with Virt_Device.c to handle controller addresses. Signed-off-by: John Ferlan --- src/Virt_RASD.c | 21 +++++++++------------ src/Virt_RASD.h | 4 ++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index df1e921..a06714e 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -289,10 +289,9 @@ static bool get_vol_size(const CMPIBroker *broker, } #endif -static CMPIStatus set_rasd_device_address(const CMPIBroker *broker, - const CMPIObjectPath *ref, - const struct device_address *addr, - CMPIInstance *inst) +CMPIStatus set_device_address(const CMPIBroker *broker, + const struct device_address *addr, + CMPIInstance *inst) { int i; CMPIArray *arr_key; @@ -489,10 +488,9 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, CMPI_boolean); if (dev->dev.disk.address.ct > 0) - set_rasd_device_address(broker, - ref, - &dev->dev.disk.address, - inst); + set_device_address(broker, + &dev->dev.disk.address, + inst); virStoragePoolFree(pool); virStorageVolFree(vol); @@ -658,10 +656,9 @@ static CMPIStatus set_net_rasd_params(const CMPIBroker *broker, CMPI_chars); if (dev->dev.net.address.ct > 0) - set_rasd_device_address(broker, - ref, - &dev->dev.net.address, - inst); + set_device_address(broker, + &dev->dev.net.address, + inst); #if LIBVIR_VERSION_NUMBER < 9000 out: diff --git a/src/Virt_RASD.h b/src/Virt_RASD.h index 400143f..c96cf43 100644 --- a/src/Virt_RASD.h +++ b/src/Virt_RASD.h @@ -69,6 +69,10 @@ int list_rasds(virConnectPtr conn, const char *host, struct virt_device **list); +CMPIStatus set_device_address(const CMPIBroker *broker, + const struct device_address *addr, + CMPIInstance *inst); + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, -- 1.8.5.3 From jferlan at redhat.com Wed Mar 19 02:49:09 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Mar 2014 22:49:09 -0400 Subject: [Libvirt-cim] [PATCH 5/6] Controller Device Details In-Reply-To: <1395197350-8552-1-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> Message-ID: <1395197350-8552-6-git-send-email-jferlan@redhat.com> Set the various fields for the KVM_Contoller instance based on the read XML from the virtual controller device structure. Signed-off-by: John Ferlan --- src/Virt_Device.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/Virt_Device.c b/src/Virt_Device.c index 12ae6bd..5f48fae 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -366,6 +366,83 @@ static CMPIInstance *input_instance(const CMPIBroker *broker, return inst; } +static int controller_set_attr(const CMPIBroker *broker, + CMPIInstance *instance, + struct controller_device *dev) +{ + const char *type_str; + + type_str = controller_protocol_type_IDToStr(dev->type); + if (type_str == NULL) { + CU_DEBUG("controller type=%d fails to return string", dev->type); + return 0; + } + + /* Use 0 for unknown or unlimited - although probably + * unnecessary since the struct is calloc'd + */ + CMSetProperty(instance, "MaxNumberControlled", + 0, CMPI_uint32); + + CMSetProperty(instance, "ProtocolSupported", + (CMPIValue *)dev->type, + CMPI_uint16); + + CMSetProperty(instance, "Index", + (CMPIValue *)dev->index, + CMPI_uint64); + + if (dev->model) + CMSetProperty(instance, "ProtocolDescription", + (CMPIValue *)dev->model, + CMPI_chars); + if (dev->ports) + CMSetProperty(instance, "Ports", + (CMPIValue *)dev->ports, + CMPI_chars); + if (dev->vectors) + CMSetProperty(instance, "Vectors", + (CMPIValue *)dev->vectors, + CMPI_chars); + if (dev->queues) + CMSetProperty(instance, "Queues", + (CMPIValue *)dev->queues, + CMPI_chars); + if (dev->address.ct > 0) + set_device_address(broker, &dev->address, instance); + + return 1; +} + +static CMPIInstance *controller_instance(const CMPIBroker *broker, + struct controller_device *dev, + const virDomainPtr dom, + const char *ns) +{ + CMPIInstance *inst; + virConnectPtr conn; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "Controller", + ns, + true); + if (inst == NULL) { + CU_DEBUG("Failed to get instance of %s_Controller", + pfx_from_conn(conn)); + return NULL; + } + + + if (!controller_set_attr(broker, inst, dev)) { + CU_DEBUG("Failed to set contoller attributes of %s_Controller", + pfx_from_conn(conn)); + return NULL; + } + + return inst; +} static int device_set_devid(CMPIInstance *instance, struct virt_device *dev, const virDomainPtr dom) @@ -521,6 +598,11 @@ static bool device_instances(const CMPIBroker *broker, &dev->dev.input, dom, ns); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + instance = controller_instance(broker, + &dev->dev.controller, + dom, + ns); else return false; @@ -555,6 +637,8 @@ uint16_t res_type_from_device_classname(const char *classname) return CIM_RES_TYPE_GRAPHICS; else if (strstr(classname, "PointingDevice")) return CIM_RES_TYPE_INPUT; + else if (strstr(classname, "Controller")) + return CIM_RES_TYPE_CONTROLLER; else return CIM_RES_TYPE_UNKNOWN; } -- 1.8.5.3 From jferlan at redhat.com Wed Mar 19 02:49:10 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 18 Mar 2014 22:49:10 -0400 Subject: [Libvirt-cim] [PATCH 6/6] VSMS: Determine if default controller exists for KVM In-Reply-To: <1395197350-8552-1-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> Message-ID: <1395197350-8552-7-git-send-email-jferlan@redhat.com> If a default controller for 'pci' with model 'pci-root' doesn't exist, create one for any add/modify type event. Signed-off-by: John Ferlan --- src/Virt_VirtualSystemManagementService.c | 106 +++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 3e7785e..4610374 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -659,6 +659,82 @@ static bool default_input_device(struct domain *domain) return true; } +static bool check_default_controller_device(struct domain *domain) +{ + int i; + struct controller_device *cdev = NULL; + + CU_DEBUG("Domain '%s' type=%d", domain->name, domain->type); + + /* Only QEMU/KVM devices need controllers */ + if (domain->type != DOMAIN_KVM && domain->type != DOMAIN_QEMU) + return true; + + /* Do we find a 'pci' device with 'pci-root' model on the system? + * If not, create one. + */ + for (i = 0; i < domain->dev_controller_ct; i++) { + struct virt_device *_dev = &domain->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) { + CU_DEBUG("controller _dev->type is unknown") + continue; + } + + cdev = &_dev->dev.controller; + + CU_DEBUG("controller type=%d model=%s", + cdev->type, cdev->model ? cdev->model : "unknown"); + + if (cdev->type == CIM_CONTROLLER_PROTOCOL_TYPE_PCI && + cdev->model != NULL && + STREQC(cdev->model, "pci-root")) { + CU_DEBUG("Found 'pci-root' for %s", domain->name); + break; + } + cdev = NULL; + } + + /* Didn't find 'pci'/'pci-root', let's add it */ + if (cdev == NULL) { + char *model; + struct virt_device *_list; + struct virt_device *_dev; + + CU_DEBUG("Domain '%s' missing 'pci-root'", domain->name); + + model = strdup("pci-root"); + if (model == NULL) { + CU_DEBUG("Fail to allocate default controller model"); + return false; + } + + if (domain->dev_controller == NULL) + _list = calloc(1, sizeof(*domain->dev_controller)); + else + _list = realloc(domain->dev_controller, + (domain->dev_controller_ct + 1) * + sizeof(struct virt_device)); + if (_list == NULL) { + CU_DEBUG("Fail to allocate controller model"); + free(model); + return false; + } + domain->dev_controller = _list; + + _dev = &domain->dev_controller[domain->dev_controller_ct]; + _dev->type = CIM_RES_TYPE_CONTROLLER; + + cdev = &_dev->dev.controller; + memset(cdev, 0, sizeof(*cdev)); + cdev->type = CIM_CONTROLLER_PROTOCOL_TYPE_PCI; + cdev->index = 0; /* By definition it must be 0 */ + cdev->model = model; + domain->dev_controller_ct += 1; + } + + return true; +} + static bool add_default_devs(struct domain *domain) { if (domain->dev_graphics_ct < 1 && @@ -2545,8 +2621,16 @@ static CMPIInstance *create_system(const CMPIContext *context, goto out; } + if (!check_default_controller_device(domain)) { + CU_DEBUG("Failed to check default controller"); + cu_statusf(_BROKER, s, + CMPI_RC_ERR_FAILED, + "Failed to create default controller"); + goto out; + } + xml = system_to_xml(domain); - CU_DEBUG("System XML:\n%s", xml); + CU_DEBUG("create_system XML:\n%s", xml); inst = connect_and_create(xml, ref, s); if (inst != NULL) { @@ -2815,9 +2899,17 @@ static CMPIStatus update_system_settings(const CMPIContext *context, goto out; } + if (!check_default_controller_device(dominfo)) { + CU_DEBUG("Failed to check default controller"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to create default controller"); + goto out; + } + xml = system_to_xml(dominfo); if (xml != NULL) { - CU_DEBUG("New XML is:\n%s", xml); + CU_DEBUG("update_system_settings XML:\n%s", xml); connect_and_create(xml, ref, &s); } @@ -3310,9 +3402,17 @@ static CMPIStatus _update_resources_for(const CMPIContext *context, goto out; } + if (!check_default_controller_device(dominfo)) { + CU_DEBUG("Failed to check default controller"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to create default controller"); + goto out; + } + xml = system_to_xml(dominfo); if (xml != NULL) { - CU_DEBUG("New XML:\n%s", xml); + CU_DEBUG("_update_resources_for XML:\n%s", xml); connect_and_create(xml, ref, &s); if (inst_list_add(&list, rasd) == 0) { -- 1.8.5.3 From jferlan at redhat.com Wed Mar 19 19:24:31 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 19 Mar 2014 15:24:31 -0400 Subject: [Libvirt-cim] [PATCH 6/6] VSMS: Determine if default controller exists for KVM In-Reply-To: <1395197350-8552-7-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> <1395197350-8552-7-git-send-email-jferlan@redhat.com> Message-ID: <5329EEEF.9000800@redhat.com> On 03/18/2014 10:49 PM, John Ferlan wrote: > If a default controller for 'pci' with model 'pci-root' doesn't exist, > create one for any add/modify type event. > > Signed-off-by: John Ferlan > --- > src/Virt_VirtualSystemManagementService.c | 106 +++++++++++++++++++++++++++++- > 1 file changed, 103 insertions(+), 3 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 3e7785e..4610374 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -659,6 +659,82 @@ static bool default_input_device(struct domain *domain) > return true; > } > > +static bool check_default_controller_device(struct domain *domain) > +{ > + int i; > + struct controller_device *cdev = NULL; > + > + CU_DEBUG("Domain '%s' type=%d", domain->name, domain->type); > + > + /* Only QEMU/KVM devices need controllers */ > + if (domain->type != DOMAIN_KVM && domain->type != DOMAIN_QEMU) > + return true; > + > + /* Do we find a 'pci' device with 'pci-root' model on the system? > + * If not, create one. > + */ > + for (i = 0; i < domain->dev_controller_ct; i++) { > + struct virt_device *_dev = &domain->dev_controller[i]; > + if (_dev->type == CIM_RES_TYPE_UNKNOWN) { > + CU_DEBUG("controller _dev->type is unknown") > + continue; > + } > + > + cdev = &_dev->dev.controller; > + > + CU_DEBUG("controller type=%d model=%s", > + cdev->type, cdev->model ? cdev->model : "unknown"); > + > + if (cdev->type == CIM_CONTROLLER_PROTOCOL_TYPE_PCI && > + cdev->model != NULL && > + STREQC(cdev->model, "pci-root")) { > + CU_DEBUG("Found 'pci-root' for %s", domain->name); > + break; > + } > + cdev = NULL; > + } > + > + /* Didn't find 'pci'/'pci-root', let's add it */ > + if (cdev == NULL) { > + char *model; > + struct virt_device *_list; > + struct virt_device *_dev; > + > + CU_DEBUG("Domain '%s' missing 'pci-root'", domain->name); > + > + model = strdup("pci-root"); > + if (model == NULL) { > + CU_DEBUG("Fail to allocate default controller model"); > + return false; > + } > + > + if (domain->dev_controller == NULL) > + _list = calloc(1, sizeof(*domain->dev_controller)); > + else > + _list = realloc(domain->dev_controller, > + (domain->dev_controller_ct + 1) * > + sizeof(struct virt_device)); > + if (_list == NULL) { > + CU_DEBUG("Fail to allocate controller model"); > + free(model); > + return false; > + } > + domain->dev_controller = _list; > + > + _dev = &domain->dev_controller[domain->dev_controller_ct]; > + _dev->type = CIM_RES_TYPE_CONTROLLER; > + > + cdev = &_dev->dev.controller; > + memset(cdev, 0, sizeof(*cdev)); > + cdev->type = CIM_CONTROLLER_PROTOCOL_TYPE_PCI; > + cdev->index = 0; /* By definition it must be 0 */ > + cdev->model = model; > + domain->dev_controller_ct += 1; > + } > + > + return true; > +} > + > static bool add_default_devs(struct domain *domain) > { > if (domain->dev_graphics_ct < 1 && > @@ -2545,8 +2621,16 @@ static CMPIInstance *create_system(const CMPIContext *context, > goto out; > } > > + if (!check_default_controller_device(domain)) { > + CU_DEBUG("Failed to check default controller"); > + cu_statusf(_BROKER, s, > + CMPI_RC_ERR_FAILED, > + "Failed to create default controller"); > + goto out; > + } > + > xml = system_to_xml(domain); > - CU_DEBUG("System XML:\n%s", xml); > + CU_DEBUG("create_system XML:\n%s", xml); > > inst = connect_and_create(xml, ref, s); > if (inst != NULL) { > @@ -2815,9 +2899,17 @@ static CMPIStatus update_system_settings(const CMPIContext *context, > goto out; > } > > + if (!check_default_controller_device(dominfo)) { > + CU_DEBUG("Failed to check default controller"); > + cu_statusf(_BROKER, &s, > + CMPI_RC_ERR_FAILED, > + "Failed to create default controller"); > + goto out; > + } > + > xml = system_to_xml(dominfo); > if (xml != NULL) { > - CU_DEBUG("New XML is:\n%s", xml); > + CU_DEBUG("update_system_settings XML:\n%s", xml); > connect_and_create(xml, ref, &s); > } > > @@ -3310,9 +3402,17 @@ static CMPIStatus _update_resources_for(const CMPIContext *context, > goto out; > } > > + if (!check_default_controller_device(dominfo)) { > + CU_DEBUG("Failed to check default controller"); > + cu_statusf(_BROKER, &s, > + CMPI_RC_ERR_FAILED, > + "Failed to create default controller"); > + goto out; > + } > + > xml = system_to_xml(dominfo); > if (xml != NULL) { > - CU_DEBUG("New XML:\n%s", xml); > + CU_DEBUG("_update_resources_for XML:\n%s", xml); > connect_and_create(xml, ref, &s); > > if (inst_list_add(&list, rasd) == 0) { > Running the changes through Coverity resulted in a simple change... Although totally unnecessary - Coverity complained that comparing dev_controller to NULL in order to decide whether to calloc or realloc, could result in a data overrun if dev_controller_ct was greater than 0. Changing the comparison to check dev_controller_ct kept Coverity quiet. Consider the following diff squashed in diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 4610374..7958537 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -708,7 +708,7 @@ static bool check_default_controller_device(struct domain *d return false; } - if (domain->dev_controller == NULL) + if (domain->dev_controller_ct == 0) _list = calloc(1, sizeof(*domain->dev_controller)); else _list = realloc(domain->dev_controller, From fiuczy at linux.vnet.ibm.com Fri Mar 21 11:57:45 2014 From: fiuczy at linux.vnet.ibm.com (Boris Fiuczynski) Date: Fri, 21 Mar 2014 12:57:45 +0100 Subject: [Libvirt-cim] [PATCH 0/6] Add Virtual Controller Device In-Reply-To: <1395197350-8552-1-git-send-email-jferlan@redhat.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> Message-ID: <532C2939.5090403@linux.vnet.ibm.com> On 03/19/2014 03:49 AM, John Ferlan wrote: > This is rework of the Controller patch series submitted by Xu Wang. I have > built upon the constructs put in place by Xu with respect to reading and > writing the XML, but for the remainder of the code I changed where the > virtual controller lives. > > Xu's patches made a Controller RASD which had some issues regarding > associations with other devices and pools. > > Rather than go with a RASD model, I have chosen to make a KVM_Controller > virtual device to mimic a CIM_Controller device. This solution keeps things In doing so you broke the DMTF Virtual System Profile! http://www.dmtf.org/sites/default/files/standards/documents/DSP1057_1.0.0_0.pdf Take a look at 7.3.1 which defines a Virtual System Configuration and a Virtual System Representation. It states the class concepts. You need to use RASDs. > at a lower level and has been able to pass the cimtest as well as the > update a defined domain with a changed value test. This second test is > what fails for RHEL7. > > As it turns out, it seems as long as a 'pci' device with model 'pci-root' > is created, then things seem to work. The code relies on the previous patch > code Xu created to read/write the XML file with some adjustments. > > Perhaps the only controversial patch (for me at least) is 6/6. I figured > that after we've read everything and just before we go to create or update > the guest that we need to make sure that at least the 'pci' device with > model 'pci-root' exists. This is similar to the add_default_devs() code, Actually libvirt-cim should not be creating default devices but let libvirt do that. Reimplementing libvirt's default behavior would a overestimation of libvirt-cim's own capabilities and in the long run cause extra effort in maintaining default consistency. > except that it's run after all that code prior to any add or update of > the guest just before the "system_to_xml()" call is made. I figure this > is the last gasp to ensure that at least the 'pci' device is there which > seems to be used by a number of "silently added" libvirt devices. > > John Ferlan (4): > Add virtual controller object defs > Change static API to global API > Controller Device Details > VSMS: Determine if default controller exists for KVM > > Xu Wang (2): > Add virtual controller device types > Parse/Store controller XML tags > > Makefile.am | 2 + > libvirt-cim.spec.in | 2 + > libxkutil/device_parsing.c | 119 +++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 15 ++++ > libxkutil/xmlgen.c | 72 +++++++++++++++++ > schema/Controller.mof | 47 +++++++++++ > schema/Controller.registration | 19 +++++ > src/Virt_Device.c | 84 ++++++++++++++++++++ > src/Virt_RASD.c | 21 +++-- > src/Virt_RASD.h | 4 + > src/Virt_VirtualSystemManagementService.c | 106 ++++++++++++++++++++++++- > src/svpc_types.h | 127 ++++++++++++++++++++++++++++++ > 12 files changed, 602 insertions(+), 16 deletions(-) > create mode 100644 schema/Controller.mof > create mode 100644 schema/Controller.registration > -- Mit freundlichen Gr??en/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina K?deritz Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From jferlan at redhat.com Fri Mar 21 15:30:52 2014 From: jferlan at redhat.com (John Ferlan) Date: Fri, 21 Mar 2014 11:30:52 -0400 Subject: [Libvirt-cim] [PATCH 0/6] Add Virtual Controller Device In-Reply-To: <532C2939.5090403@linux.vnet.ibm.com> References: <1395197350-8552-1-git-send-email-jferlan@redhat.com> <532C2939.5090403@linux.vnet.ibm.com> Message-ID: <532C5B2C.7000605@redhat.com> On 03/21/2014 07:57 AM, Boris Fiuczynski wrote: > On 03/19/2014 03:49 AM, John Ferlan wrote: >> This is rework of the Controller patch series submitted by Xu Wang. I have >> built upon the constructs put in place by Xu with respect to reading and >> writing the XML, but for the remainder of the code I changed where the >> virtual controller lives. >> >> Xu's patches made a Controller RASD which had some issues regarding >> associations with other devices and pools. >> >> Rather than go with a RASD model, I have chosen to make a KVM_Controller >> virtual device to mimic a CIM_Controller device. This solution keeps things > In doing so you broke the DMTF Virtual System Profile! > http://www.dmtf.org/sites/default/files/standards/documents/DSP1057_1.0.0_0.pdf > Take a look at 7.3.1 which defines a Virtual System Configuration and a > Virtual System Representation. It states the class concepts. > You need to use RASDs. > Hmm... Way too many standards for me to know :-). Also, to say the least the docs are written for someone that lives/breaths CIM (as far as I'm concerned at least). I see a box for "LogicalDevice" which is what CIM_Controller extends - so it seems the reality is in addition to the CIM_Controller there needs to be a KVM_ControllerResourceAllocationSettingData, right? I see for other KVM_*RASD types there is a related KVM_*LogicalDevice, so it's "more or less" a matter of extending what I already have, I think. For now the pressure is off though - the issue won't be fixed/ready for the RHEL7.0 release, so at the earliest it'll be 7.1. There's *way too much* code to backport sanely to including in a 7.0.z stream - right now there's about 30 or so patches - basically anything that's been added since 0.6.3 was created (and inserted into RHEL7.0). For me that's mostly a process issue. Furthermore, the addition of a keyboard input device in libvirt 1.2.2 has complicated things, especially the cimtest results, see: http://www.redhat.com/archives/libvir-list/2014-February/msg01058.html I'm off trying to figure out the best way to add/represent this. The libvirt code considers it an input device and on the "devices/input" XML tree. Thus it's parsed by the device_parsing code. Of course cimtest blows up because 'keyboard' doesn't match 'mouse' or 'tablet' and all the associations and links off in the weeds. There is a CIM_Keyboard device; however, given the above comments - it seems that may not be the path to take... If I make a KVM_Keyboard device and include found keyboards in the "KVM_InputRASD" there's issues because quite a few of the cimtest tests assume a 1-to-1 relationship between a classname and the RASD. They are not very happy to find two KVM_InputRASD's that are different. Building references of the RASD by the test uses the classname as a key - thus whichever is last (eg, keyboard) gets the representation. Anyway different problem, but still I think a similar need for representation - so it'll be good to understand the requirements for how a controller needs to be or can be represented. >> at a lower level and has been able to pass the cimtest as well as the >> update a defined domain with a changed value test. This second test is >> what fails for RHEL7. >> >> As it turns out, it seems as long as a 'pci' device with model 'pci-root' >> is created, then things seem to work. The code relies on the previous patch >> code Xu created to read/write the XML file with some adjustments. >> >> Perhaps the only controversial patch (for me at least) is 6/6. I figured >> that after we've read everything and just before we go to create or update >> the guest that we need to make sure that at least the 'pci' device with >> model 'pci-root' exists. This is similar to the add_default_devs() code, > Actually libvirt-cim should not be creating default devices but let > libvirt do that. Reimplementing libvirt's default behavior would a > overestimation of libvirt-cim's own capabilities and in the long run > cause extra effort in maintaining default consistency. > Right - so I wasn't sure "how" to handle the issue if someone didn't configure/add a controller at domain/guest creation time. Other devices see to use the add_default_devs() mechanism, but honestly I really don't understand it that well. John >> except that it's run after all that code prior to any add or update of >> the guest just before the "system_to_xml()" call is made. I figure this >> is the last gasp to ensure that at least the 'pci' device is there which >> seems to be used by a number of "silently added" libvirt devices. >> >> John Ferlan (4): >> Add virtual controller object defs >> Change static API to global API >> Controller Device Details >> VSMS: Determine if default controller exists for KVM >> >> Xu Wang (2): >> Add virtual controller device types >> Parse/Store controller XML tags >> >> Makefile.am | 2 + >> libvirt-cim.spec.in | 2 + >> libxkutil/device_parsing.c | 119 +++++++++++++++++++++++++++- >> libxkutil/device_parsing.h | 15 ++++ >> libxkutil/xmlgen.c | 72 +++++++++++++++++ >> schema/Controller.mof | 47 +++++++++++ >> schema/Controller.registration | 19 +++++ >> src/Virt_Device.c | 84 ++++++++++++++++++++ >> src/Virt_RASD.c | 21 +++-- >> src/Virt_RASD.h | 4 + >> src/Virt_VirtualSystemManagementService.c | 106 ++++++++++++++++++++++++- >> src/svpc_types.h | 127 ++++++++++++++++++++++++++++++ >> 12 files changed, 602 insertions(+), 16 deletions(-) >> create mode 100644 schema/Controller.mof >> create mode 100644 schema/Controller.registration >> > > From gesaint at linux.vnet.ibm.com Tue Mar 25 07:20:55 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Tue, 25 Mar 2014 15:20:55 +0800 Subject: [Libvirt-cim] [PATCH V2 0/5] Add Controller Device Support Message-ID: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> These patches are based on V1. An unexpectable accident makes me only one hand could work now so sorry everything from me takes so long time. Updates from V1: 1. Added 2 break logic in switch. 2. Changed CIM_RES_TYPE_CONTROLLER into 32771. 3. Added XEN/KVM/LXC_Controller classes for cimtest. Most of cimtest testcases have passed except the following: -------------------------------------------------------------------- HostSystem - 02_hostsystem_to_rasd.py: FAIL ERROR - Failed to get associators information for KVM_SettingsDefineState ERROR - Exception: u'KVM_Controller' -------------------------------------------------------------------- -------------------------------------------------------------------- RASD - 03_rasd_errs.py: FAIL ERROR - Expected 6 RASDs, got 7 -------------------------------------------------------------------- -------------------------------------------------------------------- ResourceAllocationFromPool - 01_forward.py: FAIL ERROR - 7 RASD insts != 6 pool insts -------------------------------------------------------------------- ResourceAllocationFromPool - 02_reverse.py: FAIL ERROR - 7 RASD insts != 6 pool insts -------------------------------------------------------------------- -------------------------------------------------------------------- SettingsDefine - 01_forward.py: FAIL ERROR - 6 device insts != 7 RASD insts -------------------------------------------------------------------- SettingsDefine - 02_reverse.py: FAIL ERROR - u'KVM_Controller' -------------------------------------------------------------------- -------------------------------------------------------------------- SystemDevice - 01_forward.py: FAIL 01_forward.py:29: DeprecationWarning: the sets module is deprecated from sets import Set ERROR - Device Class mismatch ERROR - Exception Expected Device class list: ['KVM_DisplayController', 'KVM_LogicalDisk', 'KVM_Memory', 'KVM_NetworkPort', 'KVM_PointingDevice', 'KVM_Processor'] Got: [u'KVM_Controller', u'KVM_DisplayController', u'KVM_LogicalDisk', u'KVM_Memory', u'KVM_NetworkPort', u'KVM_PointingDevice', u'KVM_Processor'] -------------------------------------------------------------------- -------------------------------------------------------------------- VirtualSystemSettingDataComponent - 02_reverse.py: FAIL ERROR - Unexpected RASD instance type ERROR - Mistmatching association value -------------------------------------------------------------------- I think they are caused by the parameter set of cimtest (such as KVM_Controller or ControllerResourceAllocationSettingData should be added into some arrays. But if you find they are caused by my coding errors, please let me know, thanks). I'll fix these issues of cimtest later. Dear John and Boris, could you help me testing it on RHEL6.5? I just have an upgraded version and introduced some packages from CentOS source (I am worried about they may influence the testing result). I'll rebuild my developing environment later using pure RHEL 6.5 version. Xu Wang (5): libxutil: Controller Support RASD: Schema and Provider Support for Controller RASDs VSMS: Support for domains with controller devices Device: CIM_LogicalDevice for controllers Virt_Device: Add a device class for controllers Makefile.am | 2 + libvirt-cim.spec.in | 2 + libxkutil/device_parsing.c | 70 ++++++++++++++++++++- libxkutil/device_parsing.h | 9 +++ libxkutil/xmlgen.c | 30 +++++++++ schema/Controller.mof | 16 +++++ schema/Controller.registration | 5 ++ schema/ResourceAllocationSettingData.mof | 27 ++++++++ schema/ResourceAllocationSettingData.registration | 3 + src/Virt_Device.c | 36 ++++++++++- src/Virt_ElementAllocatedFromPool.c | 6 ++ src/Virt_ElementSettingData.c | 3 + src/Virt_RASD.c | 24 +++++++ src/Virt_ServiceAffectsElement.c | 6 ++- src/Virt_SettingsDefineState.c | 6 ++ src/Virt_SystemDevice.c | 3 + src/Virt_VSSDComponent.c | 3 + src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++ src/svpc_types.h | 4 +- 19 files changed, 295 insertions(+), 4 deletions(-) create mode 100644 schema/Controller.mof create mode 100644 schema/Controller.registration From gesaint at linux.vnet.ibm.com Tue Mar 25 07:20:56 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Tue, 25 Mar 2014 15:20:56 +0800 Subject: [Libvirt-cim] [PATCH V2 1/5] libxutil: Controller Support In-Reply-To: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1395732060-2268-2-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 70 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 +++++ libxkutil/xmlgen.c | 30 +++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 111 insertions(+), 2 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..4240243 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith @@ -49,6 +49,7 @@ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" #define DEFAULT_BRIDGE "xenbr0" #define DEFAULT_NETWORK "default" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); } +static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller); free(dev->id); @@ -1107,6 +1119,49 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + char *index = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + if (cdev->model == NULL) { + cdev->model = strdup(""); + } + index = get_attr_value(node, "index"); + + if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s:%s", cdev->type, index); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + free(index); + + return 1; + err: + free(index); + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1285,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break; + case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + break; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1411,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); } + return dev; } @@ -1731,6 +1795,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER); return ret; @@ -1819,6 +1886,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); free(dom); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; }; +struct controller_device { + char *type; + char *model; +}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain { struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; }; struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..529c946 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,30 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; } +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + if (!STREQC(dev->model, "")) + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1129,6 +1153,11 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; + break; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1167,6 +1196,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL }; diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..7a2b653 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -36,8 +36,9 @@ #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 +#define CIM_RES_TYPE_CONTROLLER 32771 -#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.7.1 From gesaint at linux.vnet.ibm.com Tue Mar 25 07:21:00 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Tue, 25 Mar 2014 15:21:00 +0800 Subject: [Libvirt-cim] [PATCH V2 5/5] Virt_Device: Add a device class for controllers In-Reply-To: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1395732060-2268-6-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- Makefile.am | 2 ++ libvirt-cim.spec.in | 2 ++ schema/Controller.mof | 16 ++++++++++++++++ schema/Controller.registration | 5 +++++ src/Virt_Device.c | 4 +++- src/Virt_ElementAllocatedFromPool.c | 6 ++++++ src/Virt_ElementSettingData.c | 3 +++ src/Virt_ServiceAffectsElement.c | 6 +++++- src/Virt_SettingsDefineState.c | 6 ++++++ src/Virt_SystemDevice.c | 3 +++ src/Virt_VSSDComponent.c | 3 +++ 11 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 schema/Controller.mof create mode 100644 schema/Controller.registration diff --git a/Makefile.am b/Makefile.am index 69b65cf..f38c8fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,7 @@ MOFS = \ $(top_srcdir)/schema/ServiceAffectsElement.mof \ $(top_srcdir)/schema/KVMRedirectionSAP.mof \ $(top_srcdir)/schema/DisplayController.mof \ + $(top_srcdir)/schema/Controller.mof \ $(top_srcdir)/schema/PointingDevice.mof \ $(top_srcdir)/schema/GraphicsPool.mof \ $(top_srcdir)/schema/InputPool.mof \ @@ -142,6 +143,7 @@ REGS = \ $(top_srcdir)/schema/ServiceAffectsElement.registration \ $(top_srcdir)/schema/KVMRedirectionSAP.registration \ $(top_srcdir)/schema/DisplayController.registration \ + $(top_srcdir)/schema/Controller.registration \ $(top_srcdir)/schema/PointingDevice.registration \ $(top_srcdir)/schema/GraphicsPool.registration \ $(top_srcdir)/schema/InputPool.registration \ diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index 01ee329..809b9db 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -121,6 +121,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/EntriesInFilterList.registration \\\ %{_datadir}/%{name}/NestedFilterList.registration \\\ %{_datadir}/%{name}/AppliedFilterList.registration \\\ + %{_datadir}/%{name}/Controller.registration \\\ %{_datadir}/%{name}/HostedFilterList.registration %define SCHEMA %{_datadir}/%{name}/ComputerSystem.mof \\\ @@ -182,6 +183,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/EntriesInFilterList.mof \\\ %{_datadir}/%{name}/NestedFilterList.mof \\\ %{_datadir}/%{name}/AppliedFilterList.mof \\\ + %{_datadir}/%{name}/Controller.mof \\\ %{_datadir}/%{name}/HostedFilterList.mof %define INTEROP_REG %{_datadir}/%{name}/RegisteredProfile.registration \\\ diff --git a/schema/Controller.mof b/schema/Controller.mof new file mode 100644 index 0000000..91475a9 --- /dev/null +++ b/schema/Controller.mof @@ -0,0 +1,16 @@ +// Copyright IBM Corp. 2014 + +[ Provider("cmpi::Virt_Device") ] +class Xen_Controller : CIM_Controller +{ +}; + +[ Provider("cmpi::Virt_Device") ] +class KVM_Controller : CIM_Controller +{ +}; + +[ Provider("cmpi::Virt_Device") ] +class LXC_Controller : CIM_Controller +{ +}; diff --git a/schema/Controller.registration b/schema/Controller.registration new file mode 100644 index 0000000..cc73b7a --- /dev/null +++ b/schema/Controller.registration @@ -0,0 +1,5 @@ +# Copyright IBM Corp. 2014 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_Controller root/virt Virt_Device Virt_Device instance +KVM_Controller root/virt Virt_Device Virt_Device instance +LXC_Controller root/virt Virt_Device Virt_Device instance diff --git a/src/Virt_Device.c b/src/Virt_Device.c index f100f6b..3f73a76 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -381,7 +381,7 @@ static CMPIInstance *controller_instance(const CMPIBroker *broker, ns, true); if (inst == NULL) { - CU_DEBUG("Failed to get instance of ControllerDevice"); + CU_DEBUG("Failed to get instance of Controller"); return NULL; } @@ -587,6 +587,8 @@ uint16_t res_type_from_device_classname(const char *classname) return CIM_RES_TYPE_GRAPHICS; else if (strstr(classname, "PointingDevice")) return CIM_RES_TYPE_INPUT; + else if (strstr(classname, "Controller")) + return CIM_RES_TYPE_CONTROLLER; else return CIM_RES_TYPE_UNKNOWN; } diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c index 2c2f2d1..7ba3a53 100644 --- a/src/Virt_ElementAllocatedFromPool.c +++ b/src/Virt_ElementAllocatedFromPool.c @@ -269,18 +269,21 @@ static char* device[] = { "Xen_LogicalDisk", "Xen_DisplayController", "Xen_PointingDevice", + "Xen_Controller", "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", "KVM_LogicalDisk", "KVM_DisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", "LXC_LogicalDisk", "LXC_DisplayController", "LXC_PointingDevice", + "LXC_Controller", NULL }; @@ -291,18 +294,21 @@ static char* device_or_pool[] = { "Xen_LogicalDisk", "Xen_DisplayController", "Xen_PointingDevice", + "Xen_Controller", "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", "KVM_LogicalDisk", "KVM_DisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", "LXC_LogicalDisk", "LXC_DisplayController", "LXC_PointingDevice", + "LXC_Controller", "Xen_ProcessorPool", "Xen_MemoryPool", "Xen_NetworkPool", diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c index c088e49..38d7821 100644 --- a/src/Virt_ElementSettingData.c +++ b/src/Virt_ElementSettingData.c @@ -130,6 +130,7 @@ static char* resource_allocation_setting_data[] = { "Xen_GraphicsResourceAllocationSettingData", "Xen_ConsoleResourceAllocationSettingData", "Xen_InputResourceAllocationSettingData", + "Xen_ControllerResourceAllocationSettingData", "KVM_DiskResourceAllocationSettingData", "KVM_MemResourceAllocationSettingData", "KVM_NetResourceAllocationSettingData", @@ -137,6 +138,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", @@ -144,6 +146,7 @@ static char* resource_allocation_setting_data[] = { "LXC_GraphicsResourceAllocationSettingData", "LXC_ConsoleResourceAllocationSettingData", "LXC_InputResourceAllocationSettingData", + "LXC_ControllerResourceAllocationSettingData", NULL }; diff --git a/src/Virt_ServiceAffectsElement.c b/src/Virt_ServiceAffectsElement.c index 9810e02..ff63ab2 100644 --- a/src/Virt_ServiceAffectsElement.c +++ b/src/Virt_ServiceAffectsElement.c @@ -102,7 +102,8 @@ static CMPIStatus validate_cs_or_dev_ref(const CMPIContext *context, if (STREQC(classname, "ComputerSystem")) { s = get_domain_by_ref(_BROKER, ref, &inst); } else if ((STREQC(classname, "PointingDevice")) || - (STREQC(classname, "DisplayController"))) { + (STREQC(classname, "DisplayController")) || + (STREQC(classname, "Controller"))) { s = get_device_by_ref(_BROKER, ref, &inst); } @@ -146,6 +147,9 @@ static char* affected_ele[] = { "Xen_DisplayController", "KVM_DisplayController", "LXC_DisplayController", + "Xen_Controller", + "KVM_Controller", + "LXC_Controller", NULL }; diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c index c8cda97..9024fda 100644 --- a/src/Virt_SettingsDefineState.c +++ b/src/Virt_SettingsDefineState.c @@ -329,6 +329,7 @@ static char* logical_device[] = { "Xen_DisplayController", "Xen_ConsoleDisplayController", "Xen_PointingDevice", + "Xen_Controller", "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", @@ -336,6 +337,7 @@ static char* logical_device[] = { "KVM_DisplayController", "KVM_ConsoleDisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", @@ -343,6 +345,7 @@ static char* logical_device[] = { "LXC_DisplayController", "LXC_ConsoleDisplayController", "LXC_PointingDevice", + "LXC_Controller", NULL }; @@ -354,6 +357,7 @@ static char* resource_allocation_setting_data[] = { "Xen_GraphicsResourceAllocationSettingData", "Xen_InputResourceAllocationSettingData", "Xen_ConsoleResourceAllocationSettingData", + "Xen_ControllerResourceAllocationSettingData", "KVM_DiskResourceAllocationSettingData", "KVM_MemResourceAllocationSettingData", "KVM_NetResourceAllocationSettingData", @@ -361,6 +365,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", @@ -368,6 +373,7 @@ static char* resource_allocation_setting_data[] = { "LXC_GraphicsResourceAllocationSettingData", "LXC_InputResourceAllocationSettingData", "LXC_ConsoleResourceAllocationSettingData", + "LXC_ControllerResourceAllocationSettingData", NULL }; diff --git a/src/Virt_SystemDevice.c b/src/Virt_SystemDevice.c index d2e526d..92dfe19 100644 --- a/src/Virt_SystemDevice.c +++ b/src/Virt_SystemDevice.c @@ -137,6 +137,7 @@ static char* part_component[] = { "Xen_DisplayController", "Xen_ConsoleDisplayController", "Xen_PointingDevice", + "Xen_Controller", "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", @@ -144,6 +145,7 @@ static char* part_component[] = { "KVM_DisplayController", "KVM_ConsoleDisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", @@ -151,6 +153,7 @@ static char* part_component[] = { "LXC_DisplayController", "LXC_ConsoleDisplayController", "LXC_PointingDevice", + "LXC_Controller", NULL }; diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c index 35bffde..1fd1221 100644 --- a/src/Virt_VSSDComponent.c +++ b/src/Virt_VSSDComponent.c @@ -134,6 +134,7 @@ static char* part_component[] = { "Xen_GraphicsResourceAllocationSettingData", "Xen_ConsoleResourceAllocationSettingData", "Xen_InputResourceAllocationSettingData", + "Xen_ControllerResourceAllocationSettingData", "KVM_DiskResourceAllocationSettingData", "KVM_MemResourceAllocationSettingData", "KVM_NetResourceAllocationSettingData", @@ -141,6 +142,7 @@ static char* part_component[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", @@ -148,6 +150,7 @@ static char* part_component[] = { "LXC_GraphicsResourceAllocationSettingData", "LXC_InputResourceAllocationSettingData", "LXC_ConsoleResourceAllocationSettingData", + "LXC_ControllerResourceAllocationSettingData", NULL }; -- 1.7.1 From gesaint at linux.vnet.ibm.com Tue Mar 25 07:20:57 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Tue, 25 Mar 2014 15:20:57 +0800 Subject: [Libvirt-cim] [PATCH V2 2/5] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1395732060-2268-3-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; }; +[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..1142376 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index abfb09f..594fe83 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; } +static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, "Type", + (CMPIValue *)dev->dev.controller.type, CMPI_chars); + + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_CONTROLLER; + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(dev, inst); } /* FIXME: Put the HostResource in place */ @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out; @@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; } -- 1.7.1 From gesaint at linux.vnet.ibm.com Tue Mar 25 07:20:59 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Tue, 25 Mar 2014 15:20:59 +0800 Subject: [Libvirt-cim] [PATCH V2 4/5] Device: CIM_LogicalDevice for controllers In-Reply-To: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1395732060-2268-5-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- src/Virt_Device.c | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) diff --git a/src/Virt_Device.c b/src/Virt_Device.c index 12ae6bd..f100f6b 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -366,6 +366,33 @@ static CMPIInstance *input_instance(const CMPIBroker *broker, return inst; } +static CMPIInstance *controller_instance(const CMPIBroker *broker, + struct controller_device *dev, + const virDomainPtr dom, + const char *ns) +{ + CMPIInstance *inst; + virConnectPtr conn; + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "Controller", + ns, + true); + if (inst == NULL) { + CU_DEBUG("Failed to get instance of ControllerDevice"); + return NULL; + } + + CMSetProperty(inst, "Controller", + (CMPIValue *)dev->type, CMPI_chars); + CMSetProperty(inst, "Controller", + (CMPIValue *)dev->model, CMPI_chars); + + return inst; +} + static int device_set_devid(CMPIInstance *instance, struct virt_device *dev, const virDomainPtr dom) @@ -516,11 +543,16 @@ static bool device_instances(const CMPIBroker *broker, &dev->dev.console, dom, ns); - else if (dev->type == CIM_RES_TYPE_INPUT) + else if (dev->type == CIM_RES_TYPE_INPUT) instance = input_instance(broker, &dev->dev.input, dom, ns); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + instance = controller_instance(broker, + &dev->dev.controller, + dom, + ns); else return false; -- 1.7.1 From gesaint at linux.vnet.ibm.com Tue Mar 25 07:20:58 2014 From: gesaint at linux.vnet.ibm.com (Xu Wang) Date: Tue, 25 Mar 2014 15:20:58 +0800 Subject: [Libvirt-cim] [PATCH V2 3/5] VSMS: Support for domains with controller devices In-Reply-To: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <1395732060-2268-4-git-send-email-gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang --- src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index e146470..1a34ff8 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1848,6 +1848,28 @@ 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; + + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Type field not valid"); + goto out; + } + dev->dev.controller.type = strdup(val); + + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { + CU_DEBUG("Invalid value for Model in ControllerRASD"); + goto out; + } + dev->dev.controller.model = strdup(val); + + out: + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -1868,6 +1890,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"; @@ -1888,6 +1912,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"; @@ -1997,6 +2023,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; @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray *resources, &domain->dev_input[0], ns, p_error); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_controller[domain->dev_controller_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_controller_ct += 1; } + if (msg != NULL) return msg; @@ -2918,6 +2956,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; @@ -3039,6 +3080,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 { @@ -3121,6 +3163,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, ""); @@ -3198,6 +3241,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.7.1 From jferlan at redhat.com Tue Mar 25 17:51:14 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 25 Mar 2014 13:51:14 -0400 Subject: [Libvirt-cim] [PATCH 0/3] Resolved recent/new Coverity warnings Message-ID: <1395769877-5477-1-git-send-email-jferlan@redhat.com> For virlog.c and commandtest.c - it seems recent changes within the modules have allowed Coverity to dig deeper and find different issues. Not sure why Coverity has that "ability"... Since I was making changes, figured I'd clean up the lxc_controller fd leak as well - these should clean the Jenkins build environment. John Ferlan (3): Coverity: Resolve a CHECKED_RETURN message Coverity: Resolve a FORWARD_NULL Coverity: Resolve a RESOURCE_LEAK src/lxc/lxc_controller.c | 14 ++++++++++---- src/util/virlog.c | 2 +- tests/commandtest.c | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) -- 1.8.5.3 From jferlan at redhat.com Tue Mar 25 17:51:15 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 25 Mar 2014 13:51:15 -0400 Subject: [Libvirt-cim] [PATCH 1/3] Coverity: Resolve a CHECKED_RETURN message In-Reply-To: <1395769877-5477-1-git-send-email-jferlan@redhat.com> References: <1395769877-5477-1-git-send-email-jferlan@redhat.com> Message-ID: <1395769877-5477-2-git-send-email-jferlan@redhat.com> Recent changes to the module seemed to have caused Coverity to find a new issue regarding the failure to check the return from a sendmsg. The code doesn't seem to care about the return status, so just added an ignore_value to keep Coverity quiet. Signed-off-by: John Ferlan --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index d0afd10..056950e 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1003,7 +1003,7 @@ virLogOutputToJournald(virLogSourcePtr source, mh.msg_controllen = cmsg->cmsg_len; - sendmsg(journalfd, &mh, MSG_NOSIGNAL); + ignore_value(sendmsg(journalfd, &mh, MSG_NOSIGNAL)); cleanup: VIR_LOG_CLOSE(buffd); -- 1.8.5.3 From jferlan at redhat.com Tue Mar 25 17:51:17 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 25 Mar 2014 13:51:17 -0400 Subject: [Libvirt-cim] [PATCH 3/3] Coverity: Resolve a RESOURCE_LEAK In-Reply-To: <1395769877-5477-1-git-send-email-jferlan@redhat.com> References: <1395769877-5477-1-git-send-email-jferlan@redhat.com> Message-ID: <1395769877-5477-4-git-send-email-jferlan@redhat.com> On error the lofd would have been leaked. Signed-off-by: John Ferlan --- src/lxc/lxc_controller.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 800a306..928a43d 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -383,6 +383,7 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk) int lofd; char *loname = NULL; const char *src = virDomainDiskGetSource(disk); + int ret = -1; if ((lofd = virFileLoopDeviceAssociate(src, &loname)) < 0) return -1; @@ -395,13 +396,18 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk) * the rest of container setup 'just works' */ virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_BLOCK); - if (virDomainDiskSetSource(disk, loname) < 0) { - VIR_FREE(loname); - return -1; - } + if (virDomainDiskSetSource(disk, loname) < 0) + goto cleanup; + + ret = 0; + + cleanup: VIR_FREE(loname); + if (ret == -1) + VIR_FORCE_CLOSE(lofd); return lofd; + } -- 1.8.5.3 From jferlan at redhat.com Tue Mar 25 17:51:16 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 25 Mar 2014 13:51:16 -0400 Subject: [Libvirt-cim] [PATCH 2/3] Coverity: Resolve a FORWARD_NULL In-Reply-To: <1395769877-5477-1-git-send-email-jferlan@redhat.com> References: <1395769877-5477-1-git-send-email-jferlan@redhat.com> Message-ID: <1395769877-5477-3-git-send-email-jferlan@redhat.com> Recent changes in the module seemed to have caused Coverity to reanalyze certain parts of the code. Previously the code was modified via commit id '11a11812' to resolve a different error (perhaps DEADCODE). Up through commit id '7b3f1f8c' there were no issues. The new error indicats the 'outbuf' was checked for NULL and then complains because of the dereference. Adding checks for non-NULL prior to the deref resulted in a DEADCODE message. So, resolve using an sa_assert() to keep Coverity quiet especially since it doesn't understand that outbuf will change as a result of a successful virCommandRun() call. Signed-off-by: John Ferlan --- tests/commandtest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/commandtest.c b/tests/commandtest.c index c5c3a9a..7d2161c 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -690,6 +690,7 @@ static int test17(const void *unused ATTRIBUTE_UNUSED) goto cleanup; } + sa_assert(outbuf); if (*outbuf) { puts("output buffer is not an allocated empty string"); goto cleanup; -- 1.8.5.3 From jferlan at redhat.com Tue Mar 25 17:59:31 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 25 Mar 2014 13:59:31 -0400 Subject: [Libvirt-cim] [PATCH 0/3] Resolved recent/new Coverity warnings In-Reply-To: <1395769877-5477-1-git-send-email-jferlan@redhat.com> References: <1395769877-5477-1-git-send-email-jferlan@redhat.com> Message-ID: <5331C403.2030207@redhat.com> Ignore the old man with bad eyesight who picked the wrong line in his command cheat sheet file... This was supposed to go to libvir-list (sigh)... John From jferlan at redhat.com Tue Mar 25 23:45:24 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 25 Mar 2014 19:45:24 -0400 Subject: [Libvirt-cim] [PATCH V2 0/5] Add Controller Device Support In-Reply-To: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <53321514.7060002@redhat.com> On 03/25/2014 03:20 AM, Xu Wang wrote: > These patches are based on V1. An unexpectable accident makes > me only one hand could work now so sorry everything from me > takes so long time. > Sorry to hear that - I have co-worker who did the same thing this past July. Took him a while to be productive again. Not sure if you followed along with the recent posts - I did try to take what you've coded (in V1) and get things to work. There's patches from me regarding Virtual Controller Device on the list. Unfortunately it seems I didn't get the exactly right, but I'm assuming that I can further massage them in order to make a ControllerRASD as well as the Controller Logical Device (I think we're going to need one anyway if I read Boris' response correctly). Also the cimtest failures below most assuredly have to do with not having a KVM_Controller RASD in the list... I think if you start with 'XenKvmLib/rasd.py' and start adding a ControllerRASD - you'll eventually work your way through the tests. HOWEVER, I am messing with cimtest right now. Upstream libvirt added a keyboard device which (unfortunately) resides in the /devices/input list. That makes it parseable and placed into the PointingDevice RASD resulting in two InputRASD's being present. Now one can argue a keyboard is not a PointingDevice - I get it, but what I found is the cimtest tests have an inherent assumption that there's the Class Name can be used as a key for a dictionary in python. That fails if there's two InputRASD devices. I have a pile of fixes for that where I've changed the dictionary to a list of tuples with the Class Name as the first element and whatever the dictionary was referencing as the second element. I have cimtest passing with top of trunk. I have to test it on an older libvirt to see what happens. I also think that a keyboard shouldn't be a PointingDevice, but I'm trying to "wait" to add that until we close on the Controller code. So the short of it is - cimtest is going to be broken for a bit I think. Now that I have my cimtest environment "working" I'll start looking at this set of changes over the next day or so. John > Updates from V1: > 1. Added 2 break logic in switch. > 2. Changed CIM_RES_TYPE_CONTROLLER into 32771. > 3. Added XEN/KVM/LXC_Controller classes for cimtest. > > Most of cimtest testcases have passed except the following: > -------------------------------------------------------------------- > HostSystem - 02_hostsystem_to_rasd.py: FAIL > ERROR - Failed to get associators information for KVM_SettingsDefineState > ERROR - Exception: u'KVM_Controller' > -------------------------------------------------------------------- > -------------------------------------------------------------------- > RASD - 03_rasd_errs.py: FAIL > ERROR - Expected 6 RASDs, got 7 > -------------------------------------------------------------------- > -------------------------------------------------------------------- > ResourceAllocationFromPool - 01_forward.py: FAIL > ERROR - 7 RASD insts != 6 pool insts > -------------------------------------------------------------------- > ResourceAllocationFromPool - 02_reverse.py: FAIL > ERROR - 7 RASD insts != 6 pool insts > -------------------------------------------------------------------- > -------------------------------------------------------------------- > SettingsDefine - 01_forward.py: FAIL > ERROR - 6 device insts != 7 RASD insts > -------------------------------------------------------------------- > SettingsDefine - 02_reverse.py: FAIL > ERROR - u'KVM_Controller' > -------------------------------------------------------------------- > -------------------------------------------------------------------- > SystemDevice - 01_forward.py: FAIL > 01_forward.py:29: DeprecationWarning: the sets module is deprecated > from sets import Set > ERROR - Device Class mismatch > ERROR - Exception Expected Device class list: ['KVM_DisplayController', 'KVM_LogicalDisk', 'KVM_Memory', 'KVM_NetworkPort', 'KVM_PointingDevice', 'KVM_Processor'] > Got: [u'KVM_Controller', u'KVM_DisplayController', u'KVM_LogicalDisk', u'KVM_Memory', u'KVM_NetworkPort', u'KVM_PointingDevice', u'KVM_Processor'] > -------------------------------------------------------------------- > -------------------------------------------------------------------- > VirtualSystemSettingDataComponent - 02_reverse.py: FAIL > ERROR - Unexpected RASD instance type > ERROR - Mistmatching association value > -------------------------------------------------------------------- > I think they are caused by the parameter set of cimtest (such as KVM_Controller > or ControllerResourceAllocationSettingData should be added into some arrays. > But if you find they are caused by my coding errors, please let me know, thanks). > I'll fix these issues of cimtest later. > > Dear John and Boris, could you help me testing it on RHEL6.5? I just > have an upgraded version and introduced some packages from CentOS source > (I am worried about they may influence the testing result). I'll rebuild > my developing environment later using pure RHEL 6.5 version. > > Xu Wang (5): > libxutil: Controller Support > RASD: Schema and Provider Support for Controller RASDs > VSMS: Support for domains with controller devices > Device: CIM_LogicalDevice for controllers > Virt_Device: Add a device class for controllers > > Makefile.am | 2 + > libvirt-cim.spec.in | 2 + > libxkutil/device_parsing.c | 70 ++++++++++++++++++++- > libxkutil/device_parsing.h | 9 +++ > libxkutil/xmlgen.c | 30 +++++++++ > schema/Controller.mof | 16 +++++ > schema/Controller.registration | 5 ++ > schema/ResourceAllocationSettingData.mof | 27 ++++++++ > schema/ResourceAllocationSettingData.registration | 3 + > src/Virt_Device.c | 36 ++++++++++- > src/Virt_ElementAllocatedFromPool.c | 6 ++ > src/Virt_ElementSettingData.c | 3 + > src/Virt_RASD.c | 24 +++++++ > src/Virt_ServiceAffectsElement.c | 6 ++- > src/Virt_SettingsDefineState.c | 6 ++ > src/Virt_SystemDevice.c | 3 + > src/Virt_VSSDComponent.c | 3 + > src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++ > src/svpc_types.h | 4 +- > 19 files changed, 295 insertions(+), 4 deletions(-) > create mode 100644 schema/Controller.mof > create mode 100644 schema/Controller.registration > From jferlan at redhat.com Wed Mar 26 13:28:35 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 26 Mar 2014 09:28:35 -0400 Subject: [Libvirt-cim] [PATCH 0/2] Add rawio/sgio tag property support In-Reply-To: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> References: <1393808659-3006-1-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5332D603.5010103@redhat.com> On 03/02/2014 08:04 PM, Xu Wang wrote: > They are needed by virtio-scsi so add them into libvirt-cim support > > Xu Wang (2): > Add rawio property support > Add sgio property support > > libxkutil/device_parsing.c | 8 ++++++++ > libxkutil/device_parsing.h | 2 ++ > libxkutil/xmlgen.c | 4 ++++ > schema/ResourceAllocationSettingData.mof | 6 ++++++ > src/Virt_RASD.c | 12 ++++++++++++ > src/Virt_VirtualSystemManagementService.c | 10 ++++++++++ > 6 files changed, 42 insertions(+), 0 deletions(-) > As an "update" - I ran these changes using my adjusted cimtest and had no new regressions. I have pushed them, so that we can make forward progress. If these are requested to be backported into a RHEL6 release, then the BZ that gets opened needs to have a test associated with it - more than a dump of the mof via: # wbemcli gcd http://root:password at localhost:5988/root/virt:KVM_DiskResourceAllocationSettingData | egrep "rawio|sgio" (or wbemcli ei) I did update the commit message in order to include the command Tks, John From jferlan at redhat.com Wed Mar 26 22:31:24 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 26 Mar 2014 18:31:24 -0400 Subject: [Libvirt-cim] [PATCH V2 1/5] libxutil: Controller Support In-Reply-To: <1395732060-2268-2-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> <1395732060-2268-2-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5333553C.3040505@redhat.com> Precursor to review - I'll merge your changes with what I posted last week so we can then work off one common set of changes. They're pretty close anyway since what I did was based on your v1. My "goal" is to make breaks in the changes such that it's possible to bisect history and reduce cimtest failures - it's not easy to accomplish, but I'll try. ... This patch will be split into two - the two .h files in one and the two .c files in the other. It's more for easier review since I've added quite a few new properties. On 03/25/2014 03:20 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > libxkutil/device_parsing.c | 70 +++++++++++++++++++++++++++++++++++++++++++- > libxkutil/device_parsing.h | 9 +++++ > libxkutil/xmlgen.c | 30 +++++++++++++++++++ > src/svpc_types.h | 4 ++- > 4 files changed, 111 insertions(+), 2 deletions(-) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > index d2d3859..4240243 100644 > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -1,5 +1,5 @@ > /* > - * Copyright IBM Corp. 2007, 2013 > + * Copyright IBM Corp. 2007, 2014 Oh yea... Although I'll make it 2007-2014 > * > * Authors: > * Dan Smith > @@ -49,6 +49,7 @@ > #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ > "/domain/devices/console" > #define INPUT_XPATH (xmlChar *)"/domain/devices/input" > +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" > > #define DEFAULT_BRIDGE "xenbr0" > #define DEFAULT_NETWORK "default" > @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) > free(dev->bus); > } > > +static void cleanup_controller_device(struct controller_device *dev) > +{ > + if (dev == NULL) > + return; > + > + free(dev->type); > + free(dev->model); See .h comments, but while we're at it - may as well add other properties too (queues, ports, vectors, address) as well as storing the index which we'll need. > +} > + > void cleanup_virt_device(struct virt_device *dev) > { > if (dev == NULL) > @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) > cleanup_input_device(&dev->dev.input); > else if (dev->type == CIM_RES_TYPE_CONSOLE) > cleanup_console_device(&dev->dev.console); > + else if (dev->type == CIM_RES_TYPE_CONTROLLER) > + cleanup_controller_device(&dev->dev.controller); > > free(dev->id); > > @@ -1107,6 +1119,49 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) > return 0; > } > > +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) > +{ > + struct virt_device *vdev = NULL; > + struct controller_device *cdev = NULL; > + char *index = NULL; > + int ret; > + > + vdev = calloc(1, sizeof(*vdev)); > + if (vdev == NULL) > + goto err; > + > + cdev = &(vdev->dev.controller); > + > + cdev->type = get_attr_value(node, "type"); > + cdev->model = get_attr_value(node, "model"); > + if (cdev->model == NULL) { > + cdev->model = strdup(""); > + } I disagree here - if the model doesn't exist, don't save it an empty string, because then we'll write out an empty string which isn't expected. If not found, then keep model as NULL and handle that later. > + index = get_attr_value(node, "index"); We must save the index because if it exists, we need to write it out. If it doesn't exist on input - that's a problem. As pointed out by Boris in one of his reviews we'll have to handle this specially on the create from a nonXML description path, see: http://www.redhat.com/archives/libvirt-cim/2014-March/msg00037.html search for CONTROLLER_INDEX_NOT_SET > + > + if (cdev->type == NULL) > + goto err; > + > + vdev->type = CIM_RES_TYPE_CONTROLLER; > + > + ret = asprintf(&vdev->id, "%s:%s", cdev->type, index); > + if (ret == -1) { > + CU_DEBUG("Failed to create controller id string"); > + goto err; > + } > + > + *vdevs = vdev; > + free(index); > + > + return 1; > + err: > + free(index); > + cleanup_controller_device(cdev); > + free(vdev); > + > + return 0; > +} > + > static bool resize_devlist(struct virt_device **list, int newsize) > { > struct virt_device *_list; > @@ -1230,6 +1285,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) > func = &parse_input_device; > break; > > + case CIM_RES_TYPE_CONTROLLER: > + xpathstr = CONTROLLER_XPATH; > + func = &parse_controller_device; > + break; > + > default: > CU_DEBUG("Unrecognized device type. Returning."); > goto err1; > @@ -1351,7 +1411,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) > } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > console_device_dup(&dev->dev.console, > &_dev->dev.console); > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + DUP_FIELD(dev, _dev, dev.controller.type); > + DUP_FIELD(dev, _dev, dev.controller.model); There will be more fields here too > } > + > return dev; > } > > @@ -1731,6 +1795,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) > (*dominfo)->dev_vcpu_ct = parse_devices(xml, > &(*dominfo)->dev_vcpu, > CIM_RES_TYPE_PROC); > + (*dominfo)->dev_controller_ct = parse_devices(xml, > + &(*dominfo)->dev_controller, > + CIM_RES_TYPE_CONTROLLER); > > return ret; > > @@ -1819,6 +1886,7 @@ void cleanup_dominfo(struct domain **dominfo) > cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); > cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); > cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); > + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); > > free(dom); > > diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h > index a92e223..cc58970 100644 > --- a/libxkutil/device_parsing.h > +++ b/libxkutil/device_parsing.h > @@ -163,6 +163,11 @@ struct input_device { > char *bus; > }; > > +struct controller_device { > + char *type; The index should be saved too... I've also converted the type to an int and added API's to handle converting from type to string and back. > + char *model; While we're at it we should grab/store/restore other fields (ports, vectors, queues, address) > +}; > + > struct virt_device { > uint16_t type; > union { > @@ -174,6 +179,7 @@ struct virt_device { > struct graphics_device graphics; > struct console_device console; > struct input_device input; > + struct controller_device controller; > } dev; > char *id; > }; > @@ -249,6 +255,9 @@ struct domain { > > struct virt_device *dev_vcpu; > int dev_vcpu_ct; > + > + struct virt_device *dev_controller; > + int dev_controller_ct; > }; > > struct virt_device *virt_device_dup(struct virt_device *dev); > diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c > index 18c4765..529c946 100644 > --- a/libxkutil/xmlgen.c > +++ b/libxkutil/xmlgen.c > @@ -798,6 +798,30 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) > return NULL; > } > > +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) > +{ > + int i; > + > + for (i = 0; i < dominfo->dev_controller_ct; i++) { > + xmlNodePtr tmp; > + struct virt_device *_dev = &dominfo->dev_controller[i]; > + if (_dev->type == CIM_RES_TYPE_UNKNOWN) > + continue; > + > + struct controller_device *dev = &_dev->dev.controller; > + > + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + > + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); > + if (!STREQC(dev->model, "")) > + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); Also need to output other fields here if they exist as well. > + } > + > + return NULL; > +} > + > static char *system_xml(xmlNodePtr root, struct domain *domain) > { > xmlNodePtr tmp; > @@ -1129,6 +1153,11 @@ char *device_to_xml(struct virt_device *_dev) > dominfo->dev_input_ct = 1; > dominfo->dev_input = dev; > break; > + case CIM_RES_TYPE_CONTROLLER: > + func = controller_xml; > + dominfo->dev_controller_ct = 1; > + dominfo->dev_controller = dev; > + break; > default: > cleanup_virt_devices(&dev, 1); > goto out; > @@ -1167,6 +1196,7 @@ char *system_to_xml(struct domain *dominfo) > &console_xml, > &graphics_xml, > &emu_xml, > + &controller_xml, > NULL > }; > > diff --git a/src/svpc_types.h b/src/svpc_types.h > index 404e428..7a2b653 100644 > --- a/src/svpc_types.h > +++ b/src/svpc_types.h > @@ -36,8 +36,9 @@ > #define CIM_RES_TYPE_IMAGE 32768 > #define CIM_RES_TYPE_CONSOLE 32769 > #define CIM_RES_TYPE_EMU 32770 > +#define CIM_RES_TYPE_CONTROLLER 32771 > > -#define CIM_RES_TYPE_COUNT 7 > +#define CIM_RES_TYPE_COUNT 8 Avoid doing too early - causes cimtest failures since not all the plumbing is available. So in the changes you see from me, this will not be in the first patch - rather it'll be in a later patch. > const static int cim_res_types[CIM_RES_TYPE_COUNT] = > {CIM_RES_TYPE_NET, > CIM_RES_TYPE_DISK, > @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = > CIM_RES_TYPE_GRAPHICS, > CIM_RES_TYPE_INPUT, > CIM_RES_TYPE_CONSOLE, > + CIM_RES_TYPE_CONTROLLER, Avoid adding in this patch since alone it causes cimtest failures if done too early. > }; > > #define CIM_VSSD_RECOVERY_NONE 2 > The bottom of this will get a list of enum controller types and the string/type conversion routines. John From jferlan at redhat.com Wed Mar 26 22:37:48 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 26 Mar 2014 18:37:48 -0400 Subject: [Libvirt-cim] [PATCH V2 2/5] RASD: Schema and Provider Support for Controller RASDs In-Reply-To: <1395732060-2268-3-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> <1395732060-2268-3-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <533356BC.9050002@redhat.com> As it stands now - this will end up in one "final" mega patch. As it turned out - there's no way one can add the mofs without affecting how cimtest runs. Naturally vice versa applies - the code cannot be there first and then the mofs just appear. So pretty much everything in your patches 2-5 will end up in one patch from me (unfortunately). On 03/25/2014 03:20 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ > schema/ResourceAllocationSettingData.registration | 3 ++ > src/Virt_RASD.c | 24 ++++++++++++++++++ > 3 files changed, 54 insertions(+), 0 deletions(-) > > diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof > index 6b649de..3512170 100644 > --- a/schema/ResourceAllocationSettingData.mof > +++ b/schema/ResourceAllocationSettingData.mof > @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData > string BusType; > }; > > +[Description ("Xen virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData > +{ > + string Type; > + string Model; > +}; Does Xen have one? I'm following Boris' advice and removing Xen and LXC defs, see: http://www.redhat.com/archives/libvirt-cim/2014-March/msg00021.html > + > +[Description ("KVM virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData > +{ > + string Type; > + string Model; As you'll see I have many more definitions. > +}; > + > +[Description ("LXC virtual controller device"), > + Provider("cmpi::Virt_RASD") > +] > +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData > +{ > + string Type; > + string Model; > +}; > + > [Description ("Xen virtual network pool settings"), > Provider("cmpi::Virt_RASD") > ] > diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration > index b969bfe..1142376 100644 > --- a/schema/ResourceAllocationSettingData.registration > +++ b/schema/ResourceAllocationSettingData.registration > @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Again no Xen/LXC > KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > index abfb09f..594fe83 100644 > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, > return s; > } > > +static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, > + CMPIInstance *inst) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + > + CMSetProperty(inst, "Type", > + (CMPIValue *)dev->dev.controller.type, CMPI_chars); > + > + CMSetProperty(inst, "Model", > + (CMPIValue *)dev->dev.controller.model, CMPI_chars); > + There will be many more fields to handle here. > + return s; > +} > + > CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > struct virt_device *dev, > const char *host, > @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > } else if (dev->type == CIM_RES_TYPE_INPUT) { > type = CIM_RES_TYPE_INPUT; > base = "InputResourceAllocationSettingData"; > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + type = CIM_RES_TYPE_CONTROLLER; > + base = "ControllerResourceAllocationSettingData"; > } else { > return NULL; > } > @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, > s = set_input_rasd_params(dev, inst); > } else if (dev->type == CIM_RES_TYPE_CONSOLE) { > s = set_console_rasd_params(dev, inst); > + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { > + s = set_controller_rasd_params(dev, inst); > } > > /* FIXME: Put the HostResource in place */ > @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) > *type = CIM_RES_TYPE_IMAGE; > else if (STREQ(base, "ConsoleResourceAllocationSettingData")) > *type = CIM_RES_TYPE_CONSOLE; > + else if (STREQ(base, "ControllerResourceAllocationSettingData")) > + *type = CIM_RES_TYPE_CONTROLLER; > else > goto out; > > @@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) > case CIM_RES_TYPE_INPUT: > *classname = "InputResourceAllocationSettingData"; > break; > + case CIM_RES_TYPE_CONTROLLER: > + *classname = "ControllerResourceAllocationSettingData"; > + break; > default: > rc = CMPI_RC_ERR_FAILED; > } > From jferlan at redhat.com Wed Mar 26 23:32:20 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 26 Mar 2014 19:32:20 -0400 Subject: [Libvirt-cim] [PATCH V2 3/5] VSMS: Support for domains with controller devices In-Reply-To: <1395732060-2268-4-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> <1395732060-2268-4-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <53336384.7080706@redhat.com> On 03/25/2014 03:20 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++ > 1 files changed, 44 insertions(+), 0 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index e146470..1a34ff8 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1848,6 +1848,28 @@ 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; > + > + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { > + CU_DEBUG("ControllerRASD Type field not valid"); > + goto out; > + } > + dev->dev.controller.type = strdup(val); > + > + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { > + CU_DEBUG("Invalid value for Model in ControllerRASD"); > + goto out; > + } > + dev->dev.controller.model = strdup(val); Based on the changes I've made there will need to be some adjustments here. > + > + out: > + > + return NULL; > +} > + > static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev, > uint16_t type, > @@ -1868,6 +1890,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"; > @@ -1888,6 +1912,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"; > @@ -1997,6 +2023,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; > @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray *resources, > &domain->dev_input[0], > ns, > p_error); > + } else if (type == CIM_RES_TYPE_CONTROLLER) { > + msg = rasd_to_vdev(inst, > + domain, > + &domain->dev_controller[domain->dev_controller_ct], > + ns, > + p_error); > + if (msg == NULL) > + domain->dev_controller_ct += 1; > } > + > if (msg != NULL) > return msg; > > @@ -2918,6 +2956,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; > @@ -3039,6 +3080,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 { > @@ -3121,6 +3163,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, ""); > @@ -3198,6 +3241,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 { > From jferlan at redhat.com Wed Mar 26 23:32:44 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 26 Mar 2014 19:32:44 -0400 Subject: [Libvirt-cim] [PATCH V2 4/5] Device: CIM_LogicalDevice for controllers In-Reply-To: <1395732060-2268-5-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> <1395732060-2268-5-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5333639C.8040707@redhat.com> On 03/25/2014 03:20 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > src/Virt_Device.c | 34 +++++++++++++++++++++++++++++++++- > 1 files changed, 33 insertions(+), 1 deletions(-) > > diff --git a/src/Virt_Device.c b/src/Virt_Device.c > index 12ae6bd..f100f6b 100644 > --- a/src/Virt_Device.c > +++ b/src/Virt_Device.c > @@ -366,6 +366,33 @@ static CMPIInstance *input_instance(const CMPIBroker *broker, > return inst; > } > > +static CMPIInstance *controller_instance(const CMPIBroker *broker, > + struct controller_device *dev, > + const virDomainPtr dom, > + const char *ns) > +{ > + CMPIInstance *inst; > + virConnectPtr conn; > + > + conn = virDomainGetConnect(dom); > + inst = get_typed_instance(broker, > + pfx_from_conn(conn), > + "Controller", > + ns, > + true); > + if (inst == NULL) { > + CU_DEBUG("Failed to get instance of ControllerDevice"); CU_DEBUG("Failed to get instance of %s_Controller", pfx_from_conn(conn)); > + return NULL; > + } > + > + CMSetProperty(inst, "Controller", > + (CMPIValue *)dev->type, CMPI_chars); > + CMSetProperty(inst, "Controller", > + (CMPIValue *)dev->model, CMPI_chars); Not sure what you were setting here as there's not a "Controller" property from what I read... In any case, these will become: const char *type_str; type_str = controller_protocol_type_IDToStr(dev->type); if (type_str == NULL) { CU_DEBUG("controller type=%d fails to return string", dev->type); return 0; } CMSetProperty(inst, "ProtocolSupported", (CMPIValue *)dev->type, CMPI_uint16); if (dev->model) CMSetProperty(inst, "ProtocolDescription", (CMPIValue *)dev->model, CMPI_chars); Where the ProtocolSupported type will come from a new enum list in svpc_types.h as taken from the docs. The ProtocolDescription is the free form description with more detail > + > + return inst; > +} > + > static int device_set_devid(CMPIInstance *instance, > struct virt_device *dev, > const virDomainPtr dom) > @@ -516,11 +543,16 @@ static bool device_instances(const CMPIBroker *broker, > &dev->dev.console, > dom, > ns); > - else if (dev->type == CIM_RES_TYPE_INPUT) > + else if (dev->type == CIM_RES_TYPE_INPUT) > instance = input_instance(broker, > &dev->dev.input, > dom, > ns); > + else if (dev->type == CIM_RES_TYPE_CONTROLLER) > + instance = controller_instance(broker, > + &dev->dev.controller, > + dom, > + ns); > else > return false; > > From jferlan at redhat.com Wed Mar 26 23:36:28 2014 From: jferlan at redhat.com (John Ferlan) Date: Wed, 26 Mar 2014 19:36:28 -0400 Subject: [Libvirt-cim] [PATCH V2 5/5] Virt_Device: Add a device class for controllers In-Reply-To: <1395732060-2268-6-git-send-email-gesaint@linux.vnet.ibm.com> References: <1395732060-2268-1-git-send-email-gesaint@linux.vnet.ibm.com> <1395732060-2268-6-git-send-email-gesaint@linux.vnet.ibm.com> Message-ID: <5333647C.8060509@redhat.com> I'm still working my way through merging - I've had some fat finger moments and some not paying attention moments which caused me some git grief, but I'm working my way through it. I will post something tomorrow at some point... It's late for me now. On 03/25/2014 03:21 AM, Xu Wang wrote: > Signed-off-by: Xu Wang > --- > Makefile.am | 2 ++ > libvirt-cim.spec.in | 2 ++ > schema/Controller.mof | 16 ++++++++++++++++ > schema/Controller.registration | 5 +++++ > src/Virt_Device.c | 4 +++- > src/Virt_ElementAllocatedFromPool.c | 6 ++++++ > src/Virt_ElementSettingData.c | 3 +++ > src/Virt_ServiceAffectsElement.c | 6 +++++- > src/Virt_SettingsDefineState.c | 6 ++++++ > src/Virt_SystemDevice.c | 3 +++ > src/Virt_VSSDComponent.c | 3 +++ > 11 files changed, 54 insertions(+), 2 deletions(-) > create mode 100644 schema/Controller.mof > create mode 100644 schema/Controller.registration > > diff --git a/Makefile.am b/Makefile.am > index 69b65cf..f38c8fc 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -52,6 +52,7 @@ MOFS = \ > $(top_srcdir)/schema/ServiceAffectsElement.mof \ > $(top_srcdir)/schema/KVMRedirectionSAP.mof \ > $(top_srcdir)/schema/DisplayController.mof \ > + $(top_srcdir)/schema/Controller.mof \ > $(top_srcdir)/schema/PointingDevice.mof \ > $(top_srcdir)/schema/GraphicsPool.mof \ > $(top_srcdir)/schema/InputPool.mof \ > @@ -142,6 +143,7 @@ REGS = \ > $(top_srcdir)/schema/ServiceAffectsElement.registration \ > $(top_srcdir)/schema/KVMRedirectionSAP.registration \ > $(top_srcdir)/schema/DisplayController.registration \ > + $(top_srcdir)/schema/Controller.registration \ > $(top_srcdir)/schema/PointingDevice.registration \ > $(top_srcdir)/schema/GraphicsPool.registration \ > $(top_srcdir)/schema/InputPool.registration \ > diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in > index 01ee329..809b9db 100644 > --- a/libvirt-cim.spec.in > +++ b/libvirt-cim.spec.in > @@ -121,6 +121,7 @@ rm -fr $RPM_BUILD_ROOT > %{_datadir}/%{name}/EntriesInFilterList.registration \\\ > %{_datadir}/%{name}/NestedFilterList.registration \\\ > %{_datadir}/%{name}/AppliedFilterList.registration \\\ > + %{_datadir}/%{name}/Controller.registration \\\ > %{_datadir}/%{name}/HostedFilterList.registration > > %define SCHEMA %{_datadir}/%{name}/ComputerSystem.mof \\\ > @@ -182,6 +183,7 @@ rm -fr $RPM_BUILD_ROOT > %{_datadir}/%{name}/EntriesInFilterList.mof \\\ > %{_datadir}/%{name}/NestedFilterList.mof \\\ > %{_datadir}/%{name}/AppliedFilterList.mof \\\ > + %{_datadir}/%{name}/Controller.mof \\\ > %{_datadir}/%{name}/HostedFilterList.mof > > %define INTEROP_REG %{_datadir}/%{name}/RegisteredProfile.registration \\\ > diff --git a/schema/Controller.mof b/schema/Controller.mof > new file mode 100644 > index 0000000..91475a9 > --- /dev/null > +++ b/schema/Controller.mof > @@ -0,0 +1,16 @@ > +// Copyright IBM Corp. 2014 > + > +[ Provider("cmpi::Virt_Device") ] > +class Xen_Controller : CIM_Controller > +{ > +}; > + > +[ Provider("cmpi::Virt_Device") ] > +class KVM_Controller : CIM_Controller > +{ > +}; > + > +[ Provider("cmpi::Virt_Device") ] > +class LXC_Controller : CIM_Controller > +{ > +}; Again, not sure if Xen makes sense and definitely LXC doesn't > diff --git a/schema/Controller.registration b/schema/Controller.registration > new file mode 100644 > index 0000000..cc73b7a > --- /dev/null > +++ b/schema/Controller.registration > @@ -0,0 +1,5 @@ > +# Copyright IBM Corp. 2014 > +# Classname Namespace ProviderName ProviderModule ProviderTypes > +Xen_Controller root/virt Virt_Device Virt_Device instance > +KVM_Controller root/virt Virt_Device Virt_Device instance > +LXC_Controller root/virt Virt_Device Virt_Device instance Adjustments here too. > diff --git a/src/Virt_Device.c b/src/Virt_Device.c > index f100f6b..3f73a76 100644 > --- a/src/Virt_Device.c > +++ b/src/Virt_Device.c > @@ -381,7 +381,7 @@ static CMPIInstance *controller_instance(const CMPIBroker *broker, > ns, > true); > if (inst == NULL) { > - CU_DEBUG("Failed to get instance of ControllerDevice"); > + CU_DEBUG("Failed to get instance of Controller"); > return NULL; > } > > @@ -587,6 +587,8 @@ uint16_t res_type_from_device_classname(const char *classname) > return CIM_RES_TYPE_GRAPHICS; > else if (strstr(classname, "PointingDevice")) > return CIM_RES_TYPE_INPUT; > + else if (strstr(classname, "Controller")) > + return CIM_RES_TYPE_CONTROLLER; > else > return CIM_RES_TYPE_UNKNOWN; > } > diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c > index 2c2f2d1..7ba3a53 100644 > --- a/src/Virt_ElementAllocatedFromPool.c > +++ b/src/Virt_ElementAllocatedFromPool.c > @@ -269,18 +269,21 @@ static char* device[] = { > "Xen_LogicalDisk", > "Xen_DisplayController", > "Xen_PointingDevice", > + "Xen_Controller", > "KVM_Processor", > "KVM_Memory", > "KVM_NetworkPort", > "KVM_LogicalDisk", > "KVM_DisplayController", > "KVM_PointingDevice", > + "KVM_Controller", > "LXC_Processor", > "LXC_Memory", > "LXC_NetworkPort", > "LXC_LogicalDisk", > "LXC_DisplayController", > "LXC_PointingDevice", > + "LXC_Controller", > NULL No Xen/LXC > }; > > @@ -291,18 +294,21 @@ static char* device_or_pool[] = { > "Xen_LogicalDisk", > "Xen_DisplayController", > "Xen_PointingDevice", > + "Xen_Controller", > "KVM_Processor", > "KVM_Memory", > "KVM_NetworkPort", > "KVM_LogicalDisk", > "KVM_DisplayController", > "KVM_PointingDevice", > + "KVM_Controller", > "LXC_Processor", > "LXC_Memory", > "LXC_NetworkPort", > "LXC_LogicalDisk", > "LXC_DisplayController", > "LXC_PointingDevice", > + "LXC_Controller", > "Xen_ProcessorPool", > "Xen_MemoryPool", > "Xen_NetworkPool", No Xen/LXC > diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c > index c088e49..38d7821 100644 > --- a/src/Virt_ElementSettingData.c > +++ b/src/Virt_ElementSettingData.c > @@ -130,6 +130,7 @@ static char* resource_allocation_setting_data[] = { > "Xen_GraphicsResourceAllocationSettingData", > "Xen_ConsoleResourceAllocationSettingData", > "Xen_InputResourceAllocationSettingData", > + "Xen_ControllerResourceAllocationSettingData", > "KVM_DiskResourceAllocationSettingData", > "KVM_MemResourceAllocationSettingData", > "KVM_NetResourceAllocationSettingData", > @@ -137,6 +138,7 @@ static char* resource_allocation_setting_data[] = { > "KVM_GraphicsResourceAllocationSettingData", > "KVM_ConsoleResourceAllocationSettingData", > "KVM_InputResourceAllocationSettingData", > + "KVM_ControllerResourceAllocationSettingData", > "LXC_DiskResourceAllocationSettingData", > "LXC_MemResourceAllocationSettingData", > "LXC_NetResourceAllocationSettingData", > @@ -144,6 +146,7 @@ static char* resource_allocation_setting_data[] = { > "LXC_GraphicsResourceAllocationSettingData", > "LXC_ConsoleResourceAllocationSettingData", > "LXC_InputResourceAllocationSettingData", > + "LXC_ControllerResourceAllocationSettingData", > NULL > }; No Xen/LXC > > diff --git a/src/Virt_ServiceAffectsElement.c b/src/Virt_ServiceAffectsElement.c > index 9810e02..ff63ab2 100644 > --- a/src/Virt_ServiceAffectsElement.c > +++ b/src/Virt_ServiceAffectsElement.c > @@ -102,7 +102,8 @@ static CMPIStatus validate_cs_or_dev_ref(const CMPIContext *context, > if (STREQC(classname, "ComputerSystem")) { > s = get_domain_by_ref(_BROKER, ref, &inst); > } else if ((STREQC(classname, "PointingDevice")) || > - (STREQC(classname, "DisplayController"))) { > + (STREQC(classname, "DisplayController")) || > + (STREQC(classname, "Controller"))) { > s = get_device_by_ref(_BROKER, ref, &inst); > } > > @@ -146,6 +147,9 @@ static char* affected_ele[] = { > "Xen_DisplayController", > "KVM_DisplayController", > "LXC_DisplayController", > + "Xen_Controller", > + "KVM_Controller", > + "LXC_Controller", No Xen/LXC > NULL > }; > > diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c > index c8cda97..9024fda 100644 > --- a/src/Virt_SettingsDefineState.c > +++ b/src/Virt_SettingsDefineState.c > @@ -329,6 +329,7 @@ static char* logical_device[] = { > "Xen_DisplayController", > "Xen_ConsoleDisplayController", > "Xen_PointingDevice", > + "Xen_Controller", > "KVM_Processor", > "KVM_Memory", > "KVM_NetworkPort", > @@ -336,6 +337,7 @@ static char* logical_device[] = { > "KVM_DisplayController", > "KVM_ConsoleDisplayController", > "KVM_PointingDevice", > + "KVM_Controller", > "LXC_Processor", > "LXC_Memory", > "LXC_NetworkPort", > @@ -343,6 +345,7 @@ static char* logical_device[] = { > "LXC_DisplayController", > "LXC_ConsoleDisplayController", > "LXC_PointingDevice", > + "LXC_Controller", > NULL No Xen/LXC > }; > > @@ -354,6 +357,7 @@ static char* resource_allocation_setting_data[] = { > "Xen_GraphicsResourceAllocationSettingData", > "Xen_InputResourceAllocationSettingData", > "Xen_ConsoleResourceAllocationSettingData", > + "Xen_ControllerResourceAllocationSettingData", > "KVM_DiskResourceAllocationSettingData", > "KVM_MemResourceAllocationSettingData", > "KVM_NetResourceAllocationSettingData", > @@ -361,6 +365,7 @@ static char* resource_allocation_setting_data[] = { > "KVM_GraphicsResourceAllocationSettingData", > "KVM_InputResourceAllocationSettingData", > "KVM_ConsoleResourceAllocationSettingData", > + "KVM_ControllerResourceAllocationSettingData", > "LXC_DiskResourceAllocationSettingData", > "LXC_MemResourceAllocationSettingData", > "LXC_NetResourceAllocationSettingData", > @@ -368,6 +373,7 @@ static char* resource_allocation_setting_data[] = { > "LXC_GraphicsResourceAllocationSettingData", > "LXC_InputResourceAllocationSettingData", > "LXC_ConsoleResourceAllocationSettingData", > + "LXC_ControllerResourceAllocationSettingData", > NULL No Xen/LXC > }; > > diff --git a/src/Virt_SystemDevice.c b/src/Virt_SystemDevice.c > index d2e526d..92dfe19 100644 > --- a/src/Virt_SystemDevice.c > +++ b/src/Virt_SystemDevice.c > @@ -137,6 +137,7 @@ static char* part_component[] = { > "Xen_DisplayController", > "Xen_ConsoleDisplayController", > "Xen_PointingDevice", > + "Xen_Controller", > "KVM_Processor", > "KVM_Memory", > "KVM_NetworkPort", > @@ -144,6 +145,7 @@ static char* part_component[] = { > "KVM_DisplayController", > "KVM_ConsoleDisplayController", > "KVM_PointingDevice", > + "KVM_Controller", > "LXC_Processor", > "LXC_Memory", > "LXC_NetworkPort", > @@ -151,6 +153,7 @@ static char* part_component[] = { > "LXC_DisplayController", > "LXC_ConsoleDisplayController", > "LXC_PointingDevice", > + "LXC_Controller", No Xen/LXC > NULL > }; > > diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c > index 35bffde..1fd1221 100644 > --- a/src/Virt_VSSDComponent.c > +++ b/src/Virt_VSSDComponent.c > @@ -134,6 +134,7 @@ static char* part_component[] = { > "Xen_GraphicsResourceAllocationSettingData", > "Xen_ConsoleResourceAllocationSettingData", > "Xen_InputResourceAllocationSettingData", > + "Xen_ControllerResourceAllocationSettingData", > "KVM_DiskResourceAllocationSettingData", > "KVM_MemResourceAllocationSettingData", > "KVM_NetResourceAllocationSettingData", > @@ -141,6 +142,7 @@ static char* part_component[] = { > "KVM_GraphicsResourceAllocationSettingData", > "KVM_InputResourceAllocationSettingData", > "KVM_ConsoleResourceAllocationSettingData", > + "KVM_ControllerResourceAllocationSettingData", > "LXC_DiskResourceAllocationSettingData", > "LXC_MemResourceAllocationSettingData", > "LXC_NetResourceAllocationSettingData", > @@ -148,6 +150,7 @@ static char* part_component[] = { > "LXC_GraphicsResourceAllocationSettingData", > "LXC_InputResourceAllocationSettingData", > "LXC_ConsoleResourceAllocationSettingData", > + "LXC_ControllerResourceAllocationSettingData", No Xen/LXC > NULL > }; > > From jferlan at redhat.com Thu Mar 27 21:18:29 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:29 -0400 Subject: [Libvirt-cim] [PATCH v3 0/8] Add Controller Device Support Message-ID: <1395955117-2884-1-git-send-email-jferlan@redhat.com> I know this is a long cover letter, but it covers a lot of ground... I was just about done with all the merges this morning - I ran the cimtest one more time and found that there's a couple of tests which associate RASDs and Pools. So I jumped into the rabbit hole and wound my way through the maze of twisty little passages. I even heard a babbling brook (it's an old computer game reference). So here's where I'm at - I have cimtest completely passing again which keeps me happy. Although I have a pile of cimtest related changes that will also need to be made, but I have to wait to do them until I get a libvirt-cim revision number to compare against so as to be able to add conditional code to support controllers devices, rasds, and pools. For now support is only for KVM. We've already determined LXC doesn't have the concept of a controller and I have no way to test Xen. I also don't have the cycles to dig through the Xen source code and determine what that driver supports. If someone wants to add that - great - have at it! I want to put it out there for review - knowing that I probably still have a bit of cleanup left. I think I'm going to need to add KVM specific code to a number of places, but I figured I needed to get everything merged first then I could determine that. I'm also hoping it'll be pointed out to me :-). I kept the changes split even though I know only changes 1 & 2 can be compiled alone and run without any new cimtest failures. Each step of changes can compile successfully/cleanly - although once you hit change 3, you'll need to regenerate your Makefile Changes 1 & 2 are more or less Xu's previous patch #1. I split it for ease of review - there's no real reason, although you will note I have left out the addition of CONTROLLER to the cim_res_types until patch 4... With that patch 2 will have cimtest failures. Change 3 adds the MOF's and adjusts the install resulting in cimtest failures because of "missing" links between MOF and code. Change 4 adds the bulk of the code required to fill in all the fields for the mofs from the xml/data structures. Change 6 adds the various associations between the new elements Change 7 adds the MOF's and modifies install/build to include ControllerPool's Change 8 adds the code and associations for Controller Pools. Without it there are a few cimtest failures. My plan is to allow review of Changes 3->8 separately, but when it comes time to push - 3-8 could be squashed together so that the ability to bisect history and run cimtest without too many failures isn't lost. Although I'm also considering combining 3-6 and 7-8 for "functionality" likeness. I'll take suggestions from the community if it's felt strongly to keep the split as is, then so bit it. The following is a list of the differences between this set of changes and what Xu posted as his v2. All I did was pull down his changes into a clean branch, then 'git am' those changes. Then after making all my changes a simple 'git diff' of the branches let me know what was different. Makefile.am * Copyright date * Add controller pool libvirt-cim.spec.in * Order - kept closer to DisplayController/PointingDevice * Add controller pool libxkutil/device_parsing.c * Copyright date * Additional CU_DEBUG messages - useful in debugging free() issues * Merged sgio/rawio changes * cleanup_controller_device(): * Free new controller fields for queues, ports, vectors, address * Changed controller 'type' from "char *" to "uint16_t", no need to free * parse_controller_device(): * Use controller_protocol_type_StrToID() to store type integer * Fail in "index" is not present * Convert/store "index" as uint64_t and free "index" * Added controller fields for queues, ports, vectors, address * Format id as "controller::" libxkutil/device_parsing.h * Copyright date * Add CONTROLLER_INDEX_NOT_SET as -1 * Change type to uint16_t, add uint64_t index, and char */device_address fields libxkutil/xmlgen.c * Copyright date * Change how we store fields * Be sure to convert the "type" to it's string representation * Handle missing/default Index value (eg from define system from vdev) * Print out model, ports, vectors, queues, and address if present schema/Controller.mof * Remove {Xen|LXC}_Controller schema/Controller.registration * Remove {Xen|LXC}_Controller schema/ControllerPool.mof * Add ControllerPool mof schema/ControllerPool.registration * Add ControllerPool registration schema/ResourceAllocationSettingData.mof * Copyright date * Merged rawio/sgio changes * Remove {Xen|LXC}_ControllerResourceAllocationSettingData * Add comments and properties we care about schema/ResourceAllocationSettingData.registration * Copyright date * Remove {Xen|LXC}_ControllerResourceAllocationSettingData src/Virt_Device.c * Copyright date * Set the Virtual Controller Logical Device properties: * ProtocolSupported <== String from controller_device->type (pci, usb, etc.) * ProtocolDescription <== If available, string from model * Adjusted some debug messages * Removed incorrect setting of "Controller" property (twice) src/Virt_DevicePool.c * Add ControllerPool support src/Virt_ElementAllocatedFromPool.c * Copyright date * Remove Xen/LXC associations * Add ControllerPool src/Virt_ElementCapabilities.c * Copyright date * Add ControllerPool src/Virt_ElementSettingData.c * Copyright date * Remove Xen/LXC associations src/Virt_HostedResourcePool.c * Copyright date * Add ControllerPool src/Virt_RASD.c * Copyright date * Merged sgio/rawio changes * set_controller_rasd_params(): * Set the fields properly based on defintion of structure/mof * ResourceSubType <== String-ified type (pci, usb, etc) * Other fields set if available in data structure * Changed vdev_device -> type to use CIM_RES_TYPE_OTHER - this is the parent structure to the controller_device structure src/Virt_ResourceAllocationFromPool.c * Copyright date * Controller RASD Association * ControllerPool Association src/Virt_ResourcePoolConfigurationService.c * Copyright date * Add ControllerPool src/Virt_ServiceAffectsElement.c * Copyright date * Add "Controller" to list that use get_device_by_ref() call * Remove Xen/LXC associations src/Virt_SettingsDefineState.c * Copyright date * Remove Xen/LXC associations src/Virt_SystemDevice.c * Copyright date * Remove Xen/LXC associations src/Virt_VSSDComponent.c * Copyright date * Remove Xen/LXC associations src/Virt_VirtualSystemManagementService.c * Copyright date * Merged sgio/rawio changes * Fix controller_rasd_to_vdev(): * Handle the controller_device->type properly to get 'type_str' * Build dev->id based on Index: NOTE: I found through debugging cimtest code that on input the dev->id is NULL. It cannot be left that way since a subsequent call to add_device_nodup() would core on the STREQC(ptr->id, dev->id). Thus I formulated an InstanceID with the -1. If there's another similarly "undefined" element, it'll go through the overriding code and be removed. * Set other fields if present in data * Following Boris' earlier advice, mimic the method that disks, networks, and graphics devices use to set things up. * Similarly for resource_del, resource_add, and resource_mod - allow the code to do it's magic for controller devices. * HMM: Given what I discovered about dev->id in controller_rasd_to_vdev() described above, I wonder if the check in resource_add could ever happen. I guess it's "safe" to keep... src/svpc_types.h * Copyright date * Add some pointers to where to find the details we're describing * Add CIM_controller_protocol_type enum to describe the various values * Add controller_protocol_type_StrToID() and controller_protocol_type_IDToStr() to handle the "supported" conversions John Ferlan (3): Associations Add MOFS and change install for ControllerPools Add code and associations for ControllerPool Xu Wang (5): Add virtual controller device types Parse/Store controller XML tags Add virtual controller object definitions to mofs Set fields in mofs for Controller Device/RASD VSMS: Support for domains with controller devices Makefile.am | 6 +- libvirt-cim.spec.in | 4 + libxkutil/device_parsing.c | 119 ++++++++++++++++++- libxkutil/device_parsing.h | 17 ++- libxkutil/xmlgen.c | 74 +++++++++++- schema/Controller.mof | 7 ++ schema/Controller.registration | 4 + schema/ControllerPool.mof | 6 + schema/ControllerPool.registration | 3 + schema/ResourceAllocationSettingData.mof | 37 +++++- schema/ResourceAllocationSettingData.registration | 3 +- src/Virt_Device.c | 68 ++++++++++- src/Virt_DevicePool.c | 55 ++++++++- src/Virt_ElementAllocatedFromPool.c | 6 +- src/Virt_ElementCapabilities.c | 4 +- src/Virt_ElementSettingData.c | 3 +- src/Virt_HostedResourcePool.c | 3 +- src/Virt_RASD.c | 57 +++++++++- src/Virt_ResourceAllocationFromPool.c | 2 + src/Virt_ResourcePoolConfigurationCapabilities.c | 2 +- src/Virt_ResourcePoolConfigurationService.c | 2 + src/Virt_ServiceAffectsElement.c | 8 +- src/Virt_SettingsDefineState.c | 4 +- src/Virt_SystemDevice.c | 3 +- src/Virt_VSSDComponent.c | 3 +- src/Virt_VirtualSystemManagementService.c | 87 +++++++++++++- src/svpc_types.h | 132 +++++++++++++++++++++- 27 files changed, 695 insertions(+), 24 deletions(-) create mode 100644 schema/Controller.mof create mode 100644 schema/Controller.registration create mode 100644 schema/ControllerPool.mof create mode 100644 schema/ControllerPool.registration -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:30 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:30 -0400 Subject: [Libvirt-cim] [PATCH v3 1/8] Add virtual controller device types In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-2-git-send-email-jferlan@redhat.com> From: Xu Wang Add data and strutures for a virtual controller device Signed-off-by: John Ferlan --- libxkutil/device_parsing.h | 17 +++++- src/svpc_types.h | 129 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 144 insertions(+), 2 deletions(-) diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..afddc1d 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -163,6 +163,17 @@ struct input_device { char *bus; }; +#define CONTROLLER_INDEX_NOT_SET -1 +struct controller_device { + uint16_t type; + uint64_t index; + char *model; + char *ports; + char *vectors; + char *queues; + struct device_address address; +}; + struct virt_device { uint16_t type; union { @@ -174,6 +185,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +261,9 @@ struct domain { struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; }; struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d9f8032 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -24,6 +24,9 @@ #define CIM_OPERATIONAL_STATUS 2 +/* From the ResourceType list for CIM_ResourceAllocationSettingData.html + * Found on http://schemas.dmtf.org/wbem/cim-html/2.31.0 + */ #define CIM_RES_TYPE_ALL 0 #define CIM_RES_TYPE_OTHER 1 #define CIM_RES_TYPE_PROC 3 @@ -33,9 +36,11 @@ #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 #define CIM_RES_TYPE_UNKNOWN 1000 +/* libvirt-cim specific values can start here */ #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 +#define CIM_RES_TYPE_CONTROLLER 32771 #define CIM_RES_TYPE_COUNT 7 const static int cim_res_types[CIM_RES_TYPE_COUNT] = @@ -266,4 +271,126 @@ static inline const char* chardev_source_type_IDToStr(int type) return type_str; } +/* enum for Controller ProtocolSupported values + * + * From the ProtocolSupported list for CIM_Controller.html + * Found on http://schemas.dmtf.org/wbem/cim-html/2.31.0 + */ +enum CIM_controller_protocol_type { + CIM_CONTROLLER_PROTOCOL_TYPE_OTHER = 1, + CIM_CONTROLLER_PROTOCOL_TYPE_UNKNOWN = 2, + CIM_CONTROLLER_PROTOCOL_TYPE_EISA = 3, + CIM_CONTROLLER_PROTOCOL_TYPE_ISA = 4, + CIM_CONTROLLER_PROTOCOL_TYPE_PCI = 5, + CIM_CONTROLLER_PROTOCOL_TYPE_ATA = 6, + CIM_CONTROLLER_PROTOCOL_TYPE_FD = 7, + CIM_CONTROLLER_PROTOCOL_TYPE_1496 = 8, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_PI = 9, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_FC = 10, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SB = 11, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SB2 = 12, + CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SSA = 13, + CIM_CONTROLLER_PROTOCOL_TYPE_VESA = 14, + CIM_CONTROLLER_PROTOCOL_TYPE_PCMCIA = 15, + CIM_CONTROLLER_PROTOCOL_TYPE_USB = 16, + CIM_CONTROLLER_PROTOCOL_TYPE_PP = 17, + CIM_CONTROLLER_PROTOCOL_TYPE_ESCON = 18, + CIM_CONTROLLER_PROTOCOL_TYPE_DIAG = 19, + CIM_CONTROLLER_PROTOCOL_TYPE_I2C = 20, + CIM_CONTROLLER_PROTOCOL_TYPE_POWER = 21, + CIM_CONTROLLER_PROTOCOL_TYPE_HIPPI = 22, + CIM_CONTROLLER_PROTOCOL_TYPE_MULTIBUS = 23, + CIM_CONTROLLER_PROTOCOL_TYPE_VME = 24, + CIM_CONTROLLER_PROTOCOL_TYPE_IPI = 25, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE488 = 26, + CIM_CONTROLLER_PROTOCOL_TYPE_RS232 = 27, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_10BASE5 = 28, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_10BASE2 = 29, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_1BASE5 = 30, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_10BROAD36 = 31, + CIM_CONTROLLER_PROTOCOL_TYPE_IEEE8023_100BASEVG = 32, + CIM_CONTROLLER_PROTOCOL_TYPE_TOKENRING = 33, + CIM_CONTROLLER_PROTOCOL_TYPE_ANSIX3T9 = 34, + CIM_CONTROLLER_PROTOCOL_TYPE_MCA = 35, + CIM_CONTROLLER_PROTOCOL_TYPE_ESDI = 36, + CIM_CONTROLLER_PROTOCOL_TYPE_IDE = 37, + CIM_CONTROLLER_PROTOCOL_TYPE_CMD = 38, + CIM_CONTROLLER_PROTOCOL_TYPE_ST506 = 39, + CIM_CONTROLLER_PROTOCOL_TYPE_DSSI = 40, + CIM_CONTROLLER_PROTOCOL_TYPE_QIC2 = 41, + CIM_CONTROLLER_PROTOCOL_TYPE_ENH_ATA = 42, + CIM_CONTROLLER_PROTOCOL_TYPE_AGP = 43, + CIM_CONTROLLER_PROTOCOL_TYPE_TWIRP = 44, + CIM_CONTROLLER_PROTOCOL_TYPE_FIR = 45, + CIM_CONTROLLER_PROTOCOL_TYPE_SIR = 46, + CIM_CONTROLLER_PROTOCOL_TYPE_IRBUS = 47, + CIM_CONTROLLER_PROTOCOL_TYPE_SATA = 48, + /* libvirt specific */ + CIM_CONTROLLER_PROTOCOL_TYPE_CCID = 32678, + CIM_CONTROLLER_PROTOCOL_TYPE_VIRTIO_SERIAL = 32769, +}; + +static inline int controller_protocol_type_StrToID(const char *type_str) +{ + int rc = CIM_CONTROLLER_PROTOCOL_TYPE_UNKNOWN; + + if (type_str == NULL) + return rc; + + if (STREQC(type_str, "ide")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_IDE; + else if (STREQC(type_str, "fdc")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_FD; + else if (STREQC(type_str, "scsi")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SSA; /* REVISIT */ + else if (STREQC(type_str, "sata")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_SATA; + else if (STREQC(type_str, "ccid")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_CCID; + else if (STREQC(type_str, "virtio-serial")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_VIRTIO_SERIAL; + else if (STREQC(type_str, "pci")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_PCI; + else if (STREQC(type_str, "usb")) + rc = CIM_CONTROLLER_PROTOCOL_TYPE_USB; + + return rc; +} + +static inline const char* controller_protocol_type_IDToStr(int type) +{ + char *type_str = NULL; + + switch (type) + { + case CIM_CONTROLLER_PROTOCOL_TYPE_IDE: + type_str = "ide"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_FD: + type_str = "fdc"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_SCSI_SSA: + type_str = "scsi"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_SATA: + type_str = "sata"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_CCID: + type_str = "ccid"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_VIRTIO_SERIAL: + type_str = "virtio-serial"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_PCI: + type_str = "pci"; + break; + case CIM_CONTROLLER_PROTOCOL_TYPE_USB: + type_str = "usb"; + break; + default: + break; + } + return type_str; +} + #endif -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:31 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:31 -0400 Subject: [Libvirt-cim] [PATCH v3 2/8] Parse/Store controller XML tags In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-3-git-send-email-jferlan@redhat.com> From: Xu Wang Parse and store the XML tags. The generated DeviceID will be a combination of "controller" + XML device "name" + XML Index "value". This should be unique enough now and generates "controller:pci:0" or "controller:usb:0" DeviceID's. In the future, if support is added for the "" XML child a new mechanism will need to be put in place since one of those controllers is designed to have the same name and index - what changes is the function for the device. Signed-off-by: John Ferlan --- libxkutil/device_parsing.c | 119 ++++++++++++++++++++++++++++++++++++++++++++- libxkutil/xmlgen.c | 74 +++++++++++++++++++++++++++- 2 files changed, 191 insertions(+), 2 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..f863cc5 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -49,6 +49,7 @@ #define GRAPHICS_XPATH (xmlChar *)"/domain/devices/graphics | "\ "/domain/devices/console" #define INPUT_XPATH (xmlChar *)"/domain/devices/input" +#define CONTROLLER_XPATH (xmlChar *)"/domain/devices/controller" #define DEFAULT_BRIDGE "xenbr0" #define DEFAULT_NETWORK "default" @@ -69,6 +70,7 @@ static void cleanup_device_address(struct device_address *addr) if (addr == NULL) return; + CU_DEBUG("Cleanup %d addresses", addr->ct); for (i = 0; i < addr->ct; i++) { free(addr->key[i]); free(addr->value[i]); @@ -84,6 +86,7 @@ static void cleanup_disk_device(struct disk_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean Disk type %s", dev->type); free(dev->type); free(dev->device); free(dev->driver); @@ -103,6 +106,7 @@ static void cleanup_vsi_device(struct vsi_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean VSI type %s", dev->vsi_type); free(dev->vsi_type); free(dev->manager_id); free(dev->type_id); @@ -117,6 +121,7 @@ static void cleanup_net_device(struct net_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean net type %s", dev->type); free(dev->type); free(dev->mac); free(dev->source); @@ -134,6 +139,7 @@ static void cleanup_emu_device(struct emu_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean emu %s", dev->path); free(dev->path); } @@ -157,6 +163,7 @@ static void cleanup_graphics_device(struct graphics_device *dev) if (dev == NULL || dev->type == NULL) return; + CU_DEBUG("Clean graphics type %s", dev->type); if (STREQC(dev->type, "sdl")) cleanup_sdl_device(dev); else @@ -170,6 +177,7 @@ static void cleanup_path_device(struct path_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean path device %s", dev->path); free(dev->path); } @@ -179,6 +187,7 @@ static void cleanup_unixsock_device(struct unixsock_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean unixsock device"); free(dev->path); free(dev->mode); @@ -189,6 +198,7 @@ static void cleanup_tcp_device(struct tcp_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean tcp device"); free(dev->mode); free(dev->protocol); free(dev->host); @@ -201,6 +211,7 @@ static void cleanup_udp_device(struct udp_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean udb bind device"); free(dev->bind_host); free(dev->bind_service); free(dev->connect_host); @@ -212,6 +223,7 @@ static void cleanup_console_device(struct console_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean console source_type %d", dev->source_type); switch (dev->source_type) { case CIM_CHARDEV_SOURCE_TYPE_PTY: @@ -304,10 +316,24 @@ static void cleanup_input_device(struct input_device *dev) if (dev == NULL) return; + CU_DEBUG("Clean input device %s", dev->type); free(dev->type); free(dev->bus); } +static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + CU_DEBUG("Clean controller device %d", dev->type); + free(dev->model); + free(dev->queues); + free(dev->ports); + free(dev->vectors); + cleanup_device_address(&dev->address); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +351,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller); free(dev->id); @@ -339,6 +367,7 @@ void cleanup_virt_devices(struct virt_device **_devs, int count) for (i = 0; i < count; i++) cleanup_virt_device(&devs[i]); + CU_DEBUG("All devices cleaned"); free(devs); *_devs = NULL; } @@ -1107,6 +1136,75 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } +static int parse_controller_device(xmlNode *cnode, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + char *type_str = NULL; + xmlNode *child = NULL; + char *index = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + type_str = get_attr_value(cnode, "type"); + if (type_str == NULL) { + CU_DEBUG("No type"); + goto err; + } + CU_DEBUG("controller device type = %s", type_str); + cdev->type = controller_protocol_type_StrToID(type_str); + if (cdev->type == CIM_CONTROLLER_PROTOCOL_TYPE_UNKNOWN) { + CU_DEBUG("Unknown controller protocol type (%d)", cdev->type); + goto err; + } + + index = get_attr_value(cnode, "index"); + if (index != NULL) { + sscanf(index, "%" PRIu64, &cdev->index); + free(index); + } else { + CU_DEBUG("No index"); + goto err; + } + + cdev->model = get_attr_value(cnode, "model"); + cdev->ports = get_attr_value(cnode, "ports"); + cdev->vectors = get_attr_value(cnode, "vectors"); + + for (child = cnode->children; child != NULL; child = child->next) { + if (XSTREQ(child->name, "address")) { + parse_device_address(child, &cdev->address); + } else if (XSTREQ(child->name, "driver")) { + cdev->queues = get_attr_value(child, "queues"); + } + } + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "controller:%s:%" PRIu64, + type_str, cdev->index); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + CU_DEBUG("Controller id is %s", vdev->id); + free(type_str); + + *vdevs = vdev; + + return 1; + err: + free(type_str); + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1328,11 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break; + case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + break; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1454,17 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + dev->dev.controller.type = _dev->dev.controller.type; + dev->dev.controller.index = _dev->dev.controller.index; + DUP_FIELD(dev, _dev, dev.controller.model); + DUP_FIELD(dev, _dev, dev.controller.ports); + DUP_FIELD(dev, _dev, dev.controller.vectors); + DUP_FIELD(dev, _dev, dev.controller.queues); + duplicate_device_address(&dev->dev.controller.address, + &_dev->dev.controller.address); } + return dev; } @@ -1731,6 +1844,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER); return ret; @@ -1819,6 +1935,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); free(dom); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..3174ca9 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -798,6 +798,72 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; } +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + const char *msg = NULL; + + CU_DEBUG("Found %d controllers", dominfo->dev_controller_ct); + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr ctlr; + xmlNodePtr tmp; + char *type_str; + + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *cdev = &_dev->dev.controller; + + ctlr = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (ctlr == NULL) + return XML_ERROR; + + + type_str = controller_protocol_type_IDToStr(cdev->type); + if (type_str == NULL) + return XML_ERROR; + + CU_DEBUG("Type=%s Index=%" PRIu64, type_str, cdev->index); + xmlNewProp(ctlr, BAD_CAST "type", + BAD_CAST type_str); + + /* If index is missing, let libvirt generate it */ + if (cdev->index != CONTROLLER_INDEX_NOT_SET) { + char *index; + if (asprintf(&index, "%" PRIu64, cdev->index) == -1) + return XML_ERROR; + xmlNewProp(ctlr, BAD_CAST "index", BAD_CAST index); + free(index); + } + + /* Optional */ + if (cdev->model) + xmlNewProp(ctlr, BAD_CAST "model", + BAD_CAST cdev->model); + if (cdev->ports) + xmlNewProp(ctlr, BAD_CAST "ports", + BAD_CAST cdev->ports); + if (cdev->vectors) + xmlNewProp(ctlr, BAD_CAST "vectors", + BAD_CAST cdev->vectors); + if (cdev->queues) { + tmp = xmlNewChild(ctlr, NULL, BAD_CAST "driver", NULL); + xmlNewProp(tmp, BAD_CAST "queueus", + BAD_CAST cdev->queues); + } + if (cdev->address.ct > 0) { + msg = device_address_xml(ctlr, &cdev->address); + if (msg != NULL) { + CU_DEBUG("Failed to set the address"); + return msg; + } + } + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1129,6 +1195,11 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; + break; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1167,6 +1238,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL }; -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:32 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:32 -0400 Subject: [Libvirt-cim] [PATCH v3 3/8] Add virtual controller object definitions to mofs In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-4-git-send-email-jferlan@redhat.com> From: Xu Wang Add the mofs and registration to support the Controller Logical Device and RASD. The Contoller Logical Device will be a child of the CIM_Controller class and the Controller RASD will be a child of the CIM_RASD. Install the mofs and definitions, but don't yet link things up Signed-off-by: John Ferlan --- Makefile.am | 4 ++- libvirt-cim.spec.in | 2 ++ schema/Controller.mof | 7 +++++ schema/Controller.registration | 4 +++ schema/ResourceAllocationSettingData.mof | 37 ++++++++++++++++++++++- schema/ResourceAllocationSettingData.registration | 3 +- 6 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 schema/Controller.mof create mode 100644 schema/Controller.registration diff --git a/Makefile.am b/Makefile.am index 69b65cf..24b11af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -# Copyright IBM Corp. 2007 +# Copyright IBM Corp. 2007-2014 AUTOMAKE_OPTIONS=dist-bzip2 SUBDIRS = libxkutil src doc base_schema @@ -52,6 +52,7 @@ MOFS = \ $(top_srcdir)/schema/ServiceAffectsElement.mof \ $(top_srcdir)/schema/KVMRedirectionSAP.mof \ $(top_srcdir)/schema/DisplayController.mof \ + $(top_srcdir)/schema/Controller.mof \ $(top_srcdir)/schema/PointingDevice.mof \ $(top_srcdir)/schema/GraphicsPool.mof \ $(top_srcdir)/schema/InputPool.mof \ @@ -142,6 +143,7 @@ REGS = \ $(top_srcdir)/schema/ServiceAffectsElement.registration \ $(top_srcdir)/schema/KVMRedirectionSAP.registration \ $(top_srcdir)/schema/DisplayController.registration \ + $(top_srcdir)/schema/Controller.registration \ $(top_srcdir)/schema/PointingDevice.registration \ $(top_srcdir)/schema/GraphicsPool.registration \ $(top_srcdir)/schema/InputPool.registration \ diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index 01ee329..f4e4fcf 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -110,6 +110,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/ServiceAffectsElement.registration \\\ %{_datadir}/%{name}/KVMRedirectionSAP.registration \\\ %{_datadir}/%{name}/DisplayController.registration \\\ + %{_datadir}/%{name}/Controller.registration \\\ %{_datadir}/%{name}/PointingDevice.registration \\\ %{_datadir}/%{name}/GraphicsPool.registration \\\ %{_datadir}/%{name}/InputPool.registration \\\ @@ -171,6 +172,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/ServiceAffectsElement.mof \\\ %{_datadir}/%{name}/KVMRedirectionSAP.mof \\\ %{_datadir}/%{name}/DisplayController.mof \\\ + %{_datadir}/%{name}/Controller.mof \\\ %{_datadir}/%{name}/PointingDevice.mof \\\ %{_datadir}/%{name}/GraphicsPool.mof \\\ %{_datadir}/%{name}/InputPool.mof \\\ diff --git a/schema/Controller.mof b/schema/Controller.mof new file mode 100644 index 0000000..0805aa9 --- /dev/null +++ b/schema/Controller.mof @@ -0,0 +1,7 @@ +// Copyright IBM Corp. 2014 + +[ Provider("cmpi::Virt_Device") +] +class KVM_Controller : CIM_Controller +{ +}; diff --git a/schema/Controller.registration b/schema/Controller.registration new file mode 100644 index 0000000..5f59a20 --- /dev/null +++ b/schema/Controller.registration @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2014 + +# Classname Namespace ProviderName ProviderModule ProviderTypes +KVM_Controller root/virt Virt_Device Virt_Device instance diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..9c387f0 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2007, 2013 +// Copyright IBM Corp. 2007-2014 [Description ("Xen virtual disk configuration"), Provider("cmpi::Virt_RASD") @@ -328,6 +328,41 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; }; +[Description ("KVM virtual controller device. It is identified by: " + "CIM_ResourceAllocationSettingData.ResourceType=1 ('Other'), " + "CIM_ResourceAllocationSettingData.OtherResourceType='controller'" + " and CIM_ResourceAllocationSettingData.ResourceSubType set to " + "one of 'ide', 'fdc', 'scsi', 'sata', 'ccid', 'virtio-serial', " + "or 'pci'."), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + [Description ("Order in which the bus controller is encountered. " + "The order is controller type scoped.")] + uint64 Index; + + [Description ("Optional string providing a specific model " + "information based on the controller type.")] + string Model; + + [Description ("The 'virtio-serial' controller uses the Ports and " + "Vectors to control how many devices can be connected " + "through the controller.")] + string Ports; + string Vectors; + + [Description ("Number of queues for the controller.")] + string Queues; + + [Description ("For controllers that are themselves devices on a " + "bus an optional element to specify the exact " + "relationship of the controller to its master bus. " + "Stored in the property and value arrays.")] + string AddressProperties[]; + string AddressValues[]; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..74df857 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -1,4 +1,4 @@ -# Copyright IBM Corp. 2007, 2013 +# Copyright IBM Corp. 2007-2014 # Classname Namespace ProviderName ProviderModule ProviderTypes Xen_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -14,6 +14,7 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:33 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:33 -0400 Subject: [Libvirt-cim] [PATCH v3 4/8] Set fields in mofs for Controller Device/RASD In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-5-git-send-email-jferlan@redhat.com> From: Xu Wang Set basic fields for the KVM_Controller instance based on the read XML from the virtual controller device structure. Set the various KVM_ControllerRASD fields based on the read XML from the virtual controller device structure Signed-off-by: John Ferlan --- src/Virt_Device.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/Virt_RASD.c | 57 +++++++++++++++++++++++++++++++++++++++++++++- src/svpc_types.h | 3 ++- 3 files changed, 124 insertions(+), 4 deletions(-) diff --git a/src/Virt_Device.c b/src/Virt_Device.c index 12ae6bd..60465b7 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -366,6 +366,61 @@ static CMPIInstance *input_instance(const CMPIBroker *broker, return inst; } +static int controller_set_attr(const CMPIBroker *broker, + CMPIInstance *instance, + struct controller_device *dev) +{ + const char *type_str; + + type_str = controller_protocol_type_IDToStr(dev->type); + if (type_str == NULL) { + CU_DEBUG("controller type=%d fails to return string", dev->type); + return 0; + } + + CMSetProperty(instance, "ProtocolSupported", + (CMPIValue *)&dev->type, + CMPI_uint16); + + if (dev->model) + CMSetProperty(instance, "ProtocolDescription", + (CMPIValue *)dev->model, + CMPI_chars); + + return 1; +} + +static CMPIInstance *controller_instance(const CMPIBroker *broker, + struct controller_device *dev, + const virDomainPtr dom, + const char *ns) +{ + CMPIInstance *inst; + virConnectPtr conn; + + CU_DEBUG("controller_instance"); + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "Controller", + ns, + true); + if (inst == NULL) { + CU_DEBUG("Failed to get instance of %s_Controller", + pfx_from_conn(conn)); + return NULL; + } + + + if (!controller_set_attr(broker, inst, dev)) { + CU_DEBUG("Failed to set contoller attributes of %s_Controller", + pfx_from_conn(conn)); + return NULL; + } + + return inst; +} static int device_set_devid(CMPIInstance *instance, struct virt_device *dev, const virDomainPtr dom) @@ -488,6 +543,8 @@ static bool device_instances(const CMPIBroker *broker, for (i = 0; i < count; i++) { struct virt_device *dev = &devs[i]; + CU_DEBUG("device_instance dev->type=%d", dev->type); + if (dev->type == CIM_RES_TYPE_NET) instance = net_instance(broker, &dev->dev.net, @@ -516,11 +573,16 @@ static bool device_instances(const CMPIBroker *broker, &dev->dev.console, dom, ns); - else if (dev->type == CIM_RES_TYPE_INPUT) + else if (dev->type == CIM_RES_TYPE_INPUT) instance = input_instance(broker, &dev->dev.input, dom, ns); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + instance = controller_instance(broker, + &dev->dev.controller, + dom, + ns); else return false; @@ -555,6 +617,8 @@ uint16_t res_type_from_device_classname(const char *classname) return CIM_RES_TYPE_GRAPHICS; else if (strstr(classname, "PointingDevice")) return CIM_RES_TYPE_INPUT; + else if (strstr(classname, "Controller")) + return CIM_RES_TYPE_CONTROLLER; else return CIM_RES_TYPE_UNKNOWN; } diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index abfb09f..3c62c2d 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -915,6 +915,51 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; } +static CMPIStatus set_controller_rasd_params(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const struct virt_device *dev, + CMPIInstance *inst) +{ + const char *type_str; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + type_str = controller_protocol_type_IDToStr(dev->dev.controller.type); + if (type_str == NULL) { + CU_DEBUG("controller type=%d fails to return string", + dev->type); + return s; + } + CMSetProperty(inst, "OtherResourceType", "controller", CMPI_chars); + CMSetProperty(inst, "ResourceSubType", + (CMPIValue *)type_str, CMPI_chars); + CMSetProperty(inst, "Index", + (CMPIValue *)&(dev->dev.controller.index), CMPI_uint64); + + if (dev->dev.controller.model) + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + if (dev->dev.controller.ports) + CMSetProperty(inst, "Ports", + (CMPIValue *)dev->dev.controller.ports, CMPI_chars); + + if (dev->dev.controller.vectors) + CMSetProperty(inst, "Vectors", + (CMPIValue *)dev->dev.controller.vectors, CMPI_chars); + + if (dev->dev.controller.queues) + CMSetProperty(inst, "Queues", + (CMPIValue *)dev->dev.controller.queues, CMPI_chars); + + if (dev->dev.controller.address.ct > 0) + set_rasd_device_address(broker, + ref, + &dev->dev.controller.address, + inst); + + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -949,6 +994,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_OTHER; + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -1004,6 +1052,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(broker, ref, dev, inst); } /* FIXME: Put the HostResource in place */ @@ -1138,6 +1188,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out; @@ -1175,6 +1227,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; } diff --git a/src/svpc_types.h b/src/svpc_types.h index d9f8032..6270233 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -42,7 +42,7 @@ #define CIM_RES_TYPE_EMU 32770 #define CIM_RES_TYPE_CONTROLLER 32771 -#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -51,6 +51,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:34 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:34 -0400 Subject: [Libvirt-cim] [PATCH v3 5/8] VSMS: Support for domains with controller devices In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-6-git-send-email-jferlan@redhat.com> From: Xu Wang Signed-off-by: Xu Wang Signed-off-by: John Ferlan --- src/Virt_VirtualSystemManagementService.c | 87 ++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index e146470..f673c38 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -1848,6 +1848,56 @@ 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 *type_str = NULL; + const char *val = NULL; + const char *msg = NULL; + int ret; + + if (cu_get_str_prop(inst, "ResourceSubType", &type_str) != CMPI_RC_OK) { + msg = "ControllerRASD ResourceSubType field not valid"; + CU_DEBUG("%s", msg); + goto out; + } + dev->dev.controller.type = controller_protocol_type_StrToID(type_str); + + /* Required fields */ + if (cu_get_u64_prop(inst, "Index", + &dev->dev.controller.index) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Index field not set - DEFAULT"); + dev->dev.controller.index = CONTROLLER_INDEX_NOT_SET; + ret = asprintf(&dev->id, "controller:%s:-1", type_str); + } else { + /* Formulate our instance id from controller, controller type, + * and index value. This should be unique enough. + */ + ret = asprintf(&dev->id, "controller:%s:%" PRIu64, + type_str, dev->dev.controller.index); + } + if (ret == -1) { + msg = "Failed to create controller string"; + CU_DEBUG("%s", msg); + 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, @@ -1868,6 +1918,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"; @@ -1888,6 +1940,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"; @@ -1997,6 +2051,10 @@ 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; @@ -2111,7 +2169,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 ccount = 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, + ccount, + &domain->dev_controller_ct); } + if (msg != NULL) return msg; @@ -2918,6 +2992,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; @@ -3119,6 +3196,14 @@ static CMPIStatus resource_add(struct domain *dominfo, goto out; } + if (type == CIM_RES_TYPE_CONTROLLER && + dev != NULL && dev->id == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Add resource failed: Index property is required."); + goto out; + } + if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || (type == CIM_RES_TYPE_CONSOLE)) { -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:35 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:35 -0400 Subject: [Libvirt-cim] [PATCH v3 6/8] Associations In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-7-git-send-email-jferlan@redhat.com> Signed-off-by: John Ferlan --- src/Virt_ElementAllocatedFromPool.c | 4 +++- src/Virt_ElementSettingData.c | 3 ++- src/Virt_ServiceAffectsElement.c | 8 +++++--- src/Virt_SettingsDefineState.c | 4 +++- src/Virt_SystemDevice.c | 3 ++- src/Virt_VSSDComponent.c | 3 ++- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c index 2c2f2d1..262c9b9 100644 --- a/src/Virt_ElementAllocatedFromPool.c +++ b/src/Virt_ElementAllocatedFromPool.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -275,6 +275,7 @@ static char* device[] = { "KVM_LogicalDisk", "KVM_DisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", @@ -297,6 +298,7 @@ static char* device_or_pool[] = { "KVM_LogicalDisk", "KVM_DisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", diff --git a/src/Virt_ElementSettingData.c b/src/Virt_ElementSettingData.c index c088e49..5845c86 100644 --- a/src/Virt_ElementSettingData.c +++ b/src/Virt_ElementSettingData.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Kaitlin Rupert @@ -137,6 +137,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", diff --git a/src/Virt_ServiceAffectsElement.c b/src/Virt_ServiceAffectsElement.c index 9810e02..d64a877 100644 --- a/src/Virt_ServiceAffectsElement.c +++ b/src/Virt_ServiceAffectsElement.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2008 + * Copyright IBM Corp. 2008-2014 * * Authors: * Kaitlin Rupert @@ -101,9 +101,10 @@ static CMPIStatus validate_cs_or_dev_ref(const CMPIContext *context, if (STREQC(classname, "ComputerSystem")) { s = get_domain_by_ref(_BROKER, ref, &inst); - } else if ((STREQC(classname, "PointingDevice")) || + } else if ((STREQC(classname, "PointingDevice")) || + (STREQC(classname, "Controller")) || (STREQC(classname, "DisplayController"))) { - s = get_device_by_ref(_BROKER, ref, &inst); + s = get_device_by_ref(_BROKER, ref, &inst); } free(classname); @@ -146,6 +147,7 @@ static char* affected_ele[] = { "Xen_DisplayController", "KVM_DisplayController", "LXC_DisplayController", + "KVM_Controller", NULL }; diff --git a/src/Virt_SettingsDefineState.c b/src/Virt_SettingsDefineState.c index c8cda97..6338d7c 100644 --- a/src/Virt_SettingsDefineState.c +++ b/src/Virt_SettingsDefineState.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -336,6 +336,7 @@ static char* logical_device[] = { "KVM_DisplayController", "KVM_ConsoleDisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", @@ -361,6 +362,7 @@ static char* resource_allocation_setting_data[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", diff --git a/src/Virt_SystemDevice.c b/src/Virt_SystemDevice.c index d2e526d..ae13ecb 100644 --- a/src/Virt_SystemDevice.c +++ b/src/Virt_SystemDevice.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -144,6 +144,7 @@ static char* part_component[] = { "KVM_DisplayController", "KVM_ConsoleDisplayController", "KVM_PointingDevice", + "KVM_Controller", "LXC_Processor", "LXC_Memory", "LXC_NetworkPort", diff --git a/src/Virt_VSSDComponent.c b/src/Virt_VSSDComponent.c index 35bffde..fc223c2 100644 --- a/src/Virt_VSSDComponent.c +++ b/src/Virt_VSSDComponent.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -141,6 +141,7 @@ static char* part_component[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:36 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:36 -0400 Subject: [Libvirt-cim] [PATCH v3 7/8] Add MOFS and change install for ControllerPools In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-8-git-send-email-jferlan@redhat.com> Add the new MOF and modify the build/install to handle. Signed-off-by: John Ferlan --- Makefile.am | 2 ++ libvirt-cim.spec.in | 2 ++ schema/ControllerPool.mof | 6 ++++++ schema/ControllerPool.registration | 3 +++ 4 files changed, 13 insertions(+) create mode 100644 schema/ControllerPool.mof create mode 100644 schema/ControllerPool.registration diff --git a/Makefile.am b/Makefile.am index 24b11af..e332b5a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,6 +56,7 @@ MOFS = \ $(top_srcdir)/schema/PointingDevice.mof \ $(top_srcdir)/schema/GraphicsPool.mof \ $(top_srcdir)/schema/InputPool.mof \ + $(top_srcdir)/schema/ControllerPool.mof \ $(top_srcdir)/schema/HostedAccessPoint.mof \ $(top_srcdir)/schema/ServiceAccessBySAP.mof \ $(top_srcdir)/schema/SAPAvailableForElement.mof \ @@ -147,6 +148,7 @@ REGS = \ $(top_srcdir)/schema/PointingDevice.registration \ $(top_srcdir)/schema/GraphicsPool.registration \ $(top_srcdir)/schema/InputPool.registration \ + $(top_srcdir)/schema/ControllerPool.registration \ $(top_srcdir)/schema/HostedAccessPoint.registration \ $(top_srcdir)/schema/ServiceAccessBySAP.registration \ $(top_srcdir)/schema/SAPAvailableForElement.registration \ diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in index f4e4fcf..d876b81 100644 --- a/libvirt-cim.spec.in +++ b/libvirt-cim.spec.in @@ -114,6 +114,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/PointingDevice.registration \\\ %{_datadir}/%{name}/GraphicsPool.registration \\\ %{_datadir}/%{name}/InputPool.registration \\\ + %{_datadir}/%{name}/ControllerPool.registration \\\ %{_datadir}/%{name}/HostedAccessPoint.registration \\\ %{_datadir}/%{name}/ServiceAccessBySAP.registration \\\ %{_datadir}/%{name}/SAPAvailableForElement.registration \\\ @@ -176,6 +177,7 @@ rm -fr $RPM_BUILD_ROOT %{_datadir}/%{name}/PointingDevice.mof \\\ %{_datadir}/%{name}/GraphicsPool.mof \\\ %{_datadir}/%{name}/InputPool.mof \\\ + %{_datadir}/%{name}/ControllerPool.mof \\\ %{_datadir}/%{name}/HostedAccessPoint.mof \\\ %{_datadir}/%{name}/ServiceAccessBySAP.mof \\\ %{_datadir}/%{name}/SAPAvailableForElement.mof \\\ diff --git a/schema/ControllerPool.mof b/schema/ControllerPool.mof new file mode 100644 index 0000000..6dbb8a8 --- /dev/null +++ b/schema/ControllerPool.mof @@ -0,0 +1,6 @@ +// Copyright Red Hat Corp. 2014 + +[Provider("cmpi::Virt_DevicePool")] +class KVM_ControllerPool : CIM_ResourcePool +{ +}; diff --git a/schema/ControllerPool.registration b/schema/ControllerPool.registration new file mode 100644 index 0000000..0785f83 --- /dev/null +++ b/schema/ControllerPool.registration @@ -0,0 +1,3 @@ +# Copyright Red Hat Corp. 2014 +# Classname Namespace ProviderName ProviderModule ProviderTypes +KVM_ControllerPool root/virt Virt_DevicePool Virt_DevicePool instance -- 1.8.5.3 From jferlan at redhat.com Thu Mar 27 21:18:37 2014 From: jferlan at redhat.com (John Ferlan) Date: Thu, 27 Mar 2014 17:18:37 -0400 Subject: [Libvirt-cim] [PATCH v3 8/8] Add code and associations for ControllerPool In-Reply-To: <1395955117-2884-1-git-send-email-jferlan@redhat.com> References: <1395955117-2884-1-git-send-email-jferlan@redhat.com> Message-ID: <1395955117-2884-9-git-send-email-jferlan@redhat.com> Add the code and make adjustments to have ControllerPool support Signed-off-by: John Ferlan --- src/Virt_DevicePool.c | 55 +++++++++++++++++++++++- src/Virt_ElementAllocatedFromPool.c | 2 + src/Virt_ElementCapabilities.c | 4 +- src/Virt_HostedResourcePool.c | 3 +- src/Virt_ResourceAllocationFromPool.c | 2 + src/Virt_ResourcePoolConfigurationCapabilities.c | 2 +- src/Virt_ResourcePoolConfigurationService.c | 2 + 7 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/Virt_DevicePool.c b/src/Virt_DevicePool.c index aae7ed4..6c61b64 100644 --- a/src/Virt_DevicePool.c +++ b/src/Virt_DevicePool.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -797,6 +797,8 @@ char *pool_member_of(const CMPIBroker *broker, poolid = strdup("GraphicsPool/0"); else if (type == CIM_RES_TYPE_INPUT) poolid = strdup("InputPool/0"); + else if (type == CIM_RES_TYPE_CONTROLLER) + poolid = strdup("ControllerPool/0"); else return NULL; @@ -817,6 +819,8 @@ uint16_t res_type_from_pool_classname(const char *classname) return CIM_RES_TYPE_GRAPHICS; else if (strstr(classname, "InputPool")) return CIM_RES_TYPE_INPUT; + else if (strstr(classname, "ControllerPool")) + return CIM_RES_TYPE_CONTROLLER; else return CIM_RES_TYPE_UNKNOWN; } @@ -835,6 +839,8 @@ uint16_t res_type_from_pool_id(const char *id) return CIM_RES_TYPE_GRAPHICS; else if (strstr(id, "InputPool")) return CIM_RES_TYPE_INPUT; + else if (strstr(id, "ControllerPool")) + return CIM_RES_TYPE_CONTROLLER; else return CIM_RES_TYPE_UNKNOWN; } @@ -1502,6 +1508,43 @@ static CMPIStatus inputpool_instance(virConnectPtr conn, return s; } +static CMPIStatus controllerpool_instance(virConnectPtr conn, + struct inst_list *list, + const char *ns, + const char *_id, + const CMPIBroker *broker) +{ + const char *id = "ControllerPool/0"; + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + if ((_id != NULL) && (!STREQC(_id, "0"))) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "No such controller pool `%s'", id); + return s; + } + + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "ControllerPool", + ns, + false); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to get instance of %s_ControllerPool", + pfx_from_conn(conn)); + return s; + } + + set_params(inst, CIM_RES_TYPE_CONTROLLER, id, NULL, NULL, true); + + inst_list_add(list, inst); + + return s; +} + static CMPIStatus _get_pools(const CMPIBroker *broker, const CMPIObjectPath *reference, const uint16_t type, @@ -1563,6 +1606,14 @@ static CMPIStatus _get_pools(const CMPIBroker *broker, id, broker); + if ((type == CIM_RES_TYPE_CONTROLLER) || + (type == CIM_RES_TYPE_ALL)) + s = controllerpool_instance(conn, + list, + NAMESPACE(reference), + id, + broker); + if (type == CIM_RES_TYPE_UNKNOWN) cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, @@ -1712,6 +1763,8 @@ CMPIInstance *parent_device_pool(const CMPIBroker *broker, id = "GraphicsPool/0"; } else if (type == CIM_RES_TYPE_INPUT) { id = "InputPool/0"; + } else if (type == CIM_RES_TYPE_CONTROLLER) { + id = "ControllerPool/0"; } else { cu_statusf(broker, s, CMPI_RC_ERR_INVALID_PARAMETER, diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c index 262c9b9..a5fef12 100644 --- a/src/Virt_ElementAllocatedFromPool.c +++ b/src/Virt_ElementAllocatedFromPool.c @@ -253,6 +253,7 @@ static char* pool[] = { "KVM_DiskPool", "KVM_GraphicsPool", "KVM_InputPool", + "KVM_ControllerPool", "LXC_ProcessorPool", "LXC_MemoryPool", "LXC_NetworkPool", @@ -317,6 +318,7 @@ static char* device_or_pool[] = { "KVM_DiskPool", "KVM_GraphicsPool", "KVM_InputPool", + "KVM_ControllerPool", "LXC_ProcessorPool", "LXC_MemoryPool", "LXC_NetworkPool", diff --git a/src/Virt_ElementCapabilities.c b/src/Virt_ElementCapabilities.c index 77aad9a..0cb3e1e 100644 --- a/src/Virt_ElementCapabilities.c +++ b/src/Virt_ElementCapabilities.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -416,6 +416,7 @@ static char* host_sys_and_service_and_rp[] = { "KVM_DiskPool", "KVM_GraphicsPool", "KVM_InputPool", + "KVM_ControllerPool", "LXC_ProcessorPool", "LXC_MemoryPool", "LXC_NetworkPool", @@ -553,6 +554,7 @@ static char* resource_pool[] = { "KVM_DiskPool", "KVM_GraphicsPool", "KVM_InputPool", + "KVM_ControllerPool", "LXC_ProcessorPool", "LXC_MemoryPool", "LXC_NetworkPool", diff --git a/src/Virt_HostedResourcePool.c b/src/Virt_HostedResourcePool.c index 0863853..e0459c5 100644 --- a/src/Virt_HostedResourcePool.c +++ b/src/Virt_HostedResourcePool.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith @@ -113,6 +113,7 @@ static char* part_component[] = { "KVM_DiskPool", "KVM_GraphicsPool", "KVM_InputPool", + "KVM_ControllerPool", "LXC_ProcessorPool", "LXC_MemoryPool", "LXC_NetworkPool", diff --git a/src/Virt_ResourceAllocationFromPool.c b/src/Virt_ResourceAllocationFromPool.c index 7bee729..98bd24e 100644 --- a/src/Virt_ResourceAllocationFromPool.c +++ b/src/Virt_ResourceAllocationFromPool.c @@ -194,6 +194,7 @@ static char* antecedent[] = { "KVM_DiskPool", "KVM_GraphicsPool", "KVM_InputPool", + "KVM_ControllerPool", "LXC_ProcessorPool", "LXC_MemoryPool", "LXC_NetworkPool", @@ -216,6 +217,7 @@ static char* dependent[] = { "KVM_ProcResourceAllocationSettingData", "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData", diff --git a/src/Virt_ResourcePoolConfigurationCapabilities.c b/src/Virt_ResourcePoolConfigurationCapabilities.c index 63045bf..28a5de2 100644 --- a/src/Virt_ResourcePoolConfigurationCapabilities.c +++ b/src/Virt_ResourcePoolConfigurationCapabilities.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007 + * Copyright IBM Corp. 2007-2014 * * Authors: * Dan Smith diff --git a/src/Virt_ResourcePoolConfigurationService.c b/src/Virt_ResourcePoolConfigurationService.c index 02de834..ab83beb 100644 --- a/src/Virt_ResourcePoolConfigurationService.c +++ b/src/Virt_ResourcePoolConfigurationService.c @@ -431,6 +431,8 @@ static char *get_pool_id(int res_type, pool = "GraphicsPool"; else if (res_type == CIM_RES_TYPE_INPUT) pool = "InputPool"; + else if (res_type == CIM_RES_TYPE_CONTROLLER) + pool = "ControllerPool"; else pool = "Unknown"; -- 1.8.5.3