[PATCH v3 0/8] Add Controller Device Support

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:<type_str>:<index#>" 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: Xu Wang <gesaint@linux.vnet.ibm.com> Add data and strutures for a virtual controller device Signed-off-by: John Ferlan <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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: Xu Wang <gesaint@linux.vnet.ibm.com> Parse and store the <controller> 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 "<master>" 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 <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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: Xu Wang <gesaint@linux.vnet.ibm.com> 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 <jferlan@redhat.com> --- 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: Xu Wang <gesaint@linux.vnet.ibm.com> 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 <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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

于 2014年03月28日 05:18, John Ferlan 写道:
From: Xu Wang <gesaint@linux.vnet.ibm.com>
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 <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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; I noticed that only type of controller and console device are set into CIM_RES_TYPE_OTHER. And I found only two places in this function use that macro. Why not type is CIM_RES_TYPE_CONTROLLER/CONSOLE?
Thanks, Xu Wang
+ 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

On 04/14/2014 04:19 AM, Xu Wang wrote:
于 2014年03月28日 05:18, John Ferlan 写道:
From: Xu Wang <gesaint@linux.vnet.ibm.com>
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 <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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; I noticed that only type of controller and console device are set into CIM_RES_TYPE_OTHER. And I found only two places in this function use that macro. Why not type is CIM_RES_TYPE_CONTROLLER/CONSOLE?
Thanks, Xu Wang
I'm following the advice of Boris on this one... Essentially, by defining it to OTHER, the use of the OtherResourceType and ResourceSubType fields come into play. Go back to the original code review and see/read the following: http://www.redhat.com/archives/libvirt-cim/2014-March/msg00012.html then http://www.redhat.com/archives/libvirt-cim/2014-March/msg00018.html
+ 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
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

From: Xu Wang <gesaint@linux.vnet.ibm.com> Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> Signed-off-by: John Ferlan <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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

Signed-off-by: John Ferlan <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <karupert@us.ibm.com> @@ -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 <karupert@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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

FYI: I adjusted the author for this to Xu Wang... And added the commit message: Controller: Add associations for KVM_Controller Add the various associations to make the KVM_Controller work John On 03/27/2014 05:18 PM, John Ferlan wrote:
Signed-off-by: John Ferlan <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <karupert@us.ibm.com> @@ -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 <karupert@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -141,6 +141,7 @@ static char* part_component[] = { "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", "KVM_ConsoleResourceAllocationSettingData", + "KVM_ControllerResourceAllocationSettingData", "LXC_DiskResourceAllocationSettingData", "LXC_MemResourceAllocationSettingData", "LXC_NetResourceAllocationSettingData",

Add the new MOF and modify the build/install to handle. Signed-off-by: John Ferlan <jferlan@redhat.com> --- 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

Add the code and make adjustments to have ControllerPool support Signed-off-by: John Ferlan <jferlan@redhat.com> --- 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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> @@ -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 <danms@us.ibm.com> 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

Ping? Any thoughts on the changes? I'd like to get this off my list of things to do... Thanks John On 03/27/2014 05:18 PM, John Ferlan wrote:
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:<type_str>:<index#>"
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

于 2014年03月28日 05:18, John Ferlan 写道:
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 I just wonder how to get that revision, apply it from some organization or company?
Thanks, Xu Wang
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:<type_str>:<index#>"
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

On 04/14/2014 03:43 AM, Xu Wang wrote:
于 2014年03月28日 05:18, John Ferlan 写道:
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 I just wonder how to get that revision, apply it from some organization or company?
Thanks, Xu Wang
Not sure I understand the question, but I think you're asking where/how the value is generated.... Well it's generated if/when you run "autoconfiscate.sh"... It'll do the following: if test -x $(which git); then git rev-parse --short HEAD > .changeset git rev-list HEAD | wc -l > .revision else echo "Unknown" > .changeset echo "0" > .revision fi What I *really* wish is someone could write a patch to have a "make" or "make rpm" do that as well. My build environment understanding is weak and I'm not sure exactly the best way to do it. John

Are inquiries on this series of changes satisfied? Can the series be pushed? I'd like to get this off my todo list. Thanks John

I have pushed these changes as is to master. We may want to consider generating a "release" since the last one was 0.6.3 in July 2013. I would not expect any of these changes to make a RHEL6 based release. In fact, as upstream diverges further from what RHEL downstream has - it becomes more difficult to merge or cherry-pick changes from upstream. Any changes added to upstream for RHEL6 need to be easily picked and need to have a way to test easily. Tks, John
participants (2)
-
John Ferlan
-
Xu Wang