[PATCH 0/3] Add Controller Device Support

Add Xen/KVM/LXC_ControllerResourceAllocationSettingData classes for controller device operation. So far there are two variables (type and model) could be operated by calling API. Xu Wang (3): libxutil: Controller Support RASD: Schema and Provider Support for Controller RASDs VSMS: Support for domains with controller devices libxkutil/device_parsing.c | 62 ++++++++++++++++++++- libxkutil/device_parsing.h | 9 +++ libxkutil/xmlgen.c | 28 +++++++++ schema/ResourceAllocationSettingData.mof | 27 +++++++++ schema/ResourceAllocationSettingData.registration | 3 + src/Virt_RASD.c | 24 ++++++++ src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++ src/svpc_types.h | 4 +- 8 files changed, 199 insertions(+), 2 deletions(-)

Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 ++++++ libxkutil/xmlgen.c | 28 ++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..1937132 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith <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" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); } +static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller); free(dev->id); @@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; } +static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + + if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break; + case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); } + return dev; } @@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER); return ret; @@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct); free(dom); diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; }; +struct controller_device { + char *type; + char *model; +}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain { struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; }; struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..537238d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; } +static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL }; diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 #define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770 -#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, }; #define CIM_VSSD_RECOVERY_NONE 2 -- 1.7.1

Coverity points out two missing break;'s - see below... On 03/03/2014 02:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 ++++++ libxkutil/xmlgen.c | 28 ++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..1937132 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith <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" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); }
+static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller);
free(dev->id);
@@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; }
+static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + + if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break;
+ case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; +
Missing a break;
default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); } + return dev; }
@@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER);
return ret;
@@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct);
free(dom);
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; };
+struct controller_device { + char *type; + char *model; +}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain {
struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; };
struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..537238d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; }
+static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); + } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev;
Missing a break;
default: cleanup_virt_devices(&dev, 1); goto out; @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL };
diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 #define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770
-#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, };
#define CIM_VSSD_RECOVERY_NONE 2

Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 ++++++ libxkutil/xmlgen.c | 28 ++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..1937132 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith <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" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); }
+static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller);
free(dev->id);
@@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; }
+static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + + if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); What is going to happen if you have more than one instance of the same type of controller? In other words, I do not think that type is unique to be the ID. To make it unique you also need the index which is also a mandatory attribute. + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break;
+ case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); } + return dev; }
@@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER);
return ret;
@@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct);
free(dom);
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; };
+struct controller_device { + char *type; + char *model; +}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain {
struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; };
struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..537238d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; }
+static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); Model is an optional attribute. So if I read this correctly dev->model might be NULL and you create a new property with it. I am not sure what
+ } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL };
diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 33 is DMTF reserved as an Ethernet Connection the next logical number in
On 03/03/2014 08:38 AM, Xu Wang wrote: libvirt is going to do about it. libvirt-cim terms would be 32771 (see below)
#define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770
-#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, };
#define CIM_VSSD_RECOVERY_NONE 2
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 03/12/2014 12:36 PM, Boris Fiuczynski wrote:
diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 33 is DMTF reserved as an Ethernet Connection the next logical number in libvirt-cim terms would be 32771 (see below)
Do you have a link handy to the specification that describes the numbers? I know I used to have a link, but I cannot find it any more. tks, John
#define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770
-#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, };
#define CIM_VSSD_RECOVERY_NONE 2

On 03/13/2014 01:45 PM, John Ferlan wrote:
On 03/12/2014 12:36 PM, Boris Fiuczynski wrote:
diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 33 is DMTF reserved as an Ethernet Connection the next logical number in libvirt-cim terms would be 32771 (see below)
Do you have a link handy to the specification that describes the numbers? I know I used to have a link, but I cannot find it any more.
tks,
John
John, sure! http://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_ResourceAllocationSettingDa... I suggested #define CIM_RES_TYPE_CONTROLLER 32771 that is for provider pluming but when generating the CIM instance I suggested to set CIM_ResourceAllocationSettingData.ResourceType as Other or 1 to make use of CIM_ResourceAllocationSettingData.OtherResourceType and CIM_ResourceAllocationSettingData.ResourceSubType as explained in my response to Patch 2/3
#define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770
-#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, };
#define CIM_VSSD_RECOVERY_NONE 2
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 03/13/2014 10:10 AM, Boris Fiuczynski wrote:
On 03/13/2014 01:45 PM, John Ferlan wrote:
On 03/12/2014 12:36 PM, Boris Fiuczynski wrote:
diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 33 is DMTF reserved as an Ethernet Connection the next logical number in libvirt-cim terms would be 32771 (see below)
Do you have a link handy to the specification that describes the numbers? I know I used to have a link, but I cannot find it any more.
tks,
John
John, sure! http://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_ResourceAllocationSettingDa...
I was thinking more along the lines of a link where the "33" is being defined since as you pointed out it was reserved. John

ResourceType uint16 Description string The type of resource this allocation setting represents. ModelCorrespondence string CIM_ResourceAllocationSettingData.OtherResourceType, CIM_ResourceAllocationSettingData.ResourceSubType ValueMap string 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, .., 0x8000..0xFFFF Values string Other, Computer System, Processor, Memory, IDE Controller, Parallel SCSI HBA, FC HBA, iSCSI HBA, IB HCA, Ethernet Adapter, Other Network Adapter, I/O Slot, I/O Device, Floppy Drive, CD Drive, DVD drive, Disk Drive, Tape Drive, Storage Extent, Other storage device, Serial port, Parallel port, USB Controller, Graphics controller, IEEE 1394 Controller, Partitionable Unit, Base Partitionable Unit, Power, Cooling Capacity, Ethernet Switch Port, Logical Disk, Storage Volume, Ethernet Connection, DMTF reserved, Vendor Reserved That is included in the ValueMap! On 03/13/2014 04:20 PM, John Ferlan wrote:
On 03/13/2014 10:10 AM, Boris Fiuczynski wrote:
On 03/13/2014 01:45 PM, John Ferlan wrote:
On 03/12/2014 12:36 PM, Boris Fiuczynski wrote:
diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 33 is DMTF reserved as an Ethernet Connection the next logical number in libvirt-cim terms would be 32771 (see below)
Do you have a link handy to the specification that describes the numbers? I know I used to have a link, but I cannot find it any more.
tks,
John
John, sure! http://schemas.dmtf.org/wbem/cim-html/2.31.0/CIM_ResourceAllocationSettingDa...
I was thinking more along the lines of a link where the "33" is being defined since as you pointed out it was reserved.
John
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

Here the other address stuff On 03/12/2014 05:36 PM, Boris Fiuczynski wrote:
On 03/03/2014 08:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 ++++++ libxkutil/xmlgen.c | 28 ++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..1937132 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith <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" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); }
+static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); cleanup_device_address(&dev->address);
+} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller);
free(dev->id);
@@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; }
+static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + for (child = node->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "address")) { parse_device_address(child, &cdev->address); } }
+ if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); What is going to happen if you have more than one instance of the same type of controller? In other words, I do not think that type is unique to be the ID. To make it unique you also need the index which is also a mandatory attribute. + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break;
+ case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); duplicate_device_address(&dev->dev.controller.address, &_dev->dev.controller.address);
} + return dev; }
@@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER);
return ret;
@@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct);
free(dom);
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; };
+struct controller_device { + char *type; + char *model;
struct device_address address;
+}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain {
struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; };
struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..537238d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; }
+static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); Model is an optional attribute. So if I read this correctly dev->model might be NULL and you create a new property with it. I am not sure what libvirt is going to do about it.
if (dev->address.ct > 0) return device_address_xml(tmp, &dev->address); -- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 03/13/2014 09:46 AM, Boris Fiuczynski wrote:
Here the other address stuff
On 03/12/2014 05:36 PM, Boris Fiuczynski wrote:
On 03/03/2014 08:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 ++++++ libxkutil/xmlgen.c | 28 ++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..1937132 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith <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" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); }
+static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); cleanup_device_address(&dev->address);
+} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller);
free(dev->id);
@@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; }
+static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + for (child = node->children; child != NULL; child = child->next) { if (XSTREQ(child->name, "address")) { parse_device_address(child, &cdev->address); } }
+ if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); What is going to happen if you have more than one instance of the same type of controller? In other words, I do not think that type is unique to be the ID. To make it unique you also need the index which is also a mandatory attribute. + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break;
+ case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); duplicate_device_address(&dev->dev.controller.address, &_dev->dev.controller.address);
And I naturally missed this ... I've since adjusted my changes (here's a cut-n-paste): } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.index); DUP_FIELD(dev, _dev, dev.controller.model); + DUP_FIELD(dev, _dev, dev.controller.ports); + DUP_FIELD(dev, _dev, dev.controller.vectors); + DUP_FIELD(dev, _dev, dev.controller.queues); + duplicate_device_address(&dev->dev.master.address, + &_dev->dev.master.address); + duplicate_device_address(&dev->dev.controller.address, + &_dev->dev.controller.address); }
} + return dev; }
@@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER);
return ret;
@@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct);
free(dom);
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; };
+struct controller_device { + char *type; + char *model;
struct device_address address;
+}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain {
struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; };
struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..537238d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; }
+static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); Model is an optional attribute. So if I read this correctly dev->model might be NULL and you create a new property with it. I am not sure what libvirt is going to do about it.
if (dev->address.ct > 0) return device_address_xml(tmp, &dev->address);

On 03/12/2014 12:36 PM, Boris Fiuczynski wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- libxkutil/device_parsing.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libxkutil/device_parsing.h | 9 ++++++ libxkutil/xmlgen.c | 28 ++++++++++++++++++++ src/svpc_types.h | 4 ++- 4 files changed, 101 insertions(+), 2 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index d2d3859..1937132 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1,5 +1,5 @@ /* - * Copyright IBM Corp. 2007, 2013 + * Copyright IBM Corp. 2007, 2014 * * Authors: * Dan Smith <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" @@ -308,6 +309,15 @@ static void cleanup_input_device(struct input_device *dev) free(dev->bus); }
+static void cleanup_controller_device(struct controller_device *dev) +{ + if (dev == NULL) + return; + + free(dev->type); + free(dev->model); +} + void cleanup_virt_device(struct virt_device *dev) { if (dev == NULL) @@ -325,6 +335,8 @@ void cleanup_virt_device(struct virt_device *dev) cleanup_input_device(&dev->dev.input); else if (dev->type == CIM_RES_TYPE_CONSOLE) cleanup_console_device(&dev->dev.console); + else if (dev->type == CIM_RES_TYPE_CONTROLLER) + cleanup_controller_device(&dev->dev.controller);
free(dev->id);
@@ -1107,6 +1119,42 @@ static int parse_input_device(xmlNode *node, struct virt_device **vdevs) return 0; }
+static int parse_controller_device(xmlNode *node, struct virt_device **vdevs) +{ + struct virt_device *vdev = NULL; + struct controller_device *cdev = NULL; + int ret; + + vdev = calloc(1, sizeof(*vdev)); + if (vdev == NULL) + goto err; + + cdev = &(vdev->dev.controller); + + cdev->type = get_attr_value(node, "type"); + cdev->model = get_attr_value(node, "model"); + + if (cdev->type == NULL) + goto err; + + vdev->type = CIM_RES_TYPE_CONTROLLER; + + ret = asprintf(&vdev->id, "%s", cdev->type); What is going to happen if you have more than one instance of the same type of controller? In other words, I do not think that type is unique to be the ID. To make it unique you also need the index which is also a mandatory attribute. + if (ret == -1) { + CU_DEBUG("Failed to create controller id string"); + goto err; + } + + *vdevs = vdev; + + return 1; + err: + cleanup_controller_device(cdev); + free(vdev); + + return 0; +} + static bool resize_devlist(struct virt_device **list, int newsize) { struct virt_device *_list; @@ -1230,6 +1278,10 @@ static int parse_devices(const char *xml, struct virt_device **_list, int type) func = &parse_input_device; break;
+ case CIM_RES_TYPE_CONTROLLER: + xpathstr = CONTROLLER_XPATH; + func = &parse_controller_device; + default: CU_DEBUG("Unrecognized device type. Returning."); goto err1; @@ -1351,7 +1403,11 @@ struct virt_device *virt_device_dup(struct virt_device *_dev) } else if (dev->type == CIM_RES_TYPE_CONSOLE) { console_device_dup(&dev->dev.console, &_dev->dev.console); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + DUP_FIELD(dev, _dev, dev.controller.type); + DUP_FIELD(dev, _dev, dev.controller.model); } + return dev; }
@@ -1731,6 +1787,9 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo) (*dominfo)->dev_vcpu_ct = parse_devices(xml, &(*dominfo)->dev_vcpu, CIM_RES_TYPE_PROC); + (*dominfo)->dev_controller_ct = parse_devices(xml, + &(*dominfo)->dev_controller, + CIM_RES_TYPE_CONTROLLER);
return ret;
@@ -1819,6 +1878,7 @@ void cleanup_dominfo(struct domain **dominfo) cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct); cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct); cleanup_virt_devices(&dom->dev_console, dom->dev_console_ct); + cleanup_virt_devices(&dom->dev_controller, dom->dev_controller_ct);
free(dom);
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index a92e223..cc58970 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -163,6 +163,11 @@ struct input_device { char *bus; };
+struct controller_device { + char *type; + char *model; +}; + struct virt_device { uint16_t type; union { @@ -174,6 +179,7 @@ struct virt_device { struct graphics_device graphics; struct console_device console; struct input_device input; + struct controller_device controller; } dev; char *id; }; @@ -249,6 +255,9 @@ struct domain {
struct virt_device *dev_vcpu; int dev_vcpu_ct; + + struct virt_device *dev_controller; + int dev_controller_ct; };
struct virt_device *virt_device_dup(struct virt_device *dev); diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 18c4765..537238d 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -798,6 +798,29 @@ static const char *input_xml(xmlNodePtr root, struct domain *dominfo) return NULL; }
+static const char *controller_xml(xmlNodePtr root, struct domain *dominfo) +{ + int i; + + for (i = 0; i < dominfo->dev_controller_ct; i++) { + xmlNodePtr tmp; + struct virt_device *_dev = &dominfo->dev_controller[i]; + if (_dev->type == CIM_RES_TYPE_UNKNOWN) + continue; + + struct controller_device *dev = &_dev->dev.controller; + + tmp = xmlNewChild(root, NULL, BAD_CAST "controller", NULL); + if (tmp == NULL) + return XML_ERROR; + + xmlNewProp(tmp, BAD_CAST "type", BAD_CAST dev->type); + xmlNewProp(tmp, BAD_CAST "model", BAD_CAST dev->model); Model is an optional attribute. So if I read this correctly dev->model might be NULL and you create a new property with it. I am not sure what
+ } + + return NULL; +} + static char *system_xml(xmlNodePtr root, struct domain *domain) { xmlNodePtr tmp; @@ -1129,6 +1152,10 @@ char *device_to_xml(struct virt_device *_dev) dominfo->dev_input_ct = 1; dominfo->dev_input = dev; break; + case CIM_RES_TYPE_CONTROLLER: + func = controller_xml; + dominfo->dev_controller_ct = 1; + dominfo->dev_controller = dev; default: cleanup_virt_devices(&dev, 1); goto out; @@ -1167,6 +1194,7 @@ char *system_to_xml(struct domain *dominfo) &console_xml, &graphics_xml, &emu_xml, + &controller_xml, NULL };
diff --git a/src/svpc_types.h b/src/svpc_types.h index 404e428..d76097c 100644 --- a/src/svpc_types.h +++ b/src/svpc_types.h @@ -32,12 +32,13 @@ #define CIM_RES_TYPE_DISK 17 #define CIM_RES_TYPE_GRAPHICS 24 #define CIM_RES_TYPE_INPUT 13 +#define CIM_RES_TYPE_CONTROLLER 33 33 is DMTF reserved as an Ethernet Connection the next logical number in
On 03/03/2014 08:38 AM, Xu Wang wrote: libvirt is going to do about it. libvirt-cim terms would be 32771 (see below)
#define CIM_RES_TYPE_UNKNOWN 1000 #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_CONSOLE 32769 #define CIM_RES_TYPE_EMU 32770
-#define CIM_RES_TYPE_COUNT 7 +#define CIM_RES_TYPE_COUNT 8 const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, @@ -46,6 +47,7 @@ const static int cim_res_types[CIM_RES_TYPE_COUNT] = CIM_RES_TYPE_GRAPHICS, CIM_RES_TYPE_INPUT, CIM_RES_TYPE_CONSOLE, + CIM_RES_TYPE_CONTROLLER, };
#define CIM_VSSD_RECOVERY_NONE 2
Because the "importance" of this ratcheted up a bit, I've gone ahead and started trying to add the missing parts myself. I probably have gone overboard, but I added the index, ports, queues, vectors, address, and master fields as described in the controller section of the domain. The "master" inside libvirt is parsed similarly to the address as a list of pairs that we don't care what the contents are - just that we copy them over. Taking the 1/3 changes, I've attached the adjustments. I've run *just* this pair of changes thru cimtest without any new failures than I found with the rawio/sgio changes. You should be able to just "git am" them to the existing 1/3 changes. John

Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-) diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; }; +[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..1142376 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index abfb09f..594fe83 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; } +static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, "Type", + (CMPIValue *)dev->dev.controller.type, CMPI_chars); + + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_CONTROLLER; + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(dev, inst); } /* FIXME: Put the HostResource in place */ @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out; @@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; } -- 1.7.1

On 03/03/2014 08:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; };
+[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; The class CIM_ResourceAllocationSettingData has an attribute ResourceSubType. I think there is no need to introduce this new attribute here. + string Model; I think that there should at least be some minimum documentation of the attributes in the mof as well. e.g. [Description ("Order in which the bus controller is encountered. " "The order is controller type scoped.")] uint64 Index;
+}; As already said in patch 1/3 I think that you need to add the index.
+ +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..1142376 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index abfb09f..594fe83 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; }
+static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, "Type", + (CMPIValue *)dev->dev.controller.type, CMPI_chars); + + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); + + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_CONTROLLER; Setting the attribute ResourceType to CIM_RES_TYPE_OTHER since there is no value in the DMTF defined space that would fit a generic controller. By setting it to "Other" or "1" you should specify attributes OtherResourceType and ResourceSubType. I suggest to set OtherResourceType to "Controller" and as mentioned above set the ResourceSubType according to the controller type specified. You need to set these in method set_controller_rasd_params. + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(dev, inst); }
/* FIXME: Put the HostResource in place */ @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out;
@@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; }
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 03/13/2014 11:00 AM, Boris Fiuczynski wrote:
On 03/03/2014 08:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; };
+[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; The class CIM_ResourceAllocationSettingData has an attribute ResourceSubType. I think there is no need to introduce this new attribute here. + string Model; I think that there should at least be some minimum documentation of the attributes in the mof as well. e.g. [Description ("Order in which the bus controller is encountered. " "The order is controller type scoped.")] uint64 Index;
+}; As already said in patch 1/3 I think that you need to add the index. After reading John's mail about the BZ, I would suggest to also add
[Description ("Device address property names")] string AddressProperties[]; [Description ("Device address property values")] string AddressValues[]; These attributes already exist on the Disk and Net. The provider code for this is reusable and generic. See below... Below I added some code snippets for support and also will do that for hopefully most of the other spots.
+ +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ] diff --git a/schema/ResourceAllocationSettingData.registration b/schema/ResourceAllocationSettingData.registration index b969bfe..1142376 100644 --- a/schema/ResourceAllocationSettingData.registration +++ b/schema/ResourceAllocationSettingData.registration @@ -7,6 +7,7 @@ Xen_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance Xen_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +Xen_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_NetResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance @@ -14,9 +15,11 @@ KVM_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance KVM_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +KVM_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_MemResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_DiskResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ProcResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_GraphicsResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_InputResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance LXC_ConsoleResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance +LXC_ControllerResourceAllocationSettingData root/virt Virt_RASD Virt_RASD instance diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index abfb09f..594fe83 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -915,6 +915,20 @@ static CMPIStatus set_input_rasd_params(const struct virt_device *dev, return s; }
+static CMPIStatus set_controller_rasd_params(const struct virt_device *dev, + CMPIInstance *inst)
static CMPIStatus set_controller_rasd_params(const CMPIBroker *broker, const CMPIObjectPath *ref, const struct virt_device *vdev, CMPIInstance *inst)
+{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + + CMSetProperty(inst, "Type", + (CMPIValue *)dev->dev.controller.type, CMPI_chars); + + CMSetProperty(inst, "Model", + (CMPIValue *)dev->dev.controller.model, CMPI_chars); if (dev->dev.controller.address.ct > 0) set_rasd_device_address(broker, ref, &dev->dev.controller.address, inst);
+ + return s; +} + CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, struct virt_device *dev, const char *host, @@ -949,6 +963,9 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, } else if (dev->type == CIM_RES_TYPE_INPUT) { type = CIM_RES_TYPE_INPUT; base = "InputResourceAllocationSettingData"; + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + type = CIM_RES_TYPE_CONTROLLER; Setting the attribute ResourceType to CIM_RES_TYPE_OTHER since there is no value in the DMTF defined space that would fit a generic controller. By setting it to "Other" or "1" you should specify attributes OtherResourceType and ResourceSubType. I suggest to set OtherResourceType to "Controller" and as mentioned above set the ResourceSubType according to the controller type specified. You need to set these in method set_controller_rasd_params. + base = "ControllerResourceAllocationSettingData"; } else { return NULL; } @@ -1004,6 +1021,8 @@ CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, s = set_input_rasd_params(dev, inst); } else if (dev->type == CIM_RES_TYPE_CONSOLE) { s = set_console_rasd_params(dev, inst); + } else if (dev->type == CIM_RES_TYPE_CONTROLLER) { + s = set_controller_rasd_params(dev, inst); s = set_controller_rasd_params(broker, rev, dev, inst); }
/* FIXME: Put the HostResource in place */ @@ -1138,6 +1157,8 @@ CMPIrc res_type_from_rasd_classname(const char *cn, uint16_t *type) *type = CIM_RES_TYPE_IMAGE; else if (STREQ(base, "ConsoleResourceAllocationSettingData")) *type = CIM_RES_TYPE_CONSOLE; + else if (STREQ(base, "ControllerResourceAllocationSettingData")) + *type = CIM_RES_TYPE_CONTROLLER; else goto out;
@@ -1175,6 +1196,9 @@ CMPIrc rasd_classname_from_type(uint16_t type, const char **classname) case CIM_RES_TYPE_INPUT: *classname = "InputResourceAllocationSettingData"; break; + case CIM_RES_TYPE_CONTROLLER: + *classname = "ControllerResourceAllocationSettingData"; + break; default: rc = CMPI_RC_ERR_FAILED; }
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

Just revisiting the mof again. I am aware what KVM supports regarding controllers nut does LXC really support controllers? Looking below at the mof... it apparently does! If it does not than the class LXC_ControllerResourceAllocationSettingData should be deleted! Also I am not aware to what extend Xen supports controllers. Any ideas? On 03/03/2014 08:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; };
+[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ]
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 03/13/2014 11:16 AM, Boris Fiuczynski wrote:
Just revisiting the mof again. I am aware what KVM supports regarding controllers nut does LXC really support controllers? Looking below at the mof... it apparently does! If it does not than the class LXC_ControllerResourceAllocationSettingData should be deleted! Also I am not aware to what extend Xen supports controllers. Any ideas?
No idea about Xen, but in looking through the libvirt source code there is no reference to virDomainControllerDefPtr in any Xen driver, although are references to say virDomainDiskDefPtr, which is the libvirt corollary to disk definitions... And I believe you're right about LXC as well. It seems this change should be "constricted" to the KVM controller. I assume that would then also remove the Xen_* and LXC_* controller defs in the registration file too? Or we keep it there, but just empty? John
On 03/03/2014 08:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; };
+[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ]

On 03/13/2014 04:41 PM, John Ferlan wrote:
On 03/13/2014 11:16 AM, Boris Fiuczynski wrote:
Just revisiting the mof again. I am aware what KVM supports regarding controllers nut does LXC really support controllers? Looking below at the mof... it apparently does! If it does not than the class LXC_ControllerResourceAllocationSettingData should be deleted! Also I am not aware to what extend Xen supports controllers. Any ideas?
No idea about Xen, but in looking through the libvirt source code there is no reference to virDomainControllerDefPtr in any Xen driver, although are references to say virDomainDiskDefPtr, which is the libvirt corollary to disk definitions...
And I believe you're right about LXC as well.
It seems this change should be "constricted" to the KVM controller. I assume that would then also remove the Xen_* and LXC_* controller defs in the registration file too? Or we keep it there, but just empty?
John
I would suggest to remove the classes as well as the registration.
On 03/03/2014 08:38 AM, Xu Wang wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- schema/ResourceAllocationSettingData.mof | 27 +++++++++++++++++++++ schema/ResourceAllocationSettingData.registration | 3 ++ src/Virt_RASD.c | 24 ++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/schema/ResourceAllocationSettingData.mof b/schema/ResourceAllocationSettingData.mof index 6b649de..3512170 100644 --- a/schema/ResourceAllocationSettingData.mof +++ b/schema/ResourceAllocationSettingData.mof @@ -328,6 +328,33 @@ class LXC_InputResourceAllocationSettingData : LXC_ResourceAllocationSettingData string BusType; };
+[Description ("Xen virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class Xen_ControllerResourceAllocationSettingData : Xen_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("KVM virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class KVM_ControllerResourceAllocationSettingData : KVM_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + +[Description ("LXC virtual controller device"), + Provider("cmpi::Virt_RASD") +] +class LXC_ControllerResourceAllocationSettingData : LXC_ResourceAllocationSettingData +{ + string Type; + string Model; +}; + [Description ("Xen virtual network pool settings"), Provider("cmpi::Virt_RASD") ]
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index e146470..1a34ff8 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1848,6 +1848,28 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, return NULL; } +static const char *controller_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + const char *val; + + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Type field not valid"); + goto out; + } + dev->dev.controller.type = strdup(val); + + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { + CU_DEBUG("Invalid value for Model in ControllerRASD"); + goto out; + } + dev->dev.controller.model = strdup(val); + + out: + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -1868,6 +1890,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, return console_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform"; @@ -1888,6 +1912,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, return lxc_proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); } return "Resource type not supported on this platform"; @@ -1997,6 +2023,9 @@ static const char *classify_resources(CMPIArray *resources, if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) return "Failed to alloc input list"; + if (!make_space(&domain->dev_controller, domain->dev_controller_ct, count)) + return "Failed to alloc controller list"; + for (i = 0; i < count; i++) { CMPIObjectPath *op; CMPIData item; @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray *resources, &domain->dev_input[0], ns, p_error); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_controller[domain->dev_controller_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_controller_ct += 1; } + if (msg != NULL) return msg; @@ -2918,6 +2956,9 @@ static struct virt_device **find_list(struct domain *dominfo, } else if (type == CIM_RES_TYPE_INPUT) { list = &dominfo->dev_input; *count = &dominfo->dev_input_ct; + } else if (type == CIM_RES_TYPE_CONTROLLER) { + list = &dominfo->dev_controller; + *count = &dominfo->dev_controller_ct; } return list; @@ -3039,6 +3080,7 @@ static CMPIStatus resource_del(struct domain *dominfo, if (STREQ(dev->id, devid)) { if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_CONSOLE) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { @@ -3121,6 +3163,7 @@ static CMPIStatus resource_add(struct domain *dominfo, if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) { (*count)++; cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); @@ -3198,6 +3241,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { -- 1.7.1

Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index e146470..1a34ff8 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1848,6 +1848,28 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, return NULL; }
+static const char *controller_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ + const char *val; + + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Type field not valid"); + goto out; + } + dev->dev.controller.type = strdup(val); + + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { + CU_DEBUG("Invalid value for Model in ControllerRASD"); + goto out; + } + dev->dev.controller.model = strdup(val); I have already written before that the CIM instance uniqueness is with
On 03/03/2014 08:38 AM, Xu Wang wrote: the current code not guaranteed. I suggest the following schema for the instanceID: <domain name>/controller:<ResourceSubType>:<Index> To accomplish this you need to set dev->id here to (abbreviated) "controller:"+dev->dev.controller.type+":"dev->dev.controller.index btw. this is also needed to be set in method parse_controller_device in libxkutil/device_parsing.c I might have missed that before.
+ + out: + + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -1868,6 +1890,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, return console_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); }
return "Resource type not supported on this platform"; @@ -1888,6 +1912,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, return lxc_proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); }
return "Resource type not supported on this platform"; @@ -1997,6 +2023,9 @@ static const char *classify_resources(CMPIArray *resources, if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) return "Failed to alloc input list";
+ if (!make_space(&domain->dev_controller, domain->dev_controller_ct, count)) + return "Failed to alloc controller list"; + for (i = 0; i < count; i++) { CMPIObjectPath *op; CMPIData item; @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray *resources, &domain->dev_input[0], ns, p_error); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_controller[domain->dev_controller_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_controller_ct += 1; } + if (msg != NULL) return msg;
@@ -2918,6 +2956,9 @@ static struct virt_device **find_list(struct domain *dominfo, } else if (type == CIM_RES_TYPE_INPUT) { list = &dominfo->dev_input; *count = &dominfo->dev_input_ct; + } else if (type == CIM_RES_TYPE_CONTROLLER) { + list = &dominfo->dev_controller; + *count = &dominfo->dev_controller_ct; }
return list; @@ -3039,6 +3080,7 @@ static CMPIStatus resource_del(struct domain *dominfo, if (STREQ(dev->id, devid)) { if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_CONSOLE) || + (type == CIM_RES_TYPE_CONTROLLER) || In libvirt controller can be dynamically added and deleted (hotplug and hotunplug). If I am not mistaken you prevent this here and also below (resource_add & resource_mod). (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { @@ -3121,6 +3163,7 @@ static CMPIStatus resource_add(struct domain *dominfo,
if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) { (*count)++; cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); @@ -3198,6 +3241,7 @@ static CMPIStatus resource_mod(struct domain *dominfo,
if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else {
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

Here is the rest of the address code On 03/13/2014 11:13 AM, Boris Fiuczynski wrote:
Signed-off-by: Xu Wang <gesaint@linux.vnet.ibm.com> --- src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index e146470..1a34ff8 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1848,6 +1848,28 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, return NULL; }
+static const char *controller_rasd_to_vdev(CMPIInstance *inst, + struct virt_device *dev) +{ const char *msg = NULL; + const char *val; + + if (cu_get_str_prop(inst, "Type", &val) != CMPI_RC_OK) { + CU_DEBUG("ControllerRASD Type field not valid"); + goto out; + } + dev->dev.controller.type = strdup(val); + + if (cu_get_str_prop(inst, "Model", &val) != CMPI_RC_OK) { + CU_DEBUG("Invalid value for Model in ControllerRASD"); + goto out; + } + dev->dev.controller.model = strdup(val); I have already written before that the CIM instance uniqueness is with
On 03/03/2014 08:38 AM, Xu Wang wrote: the current code not guaranteed. I suggest the following schema for the instanceID: <domain name>/controller:<ResourceSubType>:<Index> To accomplish this you need to set dev->id here to (abbreviated) "controller:"+dev->dev.controller.type+":"dev->dev.controller.index btw. this is also needed to be set in method parse_controller_device in libxkutil/device_parsing.c I might have missed that before.
msg = rasd_to_device_address(inst, &dev->dev.controller.address);
+ + out: + + return msg; + return NULL; +} + static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, @@ -1868,6 +1890,8 @@ static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, return console_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); }
return "Resource type not supported on this platform"; @@ -1888,6 +1912,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, return lxc_proc_rasd_to_vdev(inst, dev); } else if (type == CIM_RES_TYPE_INPUT) { return input_rasd_to_vdev(inst, dev); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + return controller_rasd_to_vdev(inst, dev); }
return "Resource type not supported on this platform"; @@ -1997,6 +2023,9 @@ static const char *classify_resources(CMPIArray *resources, if (!make_space(&domain->dev_input, domain->dev_input_ct, count)) return "Failed to alloc input list";
+ if (!make_space(&domain->dev_controller, domain->dev_controller_ct, count)) + return "Failed to alloc controller list"; + for (i = 0; i < count; i++) { CMPIObjectPath *op; CMPIData item; @@ -2111,7 +2140,16 @@ static const char *classify_resources(CMPIArray *resources, &domain->dev_input[0], ns, p_error); + } else if (type == CIM_RES_TYPE_CONTROLLER) { + msg = rasd_to_vdev(inst, + domain, + &domain->dev_controller[domain->dev_controller_ct], + ns, + p_error); + if (msg == NULL) + domain->dev_controller_ct += 1; May I suggest this implementation? struct virt_device dev; int dcount = count + domain->dev_controller_ct;
memset(&dev, 0, sizeof(dev)); msg = rasd_to_vdev(inst, domain, &dev, ns, p_error); if (msg == NULL) msg = add_device_nodup(&dev, domain->dev_controller, dcount, &domain->dev_controller_ct);
} + if (msg != NULL) return msg;
@@ -2918,6 +2956,9 @@ static struct virt_device **find_list(struct domain *dominfo, } else if (type == CIM_RES_TYPE_INPUT) { list = &dominfo->dev_input; *count = &dominfo->dev_input_ct; + } else if (type == CIM_RES_TYPE_CONTROLLER) { + list = &dominfo->dev_controller; + *count = &dominfo->dev_controller_ct; }
return list; @@ -3039,6 +3080,7 @@ static CMPIStatus resource_del(struct domain *dominfo, if (STREQ(dev->id, devid)) { if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_CONSOLE) || + (type == CIM_RES_TYPE_CONTROLLER) ||
In libvirt controller can be dynamically added and deleted (hotplug and hotunplug). If I am not mistaken you prevent this here and also below (resource_add & resource_mod).
(type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { @@ -3121,6 +3163,7 @@ static CMPIStatus resource_add(struct domain *dominfo,
if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) { (*count)++; cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); @@ -3198,6 +3241,7 @@ static CMPIStatus resource_mod(struct domain *dominfo,
if ((type == CIM_RES_TYPE_GRAPHICS) || (type == CIM_RES_TYPE_INPUT) || + (type == CIM_RES_TYPE_CONTROLLER) || (type == CIM_RES_TYPE_CONSOLE)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else {
-- Mit freundlichen Grüßen/Kind regards Boris Fiuczynski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 03/03/2014 02:38 AM, Xu Wang wrote:
Add Xen/KVM/LXC_ControllerResourceAllocationSettingData classes for controller device operation. So far there are two variables (type and model) could be operated by calling API.
Xu Wang (3): libxutil: Controller Support RASD: Schema and Provider Support for Controller RASDs VSMS: Support for domains with controller devices
libxkutil/device_parsing.c | 62 ++++++++++++++++++++- libxkutil/device_parsing.h | 9 +++ libxkutil/xmlgen.c | 28 +++++++++ schema/ResourceAllocationSettingData.mof | 27 +++++++++ schema/ResourceAllocationSettingData.registration | 3 + src/Virt_RASD.c | 24 ++++++++ src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++ src/svpc_types.h | 4 +- 8 files changed, 199 insertions(+), 2 deletions(-)
Again, like the rawio/sgio patches - I'd like to see a test here. I think this one certainly deserves some sort of cimtest as well. My cimtest is failing in multiple places. Did you run cimtest before and after these changes? John

On 03/03/2014 02:38 AM, Xu Wang wrote:
Add Xen/KVM/LXC_ControllerResourceAllocationSettingData classes for controller device operation. So far there are two variables (type and model) could be operated by calling API.
Xu Wang (3): libxutil: Controller Support RASD: Schema and Provider Support for Controller RASDs VSMS: Support for domains with controller devices
libxkutil/device_parsing.c | 62 ++++++++++++++++++++- libxkutil/device_parsing.h | 9 +++ libxkutil/xmlgen.c | 28 +++++++++ schema/ResourceAllocationSettingData.mof | 27 +++++++++ schema/ResourceAllocationSettingData.registration | 3 + src/Virt_RASD.c | 24 ++++++++ src/Virt_VirtualSystemManagementService.c | 44 +++++++++++++++ src/svpc_types.h | 4 +- 8 files changed, 199 insertions(+), 2 deletions(-)
The "need" for this just ratcheted up a bit since for RHEL7 the PCI controller must be defined for "new" or "changed" XML. There is a BZ assigned to me now - https://bugzilla.redhat.com/show_bug.cgi?id=1075874 Of course the window of opportunity to get changes in is very small. Hopefully we can come to a resolution on this set of changes rather quickly - I don't mind jumping in to assist if you are time constrained since at least work is started. John
participants (3)
-
Boris Fiuczynski
-
John Ferlan
-
Xu Wang