From cvincent at linux.vnet.ibm.com Sun Oct 2 19:41:09 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Sun, 02 Oct 2011 15:41:09 -0400 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid extra connection to libvirt In-Reply-To: References: Message-ID: <4E88BE55.2040301@linux.vnet.ibm.com> Actually, this change only prevents a 'nested' connection. There are still 2 connects; one in update_dominfo() and one in _resource_dynamic(). Also, moving the call to update_dominfo() up negates the check done by the code block that begins with 'dom = virDomainLookupByName(conn, dominfo->name);' I don't see the real value of the change. Am I missing something? On 09/28/2011 04:44 PM, Eduardo Lima (Etrunko) wrote: > src/Virt_VirtualSystemManagementService.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317242639 10800 > # Node ID e02b7fef37d7f1f6a18d68991dc1409eef8905ec > # Parent 942e9fa22bcb2681884cb39e1dcfc459c67ce197 > VirtualSystemManagementService: Avoid extra connection to libvirt > > Function update_device_info() has been called in after a creating a connection > to libvirt, while the itself creates a new connection. Moving the function call > a few lines above adresses this issue. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -2331,6 +2331,8 @@ > return s; > } > > + update_dominfo(dominfo, refcn); > + > conn = connect_by_classname(_BROKER, refcn,&s); > if (conn == NULL) { > CU_DEBUG("Failed to connect"); > @@ -2347,8 +2349,6 @@ > goto out; > } > > - update_dominfo(dominfo, refcn); > - > if (!domain_online(dom)) { > CU_DEBUG("VS `%s' not online; skipping dynamic update", > dominfo->name); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Sun Oct 2 19:44:48 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Sun, 02 Oct 2011 15:44:48 -0400 Subject: [Libvirt-cim] [PATCH] device_parsing: Use default values for vnc graphics device In-Reply-To: <2313e472149a55714322.1317234070@eblima.br.ibm.com> References: <2313e472149a55714322.1317234070@eblima.br.ibm.com> Message-ID: <4E88BF30.4020709@linux.vnet.ibm.com> +1. I like the addition of get_attr_value_default(). I suspect there are other places we could use the same approach where libvirt does not provide all the necessary defaults we rely on. On 09/28/2011 02:21 PM, Eduardo Lima (Etrunko) wrote: > libxkutil/device_parsing.c | 24 ++++++++++++++++++++---- > 1 files changed, 20 insertions(+), 4 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317234028 10800 > # Node ID 2313e472149a557143228949878f946278d0dd3a > # Parent adc78792781448aca7a1356bd253cbdd689839cb > device_parsing: Use default values for vnc graphics device > > This patch fixes the behavior where libvirt-cim loses the graphics device > description after a call to ModifyResourceSettings method. Actually it has > nothing to do with the fact that the domain is running or not. What happens is > that if somehow we can't read either 'listen' or 'port' attributes, the > function will fail and return immediately, skipping the device inclusion. > > The default values are based on the ones found in the default_graphics_device > function in src/Virt_VirtualSystemManagementService.c. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -527,6 +527,17 @@ > return 0; > } > > +static char *get_attr_value_default(xmlNode *node, char *attrname, > + const char *default_value) > +{ > + char *ret = get_attr_value(node, attrname); > + > + if (ret == NULL&& default_value != NULL) > + ret = strdup(default_value); > + > + return ret; > +} > + > static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) > { > struct virt_device *vdev = NULL; > @@ -547,13 +558,18 @@ > CU_DEBUG("graphics device type = %s", gdev->type); > > if (STREQC(gdev->type, "vnc")) { > - gdev->dev.vnc.port = get_attr_value(node, "port"); > - gdev->dev.vnc.host = get_attr_value(node, "listen"); > + gdev->dev.vnc.port = get_attr_value_default(node, "port", > + "-1"); > + gdev->dev.vnc.host = get_attr_value_default(node, "listen", > + "127.0.0.1"); > gdev->dev.vnc.keymap = get_attr_value(node, "keymap"); > gdev->dev.vnc.passwd = get_attr_value(node, "passwd"); > - > - if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) > + > + if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) { > + CU_DEBUG("Error vnc port '%p' host '%p'", > + gdev->dev.vnc.port, gdev->dev.vnc.host); > goto err; > + } > } > else if (STREQC(gdev->type, "sdl")) { > gdev->dev.sdl.display = get_attr_value(node, "display"); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Sun Oct 2 19:46:40 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Sun, 02 Oct 2011 15:46:40 -0400 Subject: [Libvirt-cim] [PATCH] device_parsing: Use default values for vnc graphics device In-Reply-To: <2313e472149a55714322.1317234070@eblima.br.ibm.com> References: <2313e472149a55714322.1317234070@eblima.br.ibm.com> Message-ID: <4E88BFA0.3070205@linux.vnet.ibm.com> Pushed. On 09/28/2011 02:21 PM, Eduardo Lima (Etrunko) wrote: > libxkutil/device_parsing.c | 24 ++++++++++++++++++++---- > 1 files changed, 20 insertions(+), 4 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317234028 10800 > # Node ID 2313e472149a557143228949878f946278d0dd3a > # Parent adc78792781448aca7a1356bd253cbdd689839cb > device_parsing: Use default values for vnc graphics device > > This patch fixes the behavior where libvirt-cim loses the graphics device > description after a call to ModifyResourceSettings method. Actually it has > nothing to do with the fact that the domain is running or not. What happens is > that if somehow we can't read either 'listen' or 'port' attributes, the > function will fail and return immediately, skipping the device inclusion. > > The default values are based on the ones found in the default_graphics_device > function in src/Virt_VirtualSystemManagementService.c. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -527,6 +527,17 @@ > return 0; > } > > +static char *get_attr_value_default(xmlNode *node, char *attrname, > + const char *default_value) > +{ > + char *ret = get_attr_value(node, attrname); > + > + if (ret == NULL&& default_value != NULL) > + ret = strdup(default_value); > + > + return ret; > +} > + > static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs) > { > struct virt_device *vdev = NULL; > @@ -547,13 +558,18 @@ > CU_DEBUG("graphics device type = %s", gdev->type); > > if (STREQC(gdev->type, "vnc")) { > - gdev->dev.vnc.port = get_attr_value(node, "port"); > - gdev->dev.vnc.host = get_attr_value(node, "listen"); > + gdev->dev.vnc.port = get_attr_value_default(node, "port", > + "-1"); > + gdev->dev.vnc.host = get_attr_value_default(node, "listen", > + "127.0.0.1"); > gdev->dev.vnc.keymap = get_attr_value(node, "keymap"); > gdev->dev.vnc.passwd = get_attr_value(node, "passwd"); > - > - if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) > + > + if (gdev->dev.vnc.port == NULL || gdev->dev.vnc.host == NULL) { > + CU_DEBUG("Error vnc port '%p' host '%p'", > + gdev->dev.vnc.port, gdev->dev.vnc.host); > goto err; > + } > } > else if (STREQC(gdev->type, "sdl")) { > gdev->dev.sdl.display = get_attr_value(node, "display"); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Sun Oct 2 19:48:43 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Sun, 02 Oct 2011 15:48:43 -0400 Subject: [Libvirt-cim] [PATCH] device_parsing: Small code cleanup In-Reply-To: <4e1f0b6dc5e512d98b82.1317243177@eblima.br.ibm.com> References: <4e1f0b6dc5e512d98b82.1317243177@eblima.br.ibm.com> Message-ID: <4E88C01B.8080008@linux.vnet.ibm.com> +1 and pushed. On 09/28/2011 04:52 PM, Eduardo Lima (Etrunko) wrote: > libxkutil/device_parsing.c | 72 ++++++++++++++++++++++++++------------------- > 1 files changed, 42 insertions(+), 30 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317238828 10800 > # Node ID 4e1f0b6dc5e512d98b8258c2c68ac5b1f28e83b6 > # Parent 2448b5a111e723902603ed5430aa0f0b1972732d > device_parsing: Small code cleanup > > Use the specific device parsing function as parameter in do_parse() instead > of checking for the device type in both caller and callee. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c > +++ b/libxkutil/device_parsing.c > @@ -49,6 +49,9 @@ > > #define MAX(a,b) (((a)>(b))?(a):(b)) > > +/* Device parse function */ > +typedef int (*dev_parse_func_t)(xmlNode *, struct virt_device **); > + > static void cleanup_disk_device(struct disk_device *dev) > { > free(dev->type); > @@ -669,32 +672,15 @@ > return true; > } > > -static int do_parse(xmlNodeSet *nsv, int type, struct virt_device **l) > + > +static int do_parse(xmlNodeSet *nsv, dev_parse_func_t do_real_parse, > + struct virt_device **l) > { > int devidx; > int lstidx = 0; > int count = 0; > struct virt_device *list = NULL; > xmlNode **dev_nodes = NULL; > - int (*do_real_parse)(xmlNode *, struct virt_device **) = NULL; > - > - /* point to correct parser function according to type */ > - if (type == CIM_RES_TYPE_NET) > - do_real_parse =&parse_net_device; > - else if (type == CIM_RES_TYPE_DISK) > - do_real_parse =&parse_disk_device; > - else if (type == CIM_RES_TYPE_PROC) > - do_real_parse = parse_vcpu_device; > - else if (type == CIM_RES_TYPE_EMU) > - do_real_parse = parse_emu_device; > - else if (type == CIM_RES_TYPE_MEM) > - do_real_parse = parse_mem_device; > - else if (type == CIM_RES_TYPE_GRAPHICS) > - do_real_parse = parse_graphics_device; > - else if (type == CIM_RES_TYPE_INPUT) > - do_real_parse = parse_input_device; > - else > - goto out; > > if (nsv == NULL) > goto out; > @@ -743,29 +729,55 @@ > { > int len = 0; > int count = 0; > + dev_parse_func_t func = NULL; > > - CU_DEBUG("In parse_deviceso - type is %d", type); > xmlDoc *xmldoc; > xmlXPathContext *xpathCtx; > xmlXPathObject *xpathObj; > xmlChar *xpathstr; > > - if (type == CIM_RES_TYPE_NET) > + CU_DEBUG("In parse_devices - type is %d", type); > + > + switch (type) { > + case CIM_RES_TYPE_NET: > xpathstr = NET_XPATH; > - else if (type == CIM_RES_TYPE_DISK) > + func =&parse_net_device; > + break; > + > + case CIM_RES_TYPE_DISK: > xpathstr = DISK_XPATH; > - else if (type == CIM_RES_TYPE_PROC) > + func =&parse_disk_device; > + break; > + > + case CIM_RES_TYPE_PROC: > xpathstr = VCPU_XPATH; > - else if (type == CIM_RES_TYPE_EMU) > + func =&parse_vcpu_device; > + break; > + > + case CIM_RES_TYPE_EMU: > xpathstr = EMU_XPATH; > - else if (type == CIM_RES_TYPE_MEM) > + func =&parse_emu_device; > + break; > + > + case CIM_RES_TYPE_MEM: > xpathstr = MEM_XPATH; > - else if (type == CIM_RES_TYPE_GRAPHICS) > + func =&parse_mem_device; > + break; > + > + case CIM_RES_TYPE_GRAPHICS: > xpathstr = GRAPHICS_XPATH; > - else if (type == CIM_RES_TYPE_INPUT) > + func =&parse_graphics_device; > + break; > + > + case CIM_RES_TYPE_INPUT: > xpathstr = INPUT_XPATH; > - else > + func =&parse_input_device; > + break; > + > + default: > + CU_DEBUG("Unrecognized device type. Returning."); > goto err1; > + }; > > len = strlen(xml) + 1; > > @@ -780,7 +792,7 @@ > == NULL) > goto err3; > > - count = do_parse(xpathObj->nodesetval, type, _list); > + count = do_parse(xpathObj->nodesetval, func, _list); > > xmlSetGenericErrorFunc(NULL, NULL); > xmlXPathFreeObject(xpathObj); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Mon Oct 3 00:12:21 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Sun, 02 Oct 2011 20:12:21 -0400 Subject: [Libvirt-cim] [PATCH] (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: References: Message-ID: <4E88FDE5.50402@linux.vnet.ibm.com> Tests for this have completed successfully, so ACK'ing. However... Now that we have a cimtest patch for this (https://www.redhat.com/archives/libvirt-cim/2011-September/msg00047.html), I think a follow-up tweak may be order. For example, I'd prefer to simply use NULL for 'no media' rather than a null_string to simplify the code further. We should also already have the libvirt-cim and Pegasus patches (no references, sorry) that allow us to un-set attributes like this. That is, set an actual value to NULL. On 09/20/2011 11:14 PM, Wayne Xia wrote: > # HG changeset patch > # User Wayne Xia > # Date 1316154275 -28800 > # Node ID afee8d9b7214884ab74690b3ca9fd3d4f139f455 > # Parent db809376d763493849c2a19f587969eaec619b75 > (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk > > This patch would allow define a system with an empty CDROM device, and allow method modify > resource settings to insert ISO files into an empty CDROM device. > Examples: > InvokeMethod(ModifyResourceSettings): > ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "";\n};'] > InvokeMethod(ModifyResourceSettings): > ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "/var/lib/libvirt/images/test-disk.iso";\n};'] > Note that the Address property should be set to "", not None(not set), to tell that user want > an ejection. > > (#2) Add comments that saying what the code does, and improved some codes to avoid doing duplicated things. > > Signed-off-by: Wayne Xia > > diff -r db809376d763 -r afee8d9b7214 libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c Thu Jul 28 13:56:00 2011 -0300 > +++ b/libxkutil/device_parsing.c Fri Sep 16 14:24:35 2011 +0800 > @@ -287,6 +287,13 @@ > ddev->shareable = true; > } > } > + > + /* handle the situation that a cdrom device have no disk in it, no ISO file */ > + if ((XSTREQ(ddev->device, "cdrom"))&& (ddev->source == NULL)) { > + ddev->source = strdup(""); > + ddev->disk_type = DISK_FILE; > + } > + > if ((ddev->source == NULL) || (ddev->virtual_dev == NULL)) > goto err; > > diff -r db809376d763 -r afee8d9b7214 libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c Thu Jul 28 13:56:00 2011 -0300 > +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 > @@ -110,10 +110,18 @@ > xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache); > } > > - tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > - if (tmp == NULL) > - return XML_ERROR; > - xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); > + if ((XSTREQ(dev->device, "cdrom"))&& > + (XSTREQ(dev->source, ""))) { > + /* This is the situation that user defined a cdrom device without > + disk in it, so skip generating a line saying "source", for that > + xml defination for libvirt should not have this defined in this > + situation. */ > + } else { > + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); > + } > > tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); > if (tmp == NULL) > diff -r db809376d763 -r afee8d9b7214 src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Thu Jul 28 13:56:00 2011 -0300 > +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 2011 +0800 > @@ -879,6 +879,17 @@ > dev->dev.disk.device = strdup("disk"); > else if (type == VIRT_DISK_TYPE_CDROM) { > dev->dev.disk.device = strdup("cdrom"); > + /* following code is for the case that user defined cdrom device > + without disk in it, or a empty disk "" */ > + if (XSTREQ(dev->dev.disk.source, "")) { > + dev->dev.disk.disk_type = DISK_FILE; > + } > + if (XSTREQ(dev->dev.disk.source, "/dev/null")) { > + dev->dev.disk.disk_type = DISK_FILE; > + free(dev->dev.disk.source); > + dev->dev.disk.source = strdup(""); > + } > + > if (dev->dev.disk.disk_type == DISK_UNKNOWN) > dev->dev.disk.disk_type = DISK_PHY; > } > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Mon Oct 3 00:13:59 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Sun, 02 Oct 2011 20:13:59 -0400 Subject: [Libvirt-cim] [PATCH] (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: <4E88FDE5.50402@linux.vnet.ibm.com> References: <4E88FDE5.50402@linux.vnet.ibm.com> Message-ID: <4E88FE47.6070000@linux.vnet.ibm.com> Pushed. On 10/02/2011 08:12 PM, Chip Vincent wrote: > Tests for this have completed successfully, so ACK'ing. However... > Now that we have a cimtest patch for this > (https://www.redhat.com/archives/libvirt-cim/2011-September/msg00047.html), > I think a follow-up tweak may be order. For example, I'd prefer to > simply use NULL for 'no media' rather than a null_string to simplify the > code further. We should also already have the libvirt-cim and Pegasus > patches (no references, sorry) that allow us to un-set attributes like > this. That is, set an actual value to NULL. > > On 09/20/2011 11:14 PM, Wayne Xia wrote: >> # HG changeset patch >> # User Wayne Xia >> # Date 1316154275 -28800 >> # Node ID afee8d9b7214884ab74690b3ca9fd3d4f139f455 >> # Parent db809376d763493849c2a19f587969eaec619b75 >> (#2) Fix the problem that libvirt-cim can't find cdrom device that do >> not have disk >> >> This patch would allow define a system with an empty CDROM device, and >> allow method modify >> resource settings to insert ISO files into an empty CDROM device. >> Examples: >> InvokeMethod(ModifyResourceSettings): >> ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData >> {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = >> 1;\nVirtualDevice = "hdc";\nAddress = "";\n};'] >> InvokeMethod(ModifyResourceSettings): >> ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData >> {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = >> 1;\nVirtualDevice = "hdc";\nAddress = >> "/var/lib/libvirt/images/test-disk.iso";\n};'] >> Note that the Address property should be set to "", not None(not set), >> to tell that user want >> an ejection. >> >> (#2) Add comments that saying what the code does, and improved some >> codes to avoid doing duplicated things. >> >> Signed-off-by: Wayne Xia >> >> diff -r db809376d763 -r afee8d9b7214 libxkutil/device_parsing.c >> --- a/libxkutil/device_parsing.c Thu Jul 28 13:56:00 2011 -0300 >> +++ b/libxkutil/device_parsing.c Fri Sep 16 14:24:35 2011 +0800 >> @@ -287,6 +287,13 @@ >> ddev->shareable = true; >> } >> } >> + >> + /* handle the situation that a cdrom device have no disk in it, no >> ISO file */ >> + if ((XSTREQ(ddev->device, "cdrom"))&& (ddev->source == NULL)) { >> + ddev->source = strdup(""); >> + ddev->disk_type = DISK_FILE; >> + } >> + >> if ((ddev->source == NULL) || (ddev->virtual_dev == NULL)) >> goto err; >> >> diff -r db809376d763 -r afee8d9b7214 libxkutil/xmlgen.c >> --- a/libxkutil/xmlgen.c Thu Jul 28 13:56:00 2011 -0300 >> +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 >> @@ -110,10 +110,18 @@ >> xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache); >> } >> >> - tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); >> - if (tmp == NULL) >> - return XML_ERROR; >> - xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); >> + if ((XSTREQ(dev->device, "cdrom"))&& >> + (XSTREQ(dev->source, ""))) { >> + /* This is the situation that user defined a cdrom device without >> + disk in it, so skip generating a line saying "source", for that >> + xml defination for libvirt should not have this defined in this >> + situation. */ >> + } else { >> + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); >> + if (tmp == NULL) >> + return XML_ERROR; >> + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); >> + } >> >> tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); >> if (tmp == NULL) >> diff -r db809376d763 -r afee8d9b7214 >> src/Virt_VirtualSystemManagementService.c >> --- a/src/Virt_VirtualSystemManagementService.c Thu Jul 28 13:56:00 >> 2011 -0300 >> +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 >> 2011 +0800 >> @@ -879,6 +879,17 @@ >> dev->dev.disk.device = strdup("disk"); >> else if (type == VIRT_DISK_TYPE_CDROM) { >> dev->dev.disk.device = strdup("cdrom"); >> + /* following code is for the case that user defined cdrom device >> + without disk in it, or a empty disk "" */ >> + if (XSTREQ(dev->dev.disk.source, "")) { >> + dev->dev.disk.disk_type = DISK_FILE; >> + } >> + if (XSTREQ(dev->dev.disk.source, "/dev/null")) { >> + dev->dev.disk.disk_type = DISK_FILE; >> + free(dev->dev.disk.source); >> + dev->dev.disk.source = strdup(""); >> + } >> + >> if (dev->dev.disk.disk_type == DISK_UNKNOWN) >> dev->dev.disk.disk_type = DISK_PHY; >> } >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From bestor at us.ibm.com Mon Oct 3 02:47:44 2011 From: bestor at us.ibm.com (Gareth S Bestor) Date: Sun, 2 Oct 2011 19:47:44 -0700 Subject: [Libvirt-cim] [PATCH] (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: <4E88FDE5.50402@linux.vnet.ibm.com> Message-ID: >I think a follow-up tweak may be order. For example, I'd prefer to >simply use NULL for 'no media' rather than a null_string to simplify the >code further. FYI, libvirt-cim ModifyResourceSettings[] ignores properties in the modified RASD having no/null value when merging this 'new' instance with the existing one. Unfortuantely, this is a restriction from the DMTF SVPC profile itself. From DSP1042 System Virtualization Profile: "...The execution of the ModifyResourceSettings( ) method shall effect the modification of resource alloca- tions or resource allocation requests, such that non-key and non-NULL values of instances of the CIM_ResourceAllocationSettingData class provided as values for elements of the ResourceSettings[ ] ar- ray parameter override respective values in instances identified through the InstanceID property." - G Dr. Gareth S. Bestor IBM Senior Software Engineer Systems & Technology Group - Systems Management Standards 971-285-6375 (mobile) bestor at us.ibm.com Re: [Libvirt-cim] [PATCH] (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk Chip Vincent to: libvirt-cim 10/02/11 05:13 PM Sent by: libvirt-cim-bounces at redhat.com Please respond to cvincent, List for discussion and development of libvirt CIM Tests for this have completed successfully, so ACK'ing. However... Now that we have a cimtest patch for this (https://www.redhat.com/archives/libvirt-cim/2011-September/msg00047.html ), I think a follow-up tweak may be order. For example, I'd prefer to simply use NULL for 'no media' rather than a null_string to simplify the code further. We should also already have the libvirt-cim and Pegasus patches (no references, sorry) that allow us to un-set attributes like this. That is, set an actual value to NULL. On 09/20/2011 11:14 PM, Wayne Xia wrote: > # HG changeset patch > # User Wayne Xia > # Date 1316154275 -28800 > # Node ID afee8d9b7214884ab74690b3ca9fd3d4f139f455 > # Parent db809376d763493849c2a19f587969eaec619b75 > (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk > > This patch would allow define a system with an empty CDROM device, and allow method modify > resource settings to insert ISO files into an empty CDROM device. > Examples: > InvokeMethod(ModifyResourceSettings): > ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "";\n};'] > InvokeMethod(ModifyResourceSettings): > ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = 1;\nVirtualDevice = "hdc";\nAddress = "/var/lib/libvirt/images/test-disk.iso";\n};'] > Note that the Address property should be set to "", not None(not set), to tell that user want > an ejection. > > (#2) Add comments that saying what the code does, and improved some codes to avoid doing duplicated things. > > Signed-off-by: Wayne Xia > > diff -r db809376d763 -r afee8d9b7214 libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c Thu Jul 28 13:56:00 2011 -0300 > +++ b/libxkutil/device_parsing.c Fri Sep 16 14:24:35 2011 +0800 > @@ -287,6 +287,13 @@ > ddev->shareable = true; > } > } > + > + /* handle the situation that a cdrom device have no disk in it, no ISO file */ > + if ((XSTREQ(ddev->device, "cdrom"))&& (ddev->source == NULL)) { > + ddev->source = strdup(""); > + ddev->disk_type = DISK_FILE; > + } > + > if ((ddev->source == NULL) || (ddev->virtual_dev == NULL)) > goto err; > > diff -r db809376d763 -r afee8d9b7214 libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c Thu Jul 28 13:56:00 2011 -0300 > +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 > @@ -110,10 +110,18 @@ > xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache); > } > > - tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > - if (tmp == NULL) > - return XML_ERROR; > - xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); > + if ((XSTREQ(dev->device, "cdrom"))&& > + (XSTREQ(dev->source, ""))) { > + /* This is the situation that user defined a cdrom device without > + disk in it, so skip generating a line saying "source", for that > + xml defination for libvirt should not have this defined in this > + situation. */ > + } else { > + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); > + } > > tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); > if (tmp == NULL) > diff -r db809376d763 -r afee8d9b7214 src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Thu Jul 28 13:56:00 2011 -0300 > +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 2011 +0800 > @@ -879,6 +879,17 @@ > dev->dev.disk.device = strdup("disk"); > else if (type == VIRT_DISK_TYPE_CDROM) { > dev->dev.disk.device = strdup("cdrom"); > + /* following code is for the case that user defined cdrom device > + without disk in it, or a empty disk "" */ > + if (XSTREQ(dev->dev.disk.source, "")) { > + dev->dev.disk.disk_type = DISK_FILE; > + } > + if (XSTREQ(dev->dev.disk.source, "/dev/null")) { > + dev->dev.disk.disk_type = DISK_FILE; > + free(dev->dev.disk.source); > + dev->dev.disk.source = strdup(""); > + } > + > if (dev->dev.disk.disk_type == DISK_UNKNOWN) > dev->dev.disk.disk_type = DISK_PHY; > } > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com _______________________________________________ Libvirt-cim mailing list Libvirt-cim at redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From bestor at us.ibm.com Mon Oct 3 09:52:10 2011 From: bestor at us.ibm.com (Gareth S. Bestor) Date: Mon, 03 Oct 2011 02:52:10 -0700 Subject: [Libvirt-cim] [PATCH] Add support for libvirt CPU cgroup for active KVM guests Message-ID: <2c9a378e141c23eae0b9.1317635530@rhel6> # HG changeset patch # User Gareth S. Bestor # Date 1317635486 25200 # Node ID 2c9a378e141c23eae0b96b2f021adbd14cfb8ef2 # Parent fb09136deb494008eb3aacee420ad74da7d7c294 Add support for libvirt CPU cgroup for active KVM guests Add support for setting and retreiving the CPU cgroup setting for an active KVM guest using libivirt scheduling parameter support. Presently this patches only supports earlier libvirt versions' support of this feature, which only support setting these scheduling params for *active* guests only, and uses libivrt's earlier scheduling APIs; a subsequent patch will support both and the newer APIs (version dependent). A guest's CPU cgroup setting it exposed via the KVM_ProcResourceAllocationSettingData.Weight property. Minimum, maximum, Increment and Default weights are exposed appropriately via the respective Processor pool. Weight for new guest can be passed in on DefineSystem[] Weigh for existing (active) guest can be changed via ModifyResourceSettings[] Signed-off-by: Gareth S. Bestor diff -r fb09136deb49 -r 2c9a378e141c libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Tue Aug 30 08:48:36 2011 -0700 +++ b/libxkutil/device_parsing.c Mon Oct 03 02:51:26 2011 -0700 @@ -1297,6 +1297,24 @@ { int ret; + /* Change vcpu cgroup cpu_shares */ + if (dev->dev.vcpu.weight > 0) { + virSchedParameter param; + + strncpy(param.field, "cpu_shares", VIR_DOMAIN_SCHED_FIELD_LENGTH); + param.type = VIR_DOMAIN_SCHED_FIELD_ULLONG; + param.value.ul = dev->dev.vcpu.weight; + + if (virDomainSetSchedulerParameters(dom, ¶m, 1) != 0) { + CU_DEBUG("Failed to set scheduler params for domain"); + return 0; + } + + CU_DEBUG("Changed %s vcpu cgroup cpu_shares to %i", + virDomainGetName(dom), + dev->dev.vcpu.weight); + } + if (dev->dev.vcpu.quantity <= 0) { CU_DEBUG("Unable to set VCPU count to %i", dev->dev.vcpu.quantity); diff -r fb09136deb49 -r 2c9a378e141c src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_ComputerSystem.c Mon Oct 03 02:51:26 2011 -0700 @@ -858,6 +858,30 @@ return 0; } +static int kvm_scheduler_params(struct infostore_ctx *ctx, + virSchedParameter **params) +{ + unsigned long long value; + + *params = calloc(1, sizeof(virSchedParameter)); + if (*params == NULL) + return -1; + + value = infostore_get_u64(ctx, "weight"); + + if (value != 0) { + strncpy((*params)[0].field, + "cpu_shares", + VIR_DOMAIN_SCHED_FIELD_LENGTH); + (*params)[0].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; + (*params)[0].value.ul = value; + + return 1; + } + + return 0; +} + static void set_scheduler_params(virDomainPtr dom) { struct infostore_ctx *ctx; @@ -881,6 +905,8 @@ count = xen_scheduler_params(ctx, ¶ms); else if (STREQC(virConnectGetType(conn), "lxc")) count = lxc_scheduler_params(ctx, ¶ms); + else if (STREQC(virConnectGetType(conn), "QEMU")) + count = kvm_scheduler_params(ctx, ¶ms); else { CU_DEBUG("Not setting sched params for type %s", virConnectGetType(conn)); diff -r fb09136deb49 -r 2c9a378e141c src/Virt_RASD.c --- a/src/Virt_RASD.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_RASD.c Mon Oct 03 02:51:26 2011 -0700 @@ -110,7 +110,7 @@ virConnectPtr conn = NULL; virDomainPtr dom = NULL; struct infostore_ctx *info = NULL; - uint32_t weight; + uint32_t weight = 0; uint64_t limit; uint64_t count; @@ -147,7 +147,45 @@ goto out; } - weight = (uint32_t)infostore_get_u64(info, "weight"); + /* Currently only support CPU cgroups for running KVM guests */ + if (domain_online(dom) && STREQC(virConnectGetType(conn), "QEMU")) { + char *sched; + int nparams; + unsigned int i; + virSchedParameter *params; + + /* First find the number of scheduler params, in order malloc space for them all */ + sched = virDomainGetSchedulerType(dom, &nparams); + if (sched == NULL) { + CU_DEBUG("Failed to get scheduler type"); + goto out; + } + CU_DEBUG("domain has %d scheduler params", nparams); + free(sched); + + /* Now retrieve all the scheduler params for this domain */ + params = calloc(nparams, sizeof(virSchedParameter)); + if (virDomainGetSchedulerParameters(dom, params, &nparams) != 0) { + CU_DEBUG("Failed to get scheduler params for domain"); + goto out; + } + + /* Look for the CPU cgroup scheduler parameter, called 'cpu_shares' */ + for (i = 0 ; i < nparams ; i++) { + CU_DEBUG("scheduler param #%d name is %s (type %d)", + i, params[i].field, params[i].type); + if (STREQ(params[i].field, "cpu_shares") && + (params[i].type == VIR_DOMAIN_SCHED_FIELD_ULLONG)) { + CU_DEBUG("scheduler param %s = %d", + params[i].field, params[i].value.ul); + weight = (uint32_t)params[i].value.ul; + break; /* Found it! */ + } + } + free(params); + } + else + weight = (uint32_t)infostore_get_u64(info, "weight"); limit = infostore_get_u64(info, "limit"); CMSetProperty(inst, "Weight", diff -r fb09136deb49 -r 2c9a378e141c src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Mon Oct 03 02:51:26 2011 -0700 @@ -410,7 +410,10 @@ case SDC_RASD_MIN: num_procs = 0; limit = 1; - weight = MIN_XEN_WEIGHT; + if (STARTS_WITH(CLASSNAME(ref), "Xen")) + weight = MIN_XEN_WEIGHT; + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) + weight = MIN_KVM_WEIGHT; id = "Minimum"; break; case SDC_RASD_MAX: @@ -418,19 +421,28 @@ if (!ret) goto out; limit = 0; - weight = MAX_XEN_WEIGHT; + if (STARTS_WITH(CLASSNAME(ref), "Xen")) + weight = MAX_XEN_WEIGHT; + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) + weight = MAX_KVM_WEIGHT; id = "Maximum"; break; case SDC_RASD_INC: num_procs = 1; limit = 50; - weight = INC_XEN_WEIGHT; + if (STARTS_WITH(CLASSNAME(ref), "Xen")) + weight = INC_XEN_WEIGHT; + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) + weight = INC_KVM_WEIGHT; id = "Increment"; break; case SDC_RASD_DEF: num_procs = 1; limit = 0; - weight = DEFAULT_XEN_WEIGHT; + if (STARTS_WITH(CLASSNAME(ref), "Xen")) + weight = DEFAULT_XEN_WEIGHT; + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) + weight = DEFAULT_KVM_WEIGHT; id = "Default"; break; default: @@ -455,6 +467,10 @@ CMSetProperty(inst, "Weight", (CMPIValue *)&weight, CMPI_uint32); } + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) { + CMSetProperty(inst, "Weight", + (CMPIValue *)&weight, CMPI_uint32); + } inst_list_add(list, inst); diff -r fb09136deb49 -r 2c9a378e141c src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 03 02:51:26 2011 -0700 @@ -1012,6 +1012,8 @@ if (STARTS_WITH(CLASSNAME(op), "Xen")) def_weight = DEFAULT_XEN_WEIGHT; + else if (STARTS_WITH(CLASSNAME(op), "QEMU")) + def_weight = DEFAULT_KVM_WEIGHT; rc = cu_get_u64_prop(inst, "Limit", &dev->dev.vcpu.limit); if (rc != CMPI_RC_OK) diff -r fb09136deb49 -r 2c9a378e141c src/Virt_VirtualSystemManagementService.h --- a/src/Virt_VirtualSystemManagementService.h Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_VirtualSystemManagementService.h Mon Oct 03 02:51:26 2011 -0700 @@ -24,6 +24,11 @@ #define INC_XEN_WEIGHT MAX_XEN_WEIGHT / 2 #define DEFAULT_XEN_WEIGHT 1024 +#define MIN_KVM_WEIGHT 2 +#define MAX_KVM_WEIGHT 262144 +#define INC_KVM_WEIGHT 1 +#define DEFAULT_KVM_WEIGHT 1024 + CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker, From snmishra at us.ibm.com Mon Oct 3 17:23:55 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 3 Oct 2011 10:23:55 -0700 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid extra connection to libvirt In-Reply-To: <4E88BE55.2040301@linux.vnet.ibm.com> References: <4E88BE55.2040301@linux.vnet.ibm.com> Message-ID: libvirt-cim-bounces at redhat.com wrote on 10/02/2011 12:41:09 PM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 10/02/11 12:41 PM > > Please respond to > cvincent at linux.vnet.ibm.com; Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > Re: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid > extra connection to libvirt > > Actually, this change only prevents a 'nested' connection. There are > still 2 connects; one in update_dominfo() and one in _resource_dynamic(). There should not be 2 connects here. One connection will be created in update_dominfo which will be closed on exiting that function and a new one created later in _resource_dynamic(). > > Also, moving the call to update_dominfo() up negates the check > done by the code block that begins with > 'dom = virDomainLookupByName(conn, dominfo->name);' There is a similar check in update_dominfo too. In my opinion this patch makes sense. -Sharad Mishra > > I don't see the real value of the change. Am I missing something? > > On 09/28/2011 04:44 PM, Eduardo Lima (Etrunko) wrote: > > src/Virt_VirtualSystemManagementService.c | 4 ++-- > > 1 files changed, 2 insertions(+), 2 deletions(-) > > > > > > # HG changeset patch > > # User Eduardo Lima (Etrunko) > > # Date 1317242639 10800 > > # Node ID e02b7fef37d7f1f6a18d68991dc1409eef8905ec > > # Parent 942e9fa22bcb2681884cb39e1dcfc459c67ce197 > > VirtualSystemManagementService: Avoid extra connection to libvirt > > > > Function update_device_info() has been called in after a creating > a connection > > to libvirt, while the itself creates a new connection. Moving the > function call > > a few lines above adresses this issue. > > > > Signed-off-by: Eduardo Lima (Etrunko) > > > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -2331,6 +2331,8 @@ > > return s; > > } > > > > + update_dominfo(dominfo, refcn); > > + > > conn = connect_by_classname(_BROKER, refcn,&s); > > if (conn == NULL) { > > CU_DEBUG("Failed to connect"); > > @@ -2347,8 +2349,6 @@ > > goto out; > > } > > > > - update_dominfo(dominfo, refcn); > > - > > if (!domain_online(dom)) { > > CU_DEBUG("VS `%s' not online; skipping dynamic update", > > dominfo->name); > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- > Chip Vincent > Open Virtualization > IBM Linux Technology Center > cvincent at linux.vnet.ibm.com > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From snmishra at us.ibm.com Wed Oct 5 19:11:51 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 05 Oct 2011 12:11:51 -0700 Subject: [Libvirt-cim] [PATCH] Pool names with space do not get parsed properly Message-ID: <8f5d112e4aea945d09c6.1317841911@elm3b151.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1317836416 25200 # Node ID 8f5d112e4aea945d09c6120c6cea2817592d08aa # Parent 1f93220799a57477a6b1e04a90e8ffe797d85581 Pool names with space do not get parsed properly. This patch fixes the issue where a disk pool with space in its name does not get parsed correctly. Signed-off-by: Sharad Mishra diff -r 1f93220799a5 -r 8f5d112e4aea src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Fri Sep 16 14:24:35 2011 +0800 +++ b/src/Virt_DevicePool.c Wed Oct 05 10:40:16 2011 -0700 @@ -1281,7 +1281,7 @@ goto out; } - ret = sscanf(id, "%*[^/]/%as", &poolid); + ret = sscanf(id, "%*[^/]/%a[^\n]", &poolid); if (ret != 1) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, From eblima at linux.vnet.ibm.com Thu Oct 6 15:46:33 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 12:46:33 -0300 Subject: [Libvirt-cim] [PATCH 0 of 4] Various fixes to FilterEntry provider Message-ID: [1/4] acl_parsing: Share code for icmp and icmp rule types The struct for both ICMP and IGMP rule types have the exact same fields. With this patch, we avoid duplicating code to handle those rules. [2/4] FilterEntry: Should be using srcipaddr instead of srcmacaddr [3/4] FilterEntry: Support for mask in CIDR notation The values for mask fields may have been written using the CIDR notation[1]. For instance, take the libvirt 'no-ip-multicast' builtin filter: 47756f11-6057-1448-2cce-fda40fa23ba4 As libvirt-cim expects an address like string, for the mask, in this case the conversion will fail and will output an array with only zero values [0,0,0,0], when it actually should be [240,0,0,0]. [1] http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing [4/4] FilterEntry: Fix behavior of convert_ip_rule_to_instance The function was always referencing the 'tcp' fileld of the var union in struct acl_rule, while it should take into account the rule type to access the correct fields. This could probably go to acl_parsing, but I thought it would be a less intrusive change to patch only FilterEntry provider. Signed-off-by: Eduardo Lima (Etrunko) libxkutil/acl_parsing.c | 119 ++++++++++------------------------ libxkutil/acl_parsing.h | 29 +------- src/Virt_FilterEntry.c | 3 +- src/Virt_FilterEntry.c | 2 +- src/Virt_FilterEntry.c | 88 +++++++++++++++++++++---- src/Virt_FilterEntry.c | 162 +++++++++++++++++++++++++++++++++++++---------- 6 files changed, 242 insertions(+), 161 deletions(-) From eblima at linux.vnet.ibm.com Thu Oct 6 15:46:35 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 12:46:35 -0300 Subject: [Libvirt-cim] [PATCH 2 of 4] FilterEntry: Should be using srcipaddr instead of srcmacaddr In-Reply-To: References: Message-ID: src/Virt_FilterEntry.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1317912440 10800 # Node ID a323895be993b3807cc41348ba3b74c76fb42596 # Parent fa576f11a652c4632afb62c687707effb2e98a80 FilterEntry: Should be using srcipaddr instead of srcmacaddr Signed-off-by: Eduardo Lima (Etrunko) diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -238,7 +238,7 @@ (CMPIValue *)&array, CMPI_uint8A); } else { memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.srcmacaddr, + size = octets_from_ip(rule->var.tcp.srcipaddr, bytes, sizeof(bytes)); array = octets_to_cmpi(broker, bytes, size); From eblima at linux.vnet.ibm.com Thu Oct 6 15:46:37 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 12:46:37 -0300 Subject: [Libvirt-cim] [PATCH 4 of 4] FilterEntry: Fix behavior of convert_ip_rule_to_instance In-Reply-To: References: Message-ID: src/Virt_FilterEntry.c | 162 ++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 126 insertions(+), 36 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1317915956 10800 # Node ID e6c6f9ccb51303f67fce26e74de9ab746d10a04b # Parent 1a08d8186f3064dfb0c38ecb5846ffc1e7d5de4d FilterEntry: Fix behavior of convert_ip_rule_to_instance The function was always referencing the 'tcp' fileld of the var union in struct acl_rule, while it should take into account the rule type to access the correct fields. This could probably go to acl_parsing, but I thought it would be a less intrusive change to patch only FilterEntry provider. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -35,6 +35,27 @@ #include "Virt_HostSystem.h" const static CMPIBroker *_BROKER; +struct rule_data_t { + const char *srcmacaddr; + const char *srcmacmask; + const char *dstmacaddr; + const char *dstmacmask; + + const char *srcipaddr; + const char *srcipmask; + const char *dstipaddr; + const char *dstipmask; + + const char *srcipfrom; + const char *srcipto; + const char *dstipfrom; + const char *dstipto; + + const char *srcportstart; + const char *srcportend; + const char *dstportstart; + const char *dstportend; +}; static int octets_from_mac(const char * s, unsigned int *buffer, unsigned int size) @@ -239,6 +260,75 @@ (CMPIValue *)&array, CMPI_uint8A); } +static void fill_rule_data(struct acl_rule *rule, + struct rule_data_t *data) +{ + if (rule == NULL || data == NULL) + return; + + memset(data, 0, sizeof(*data)); + + switch (rule->type) { + case IP_RULE: + data->srcmacaddr = rule->var.ip.srcmacaddr; + data->srcmacmask = rule->var.ip.srcmacmask; + data->dstmacaddr = rule->var.ip.srcmacaddr; + data->dstmacmask = rule->var.ip.dstmacmask; + + data->srcipaddr = rule->var.ip.srcipaddr; + data->srcipmask = rule->var.ip.srcipmask; + data->dstipaddr = rule->var.ip.dstipaddr; + data->dstipmask = rule->var.ip.dstipmask; + + data->srcportstart = rule->var.ip.srcportstart; + data->srcportend = rule->var.ip.srcportend; + data->dstportstart = rule->var.ip.dstportstart; + data->dstportend = rule->var.ip.dstportend; + break; + + case TCP_RULE: + data->srcmacaddr = rule->var.tcp.srcmacaddr; + + data->srcipaddr = rule->var.tcp.srcipaddr; + data->srcipmask = rule->var.tcp.srcipmask; + data->dstipaddr = rule->var.tcp.dstipaddr; + data->dstipmask = rule->var.tcp.dstipmask; + + data->srcipfrom = rule->var.tcp.srcipfrom; + data->srcipto = rule->var.tcp.srcipto; + data->dstipfrom = rule->var.tcp.dstipfrom; + data->dstipto = rule->var.tcp.dstipto; + + data->srcportstart = rule->var.tcp.srcportstart; + data->srcportend = rule->var.tcp.srcportend; + data->dstportstart = rule->var.tcp.dstportstart; + data->dstportend = rule->var.tcp.dstportend; + break; + + case ICMP_IGMP_RULE: + data->srcmacaddr = rule->var.icmp_igmp.srcmacaddr; + data->srcmacmask = rule->var.icmp_igmp.srcmacmask; + data->dstmacaddr = rule->var.icmp_igmp.srcmacaddr; + data->dstmacmask = rule->var.icmp_igmp.dstmacmask; + + data->srcipaddr = rule->var.icmp_igmp.srcipaddr; + data->srcipmask = rule->var.icmp_igmp.srcipmask; + data->dstipaddr = rule->var.icmp_igmp.dstipaddr; + data->dstipmask = rule->var.icmp_igmp.dstipmask; + + data->srcipfrom = rule->var.icmp_igmp.srcipfrom; + data->srcipto = rule->var.icmp_igmp.srcipto; + data->dstipfrom = rule->var.icmp_igmp.dstipfrom; + data->dstipto = rule->var.icmp_igmp.dstipto; + break; + + default: + CU_DEBUG("%s(): unhandled rule type '%d'", + __FUNCTION__, rule->type); + break; + } +} + static void convert_ip_rule_to_instance( struct acl_rule *rule, CMPIInstance *inst, @@ -248,6 +338,7 @@ unsigned int size = 0; unsigned int n = 0; CMPIArray *array = NULL; + struct rule_data_t rule_data; if (strstr(rule->protocol_id, "v6")) n = 6; @@ -256,9 +347,11 @@ CMSetProperty(inst, "HdrIPVersion",(CMPIValue *)&n, CMPI_uint8); - if (rule->var.tcp.srcipfrom && rule->var.tcp.srcipto) { + fill_rule_data(rule, &rule_data); + + if (rule_data.srcipfrom && rule_data.srcipto) { memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.srcipfrom, + size = octets_from_ip(rule_data.srcipfrom, bytes, sizeof(bytes)); array = octets_to_cmpi(broker, bytes, size); @@ -267,7 +360,7 @@ (CMPIValue *)&array, CMPI_uint8A); memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.srcipto, + size = octets_from_ip(rule_data.srcipto, bytes, sizeof(bytes)); array = octets_to_cmpi(broker, bytes, size); @@ -276,7 +369,7 @@ (CMPIValue *)&array, CMPI_uint8A); } else { memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.srcipaddr, + size = octets_from_ip(rule_data.srcipaddr, bytes, sizeof(bytes)); array = octets_to_cmpi(broker, bytes, size); @@ -285,8 +378,8 @@ (CMPIValue *)&array, CMPI_uint8A); /* CIDR notation? */ - if (rule->var.tcp.srcipmask) { - char *netmask = strdup(rule->var.tcp.srcipmask); + if (rule_data.srcipmask) { + char *netmask = strdup(rule_data.srcipmask); if (strstr(netmask, ".") == NULL) { char *tmp = cidr_to_str(netmask); free(netmask); @@ -305,9 +398,9 @@ } } - if (rule->var.tcp.dstipfrom && rule->var.tcp.dstipto) { + if (rule_data.dstipfrom && rule_data.dstipto) { memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.dstipfrom, + size = octets_from_ip(rule_data.dstipfrom, bytes, sizeof(bytes)); array = octets_to_cmpi(broker, bytes, size); @@ -316,7 +409,7 @@ (CMPIValue *)&array, CMPI_uint8A); memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.dstipto, + size = octets_from_ip(rule_data.dstipto, bytes, sizeof(bytes)); array = octets_to_cmpi(broker, bytes, size); @@ -325,7 +418,7 @@ (CMPIValue *)&array, CMPI_uint8A); } else { memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.dstipaddr, + size = octets_from_ip(rule_data.dstipaddr, bytes, sizeof(bytes)); array = octets_to_cmpi(broker, bytes, size); @@ -334,8 +427,8 @@ (CMPIValue *)&array, CMPI_uint8A); /* CIDR notation? */ - if (rule->var.tcp.dstipmask) { - char *netmask = strdup(rule->var.tcp.dstipmask); + if (rule_data.dstipmask) { + char *netmask = strdup(rule_data.dstipmask); if (strstr(netmask, ".") == NULL) { char *tmp = cidr_to_str(netmask); free(netmask); @@ -354,32 +447,29 @@ } } - if ((rule->type == IP_RULE) || (rule->type == TCP_RULE)) { - if (rule->var.tcp.srcportstart) { - n = atoi(rule->var.tcp.srcportstart); - CMSetProperty(inst, "HdrSrcPortStart", - (CMPIValue *)&n, CMPI_uint16); - } - - if (rule->var.tcp.srcportend) { - n = atoi(rule->var.tcp.srcportend); - CMSetProperty(inst, "HdrSrcPortEnd", - (CMPIValue *)&n, CMPI_uint16); - } - - if (rule->var.tcp.dstportstart) { - n = atoi(rule->var.tcp.dstportstart); - CMSetProperty(inst, "HdrDestPortStart", - (CMPIValue *)&n, CMPI_uint16); - } - - if (rule->var.tcp.dstportend) { - n = atoi(rule->var.tcp.dstportend); - CMSetProperty(inst, "HdrDestPortEnd", - (CMPIValue *)&n, CMPI_uint16); - } + if (rule_data.srcportstart) { + n = atoi(rule_data.srcportstart); + CMSetProperty(inst, "HdrSrcPortStart", + (CMPIValue *)&n, CMPI_uint16); } + if (rule_data.srcportend) { + n = atoi(rule_data.srcportend); + CMSetProperty(inst, "HdrSrcPortEnd", + (CMPIValue *)&n, CMPI_uint16); + } + + if (rule_data.dstportstart) { + n = atoi(rule_data.dstportstart); + CMSetProperty(inst, "HdrDestPortStart", + (CMPIValue *)&n, CMPI_uint16); + } + + if (rule_data.dstportend) { + n = atoi(rule_data.dstportend); + CMSetProperty(inst, "HdrDestPortEnd", + (CMPIValue *)&n, CMPI_uint16); + } } static CMPIInstance *convert_rule_to_instance( From eblima at linux.vnet.ibm.com Thu Oct 6 15:46:36 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 12:46:36 -0300 Subject: [Libvirt-cim] [PATCH 3 of 4] FilterEntry: Support for mask in CIDR notation In-Reply-To: References: Message-ID: <1a08d8186f3064dfb0c3.1317915996@eblima.br.ibm.com> src/Virt_FilterEntry.c | 88 ++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 74 insertions(+), 14 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1317914740 10800 # Node ID 1a08d8186f3064dfb0c38ecb5846ffc1e7d5de4d # Parent a323895be993b3807cc41348ba3b74c76fb42596 FilterEntry: Support for mask in CIDR notation The values for mask fields may have been written using the CIDR notation[1]. For instance, take the libvirt 'no-ip-multicast' builtin filter: 47756f11-6057-1448-2cce-fda40fa23ba4 As libvirt-cim expects an address like string, for the mask, in this case the conversion will fail and will output an array with only zero values [0,0,0,0], when it actually should be [240,0,0,0]. [1] http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing Signed-off-by: Eduardo Lima (Etrunko) diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -115,6 +115,44 @@ return array; } +static char *cidr_to_str(const char *cidr) +{ + char *ret = NULL; + int val; + unsigned int o1, o2, o3, o4; + + if (cidr == NULL || strlen(cidr) == 0) + return NULL; + + CU_DEBUG("Enter %s(%s)", __FUNCTION__, cidr); + + /* String value to integer */ + val = atoi(cidr); + if (val < 0 || val > 32) + return NULL; + + if (val == 0) + return strdup("0.0.0.0"); + else if (val == 32) + return strdup("255.255.255.255"); + + /* CIDR to bits */ + val = (0xffffffff >> (32 - val)) << (32 - val); + + /* bits to octets */ + o1 = (val & 0xff000000) >> 24; + o2 = (val & 0x00ff0000) >> 16; + o3 = (val & 0x0000ff00) >> 8; + o4 = val & 0x000000ff; + + /* octets to address string */ + ret = calloc(1, sizeof(*ret) * 16); + snprintf(ret, 16, "%u.%u.%u.%u", o1, o2, o3, o4); + + CU_DEBUG("%s: returning '%s'", __FUNCTION__, ret); + return ret; +} + static int convert_direction(const char *s) { enum {NOT_APPLICABLE, INPUT, OUTPUT, BOTH} direction = NOT_APPLICABLE; @@ -246,14 +284,25 @@ CMSetProperty(inst, "HdrSrcAddress", (CMPIValue *)&array, CMPI_uint8A); - memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.srcipmask, - bytes, sizeof(bytes)); + /* CIDR notation? */ + if (rule->var.tcp.srcipmask) { + char *netmask = strdup(rule->var.tcp.srcipmask); + if (strstr(netmask, ".") == NULL) { + char *tmp = cidr_to_str(netmask); + free(netmask); + netmask = tmp; + } - array = octets_to_cmpi(broker, bytes, size); - if (array != NULL) - CMSetProperty(inst, "HdrSrcMask", - (CMPIValue *)&array, CMPI_uint8A); + memset(bytes, 0, sizeof(bytes)); + size = octets_from_ip(netmask, bytes, sizeof(bytes)); + + array = octets_to_cmpi(broker, bytes, size); + if (array != NULL) + CMSetProperty(inst, "HdrSrcMask", + (CMPIValue *)&array, CMPI_uint8A); + + free(netmask); + } } if (rule->var.tcp.dstipfrom && rule->var.tcp.dstipto) { @@ -284,14 +333,25 @@ CMSetProperty(inst, "HdrDestAddress", (CMPIValue *)&array, CMPI_uint8A); - memset(bytes, 0, sizeof(bytes)); - size = octets_from_ip(rule->var.tcp.dstipmask, - bytes, sizeof(bytes)); + /* CIDR notation? */ + if (rule->var.tcp.dstipmask) { + char *netmask = strdup(rule->var.tcp.dstipmask); + if (strstr(netmask, ".") == NULL) { + char *tmp = cidr_to_str(netmask); + free(netmask); + netmask = tmp; + } - array = octets_to_cmpi(broker, bytes, size); - if (array != NULL) - CMSetProperty(inst, "HdrDestMask", - (CMPIValue *)&array, CMPI_uint8A); + memset(bytes, 0, sizeof(bytes)); + size = octets_from_ip(netmask, bytes, sizeof(bytes)); + + array = octets_to_cmpi(broker, bytes, size); + if (array != NULL) + CMSetProperty(inst, "HdrDestMask", + (CMPIValue *)&array, CMPI_uint8A); + + free(netmask); + } } if ((rule->type == IP_RULE) || (rule->type == TCP_RULE)) { From eblima at linux.vnet.ibm.com Thu Oct 6 15:46:34 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 12:46:34 -0300 Subject: [Libvirt-cim] [PATCH 1 of 4] acl_parsing: Share code for icmp and icmp rule types In-Reply-To: References: Message-ID: libxkutil/acl_parsing.c | 119 ++++++++++++++--------------------------------- libxkutil/acl_parsing.h | 29 +---------- src/Virt_FilterEntry.c | 3 +- 3 files changed, 41 insertions(+), 110 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1317840215 10800 # Node ID fa576f11a652c4632afb62c687707effb2e98a80 # Parent 1f93220799a57477a6b1e04a90e8ffe797d85581 acl_parsing: Share code for icmp and icmp rule types The struct for both ICMP and IGMP rule types have the exact same fields. With this patch, we avoid duplicating code to handle those rules. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c --- a/libxkutil/acl_parsing.c +++ b/libxkutil/acl_parsing.c @@ -97,41 +97,23 @@ free(rule->var.tcp.comment); free(rule->var.tcp.state); break; - case IGMP_RULE: - free(rule->var.igmp.srcmacaddr); - free(rule->var.igmp.srcmacmask); - free(rule->var.igmp.dstmacaddr); - free(rule->var.igmp.dstmacmask); - free(rule->var.igmp.srcipaddr); - free(rule->var.igmp.srcipmask); - free(rule->var.igmp.dstipaddr); - free(rule->var.igmp.dstipmask); - free(rule->var.igmp.srcipfrom); - free(rule->var.igmp.srcipto); - free(rule->var.igmp.dstipfrom); - free(rule->var.igmp.dstipto); - free(rule->var.igmp.type); - free(rule->var.igmp.code); - free(rule->var.igmp.comment); - free(rule->var.igmp.state); - break; - case ICMP_RULE: - free(rule->var.icmp.srcmacaddr); - free(rule->var.icmp.srcmacmask); - free(rule->var.icmp.dstmacaddr); - free(rule->var.icmp.dstmacmask); - free(rule->var.icmp.srcipaddr); - free(rule->var.icmp.srcipmask); - free(rule->var.icmp.dstipaddr); - free(rule->var.icmp.dstipmask); - free(rule->var.icmp.srcipfrom); - free(rule->var.icmp.srcipto); - free(rule->var.icmp.dstipfrom); - free(rule->var.icmp.dstipto); - free(rule->var.icmp.type); - free(rule->var.icmp.code); - free(rule->var.icmp.comment); - free(rule->var.icmp.state); + case ICMP_IGMP_RULE: + free(rule->var.icmp_igmp.srcmacaddr); + free(rule->var.icmp_igmp.srcmacmask); + free(rule->var.icmp_igmp.dstmacaddr); + free(rule->var.icmp_igmp.dstmacmask); + free(rule->var.icmp_igmp.srcipaddr); + free(rule->var.icmp_igmp.srcipmask); + free(rule->var.icmp_igmp.dstipaddr); + free(rule->var.icmp_igmp.dstipmask); + free(rule->var.icmp_igmp.srcipfrom); + free(rule->var.icmp_igmp.srcipto); + free(rule->var.icmp_igmp.dstipfrom); + free(rule->var.icmp_igmp.dstipto); + free(rule->var.icmp_igmp.type); + free(rule->var.icmp_igmp.code); + free(rule->var.icmp_igmp.comment); + free(rule->var.icmp_igmp.state); break; case UNKNOWN_RULE: default: @@ -265,50 +247,25 @@ return 1; } -static int parse_acl_icmp_rule(xmlNode *rnode, struct acl_rule *rule) +static int parse_acl_icmp_igmp_rule(xmlNode *rnode, struct acl_rule *rule) { - CU_DEBUG("ACL icmp rule %s", rnode->name); + CU_DEBUG("ACL %s rule %s", rule->protocol_id, rnode->name); - rule->type = ICMP_RULE; - rule->var.icmp.srcmacaddr = get_attr_value(rnode, "srcmacaddr"); - rule->var.icmp.srcmacmask = get_attr_value(rnode, "srcmacmask"); - rule->var.icmp.dstmacaddr = get_attr_value(rnode, "dstmacaddr"); - rule->var.icmp.dstmacmask = get_attr_value(rnode, "dstmacmask"); - rule->var.icmp.srcipaddr = get_attr_value(rnode, "srcipaddr"); - rule->var.icmp.srcipmask = get_attr_value(rnode, "srcipmask"); - rule->var.icmp.dstipaddr = get_attr_value(rnode, "dstipaddr"); - rule->var.icmp.dstipmask = get_attr_value(rnode, "dstipmask"); - rule->var.icmp.srcipfrom = get_attr_value(rnode, "srcipfrom"); - rule->var.icmp.srcipto = get_attr_value(rnode, "srcipto"); - rule->var.icmp.dstipfrom = get_attr_value(rnode, "dstipfrom"); - rule->var.icmp.dstipto = get_attr_value(rnode, "dstipto"); - rule->var.icmp.comment = get_attr_value(rnode, "comment"); - rule->var.icmp.state = get_attr_value(rnode, "state"); - - return 1; -} - -static int parse_acl_igmp_rule(xmlNode *rnode, struct acl_rule *rule) -{ - CU_DEBUG("ACL igmp rule %s", rnode->name); - - rule->type = IGMP_RULE; - rule->var.igmp.srcmacaddr = get_attr_value(rnode, "srcmacaddr"); - rule->var.igmp.srcmacmask = get_attr_value(rnode, "srcmacmask"); - rule->var.igmp.dstmacaddr = get_attr_value(rnode, "dstmacaddr"); - rule->var.igmp.dstmacmask = get_attr_value(rnode, "dstmacmask"); - rule->var.igmp.srcipaddr = get_attr_value(rnode, "srcipaddr"); - rule->var.igmp.srcipmask = get_attr_value(rnode, "srcipmask"); - rule->var.igmp.dstipaddr = get_attr_value(rnode, "dstipaddr"); - rule->var.igmp.dstipmask = get_attr_value(rnode, "dstipmask"); - rule->var.igmp.srcipfrom = get_attr_value(rnode, "srcipfrom"); - rule->var.igmp.srcipto = get_attr_value(rnode, "srcipto"); - rule->var.igmp.dstipfrom = get_attr_value(rnode, "dstipfrom"); - rule->var.igmp.dstipto = get_attr_value(rnode, "dstipto"); - rule->var.igmp.type = get_attr_value(rnode, "type"); - rule->var.igmp.code = get_attr_value(rnode, "code"); - rule->var.igmp.comment = get_attr_value(rnode, "comment"); - rule->var.igmp.state = get_attr_value(rnode, "state"); + rule->type = ICMP_IGMP_RULE; + rule->var.icmp_igmp.srcmacaddr = get_attr_value(rnode, "srcmacaddr"); + rule->var.icmp_igmp.srcmacmask = get_attr_value(rnode, "srcmacmask"); + rule->var.icmp_igmp.dstmacaddr = get_attr_value(rnode, "dstmacaddr"); + rule->var.icmp_igmp.dstmacmask = get_attr_value(rnode, "dstmacmask"); + rule->var.icmp_igmp.srcipaddr = get_attr_value(rnode, "srcipaddr"); + rule->var.icmp_igmp.srcipmask = get_attr_value(rnode, "srcipmask"); + rule->var.icmp_igmp.dstipaddr = get_attr_value(rnode, "dstipaddr"); + rule->var.icmp_igmp.dstipmask = get_attr_value(rnode, "dstipmask"); + rule->var.icmp_igmp.srcipfrom = get_attr_value(rnode, "srcipfrom"); + rule->var.icmp_igmp.srcipto = get_attr_value(rnode, "srcipto"); + rule->var.icmp_igmp.dstipfrom = get_attr_value(rnode, "dstipfrom"); + rule->var.icmp_igmp.dstipto = get_attr_value(rnode, "dstipto"); + rule->var.icmp_igmp.comment = get_attr_value(rnode, "comment"); + rule->var.icmp_igmp.state = get_attr_value(rnode, "state"); return 1; } @@ -351,10 +308,8 @@ rule->protocol_id = strdup((char *)child->name); parse_acl_tcp_rule(child, rule); } else if (XSTREQ(child->name, "icmp") || - XSTREQ(child->name, "icmpv6")) { - rule->protocol_id = strdup((char *)child->name); - parse_acl_icmp_rule(child, rule); - } else if (XSTREQ(child->name, "igmp") || + XSTREQ(child->name, "icmpv6") || + XSTREQ(child->name, "igmp") || XSTREQ(child->name, "igmp-ipv6") || XSTREQ(child->name, "esp") || XSTREQ(child->name, "esp-ipv6") || @@ -365,7 +320,7 @@ XSTREQ(child->name, "all") || XSTREQ(child->name, "all-ipv6")) { rule->protocol_id = strdup((char *)child->name); - parse_acl_igmp_rule(child, rule); + parse_acl_icmp_igmp_rule(child, rule); } } diff --git a/libxkutil/acl_parsing.h b/libxkutil/acl_parsing.h --- a/libxkutil/acl_parsing.h +++ b/libxkutil/acl_parsing.h @@ -95,7 +95,7 @@ char *state; }; -struct acl_igmp_rule { +struct acl_icmp_igmp_rule { char *srcmacaddr; char *srcmacmask; char *dstmacaddr; @@ -117,27 +117,6 @@ char *state; }; -struct acl_icmp_rule { - char *srcmacaddr; - char *srcmacmask; - char *dstmacaddr; - char *dstmacmask; - - char *srcipaddr; - char *srcipmask; - char *dstipaddr; - char *dstipmask; - - char *srcipfrom; - char *srcipto; - char *dstipfrom; - char *dstipto; - - char *type; - char *code; - char *comment; - char *state; -}; struct acl_rule { char *name; @@ -153,8 +132,7 @@ ARP_RULE, IP_RULE, TCP_RULE, - ICMP_RULE, - IGMP_RULE + ICMP_IGMP_RULE, } type; union { @@ -162,8 +140,7 @@ struct acl_arp_rule arp; struct acl_ip_rule ip; struct acl_tcp_rule tcp; - struct acl_icmp_rule icmp; - struct acl_igmp_rule igmp; + struct acl_icmp_igmp_rule icmp_igmp; } var; }; diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -348,8 +348,7 @@ break; case IP_RULE: case TCP_RULE: - case ICMP_RULE: - case IGMP_RULE: + case ICMP_IGMP_RULE: basename = "IPHeadersFilter"; convert_f = convert_ip_rule_to_instance; break; From eblima at linux.vnet.ibm.com Thu Oct 6 19:48:39 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 16:48:39 -0300 Subject: [Libvirt-cim] [PATCH] FilterEntry: Set HdrProtocolID8021 property Message-ID: <8384b32b9a79999bcf3c.1317930519@eblima.br.ibm.com> src/Virt_FilterEntry.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1317929569 10800 # Node ID 8384b32b9a79999bcf3c414d94bc18789b6d9318 # Parent e6c6f9ccb51303f67fce26e74de9ab746d10a04b FilterEntry: Set HdrProtocolID8021 property Also remove a couple of duplicate (CMPIValue *) casts. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -27,6 +27,8 @@ #include +#include + #include "acl_parsing.h" #include "misc_util.h" #include "xmlgen.h" @@ -247,7 +249,7 @@ array = octets_to_cmpi(broker, bytes, size); if (array != NULL) - CMSetProperty(inst, "HdrDestMACAddr8021", (CMPIValue *) + CMSetProperty(inst, "HdrDestMACAddr8021", (CMPIValue *)&array, CMPI_uint8A); memset(bytes, 0, sizeof(bytes)); @@ -256,8 +258,16 @@ array = octets_to_cmpi(broker, bytes, size); if (array != NULL) - CMSetProperty(inst, "HdrDestMACMask8021", (CMPIValue *) + CMSetProperty(inst, "HdrDestMACMask8021", (CMPIValue *)&array, CMPI_uint8A); + + if (rule->var.mac.protocol_id != NULL) { + unsigned long n = strtoul(rule->var.mac.protocol_id, + NULL, 16); + CMSetProperty(inst, "HdrProtocolID8021", + (CMPIValue *)&n, CMPI_uint16); + } + } static void fill_rule_data(struct acl_rule *rule, From eblima at linux.vnet.ibm.com Thu Oct 6 20:11:40 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 17:11:40 -0300 Subject: [Libvirt-cim] [PATCH] [TEST] Adding tests for FilterLists Message-ID: suites/libvirt-cim/cimtest/FilterList/01_enum.py | 71 ++ suites/libvirt-cim/cimtest/FilterList/02_assoc.py | 158 ++++++ suites/libvirt-cim/cimtest/FilterList/03_create.py | 199 ++++++++ suites/libvirt-cim/cimtest/FilterList/helper.py | 515 +++++++++++++++++++++ 4 files changed, 943 insertions(+), 0 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1310498051 10800 # Node ID d9741a8b5eb7ccebf21d69f3cde72729bb60ad22 # Parent 779871660a3583dedf1652773196d07093ff26ff [TEST] Adding tests for FilterLists helper.py: - Helper module with classes and functions used by all tests 01_enum.py: - Enumerate FilterList instances and compare to results from libvirt 02_assoc.py: - For each FilterList instance, call Associators to get respective FilterEntries instances and compare to results from libvirt 03_create.py: - Creates a new FilterList instance and a NestedFilterList associated to this new instance. Creates a new domain and a new AppliedFilterList instance associated to the NetworkPort instance of that new domain. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/suites/libvirt-cim/cimtest/FilterList/01_enum.py b/suites/libvirt-cim/cimtest/FilterList/01_enum.py new file mode 100644 --- /dev/null +++ b/suites/libvirt-cim/cimtest/FilterList/01_enum.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Eduardo Lima (Etrunko) +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# +# CIMTest Filter Lists Enumerate +# + +import sys +import helper + +from CimTest.ReturnCodes import PASS, FAIL +from CimTest.Globals import logger +from XenKvmLib.const import do_main + +sup_types = ["KVM",] + + at do_main(sup_types) +def main(): + options = main.options + + _test = helper.FilterListTest(options.ip, options.virt) + + # Fetch current filters with libvirt + libvirt_filters = _test.libvirt_filter_lists() + if not libvirt_filters: + return FAIL + + logger.info("libvirt filters:\n%s", libvirt_filters) + + # Fetch current filters with libvirt-cim + cim_filters = _test.cim_filter_lists() + if not cim_filters: + # TODO: Add some filters of our own + return FAIL + + logger.info("libvirt-cim filters:\n%s", cim_filters) + + # Compare results + if len(libvirt_filters) != len(cim_filters): + logger.error("CIM filters list length is different than libvirt filters list") + return FAIL + + for f in libvirt_filters: + if f not in cim_filters: + logger.error("Filter %s, not found in CIM filters list", f) + return FAIL + + return PASS +# main + +if __name__ == "__main__": + sys.exit(main()) diff --git a/suites/libvirt-cim/cimtest/FilterList/02_assoc.py b/suites/libvirt-cim/cimtest/FilterList/02_assoc.py new file mode 100644 --- /dev/null +++ b/suites/libvirt-cim/cimtest/FilterList/02_assoc.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Eduardo Lima (Etrunko) +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# +# CIMTest Filter Lists Associators +# + +import sys +import helper + +from CimTest.ReturnCodes import PASS, FAIL, XFAIL +from CimTest.Globals import logger +from XenKvmLib.const import do_main + +sup_types = ["KVM",] + + at do_main(sup_types) +def main(): + options = main.options + + _test = helper.FilterListTest(options.ip, options.virt) + + # Fetch current filters with libvirt + libvirt_filters = _test.libvirt_entries_in_filter_lists() + if not libvirt_filters: + return FAIL + + #logger.info("libvirt filters:\n%s", libvirt_filters) + + # Fetch current filters with libvirt-cim + cim_filters = _test.cim_entries_in_filter_lists() + if not cim_filters: + return FAIL + + #logger.info("libvirt-cim filters:\n%s", cim_filters) + + # Compare results + if len(libvirt_filters) != len(cim_filters): + logger.error("CIM filters list length and libvirt filters list differ") + return FAIL + + # Compare each result + for inst_name in cim_filters: + _cim_f = _test.GetInstance(inst_name) + try: + _key = (_cim_f["InstanceID"], _cim_f["Name"]) + _vir_f = libvirt_filters[_key] + except KeyError, e: + logger.error(e) + return FAIL + + logger.info("") + logger.info("Processing '%s' filter", _key[1]) + + # Check number of rules + n_vir_rules = len([e for e in _vir_f.getchildren() if e.tag in ["rule", "filterref"]]) + + # process each element + instances = cim_filters[inst_name] + n_cim_rules = len(instances) + + if n_cim_rules != n_vir_rules: + logger.error("Number of rules returned by libvirt (%d) and libvirt-cim (%d) differ", + n_vir_rules, n_cim_rules) + return FAIL + + + # TODO: Create a new class to handle the filter parsing + def parse_filter(element, spaces=""): + logger.info("%s%s(%s)%s", + spaces, + element.tag, + element.attrib and element.attrib or "", + element.text and ": %s" % element.text or "") + + # Recurse to last element in tree + for e in element: + parse_filter(e, "%s " % spaces) + + if element.tag == "filterref": + name = element.get("filter") + try: + i = [inst for inst in instances if inst["Name"] == name][0] + logger.info("%s* MATCH: Instance: %s", spaces, i) + instances.remove(i) + return + except: + raise Exception("No CIM Instance matching this rule was found") + elif element.tag == "rule": + if not instances: + raise Exception("No CIM Instance matching this rule was found") + + rule = helper.FilterRule(element) + + # Find matching instance + logger.info("%s* %s", spaces, rule) + for i in instances: + props = "" + for p in i.properties.keys(): + props = "%s '%s':'%s'" % (props, p, i[p]) + logger.info("%s* %s(%s)", spaces, i.classname, props) + + matches, msg = rule.matches(i) + if msg: + logger.info("%s* %s: %s", spaces, matches and "MATCH" or "DON'T MATCH", msg) + + if matches: + instances.remove(i) + return + + # No matching instance + raise Exception("No CIM instance matching rule found") + else: + # Unexpected tag, ignore by now + pass + # parse_filter + + try: + parse_filter(_vir_f) + except Exception, e: + logger.error("Error parsing filter '%s': %s", _vir_f.tag, e) + return FAIL + + # Check for leftovers + for i in instances: + props = "" + for p in i.properties.keys(): + props = "%s '%s':'%s'" % (props, p, i[p]) + + logger.error("Could NOT find match for instance %s : {%s}", i.classname, props) + return FAIL + # end for inst_name in cim_filters + + logger.info("====End of test====") + return PASS +# main + +if __name__ == "__main__": + sys.exit(main()) diff --git a/suites/libvirt-cim/cimtest/FilterList/03_create.py b/suites/libvirt-cim/cimtest/FilterList/03_create.py new file mode 100644 --- /dev/null +++ b/suites/libvirt-cim/cimtest/FilterList/03_create.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Eduardo Lima (Etrunko) +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# +# CIMTest Filter Lists Create +# + +import sys +import helper + +import pywbem + +from CimTest.ReturnCodes import PASS, FAIL, XFAIL +from CimTest.Globals import logger +from XenKvmLib.const import do_main +from XenKvmLib.vxml import get_class +from VirtLib.utils import run_remote + +sup_types = ["KVM",] + +domain = None + +def get_filter_inst_and_inst_name(name): + try: + _filters = test.libvirt_filter_lists() + _id = test.id_for_filter_name(_filters, name) + except Exception, e: + # TODO: define a filter of our own + logger.error("'%s' filter list not found in libvirt:\n%s", name, e) + raise + + # Retrieve instance name for "clean-traffic" + try: + inst_name = test.FindInstanceName(name) + except Exception, e: + logger.error("'%s' filter list not found in libvirt-cim\n%s", name, e) + raise + + # Retrieve instance for "clean-traffic" + inst = test.GetInstance(inst_name) + + if not inst: + logger.error("Unable to retrieve instance for '%s' filter list", name) + raise Exception() + elif inst["InstanceID"] != _id: + logger.error("'%s' ids from libvirt and libvirt-cim differ", name) + raise Exception() + + return inst, inst_name +# get_filter_inst_and_inst_name + + +def create_filter_list(name): + # Get "clean-traffic" filter instance and instance name + clean, clean_name = get_filter_inst_and_inst_name("clean-traffic") + + # Check if filter list already exist then delete it + try: + inst_name = test.FindInstanceName(name) + test.wbem.DeleteInstance(inst_name) + logger.info("Instance with name '%s' already exists. Deleting.", name) + except: + logger.info("No previous Instance with name '%s' found.", name) + + # Create a new FilterList instance based on name parameter + global flist_name + logger.info("Creating FilterList '%s'", name) + flist_name = test.CreateFilterListInstance(name) + flist = test.GetInstance(flist_name) + + # A NestedFilterList instance will add the "clean-traffic" filter + # as an entry of the newly created FilterList + logger.info("Creating NestedFilterList instance") + nested_name = test.CreateFilterListInstance(None, "KVM_NestedFilterList", + {"Antecedent":flist_name, + "Dependent":clean_name}) + + logger.info("Got NestedFilterList name '%s'", nested_name) + #nested = test.GetInstance(nested_name) + #logger.info("Got NestedFilterList '%s'", nested) + + # Check if results match + _id, _name = [f for f in test.libvirt_filter_lists() if f[1] == name][0] + elements = test.libvirt_filter_dumpxml(_id) + filterref = [e for e in elements if e.tag == "filterref"][0] + if clean["Name"] != filterref.get("filter"): + raise Exception("NestedFilterList name and libvirt filter don't match") + + logger.info("NestedFilterList created successfuly") + return flist, flist_name +# create_filter_list + + +def get_nwport_inst_and_inst_name(domain_name): + try: + inst_name = test.FindInstanceName(domain_name, "SystemName", + "KVM_NetworkPort") + inst = test.GetInstance(inst_name) + except Exception, e: + logger.error("Unable to get NetworkPort instance name for '%s' domain", domain_name) + raise + + return inst, inst_name +#get_nwport_inst_and_inst_name + + +def cleanup(): + try: + # Destroy filter list + test.wbem.DeleteInstance(flist_name) + except Exception, e: + logger.error("Error deleting filter list: %s", e) + + try: + # Destroy domain + if domain: + domain.destroy() + domain.undefine() + except Exception, e: + logger.error("Error destroying domain: %s", e) +# cleanup + + + at do_main(sup_types) +def main(): + result = XFAIL + options = main.options + + test_flist = "cimtest-filterlist" + + global test + test = helper.FilterListTest(options.ip, options.virt) + + try: + # Create a new FilterList instance + flist, flist_name = create_filter_list(test_flist) + + # Create a new domain (VM) + domain_name = "cimtest-filterlist-domain" + global domain + domain = helper.CIMDomain(domain_name, test.virt, test.server) + domain.define() + + # Get NetworkPort instance and instance name for defined domain + nwport, nwport_name = get_nwport_inst_and_inst_name(domain_name) + + # An AppliedFilterList Instance will apply the filter to the network + # port of the defined domain + test.CreateFilterListInstance(None, "KVM_AppliedFilterList", + {"Antecedent":nwport_name, + "Dependent":flist_name}) + except Exception, e: + logger.error("Caught exception: %s", e) + result = FAIL + + # Check results + + # Cleanup + cleanup() + + # Leftovers? + try: + inst = test.FindInstance(test_flist) + logger.error("Leftovers in CIM FilterLists: %s", inst) + result = FAIL + except IndexError: + pass + + try: + filt = [f for f in test.libvirt_filter_lists() if f[1] == test_flist][0] + logger.error("Leftovers in libvirt filters: %s", filt) + result = FAIL + except IndexError: + pass + + return result +# main + +if __name__ == "__main__": + sys.exit(main()) diff --git a/suites/libvirt-cim/cimtest/FilterList/helper.py b/suites/libvirt-cim/cimtest/FilterList/helper.py new file mode 100644 --- /dev/null +++ b/suites/libvirt-cim/cimtest/FilterList/helper.py @@ -0,0 +1,515 @@ +#!/usr/bin/env python +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Eduardo Lima (Etrunko) +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# + +import pywbem +import libvirt + +import CimTest +from CimTest.Globals import logger + +import XenKvmLib +from XenKvmLib.xm_virt_util import virt2uri +from XenKvmLib.classes import get_typed_class +from XenKvmLib.vxml import get_class + +import VirtLib +from VirtLib.utils import run_remote + +try: + from xml.etree import cElementTree as ElementTree +except: + from xml.etree import ElementTree + + +class BaseTestObject(object): + + def __init__(self, server, virt): + self.server = server + self.virt = virt + self.typed_class = get_typed_class(virt, self.cim_basename) + self.uri = virt2uri(virt) + self.user = CimTest.Globals.CIM_USER + self.passwd = CimTest.Globals.CIM_PASS + self.namespace = CimTest.Globals.CIM_NS + self.wbem = pywbem.WBEMConnection("http://%s" % server, + (self.user, self.passwd), + self.namespace) + self.wbem.debug = True + # __init__ + + def EnumerateInstances(self, typed_class=None): + if not typed_class: + typed_class = self.typed_class + + return self.wbem.EnumerateInstances(typed_class) + # EnumerateInstances + + def EnumerateInstanceNames(self, typed_class=None): + if not typed_class: + typed_class = self.typed_class + + return self.wbem.EnumerateInstanceNames(typed_class) + # EnumerateInstanceNames + + def __assoc_args(self, assoc_class=None, result_class=None): + kargs = {} + if assoc_class: + kargs["AssocClass"] = assoc_class + + if result_class: + kargs["ResultClass"] = result_class + + return kargs + # __assoc_args + + def Associators(self, typed_class=None, assoc_class=None, result_class=None): + if not typed_class: + typed_class = self.typed_class + + kargs = self.__assoc_args(assoc_class, result_class) + + if kargs: + return self.wbem.Associators(typed_class, **kargs) + + return self.wbem.Associators(typed_class) + # Associators + + def AssociatorNames(self, typed_class=None, assoc_class=None, result_class=None): + if not typed_class: + typed_class = self.typed_class + + kargs = self.__assoc_args(assoc_class, result_class) + + if kargs: + return self.wbem.Associators(typed_class, **kargs) + + return self.wbem.AssociatorNamess(typed_class) + # AssociatorNames + + def GetInstance(self, inst_name): + return self.wbem.GetInstance(inst_name) + # GetInstance + + def FindInstance(self, inst_name, attr="Name", class_name=None): + if not class_name: + class_name = self.typed_class + + if isinstance(inst_name, str) or isinstance(inst_name, unicode): + _insts = self.EnumerateInstances(class_name) + return [i for i in _insts if i[attr] == inst_name][0] + + return self.GetInstance(self, inst_name) + # FindInstance + + def FindInstanceName(self, _name, attr="Name", class_name=None): + if not class_name: + class_name = self.typed_class + + _inst_names = self.EnumerateInstanceNames(class_name) + return [i for i in _inst_names if i[attr] == _name][0] + # FindInstanceName + + def CreateFilterListInstance(self, name, class_name=None, props={}): + if not class_name: + class_name = self.typed_class + + if name: + props["Name"] = name + + logger.info("Creating Instance of %s", class_name) + inst = pywbem.CIMInstance(class_name, props) + return self.wbem.CreateInstance(inst) + # CreateFilterListInstance + + def DumpWBEMDebug(self): + logger.info("*** Begin WBEM Debug ***") + logger.info(" * Last raw request\n'%s'", self.wbem.last_raw_request) + logger.info(" * Last raw reply\n'%s'", self.wbem.last_raw_reply) + + logger.info(" * Last request\n'%s'", self.wbem.last_request) + logger.info(" * Last reply\n'%s'", self.wbem.last_reply) + logger.info("*** End WBEM Debug ***") + # DumpWBEMDebug +# BaseTestObject + + +class CIMDomain(object): + + def __init__(self, name, virt, server): + self.name = name + self.server = server + self.virt = virt + self._domain = get_class(virt)(name) + #__init__ + + def define(self): + return self._domain.cim_define(self.server) + # define + + def start(self): + return self._domain.cim_start(self.server) + # start + + def shutdown(self): + return self._domain.cim_shutdown(self.server) + # shutdown + + def undefine(self): + return self._domain.undefine(self.server) + # undefine + + def destroy(self): + return self._domain.cim_destroy(self.server) + #destroy +# CIMDomain + + +class FilterListTest(BaseTestObject): + cim_basename = "FilterList" + + def __init__(self, server, virt): + BaseTestObject.__init__(self, server, virt) + # __init__ + + def libvirt_filter_lists(self): + cmd = "virsh -q -c %s nwfilter-list 2>/dev/null" % self.uri + ret, filters = run_remote(self.server, cmd) + if ret: + logger.error("Error listing existing filters") + return None + + filters = filters.split("\n") + l = [] + for f in filters: + # Append a tuple of (id, name) to list + t = tuple(a for a in f.strip().split() if a) + l.append(t) + + return l + # libvirt_filter_lists + + def cim_filter_lists(self): + _instances = self.EnumerateInstances() + l = [] + for i in _instances: + try: + # Append a tuple of (id, name) to list + l.append((i["InstanceId"], i["Name"])) + except KeyError: + logger.error("'InstanceID', 'Name' properties not found in Instance %s", i) + return None + + return l + # cim_filter_lists + + def id_for_filter_name(self, _list, _name): + if isinstance(_list[0], tuple): + return [t[0] for t in _list if t[1] == _name][0] + elif isinstance(_list[0], CIMInstanceName): + return self.GetInstance(inst_name)["InstanceID"] + raise AttributeError("Expecting list of either tuple or CIMInstanceName") + # id_for_filter_name + + def name_for_filter_id(self, _list, _id): + if isinstance(_list[0], tuple): + return [t[1] for t in _list if t[0] == _id][0] + elif isinstance(_list[0], CIMInstance): + return [i for i in _list if i["InstanceID"] == _id][0]["Name"] + raise AttributeError("Expecting list of either tuple or CIMInstance") + # name_for_filter_id + + def libvirt_filter_dumpxml(self, uuid): + cmd = "virsh -q -c %s nwfilter-dumpxml %s 2>/dev/null" % (self.uri, uuid) + ret, out = run_remote(self.server, cmd) + if ret: + logger.error("Error executing nwfilter-dumpxml") + return None + + # Remove all unecessary spaces and new lines + _xml = "".join([a.strip() for a in out.split("\n") if a]) + return ElementTree.fromstring(_xml) + # libvirt_filter_dumpxml + + def libvirt_entries_in_filter_lists(self): + filters = self.libvirt_filter_lists() + + d = {} + for f in filters: + root = self.libvirt_filter_dumpxml(f[0]) + if not root: + return None + + d[f] = root + + return d + # libvirt_entries_in_filter_lists + + def cim_entries_in_filter_lists(self): + d = {} + + _names = self.EnumerateInstanceNames() + for n in _names: + l = [] + l.extend(self.Associators(n, result_class="CIM_FilterEntryBase")) + l.extend(self.Associators(n, assoc_class="KVM_NestedFilterList")) + d[n] = l + + return d + # cim_entries_in_filter_lists + + def libvirt_entries_in_filter_list(self, _name, _id=None): + _id_name = (_id, _name) + + if not _id: + try: + _id_name = (self.id_for_filter_name(d.keys(), _name), _name) + except IndexError: + return None + elif not _name: + try: + _id_name = (_id, self.name_for_filter_id(d.keys(), _id)) + except IndexError: + return None + + return self.libvirt_filter_dumpxml(_id_name[0]) + # libvirt_entries_in_filter_list + + def cim_entries_in_filter_list(self, _name, _id=None): + _inst_name = None + + if not _id: + try: + _inst_name = self.GetInstanceName(_name) + except IndexError: + return None + elif not _name: + try: + _inst = self.GetInstance(_id, "InstanceID") + _inst_name = self.GetInstanceName(_inst["Name"]) + except IndexError: + return None + + return self.Associators(_inst_name, result_class="CIM_FilterEntryBase") + # cim_entries_in_filter_list +# FilterListTest + + +class FilterRule(object): + + __directions = {"in" : "1", + "out" : "2", + "inout": "3",} + + __versions = {"ip" : "4", + "ipv6": "6",} + + __actions = {"accept" : "1", + "deny" : "2", + "drop" : "2",} + + __baserule_map = {"action" : "Action", + "direction" : "Direction", + "priority" : "Priority",} + + __iprule_map = {"version" : "HdrIPVersion", + "" : "HdrFlowLabel", + "srcipaddr" : "HdrSrcAddress", + "dstipaddr" : "HdrDestAddress", + "srcipmask" : "HdrSrcMask", + "dstipmask" : "HdrDestMask", + "srcipto" : "HdrSrcAddressEndOfRange", + "dstipto" : "HdrDestAddressEndOfRange", + "srcportstart": "HdrSrcPortStart", + "dstportstart": "HdrDestPortStart", + "srcportend" : "HdrSrcPortEnd", + "dstportend" : "HdrDestPortEnd", + "" : "HdrDSCP", + "" : "HdrProtocolID",} + + __hdr8021rule_map = {"srcmacaddr": "HdrSrcMACAddr8021", + "dstmacaddr": "HdrDestMACAddr8021", + "srcmacmask": "HdrSrcMACMask8021", + "dstmacmask": "HdrDestMACMask8021", + "" : "HdrPriorityValue8021", + "" : "HdrVLANID8021", + "protocolid": "HdrProtocolID8021",} + + ### FIXME Add to proper rule map + """ + "": "HealthState", + "": "StatusDescriptions", + "": "Generation", + "": "CommunicationStatus", + "": "SystemName", + "": "DetailedStatus", + "": "Caption", + "": "OperationalStatus", + "": "SystemCreationClassName", + "": "Status", + "": "Description", + "": "InstallDate", + "": "CreationClassName", + "": "PrimaryStatus", + "": "ElementName", + "": "Name", + "": "IsNegated", + "": "InstanceID", + "": "OperatingStatus", + """ + + __basenames = {None : "FilterEntry", + "ip" : "IPHeadersFilter", + "ipv6": "IPHeadersFilter", + "tcp" : "IPHeadersFilter", + "udp" : "IPHeadersFilter", + "igmp": "IPHeadersFilter", + "icmp": "IPHeadersFilter", + "mac" : "Hdr8021Filter", + "arp" : "Hdr8021Filter", + "rarp": "Hdr8021Filter",} + + __rulemaps = {"FilterEntry" : __baserule_map, + "IPHeadersFilter": dict(__baserule_map, **__iprule_map), + "Hdr8021Filter" : dict(__baserule_map, **__hdr8021rule_map),} + + def __init__(self, element): + self.__dict = element.attrib + self.__type = None + + for e in element: + self.__dict = dict(self.__dict, **e.attrib) + if not self.__type: + self.__type = e.tag + + try: + self.basename = self.__basenames[self.__type] + self.rulemap = self.__rulemaps[self.basename] + except KeyError: + self.basename = None + self.rulemap = None + # __init__ + + def __getattr__(self, key): + if key == "direction": + return self.__directions[self.__dict[key]] + elif key == "version": + if self.__type and "ip" in self.__type: + return self.__versions[self.__type] + elif key == "action": + return self.__actions[self.__dict[key]] + elif key == "type": + return self.__type + + try: + return self.__dict[key] + except KeyError: + return None + # __getattr__ + + def __repr__(self): + return "FilterRule(type=%s, attributes=%s)" % (self.__type, self.__dict) + # __repr__ + + def __addr_to_list(self, val, base, sep): + return [long(v, base) for v in val.split(sep)] + # __addr_to_list + + def __cidr_to_list(self, val): + int_val = int(val, 10) + int_val = (0xffffffff >> (32 - int_val)) << (32 - int_val) + o1 = (int_val & 0xff000000) >> 24 + o2 = (int_val & 0x00ff0000) >> 16 + o3 = (int_val & 0x0000ff00) >> 8 + o4 = int_val & 0x000000ff + return [o1, o2, o3, o4] + # __cidr_to_list + + def matches(self, instance): + # Classname + if not self.basename or self.basename not in instance.classname: + return (False, "Classname '%s' does not match instance '%s'" % (self.basename, instance.classname)) + + # IP Version + if self.version: + prop_name = self.rulemap["version"] + try: + inst_version = str(instance[prop_name]) + except KeyError: + inst_version = None + + if self.version != inst_version: + return (False, "IP version '%s' does not match instance '%s'" % (self.version, inst_version)) + + # Other properties + for key in self.__dict: + try: + inst_key = self.rulemap[key] + except KeyError: + inst_key = None + + if not inst_key: + # logger.info("No match for rule attribute '%s'", key) + continue + + # convert the property value to string + prop = instance.properties[inst_key] + val = self.__getattr__(key) + if val.startswith("0x"): + inst_val = hex(int(prop.value)) + else: + inst_val = str(prop.value) + + # Handle special cases + if inst_val != "None": + # Netmask? + if "mask" in key: + if "." in val: + val = self.__addr_to_list(val, base, sep) + else: + # Assume CIDR + val = self.__cidr_to_list(val) + inst_val = prop.value + # Address? + elif "addr" in key: + if val.startswith("$"): + # Can't translate address starting with '$' + logger.info("Assuming matching address for '%s:%s' and '%s:%s'", key, val, inst_key,inst_val) + continue + elif prop.is_array and prop.value: + sep = "." + base = 10 + if ":" in val: + sep = ":" + base = 16 + + val = self.__addr_to_list(val, base, sep) + inst_val = prop.value + # if inst_val != None + + if inst_val != val: + return (False, "Values for '%s':'%s' and '%s':'%s' don't match" % (key, val, inst_key, inst_val)) + + return (True, "Found matching CIM Instance: %s" % instance) + # matches +# FilterRule + From eblima at linux.vnet.ibm.com Thu Oct 6 20:43:01 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 17:43:01 -0300 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid extra connection to libvirt In-Reply-To: References: <4E88BE55.2040301@linux.vnet.ibm.com> Message-ID: <4E8E12D5.8050202@linux.vnet.ibm.com> On 10/03/2011 02:23 PM, Sharad Mishra wrote: >> >> Re: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid >> extra connection to libvirt >> >> Actually, this change only prevents a 'nested' connection. There are >> still 2 connects; one in update_dominfo() and one in _resource_dynamic(). > > There should not be 2 connects here. One connection will be created in > update_dominfo which will be closed on exiting that function and a new > one created later in _resource_dynamic(). > >> >> Also, moving the call to update_dominfo() up negates the check >> done by the code block that begins with >> 'dom = virDomainLookupByName(conn, dominfo->name);' > > There is a similar check in update_dominfo too. > > In my opinion this patch makes sense. > > -Sharad Mishra > Yes, that was the rationale of the patch. In fact, the update_dominfo function does not make any use of the values in _resource_dynamic. Best regards, Etrunko -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From eblima at linux.vnet.ibm.com Thu Oct 6 20:45:29 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 17:45:29 -0300 Subject: [Libvirt-cim] [PATCH] Pool names with space do not get parsed properly In-Reply-To: <8f5d112e4aea945d09c6.1317841911@elm3b151.beaverton.ibm.com> References: <8f5d112e4aea945d09c6.1317841911@elm3b151.beaverton.ibm.com> Message-ID: <4E8E1369.2080008@linux.vnet.ibm.com> +1 On 10/05/2011 04:11 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1317836416 25200 > # Node ID 8f5d112e4aea945d09c6120c6cea2817592d08aa > # Parent 1f93220799a57477a6b1e04a90e8ffe797d85581 > Pool names with space do not get parsed properly. > > This patch fixes the issue where a disk pool with space in its > name does not get parsed correctly. > > Signed-off-by: Sharad Mishra > > diff -r 1f93220799a5 -r 8f5d112e4aea src/Virt_DevicePool.c > --- a/src/Virt_DevicePool.c Fri Sep 16 14:24:35 2011 +0800 > +++ b/src/Virt_DevicePool.c Wed Oct 05 10:40:16 2011 -0700 > @@ -1281,7 +1281,7 @@ > goto out; > } > > - ret = sscanf(id, "%*[^/]/%as", &poolid); > + ret = sscanf(id, "%*[^/]/%a[^\n]", &poolid); > if (ret != 1) { > cu_statusf(broker, &s, > CMPI_RC_ERR_NOT_FOUND, > -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From eblima at linux.vnet.ibm.com Thu Oct 6 20:51:16 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 06 Oct 2011 17:51:16 -0300 Subject: [Libvirt-cim] [PATCH] [TEST] Adding tests for FilterLists In-Reply-To: References: Message-ID: <4E8E14C4.50703@linux.vnet.ibm.com> On 10/06/2011 05:11 PM, Eduardo Lima (Etrunko) wrote: > suites/libvirt-cim/cimtest/FilterList/01_enum.py | 71 ++ > suites/libvirt-cim/cimtest/FilterList/02_assoc.py | 158 ++++++ > suites/libvirt-cim/cimtest/FilterList/03_create.py | 199 ++++++++ > suites/libvirt-cim/cimtest/FilterList/helper.py | 515 +++++++++++++++++++++ > 4 files changed, 943 insertions(+), 0 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1310498051 10800 > # Node ID d9741a8b5eb7ccebf21d69f3cde72729bb60ad22 > # Parent 779871660a3583dedf1652773196d07093ff26ff > [TEST] Adding tests for FilterLists > > helper.py: > - Helper module with classes and functions used by all tests > > 01_enum.py: > - Enumerate FilterList instances and compare to results from libvirt > > 02_assoc.py: > - For each FilterList instance, call Associators to get respective > FilterEntries instances and compare to results from libvirt > > 03_create.py: > - Creates a new FilterList instance and a NestedFilterList associated > to this new instance. Creates a new domain and a new > AppliedFilterList instance associated to the NetworkPort instance of > that new domain. Please note that these tests require the latest series of patches to FilterEntry provider that were been sent to this mailing list in order to produce the right results. Best regards, Etrunko -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From xiawenc at linux.vnet.ibm.com Tue Oct 11 09:26:25 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Tue, 11 Oct 2011 17:26:25 +0800 Subject: [Libvirt-cim] [PATCH 1 of 2] [TEST] 32_modify_cdrom_media.py: new test for VirtualSystemManagementService In-Reply-To: <85c624ef88f4e1487f95.1317409181@eblima.br.ibm.com> References: <85c624ef88f4e1487f95.1317409181@eblima.br.ibm.com> Message-ID: <4E940BC1.8090903@linux.vnet.ibm.com> tested, good case with nice skills.. But does this case included the situation that changing media when guest is running? ? 2011-10-1 2:59, Eduardo Lima (Etrunko) ??: > suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py | 221 ++++++++++ > 1 files changed, 221 insertions(+), 0 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317409066 10800 > # Node ID 85c624ef88f4e1487f95a5e50674a626a4ebf8f4 > # Parent f4bcd9833525c6914f61e29e9d2d8adbac240682 > [TEST] 32_modify_cdrom_media.py: new test for VirtualSystemManagementService > > This test case covers a requirement to change the media in the CDROM using > libvirt-cim, which is done via a ModifyResourceSettings call. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py > new file mode 100755 > --- /dev/null > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py > @@ -0,0 +1,221 @@ > +#!/usr/bin/env python > + > +# > +# Copyright 2011 IBM Corp. > +# > +# Authors: > +# Eduardo Lima (Etrunko) > +# > +# This library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > +# > +# This library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# General Public License for more details. > +# > +# You should have received a copy of the GNU General Public > +# License along with this library; if not, write to the Free Software > +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > +# > + > +# > +# Create a domain with cdrom device without media connected. > +# ModifyResourceSettings call to change the cdrom media > +# > + > +import sys > +import os > +import pywbem > + > +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP > +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS > +from XenKvmLib.const import do_main, _image_dir > +from XenKvmLib.classes import get_typed_class > +from XenKvmLib.vxml import get_class > + > +supported = ['KVM',] > + > +cim = None > +sys_mgmt_service = None > +domain = None > + > +class CIMDomain(object): > + > + def __init__(self, name, virt, server): > + self.name = name > + self.server = server > + self.virt = virt > + self._domain = get_class(virt)(name) > + #__init__ > + > + def define(self): > + return self._domain.cim_define(self.server) > + # define > + > + def undefine(self): > + return self._domain.undefine(self.server) > + # undefine > + > + def destroy(self): > + return self._domain.cim_destroy(self.server) > + #destroy > +# CIMDomain > + > + > +def set_device_addr(inst, address): > + return """ > +instance of %s { > + InstanceID="%s"; > + ResourceType=%d; > + PoolID="%s"; > + AllocationUnits="%s"; > + Address="%s"; > + VirtualQuantityUnits="%s"; > + VirtualDevice="%s"; > + EmulatedType=%d; > + BusType="%s"; > + DriverName="%s"; > + DriverType="%s"; > +};""" % (get_typed_class(domain.virt, "DiskResourceAllocationSettingData"), > + inst["InstanceID"], > + inst["ResourceType"], > + inst["PoolID"], > + inst["AllocationUnits"], > + address, > + inst["VirtualQuantityUnits"], > + inst["VirtualDevice"], > + inst["EmulatedType"], > + inst["BusType"], > + inst["DriverName"], > + inst["DriverType"],) > +# set_device_addr() > + > + > +def modify_media(cim, inst, addr): > + logger.info("Setting media addr to '%s'", addr) > + > + val = set_device_addr(inst, addr) > + ret = cim.InvokeMethod("ModifyResourceSettings", sys_mgmt_service, **{"ResourceSettings": [val,],}) > + > + if ret[0]: > + logger.error("Modifying media: %s", ret) > + return None > + > + inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) > + new_addr = inst["Address"] > + > + if new_addr != addr: > + logger.error("New media '%s' does not match expected '%s'", new_addr, addr) > + return None > + > + return inst > +# modify_media() > + > + > + at do_main(supported) > +def main(): > + options = main.options > + server = options.ip > + virt = options.virt > + > + server_url = "http://%s" % server > + global cim > + cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS) > + > + _class = get_typed_class(virt, "VirtualSystemManagementService") > + global sys_mgmt_service > + sys_mgmt_service = cim.EnumerateInstanceNames(_class)[0] > + > + # Create new domain > + global domain > + domain = CIMDomain("cimtest_modify_cdrom", virt, server) > + if not domain.define(): > + logger.error("Error defining test domain") > + return FAIL > + > + logger.info("Domain XML\n%s", domain._domain) > + # ein KVM_ComputerSystem > + _class = get_typed_class(virt, "ComputerSystem") > + computer_system_names = [i for i in cim.EnumerateInstanceNames(_class) if i["Name"] == domain.name] > + > + logger.info("ComputerSystem Names\n%s", computer_system_names) > + > + if not computer_system_names: > + logger.info("Host has no domains defined") > + return SKIP > + > + # ain -ac KVM_SystemDevice -arc KVM_LogicalDisk > + a_class = get_typed_class(virt, "SystemDevice") > + r_class = get_typed_class(virt, "LogicalDisk") > + logical_disk_names = [] > + > + for inst_name in computer_system_names: > + assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class) > + logical_disk_names.extend(assoc_names) > + > + logger.info("LogicalDisk Names\n%s", logical_disk_names) > + > + if not logical_disk_names: > + logger.info("No LogicalDisk instances returned") > + return FAIL > + > + # ai -arc KVM_DiskResourceAllocationSettingData > + rclass = get_typed_class(virt, "DiskResourceAllocationSettingData") > + disk_rasd_names = [] > + > + for inst_name in logical_disk_names: > + assoc_names = cim.AssociatorNames(inst_name, ResultClass=rclass) > + disk_rasd_names.extend(assoc_names) > + > + logger.info("DiskRASD names\n%s", disk_rasd_names) > + > + if not disk_rasd_names: > + logger.info("No DiskRASD instances returned") > + return FAIL > + > + cdrom_devices = [i for i in disk_rasd_names if cim.GetInstance(i)["EmulatedType"] == 1] > + > + logger.info("CDROM devices\n%s", cdrom_devices) > + > + if not cdrom_devices: > + logger.info("No CDROM device found") > + return FAIL > + > + cdrom = cdrom_devices[0] > + inst = cim.GetInstance(cdrom) > + > + for media in ["cdrom01.iso", "cdrom02.iso"]: > + if not inst: > + logger.error("Unable to get CDROM device instance") > + return FAIL > + > + # Get current media address > + old_media = inst["Address"] > + > + logger.info("Current CDROM media: '%s'", old_media) > + > + if not media and not old_media: > + logger.info("CDROM device has no media connected") > + continue > + > + # Need to eject first? > + if media and old_media: > + inst = modify_media(cim, inst, "") > + > + media_path = os.path.join(_image_dir, media) > + inst = modify_media(cim, inst, media_path) > + > + return PASS > +# main() > + > +if __name__ == "__main__": > + ret = main() > + > + if domain: > + domain.destroy() > + domain.undefine() > + > + sys.exit(ret) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Tue Oct 11 09:35:50 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Tue, 11 Oct 2011 17:35:50 +0800 Subject: [Libvirt-cim] [PATCH] (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: References: Message-ID: <4E940DF6.5070100@linux.vnet.ibm.com> Back to work now. :) ? 2011-10-3 10:47, Gareth S Bestor ??: > > >I think a follow-up tweak may be order. For example, I'd prefer to > >simply use NULL for 'no media' rather than a null_string to simplify the > >code further. > > FYI, libvirt-cim ModifyResourceSettings[] ignores properties in the > modified RASD having no/null value when merging this 'new' instance with > the existing one. Unfortuantely, this is a restriction from the DMTF > SVPC profile itself. From DSP1042 System Virtualization Profile: > " ...The execution of the ModifyResourceSettings( ) method shall effect > the modification of resource alloca- > tions or resource allocation requests, such that non-key and non-NULL > values of instances of the > CIM_ResourceAllocationSettingData class provided as values for elements > of the ResourceSettings[ ] ar- > ray parameter override respective values in instances identified through > the InstanceID property. " > > - G > > Dr. Gareth S. Bestor > IBM Senior Software Engineer > Systems & Technology Group - Systems Management Standards > 971-285-6375 (mobile) > bestor at us.ibm.com > > from my understanding, the pegasus need to tell libvirt-cim a special value such as '' (empty string) or 'NULL', to show that user want a empty media setting in the calling of method ModifyResourceSettings, For that property not specified should not be merged, otherwise in some case libvirt-cim may overwrite some properties to empty ones that user do not want to. So I think a string 'NULL' or '' representing an empty media setting make sense. > > *Re: [Libvirt-cim] [PATCH] (#2) Fix the problem that libvirt-cim can't > find cdrom device that do not have disk* > > > *Chip Vincent * to: libvirt-cim > 10/02/11 05:13 PM > > > Sent by: *libvirt-cim-bounces at redhat.com* > > > *Please respond to cvincent, List for discussion and development of > libvirt CIM * > > > > > > > > Tests for this have completed successfully, so ACK'ing. However... > Now that we have a cimtest patch for this > ( > https://www.redhat.com/archives/libvirt-cim/2011-September/msg00047.html), > I think a follow-up tweak may be order. For example, I'd prefer to > simply use NULL for 'no media' rather than a null_string to simplify the > code further. We should also already have the libvirt-cim and Pegasus > patches (no references, sorry) that allow us to un-set attributes like > this. That is, set an actual value to NULL. > > On 09/20/2011 11:14 PM, Wayne Xia wrote: > > # HG changeset patch > > # User Wayne Xia > > # Date 1316154275 -28800 > > # Node ID afee8d9b7214884ab74690b3ca9fd3d4f139f455 > > # Parent db809376d763493849c2a19f587969eaec619b75 > > (#2) Fix the problem that libvirt-cim can't find cdrom device that do > not have disk > > > > This patch would allow define a system with an empty CDROM device, > and allow method modify > > resource settings to insert ISO files into an empty CDROM device. > > Examples: > > InvokeMethod(ModifyResourceSettings): > > ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData > {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = > 1;\nVirtualDevice = "hdc";\nAddress = "";\n};'] > > InvokeMethod(ModifyResourceSettings): > > ResourceSettings: ['instance of KVM_DiskResourceAllocationSettingData > {\nResourceType = 17;\nInstanceID = "test/hdc";\nEmulatedType = > 1;\nVirtualDevice = "hdc";\nAddress = > "/var/lib/libvirt/images/test-disk.iso";\n};'] > > Note that the Address property should be set to "", not None(not > set), to tell that user want > > an ejection. > > > > (#2) Add comments that saying what the code does, and improved some > codes to avoid doing duplicated things. > > > > Signed-off-by: Wayne Xia > > > > diff -r db809376d763 -r afee8d9b7214 libxkutil/device_parsing.c > > --- a/libxkutil/device_parsing.c Thu Jul 28 13:56:00 2011 -0300 > > +++ b/libxkutil/device_parsing.c Fri Sep 16 14:24:35 2011 +0800 > > @@ -287,6 +287,13 @@ > > ddev->shareable = true; > > } > > } > > + > > + /* handle the situation that a cdrom device have no disk in it, no > ISO file */ > > + if ((XSTREQ(ddev->device, "cdrom"))&& (ddev->source == NULL)) { > > + ddev->source = strdup(""); > > + ddev->disk_type = DISK_FILE; > > + } > > + > > if ((ddev->source == NULL) || (ddev->virtual_dev == NULL)) > > goto err; > > > > diff -r db809376d763 -r afee8d9b7214 libxkutil/xmlgen.c > > --- a/libxkutil/xmlgen.c Thu Jul 28 13:56:00 2011 -0300 > > +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 > > @@ -110,10 +110,18 @@ > > xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev->cache); > > } > > > > - tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > > - if (tmp == NULL) > > - return XML_ERROR; > > - xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); > > + if ((XSTREQ(dev->device, "cdrom"))&& > > + (XSTREQ(dev->source, ""))) { > > + /* This is the situation that user defined a cdrom device without > > + disk in it, so skip generating a line saying "source", for that > > + xml defination for libvirt should not have this defined in this > > + situation. */ > > + } else { > > + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > > + if (tmp == NULL) > > + return XML_ERROR; > > + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); > > + } > > > > tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); > > if (tmp == NULL) > > diff -r db809376d763 -r afee8d9b7214 > src/Virt_VirtualSystemManagementService.c > > --- a/src/Virt_VirtualSystemManagementService.c Thu Jul 28 13:56:00 > 2011 -0300 > > +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 > 2011 +0800 > > @@ -879,6 +879,17 @@ > > dev->dev.disk.device = strdup("disk"); > > else if (type == VIRT_DISK_TYPE_CDROM) { > > dev->dev.disk.device = strdup("cdrom"); > > + /* following code is for the case that user defined cdrom device > > + without disk in it, or a empty disk "" */ > > + if (XSTREQ(dev->dev.disk.source, "")) { > > + dev->dev.disk.disk_type = DISK_FILE; > > + } > > + if (XSTREQ(dev->dev.disk.source, "/dev/null")) { > > + dev->dev.disk.disk_type = DISK_FILE; > > + free(dev->dev.disk.source); > > + dev->dev.disk.source = strdup(""); > > + } > > + > > if (dev->dev.disk.disk_type == DISK_UNKNOWN) > > dev->dev.disk.disk_type = DISK_PHY; > > } > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- > Chip Vincent > Open Virtualization > IBM Linux Technology Center > cvincent at linux.vnet.ibm.com > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From tyreld at us.ibm.com Tue Oct 11 10:04:06 2011 From: tyreld at us.ibm.com (Tyrel Datwyler) Date: Tue, 11 Oct 2011 04:04:06 -0600 Subject: [Libvirt-cim] Tyrel Datwyler is out of the office. Message-ID: I will be out of the office starting 10/11/2011 and will not return until 10/17/2011. During this time I will have limited access to email. In case of urgent issues please contact my back up David Heller. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Tue Oct 11 16:25:46 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:25:46 -0400 Subject: [Libvirt-cim] [PATCH] Pool names with space do not get parsed properly In-Reply-To: <4E8E1369.2080008@linux.vnet.ibm.com> References: <8f5d112e4aea945d09c6.1317841911@elm3b151.beaverton.ibm.com> <4E8E1369.2080008@linux.vnet.ibm.com> Message-ID: <4E946E0A.2030906@linux.vnet.ibm.com> Thanks. Pushed. On 10/06/2011 04:45 PM, Eduardo Lima (Etrunko) wrote: > +1 > > On 10/05/2011 04:11 PM, Sharad Mishra wrote: >> # HG changeset patch >> # User Sharad Mishra >> # Date 1317836416 25200 >> # Node ID 8f5d112e4aea945d09c6120c6cea2817592d08aa >> # Parent 1f93220799a57477a6b1e04a90e8ffe797d85581 >> Pool names with space do not get parsed properly. >> >> This patch fixes the issue where a disk pool with space in its >> name does not get parsed correctly. >> >> Signed-off-by: Sharad Mishra >> >> diff -r 1f93220799a5 -r 8f5d112e4aea src/Virt_DevicePool.c >> --- a/src/Virt_DevicePool.c Fri Sep 16 14:24:35 2011 +0800 >> +++ b/src/Virt_DevicePool.c Wed Oct 05 10:40:16 2011 -0700 >> @@ -1281,7 +1281,7 @@ >> goto out; >> } >> >> - ret = sscanf(id, "%*[^/]/%as",&poolid); >> + ret = sscanf(id, "%*[^/]/%a[^\n]",&poolid); >> if (ret != 1) { >> cu_statusf(broker,&s, >> CMPI_RC_ERR_NOT_FOUND, >> > > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 16:23:47 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:23:47 -0400 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid extra connection to libvirt In-Reply-To: <4E8E12D5.8050202@linux.vnet.ibm.com> References: <4E88BE55.2040301@linux.vnet.ibm.com> <4E8E12D5.8050202@linux.vnet.ibm.com> Message-ID: <4E946D93.7090509@linux.vnet.ibm.com> Okay. Pushed. On 10/06/2011 04:43 PM, Eduardo Lima (Etrunko) wrote: > On 10/03/2011 02:23 PM, Sharad Mishra wrote: >>> >>> Re: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid >>> extra connection to libvirt >>> >>> Actually, this change only prevents a 'nested' connection. There are >>> still 2 connects; one in update_dominfo() and one in _resource_dynamic(). >> >> There should not be 2 connects here. One connection will be created in >> update_dominfo which will be closed on exiting that function and a new >> one created later in _resource_dynamic(). >> >>> >>> Also, moving the call to update_dominfo() up negates the check >>> done by the code block that begins with >>> 'dom = virDomainLookupByName(conn, dominfo->name);' >> >> There is a similar check in update_dominfo too. >> >> In my opinion this patch makes sense. >> >> -Sharad Mishra >> > > Yes, that was the rationale of the patch. In fact, the update_dominfo > function does not make any use of the values in _resource_dynamic. > > Best regards, Etrunko > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 16:35:47 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:35:47 -0400 Subject: [Libvirt-cim] [PATCH 2 of 4] FilterEntry: Should be using srcipaddr instead of srcmacaddr In-Reply-To: References: Message-ID: <4E947063.5050205@linux.vnet.ibm.com> +1. Good catch. On 10/06/2011 11:46 AM, Eduardo Lima (Etrunko) wrote: > src/Virt_FilterEntry.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317912440 10800 > # Node ID a323895be993b3807cc41348ba3b74c76fb42596 > # Parent fa576f11a652c4632afb62c687707effb2e98a80 > FilterEntry: Should be using srcipaddr instead of srcmacaddr > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -238,7 +238,7 @@ > (CMPIValue *)&array, CMPI_uint8A); > } else { > memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.srcmacaddr, > + size = octets_from_ip(rule->var.tcp.srcipaddr, > bytes, sizeof(bytes)); > > array = octets_to_cmpi(broker, bytes, size); > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 16:38:19 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:38:19 -0400 Subject: [Libvirt-cim] [PATCH 4 of 4] FilterEntry: Fix behavior of convert_ip_rule_to_instance In-Reply-To: References: Message-ID: <4E9470FB.1050805@linux.vnet.ibm.com> +1. I like the new struct in the provider since that's the layer that "flattens" the data--that is, converts the various rules types to one of the three instance types. On 10/06/2011 11:46 AM, Eduardo Lima (Etrunko) wrote: > src/Virt_FilterEntry.c | 162 ++++++++++++++++++++++++++++++++++++++---------- > 1 files changed, 126 insertions(+), 36 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317915956 10800 > # Node ID e6c6f9ccb51303f67fce26e74de9ab746d10a04b > # Parent 1a08d8186f3064dfb0c38ecb5846ffc1e7d5de4d > FilterEntry: Fix behavior of convert_ip_rule_to_instance > > The function was always referencing the 'tcp' fileld of the var union in struct > acl_rule, while it should take into account the rule type to access the correct > fields. This could probably go to acl_parsing, but I thought it would be a less > intrusive change to patch only FilterEntry provider. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -35,6 +35,27 @@ > #include "Virt_HostSystem.h" > > const static CMPIBroker *_BROKER; > +struct rule_data_t { > + const char *srcmacaddr; > + const char *srcmacmask; > + const char *dstmacaddr; > + const char *dstmacmask; > + > + const char *srcipaddr; > + const char *srcipmask; > + const char *dstipaddr; > + const char *dstipmask; > + > + const char *srcipfrom; > + const char *srcipto; > + const char *dstipfrom; > + const char *dstipto; > + > + const char *srcportstart; > + const char *srcportend; > + const char *dstportstart; > + const char *dstportend; > +}; > > static int octets_from_mac(const char * s, unsigned int *buffer, > unsigned int size) > @@ -239,6 +260,75 @@ > (CMPIValue *)&array, CMPI_uint8A); > } > > +static void fill_rule_data(struct acl_rule *rule, > + struct rule_data_t *data) > +{ > + if (rule == NULL || data == NULL) > + return; > + > + memset(data, 0, sizeof(*data)); > + > + switch (rule->type) { > + case IP_RULE: > + data->srcmacaddr = rule->var.ip.srcmacaddr; > + data->srcmacmask = rule->var.ip.srcmacmask; > + data->dstmacaddr = rule->var.ip.srcmacaddr; > + data->dstmacmask = rule->var.ip.dstmacmask; > + > + data->srcipaddr = rule->var.ip.srcipaddr; > + data->srcipmask = rule->var.ip.srcipmask; > + data->dstipaddr = rule->var.ip.dstipaddr; > + data->dstipmask = rule->var.ip.dstipmask; > + > + data->srcportstart = rule->var.ip.srcportstart; > + data->srcportend = rule->var.ip.srcportend; > + data->dstportstart = rule->var.ip.dstportstart; > + data->dstportend = rule->var.ip.dstportend; > + break; > + > + case TCP_RULE: > + data->srcmacaddr = rule->var.tcp.srcmacaddr; > + > + data->srcipaddr = rule->var.tcp.srcipaddr; > + data->srcipmask = rule->var.tcp.srcipmask; > + data->dstipaddr = rule->var.tcp.dstipaddr; > + data->dstipmask = rule->var.tcp.dstipmask; > + > + data->srcipfrom = rule->var.tcp.srcipfrom; > + data->srcipto = rule->var.tcp.srcipto; > + data->dstipfrom = rule->var.tcp.dstipfrom; > + data->dstipto = rule->var.tcp.dstipto; > + > + data->srcportstart = rule->var.tcp.srcportstart; > + data->srcportend = rule->var.tcp.srcportend; > + data->dstportstart = rule->var.tcp.dstportstart; > + data->dstportend = rule->var.tcp.dstportend; > + break; > + > + case ICMP_IGMP_RULE: > + data->srcmacaddr = rule->var.icmp_igmp.srcmacaddr; > + data->srcmacmask = rule->var.icmp_igmp.srcmacmask; > + data->dstmacaddr = rule->var.icmp_igmp.srcmacaddr; > + data->dstmacmask = rule->var.icmp_igmp.dstmacmask; > + > + data->srcipaddr = rule->var.icmp_igmp.srcipaddr; > + data->srcipmask = rule->var.icmp_igmp.srcipmask; > + data->dstipaddr = rule->var.icmp_igmp.dstipaddr; > + data->dstipmask = rule->var.icmp_igmp.dstipmask; > + > + data->srcipfrom = rule->var.icmp_igmp.srcipfrom; > + data->srcipto = rule->var.icmp_igmp.srcipto; > + data->dstipfrom = rule->var.icmp_igmp.dstipfrom; > + data->dstipto = rule->var.icmp_igmp.dstipto; > + break; > + > + default: > + CU_DEBUG("%s(): unhandled rule type '%d'", > + __FUNCTION__, rule->type); > + break; > + } > +} > + > static void convert_ip_rule_to_instance( > struct acl_rule *rule, > CMPIInstance *inst, > @@ -248,6 +338,7 @@ > unsigned int size = 0; > unsigned int n = 0; > CMPIArray *array = NULL; > + struct rule_data_t rule_data; > > if (strstr(rule->protocol_id, "v6")) > n = 6; > @@ -256,9 +347,11 @@ > > CMSetProperty(inst, "HdrIPVersion",(CMPIValue *)&n, CMPI_uint8); > > - if (rule->var.tcp.srcipfrom&& rule->var.tcp.srcipto) { > + fill_rule_data(rule,&rule_data); > + > + if (rule_data.srcipfrom&& rule_data.srcipto) { > memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.srcipfrom, > + size = octets_from_ip(rule_data.srcipfrom, > bytes, sizeof(bytes)); > > array = octets_to_cmpi(broker, bytes, size); > @@ -267,7 +360,7 @@ > (CMPIValue *)&array, CMPI_uint8A); > > memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.srcipto, > + size = octets_from_ip(rule_data.srcipto, > bytes, sizeof(bytes)); > > array = octets_to_cmpi(broker, bytes, size); > @@ -276,7 +369,7 @@ > (CMPIValue *)&array, CMPI_uint8A); > } else { > memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.srcipaddr, > + size = octets_from_ip(rule_data.srcipaddr, > bytes, sizeof(bytes)); > > array = octets_to_cmpi(broker, bytes, size); > @@ -285,8 +378,8 @@ > (CMPIValue *)&array, CMPI_uint8A); > > /* CIDR notation? */ > - if (rule->var.tcp.srcipmask) { > - char *netmask = strdup(rule->var.tcp.srcipmask); > + if (rule_data.srcipmask) { > + char *netmask = strdup(rule_data.srcipmask); > if (strstr(netmask, ".") == NULL) { > char *tmp = cidr_to_str(netmask); > free(netmask); > @@ -305,9 +398,9 @@ > } > } > > - if (rule->var.tcp.dstipfrom&& rule->var.tcp.dstipto) { > + if (rule_data.dstipfrom&& rule_data.dstipto) { > memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.dstipfrom, > + size = octets_from_ip(rule_data.dstipfrom, > bytes, sizeof(bytes)); > > array = octets_to_cmpi(broker, bytes, size); > @@ -316,7 +409,7 @@ > (CMPIValue *)&array, CMPI_uint8A); > > memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.dstipto, > + size = octets_from_ip(rule_data.dstipto, > bytes, sizeof(bytes)); > > array = octets_to_cmpi(broker, bytes, size); > @@ -325,7 +418,7 @@ > (CMPIValue *)&array, CMPI_uint8A); > } else { > memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.dstipaddr, > + size = octets_from_ip(rule_data.dstipaddr, > bytes, sizeof(bytes)); > > array = octets_to_cmpi(broker, bytes, size); > @@ -334,8 +427,8 @@ > (CMPIValue *)&array, CMPI_uint8A); > > /* CIDR notation? */ > - if (rule->var.tcp.dstipmask) { > - char *netmask = strdup(rule->var.tcp.dstipmask); > + if (rule_data.dstipmask) { > + char *netmask = strdup(rule_data.dstipmask); > if (strstr(netmask, ".") == NULL) { > char *tmp = cidr_to_str(netmask); > free(netmask); > @@ -354,32 +447,29 @@ > } > } > > - if ((rule->type == IP_RULE) || (rule->type == TCP_RULE)) { > - if (rule->var.tcp.srcportstart) { > - n = atoi(rule->var.tcp.srcportstart); > - CMSetProperty(inst, "HdrSrcPortStart", > - (CMPIValue *)&n, CMPI_uint16); > - } > - > - if (rule->var.tcp.srcportend) { > - n = atoi(rule->var.tcp.srcportend); > - CMSetProperty(inst, "HdrSrcPortEnd", > - (CMPIValue *)&n, CMPI_uint16); > - } > - > - if (rule->var.tcp.dstportstart) { > - n = atoi(rule->var.tcp.dstportstart); > - CMSetProperty(inst, "HdrDestPortStart", > - (CMPIValue *)&n, CMPI_uint16); > - } > - > - if (rule->var.tcp.dstportend) { > - n = atoi(rule->var.tcp.dstportend); > - CMSetProperty(inst, "HdrDestPortEnd", > - (CMPIValue *)&n, CMPI_uint16); > - } > + if (rule_data.srcportstart) { > + n = atoi(rule_data.srcportstart); > + CMSetProperty(inst, "HdrSrcPortStart", > + (CMPIValue *)&n, CMPI_uint16); > } > > + if (rule_data.srcportend) { > + n = atoi(rule_data.srcportend); > + CMSetProperty(inst, "HdrSrcPortEnd", > + (CMPIValue *)&n, CMPI_uint16); > + } > + > + if (rule_data.dstportstart) { > + n = atoi(rule_data.dstportstart); > + CMSetProperty(inst, "HdrDestPortStart", > + (CMPIValue *)&n, CMPI_uint16); > + } > + > + if (rule_data.dstportend) { > + n = atoi(rule_data.dstportend); > + CMSetProperty(inst, "HdrDestPortEnd", > + (CMPIValue *)&n, CMPI_uint16); > + } > } > > static CMPIInstance *convert_rule_to_instance( > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 16:35:26 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:35:26 -0400 Subject: [Libvirt-cim] [PATCH 1 of 4] acl_parsing: Share code for icmp and icmp rule types In-Reply-To: References: Message-ID: <4E94704E.1040803@linux.vnet.ibm.com> +1. I doubt this will change anytime, so good optimization. On 10/06/2011 11:46 AM, Eduardo Lima (Etrunko) wrote: > libxkutil/acl_parsing.c | 119 ++++++++++++++--------------------------------- > libxkutil/acl_parsing.h | 29 +---------- > src/Virt_FilterEntry.c | 3 +- > 3 files changed, 41 insertions(+), 110 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317840215 10800 > # Node ID fa576f11a652c4632afb62c687707effb2e98a80 > # Parent 1f93220799a57477a6b1e04a90e8ffe797d85581 > acl_parsing: Share code for icmp and icmp rule types > > The struct for both ICMP and IGMP rule types have the exact same fields. > With this patch, we avoid duplicating code to handle those rules. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/libxkutil/acl_parsing.c b/libxkutil/acl_parsing.c > --- a/libxkutil/acl_parsing.c > +++ b/libxkutil/acl_parsing.c > @@ -97,41 +97,23 @@ > free(rule->var.tcp.comment); > free(rule->var.tcp.state); > break; > - case IGMP_RULE: > - free(rule->var.igmp.srcmacaddr); > - free(rule->var.igmp.srcmacmask); > - free(rule->var.igmp.dstmacaddr); > - free(rule->var.igmp.dstmacmask); > - free(rule->var.igmp.srcipaddr); > - free(rule->var.igmp.srcipmask); > - free(rule->var.igmp.dstipaddr); > - free(rule->var.igmp.dstipmask); > - free(rule->var.igmp.srcipfrom); > - free(rule->var.igmp.srcipto); > - free(rule->var.igmp.dstipfrom); > - free(rule->var.igmp.dstipto); > - free(rule->var.igmp.type); > - free(rule->var.igmp.code); > - free(rule->var.igmp.comment); > - free(rule->var.igmp.state); > - break; > - case ICMP_RULE: > - free(rule->var.icmp.srcmacaddr); > - free(rule->var.icmp.srcmacmask); > - free(rule->var.icmp.dstmacaddr); > - free(rule->var.icmp.dstmacmask); > - free(rule->var.icmp.srcipaddr); > - free(rule->var.icmp.srcipmask); > - free(rule->var.icmp.dstipaddr); > - free(rule->var.icmp.dstipmask); > - free(rule->var.icmp.srcipfrom); > - free(rule->var.icmp.srcipto); > - free(rule->var.icmp.dstipfrom); > - free(rule->var.icmp.dstipto); > - free(rule->var.icmp.type); > - free(rule->var.icmp.code); > - free(rule->var.icmp.comment); > - free(rule->var.icmp.state); > + case ICMP_IGMP_RULE: > + free(rule->var.icmp_igmp.srcmacaddr); > + free(rule->var.icmp_igmp.srcmacmask); > + free(rule->var.icmp_igmp.dstmacaddr); > + free(rule->var.icmp_igmp.dstmacmask); > + free(rule->var.icmp_igmp.srcipaddr); > + free(rule->var.icmp_igmp.srcipmask); > + free(rule->var.icmp_igmp.dstipaddr); > + free(rule->var.icmp_igmp.dstipmask); > + free(rule->var.icmp_igmp.srcipfrom); > + free(rule->var.icmp_igmp.srcipto); > + free(rule->var.icmp_igmp.dstipfrom); > + free(rule->var.icmp_igmp.dstipto); > + free(rule->var.icmp_igmp.type); > + free(rule->var.icmp_igmp.code); > + free(rule->var.icmp_igmp.comment); > + free(rule->var.icmp_igmp.state); > break; > case UNKNOWN_RULE: > default: > @@ -265,50 +247,25 @@ > return 1; > } > > -static int parse_acl_icmp_rule(xmlNode *rnode, struct acl_rule *rule) > +static int parse_acl_icmp_igmp_rule(xmlNode *rnode, struct acl_rule *rule) > { > - CU_DEBUG("ACL icmp rule %s", rnode->name); > + CU_DEBUG("ACL %s rule %s", rule->protocol_id, rnode->name); > > - rule->type = ICMP_RULE; > - rule->var.icmp.srcmacaddr = get_attr_value(rnode, "srcmacaddr"); > - rule->var.icmp.srcmacmask = get_attr_value(rnode, "srcmacmask"); > - rule->var.icmp.dstmacaddr = get_attr_value(rnode, "dstmacaddr"); > - rule->var.icmp.dstmacmask = get_attr_value(rnode, "dstmacmask"); > - rule->var.icmp.srcipaddr = get_attr_value(rnode, "srcipaddr"); > - rule->var.icmp.srcipmask = get_attr_value(rnode, "srcipmask"); > - rule->var.icmp.dstipaddr = get_attr_value(rnode, "dstipaddr"); > - rule->var.icmp.dstipmask = get_attr_value(rnode, "dstipmask"); > - rule->var.icmp.srcipfrom = get_attr_value(rnode, "srcipfrom"); > - rule->var.icmp.srcipto = get_attr_value(rnode, "srcipto"); > - rule->var.icmp.dstipfrom = get_attr_value(rnode, "dstipfrom"); > - rule->var.icmp.dstipto = get_attr_value(rnode, "dstipto"); > - rule->var.icmp.comment = get_attr_value(rnode, "comment"); > - rule->var.icmp.state = get_attr_value(rnode, "state"); > - > - return 1; > -} > - > -static int parse_acl_igmp_rule(xmlNode *rnode, struct acl_rule *rule) > -{ > - CU_DEBUG("ACL igmp rule %s", rnode->name); > - > - rule->type = IGMP_RULE; > - rule->var.igmp.srcmacaddr = get_attr_value(rnode, "srcmacaddr"); > - rule->var.igmp.srcmacmask = get_attr_value(rnode, "srcmacmask"); > - rule->var.igmp.dstmacaddr = get_attr_value(rnode, "dstmacaddr"); > - rule->var.igmp.dstmacmask = get_attr_value(rnode, "dstmacmask"); > - rule->var.igmp.srcipaddr = get_attr_value(rnode, "srcipaddr"); > - rule->var.igmp.srcipmask = get_attr_value(rnode, "srcipmask"); > - rule->var.igmp.dstipaddr = get_attr_value(rnode, "dstipaddr"); > - rule->var.igmp.dstipmask = get_attr_value(rnode, "dstipmask"); > - rule->var.igmp.srcipfrom = get_attr_value(rnode, "srcipfrom"); > - rule->var.igmp.srcipto = get_attr_value(rnode, "srcipto"); > - rule->var.igmp.dstipfrom = get_attr_value(rnode, "dstipfrom"); > - rule->var.igmp.dstipto = get_attr_value(rnode, "dstipto"); > - rule->var.igmp.type = get_attr_value(rnode, "type"); > - rule->var.igmp.code = get_attr_value(rnode, "code"); > - rule->var.igmp.comment = get_attr_value(rnode, "comment"); > - rule->var.igmp.state = get_attr_value(rnode, "state"); > + rule->type = ICMP_IGMP_RULE; > + rule->var.icmp_igmp.srcmacaddr = get_attr_value(rnode, "srcmacaddr"); > + rule->var.icmp_igmp.srcmacmask = get_attr_value(rnode, "srcmacmask"); > + rule->var.icmp_igmp.dstmacaddr = get_attr_value(rnode, "dstmacaddr"); > + rule->var.icmp_igmp.dstmacmask = get_attr_value(rnode, "dstmacmask"); > + rule->var.icmp_igmp.srcipaddr = get_attr_value(rnode, "srcipaddr"); > + rule->var.icmp_igmp.srcipmask = get_attr_value(rnode, "srcipmask"); > + rule->var.icmp_igmp.dstipaddr = get_attr_value(rnode, "dstipaddr"); > + rule->var.icmp_igmp.dstipmask = get_attr_value(rnode, "dstipmask"); > + rule->var.icmp_igmp.srcipfrom = get_attr_value(rnode, "srcipfrom"); > + rule->var.icmp_igmp.srcipto = get_attr_value(rnode, "srcipto"); > + rule->var.icmp_igmp.dstipfrom = get_attr_value(rnode, "dstipfrom"); > + rule->var.icmp_igmp.dstipto = get_attr_value(rnode, "dstipto"); > + rule->var.icmp_igmp.comment = get_attr_value(rnode, "comment"); > + rule->var.icmp_igmp.state = get_attr_value(rnode, "state"); > > return 1; > } > @@ -351,10 +308,8 @@ > rule->protocol_id = strdup((char *)child->name); > parse_acl_tcp_rule(child, rule); > } else if (XSTREQ(child->name, "icmp") || > - XSTREQ(child->name, "icmpv6")) { > - rule->protocol_id = strdup((char *)child->name); > - parse_acl_icmp_rule(child, rule); > - } else if (XSTREQ(child->name, "igmp") || > + XSTREQ(child->name, "icmpv6") || > + XSTREQ(child->name, "igmp") || > XSTREQ(child->name, "igmp-ipv6") || > XSTREQ(child->name, "esp") || > XSTREQ(child->name, "esp-ipv6") || > @@ -365,7 +320,7 @@ > XSTREQ(child->name, "all") || > XSTREQ(child->name, "all-ipv6")) { > rule->protocol_id = strdup((char *)child->name); > - parse_acl_igmp_rule(child, rule); > + parse_acl_icmp_igmp_rule(child, rule); > } > } > > diff --git a/libxkutil/acl_parsing.h b/libxkutil/acl_parsing.h > --- a/libxkutil/acl_parsing.h > +++ b/libxkutil/acl_parsing.h > @@ -95,7 +95,7 @@ > char *state; > }; > > -struct acl_igmp_rule { > +struct acl_icmp_igmp_rule { > char *srcmacaddr; > char *srcmacmask; > char *dstmacaddr; > @@ -117,27 +117,6 @@ > char *state; > }; > > -struct acl_icmp_rule { > - char *srcmacaddr; > - char *srcmacmask; > - char *dstmacaddr; > - char *dstmacmask; > - > - char *srcipaddr; > - char *srcipmask; > - char *dstipaddr; > - char *dstipmask; > - > - char *srcipfrom; > - char *srcipto; > - char *dstipfrom; > - char *dstipto; > - > - char *type; > - char *code; > - char *comment; > - char *state; > -}; > > struct acl_rule { > char *name; > @@ -153,8 +132,7 @@ > ARP_RULE, > IP_RULE, > TCP_RULE, > - ICMP_RULE, > - IGMP_RULE > + ICMP_IGMP_RULE, > } type; > > union { > @@ -162,8 +140,7 @@ > struct acl_arp_rule arp; > struct acl_ip_rule ip; > struct acl_tcp_rule tcp; > - struct acl_icmp_rule icmp; > - struct acl_igmp_rule igmp; > + struct acl_icmp_igmp_rule icmp_igmp; > } var; > }; > > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -348,8 +348,7 @@ > break; > case IP_RULE: > case TCP_RULE: > - case ICMP_RULE: > - case IGMP_RULE: > + case ICMP_IGMP_RULE: > basename = "IPHeadersFilter"; > convert_f = convert_ip_rule_to_instance; > break; > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 16:35:58 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:35:58 -0400 Subject: [Libvirt-cim] [PATCH 3 of 4] FilterEntry: Support for mask in CIDR notation In-Reply-To: <1a08d8186f3064dfb0c3.1317915996@eblima.br.ibm.com> References: <1a08d8186f3064dfb0c3.1317915996@eblima.br.ibm.com> Message-ID: <4E94706E.8060909@linux.vnet.ibm.com> +1. On 10/06/2011 11:46 AM, Eduardo Lima (Etrunko) wrote: > src/Virt_FilterEntry.c | 88 ++++++++++++++++++++++++++++++++++++++++++------- > 1 files changed, 74 insertions(+), 14 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317914740 10800 > # Node ID 1a08d8186f3064dfb0c38ecb5846ffc1e7d5de4d > # Parent a323895be993b3807cc41348ba3b74c76fb42596 > FilterEntry: Support for mask in CIDR notation > > The values for mask fields may have been written using the CIDR notation[1]. > For instance, take the libvirt 'no-ip-multicast' builtin filter: > > > 47756f11-6057-1448-2cce-fda40fa23ba4 > > > > > > As libvirt-cim expects an address like string, for the mask, in this case the > conversion will fail and will output an array with only zero values [0,0,0,0], > when it actually should be [240,0,0,0]. > > [1] http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -115,6 +115,44 @@ > return array; > } > > +static char *cidr_to_str(const char *cidr) > +{ > + char *ret = NULL; > + int val; > + unsigned int o1, o2, o3, o4; > + > + if (cidr == NULL || strlen(cidr) == 0) > + return NULL; > + > + CU_DEBUG("Enter %s(%s)", __FUNCTION__, cidr); > + > + /* String value to integer */ > + val = atoi(cidr); > + if (val< 0 || val> 32) > + return NULL; > + > + if (val == 0) > + return strdup("0.0.0.0"); > + else if (val == 32) > + return strdup("255.255.255.255"); > + > + /* CIDR to bits */ > + val = (0xffffffff>> (32 - val))<< (32 - val); > + > + /* bits to octets */ > + o1 = (val& 0xff000000)>> 24; > + o2 = (val& 0x00ff0000)>> 16; > + o3 = (val& 0x0000ff00)>> 8; > + o4 = val& 0x000000ff; > + > + /* octets to address string */ > + ret = calloc(1, sizeof(*ret) * 16); > + snprintf(ret, 16, "%u.%u.%u.%u", o1, o2, o3, o4); > + > + CU_DEBUG("%s: returning '%s'", __FUNCTION__, ret); > + return ret; > +} > + > static int convert_direction(const char *s) > { > enum {NOT_APPLICABLE, INPUT, OUTPUT, BOTH} direction = NOT_APPLICABLE; > @@ -246,14 +284,25 @@ > CMSetProperty(inst, "HdrSrcAddress", > (CMPIValue *)&array, CMPI_uint8A); > > - memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.srcipmask, > - bytes, sizeof(bytes)); > + /* CIDR notation? */ > + if (rule->var.tcp.srcipmask) { > + char *netmask = strdup(rule->var.tcp.srcipmask); > + if (strstr(netmask, ".") == NULL) { > + char *tmp = cidr_to_str(netmask); > + free(netmask); > + netmask = tmp; > + } > > - array = octets_to_cmpi(broker, bytes, size); > - if (array != NULL) > - CMSetProperty(inst, "HdrSrcMask", > - (CMPIValue *)&array, CMPI_uint8A); > + memset(bytes, 0, sizeof(bytes)); > + size = octets_from_ip(netmask, bytes, sizeof(bytes)); > + > + array = octets_to_cmpi(broker, bytes, size); > + if (array != NULL) > + CMSetProperty(inst, "HdrSrcMask", > + (CMPIValue *)&array, CMPI_uint8A); > + > + free(netmask); > + } > } > > if (rule->var.tcp.dstipfrom&& rule->var.tcp.dstipto) { > @@ -284,14 +333,25 @@ > CMSetProperty(inst, "HdrDestAddress", > (CMPIValue *)&array, CMPI_uint8A); > > - memset(bytes, 0, sizeof(bytes)); > - size = octets_from_ip(rule->var.tcp.dstipmask, > - bytes, sizeof(bytes)); > + /* CIDR notation? */ > + if (rule->var.tcp.dstipmask) { > + char *netmask = strdup(rule->var.tcp.dstipmask); > + if (strstr(netmask, ".") == NULL) { > + char *tmp = cidr_to_str(netmask); > + free(netmask); > + netmask = tmp; > + } > > - array = octets_to_cmpi(broker, bytes, size); > - if (array != NULL) > - CMSetProperty(inst, "HdrDestMask", > - (CMPIValue *)&array, CMPI_uint8A); > + memset(bytes, 0, sizeof(bytes)); > + size = octets_from_ip(netmask, bytes, sizeof(bytes)); > + > + array = octets_to_cmpi(broker, bytes, size); > + if (array != NULL) > + CMSetProperty(inst, "HdrDestMask", > + (CMPIValue *)&array, CMPI_uint8A); > + > + free(netmask); > + } > } > > if ((rule->type == IP_RULE) || (rule->type == TCP_RULE)) { > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 16:40:14 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:40:14 -0400 Subject: [Libvirt-cim] [PATCH 0 of 4] Various fixes to FilterEntry provider In-Reply-To: References: Message-ID: <4E94716E.8080309@linux.vnet.ibm.com> Thanks. Pushed series. On 10/06/2011 11:46 AM, Eduardo Lima (Etrunko) wrote: > > [1/4] acl_parsing: Share code for icmp and icmp rule types > > The struct for both ICMP and IGMP rule types have the exact same fields. > With this patch, we avoid duplicating code to handle those rules. > > [2/4] FilterEntry: Should be using srcipaddr instead of srcmacaddr > > [3/4] FilterEntry: Support for mask in CIDR notation > > The values for mask fields may have been written using the CIDR notation[1]. > For instance, take the libvirt 'no-ip-multicast' builtin filter: > > > 47756f11-6057-1448-2cce-fda40fa23ba4 > > > > > > As libvirt-cim expects an address like string, for the mask, in this case the > conversion will fail and will output an array with only zero values [0,0,0,0], > when it actually should be [240,0,0,0]. > > [1] http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing > > [4/4] FilterEntry: Fix behavior of convert_ip_rule_to_instance > > The function was always referencing the 'tcp' fileld of the var union in struct > acl_rule, while it should take into account the rule type to access the correct > fields. This could probably go to acl_parsing, but I thought it would be a less > intrusive change to patch only FilterEntry provider. > > Signed-off-by: Eduardo Lima (Etrunko) > > libxkutil/acl_parsing.c | 119 ++++++++++------------------------ > libxkutil/acl_parsing.h | 29 +------- > src/Virt_FilterEntry.c | 3 +- > src/Virt_FilterEntry.c | 2 +- > src/Virt_FilterEntry.c | 88 +++++++++++++++++++++---- > src/Virt_FilterEntry.c | 162 +++++++++++++++++++++++++++++++++++++---------- > 6 files changed, 242 insertions(+), 161 deletions(-) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 16:52:36 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 12:52:36 -0400 Subject: [Libvirt-cim] [PATCH] FilterEntry: Set HdrProtocolID8021 property In-Reply-To: <8384b32b9a79999bcf3c.1317930519@eblima.br.ibm.com> References: <8384b32b9a79999bcf3c.1317930519@eblima.br.ibm.com> Message-ID: <4E947454.40502@linux.vnet.ibm.com> +1 & pushed. On 10/06/2011 03:48 PM, Eduardo Lima (Etrunko) wrote: > src/Virt_FilterEntry.c | 14 ++++++++++++-- > 1 files changed, 12 insertions(+), 2 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317929569 10800 > # Node ID 8384b32b9a79999bcf3c414d94bc18789b6d9318 > # Parent e6c6f9ccb51303f67fce26e74de9ab746d10a04b > FilterEntry: Set HdrProtocolID8021 property > > Also remove a couple of duplicate (CMPIValue *) casts. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -27,6 +27,8 @@ > > #include > > +#include > + > #include "acl_parsing.h" > #include "misc_util.h" > #include "xmlgen.h" > @@ -247,7 +249,7 @@ > > array = octets_to_cmpi(broker, bytes, size); > if (array != NULL) > - CMSetProperty(inst, "HdrDestMACAddr8021", (CMPIValue *) > + CMSetProperty(inst, "HdrDestMACAddr8021", > (CMPIValue *)&array, CMPI_uint8A); > > memset(bytes, 0, sizeof(bytes)); > @@ -256,8 +258,16 @@ > > array = octets_to_cmpi(broker, bytes, size); > if (array != NULL) > - CMSetProperty(inst, "HdrDestMACMask8021", (CMPIValue *) > + CMSetProperty(inst, "HdrDestMACMask8021", > (CMPIValue *)&array, CMPI_uint8A); > + > + if (rule->var.mac.protocol_id != NULL) { > + unsigned long n = strtoul(rule->var.mac.protocol_id, > + NULL, 16); > + CMSetProperty(inst, "HdrProtocolID8021", > + (CMPIValue *)&n, CMPI_uint16); > + } > + > } > > static void fill_rule_data(struct acl_rule *rule, > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Tue Oct 11 21:09:27 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 11 Oct 2011 17:09:27 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Adding tests for FilterLists In-Reply-To: <4E8E14C4.50703@linux.vnet.ibm.com> References: <4E8E14C4.50703@linux.vnet.ibm.com> Message-ID: <4E94B087.3070203@linux.vnet.ibm.com> -------------------------------------------------------------------- FilterList - 01_enum.py: PASS -------------------------------------------------------------------- FilterList - 02_assoc.py: PASS -------------------------------------------------------------------- FilterList - 03_create.py: FAIL ERROR - Caught exception: (1, u'CIM_ERR_FAILED: Failed to update device') -------------------------------------------------------------------- The last error is either a bug or as-designed (at least in libvirt-0.8.7). I'm working with the network folks who did the ACL impl in libvirt to see which it is. +1 and pushed. Thanks, Eduardo. On 10/06/2011 04:51 PM, Eduardo Lima (Etrunko) wrote: > On 10/06/2011 05:11 PM, Eduardo Lima (Etrunko) wrote: >> suites/libvirt-cim/cimtest/FilterList/01_enum.py | 71 ++ >> suites/libvirt-cim/cimtest/FilterList/02_assoc.py | 158 ++++++ >> suites/libvirt-cim/cimtest/FilterList/03_create.py | 199 ++++++++ >> suites/libvirt-cim/cimtest/FilterList/helper.py | 515 +++++++++++++++++++++ >> 4 files changed, 943 insertions(+), 0 deletions(-) >> >> >> # HG changeset patch >> # User Eduardo Lima (Etrunko) >> # Date 1310498051 10800 >> # Node ID d9741a8b5eb7ccebf21d69f3cde72729bb60ad22 >> # Parent 779871660a3583dedf1652773196d07093ff26ff >> [TEST] Adding tests for FilterLists >> >> helper.py: >> - Helper module with classes and functions used by all tests >> >> 01_enum.py: >> - Enumerate FilterList instances and compare to results from libvirt >> >> 02_assoc.py: >> - For each FilterList instance, call Associators to get respective >> FilterEntries instances and compare to results from libvirt >> >> 03_create.py: >> - Creates a new FilterList instance and a NestedFilterList associated >> to this new instance. Creates a new domain and a new >> AppliedFilterList instance associated to the NetworkPort instance of >> that new domain. > > Please note that these tests require the latest series of patches to > FilterEntry provider that were been sent to this mailing list in order > to produce the right results. > > Best regards, Etrunko > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Wed Oct 12 14:45:43 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 12 Oct 2011 10:45:43 -0400 Subject: [Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService In-Reply-To: References: Message-ID: <4E95A817.9020602@linux.vnet.ibm.com> Using tog-pegasus-2.11.0-1, I see the following: -------------------------------------------------------------------- VirtualSystemManagementService - 31_unset_netrasd.py: FAIL ERROR - Current 'virtio' and expected '' ResourceSubType differ -------------------------------------------------------------------- Does this mean my pegasus version has the bug? If so, should we check the CIMOM version as part of this test? On 09/28/2011 09:41 AM, Eduardo Lima (Etrunko) wrote: > suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py | 193 ++++++++++ > 1 files changed, 193 insertions(+), 0 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317153134 10800 > # Node ID eac4909ac68adc28cad9cb6389ea93a053b23aec > # Parent 83921669cae17a4f0a18bb440ebec01de1a3e691 > [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService > > This test case covers a recent bug found in Pegasus which makes impossible for > libvirt-cim to set a property values if the value is an empty string via a > ModifyResourceSettings call. > > Link to Pegasus bug follows: > http://bugzilla.openpegasus.org/show_bug.cgi?id=9053 > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > new file mode 100755 > --- /dev/null > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > @@ -0,0 +1,193 @@ > +#!/usr/bin/env python > + > +# > +# Copyright 2011 IBM Corp. > +# > +# Authors: > +# Eduardo Lima (Etrunko) > +# > +# This library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > +# > +# This library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# General Public License for more details. > +# > +# You should have received a copy of the GNU General Public > +# License along with this library; if not, write to the Free Software > +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > +# > + > +# > +# ModifyResourceSettings call to set/unset NetRASD ResourceType property > +# > + > +import sys > +import pywbem > + > +from CimTest.ReturnCodes import PASS, FAIL > +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS > +from XenKvmLib.const import do_main > +from XenKvmLib.classes import get_typed_class > +from XenKvmLib.vxml import get_class > + > +supported = ['Xen', 'KVM', 'XenFV', 'LXC'] > +domain = None > + > +class CIMDomain(object): > + > + def __init__(self, name, virt, server): > + self.name = name > + self.server = server > + self._domain = get_class(virt)(name) > + #__init__ > + > + def define(self): > + return self._domain.cim_define(self.server) > + # define > + > + def undefine(self): > + return self._domain.undefine(self.server) > + # undefine > + > + def destroy(self): > + return self._domain.cim_destroy(self.server) > + #destroy > +# CIMDomain > + > + > +def resource_settings(inst, virt, resource_subtype): > + return """ > +instance of %s { > + InstanceID="%s"; > + ResourceType=%d; > + Address="%s"; > + VirtualQuantityUnits="%s"; > + NetworkType="%s"; > + NetworkName="%s"; > + ResourceSubType="%s"; > +};""" % (get_typed_class(virt, "NetResourceAllocationSettingData"), > + inst["InstanceID"], > + inst["ResourceType"], > + inst["Address"], > + inst["VirtualQuantityUnits"], > + inst["NetworkType"], > + inst["NetworkName"], > + resource_subtype) > +# resource_settings() > + > + > + at do_main(supported) > +def main(): > + # init > + options = main.options > + server = options.ip > + virt = options.virt > + > + server_url = "http://%s" % server > + cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS) > + > + _class = get_typed_class(virt, "VirtualSystemManagementService") > + sys_mgmt_service = cim.EnumerateInstanceNames(_class)[0] > + > + # Create new domain > + global domain > + domain = CIMDomain("cimtest_unset_netrasd", virt, server) > + if not domain.define(): > + logger.error("Error defining test domain") > + return FAIL > + > + # ein KVM_ComputerSystem > + _class = get_typed_class(virt, "ComputerSystem") > + computer_system_names = [i for i in cim.EnumerateInstanceNames(_class) if i["Name"] == domain.name] > + > + logger.info("ComputerSystem Names\n%s", computer_system_names) > + > + if not computer_system_names: > + logger.info("Host has no domains defined") > + return SKIP > + > + # ain -ac KVM_SystemDevice -arc KVM_NetworkPort > + a_class = get_typed_class(virt, "SystemDevice") > + r_class = get_typed_class(virt, "NetworkPort") > + network_port_names = [] > + > + for inst_name in computer_system_names: > + assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class) > + network_port_names.extend(assoc_names) > + > + logger.info("NetworkPort Names\n%s", network_port_names) > + > + if not network_port_names: > + logger.info("No NetworkPort instances returned") > + return XFAIL > + > + # ai -arc KVM_NetResourceAllocationSettingData > + r_class = get_typed_class(virt, "NetResourceAllocationSettingData") > + net_rasd_names = [] > + > + for inst_name in network_port_names: > + assoc_names = cim.AssociatorNames(inst_name, ResultClass=r_class) > + net_rasd_names.extend(assoc_names) > + > + logger.info("NetRASD names\n%s", net_rasd_names) > + > + if not net_rasd_names: > + logger.info("No NetRASD instances returned") > + return XFAIL > + > + for subtype in ["virtio", "",]: > + logger.info("Setting ResourceSubType to '%s'", subtype) > + > + modified_net_rasd_names = [] > + > + for inst_name in net_rasd_names: > + # Get current instance data > + inst = cim.GetInstance(inst_name) > + cur_id = inst["InstanceID"] > + cur_subtype = inst["ResourceSubType"] > + logger.info("Current ResourceSubType of %s: '%s'", cur_id, cur_subtype) > + > + # Invoke ModifyResourceSettings > + val = resource_settings(inst, virt, subtype) > + ret = cim.InvokeMethod("ModifyResourceSettings", sys_mgmt_service, **{"ResourceSettings": [val,],}) > + > + if ret[0]: > + logger.error("ERROR Setting ResourceSubtype to '%s': %s", subtype, ret) > + return FAIL > + > + modified_net_rasd_names.extend(ret[1]["ResultingResourceSettings"]) > + > + # Get modified instance data > + inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) > + new_id = inst["InstanceID"] > + new_subtype = inst["ResourceSubType"] > + > + logger.info("Modified ResourceSubType of %s: '%s'", new_id, new_subtype) > + > + if cur_id != new_id: > + logger.error("Current '%s' and new '%s' InstanceID differ", cur_id, new_id) > + return FAIL > + > + if new_subtype != subtype: > + logger.error("Current '%s' and expected '%s' ResourceSubType differ", new_subtype, subtype) > + return FAIL > + # for inst_name... > + > + net_rasd_names = modified_net_rasd_names > + #for subtype... > + > + return PASS > +#main() > + > +if __name__ == "__main__": > + ret = main() > + > + if domain: > + domain.destroy() > + domain.undefine() > + > + sys.exit(ret) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From bestor at us.ibm.com Wed Oct 12 17:01:10 2011 From: bestor at us.ibm.com (Gareth S Bestor) Date: Wed, 12 Oct 2011 10:01:10 -0700 Subject: [Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService In-Reply-To: <4E95A817.9020602@linux.vnet.ibm.com> Message-ID: This fix is in tog-pegasus-2.12, so yes you probably have this bug in your version (unless its been patched) Ideally, the cimom type (sfcb vs pegasus) and version shouldn't matter in most instances, with the excpetion of perhaps actual *new* features, like reliable indications, embeeded instance support, etc... I think having a cimom check in the cimtest suites would be OK for such things. But I dont think adding explicit checks for what are ostensibly occasional bugs in a particular version of a particular packages is a path we really want to go down... (eg this bug popped up only in pegasus 2.10/2.11; this worked back in 2.9 days). Eduardo's testcase is valid; this is just a test that will fail when run against a particular version of (unpatched) pegasus. That should be noted somewhere, but I dont think we necessarily need to 'work around it'... just my $0.02 - G Dr. Gareth S. Bestor IBM Senior Software Engineer Systems & Technology Group - Systems Management Standards 971-285-6375 (mobile) bestor at us.ibm.com Re: [Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService Chip Vincent to: libvirt-cim 10/12/11 08:04 AM Sent by: libvirt-cim-bounces at redhat.com Please respond to cvincent, List for discussion and development of libvirt CIM Using tog-pegasus-2.11.0-1, I see the following: -------------------------------------------------------------------- VirtualSystemManagementService - 31_unset_netrasd.py: FAIL ERROR - Current 'virtio' and expected '' ResourceSubType differ -------------------------------------------------------------------- Does this mean my pegasus version has the bug? If so, should we check the CIMOM version as part of this test? On 09/28/2011 09:41 AM, Eduardo Lima (Etrunko) wrote: > suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py | 193 ++++++++++ > 1 files changed, 193 insertions(+), 0 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317153134 10800 > # Node ID eac4909ac68adc28cad9cb6389ea93a053b23aec > # Parent 83921669cae17a4f0a18bb440ebec01de1a3e691 > [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService > > This test case covers a recent bug found in Pegasus which makes impossible for > libvirt-cim to set a property values if the value is an empty string via a > ModifyResourceSettings call. > > Link to Pegasus bug follows: > http://bugzilla.openpegasus.org/show_bug.cgi?id=9053 > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > new file mode 100755 > --- /dev/null > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > @@ -0,0 +1,193 @@ > +#!/usr/bin/env python > + > +# > +# Copyright 2011 IBM Corp. > +# > +# Authors: > +# Eduardo Lima (Etrunko) > +# > +# This library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > +# > +# This library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# General Public License for more details. > +# > +# You should have received a copy of the GNU General Public > +# License along with this library; if not, write to the Free Software > +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > +# > + > +# > +# ModifyResourceSettings call to set/unset NetRASD ResourceType property > +# > + > +import sys > +import pywbem > + > +from CimTest.ReturnCodes import PASS, FAIL > +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS > +from XenKvmLib.const import do_main > +from XenKvmLib.classes import get_typed_class > +from XenKvmLib.vxml import get_class > + > +supported = ['Xen', 'KVM', 'XenFV', 'LXC'] > +domain = None > + > +class CIMDomain(object): > + > + def __init__(self, name, virt, server): > + self.name = name > + self.server = server > + self._domain = get_class(virt)(name) > + #__init__ > + > + def define(self): > + return self._domain.cim_define(self.server) > + # define > + > + def undefine(self): > + return self._domain.undefine(self.server) > + # undefine > + > + def destroy(self): > + return self._domain.cim_destroy(self.server) > + #destroy > +# CIMDomain > + > + > +def resource_settings(inst, virt, resource_subtype): > + return """ > +instance of %s { > + InstanceID="%s"; > + ResourceType=%d; > + Address="%s"; > + VirtualQuantityUnits="%s"; > + NetworkType="%s"; > + NetworkName="%s"; > + ResourceSubType="%s"; > +};""" % (get_typed_class(virt, "NetResourceAllocationSettingData"), > + inst["InstanceID"], > + inst["ResourceType"], > + inst["Address"], > + inst["VirtualQuantityUnits"], > + inst["NetworkType"], > + inst["NetworkName"], > + resource_subtype) > +# resource_settings() > + > + > + at do_main(supported) > +def main(): > + # init > + options = main.options > + server = options.ip > + virt = options.virt > + > + server_url = "http://%s" % server > + cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS) > + > + _class = get_typed_class(virt, "VirtualSystemManagementService") > + sys_mgmt_service = cim.EnumerateInstanceNames(_class)[0] > + > + # Create new domain > + global domain > + domain = CIMDomain("cimtest_unset_netrasd", virt, server) > + if not domain.define(): > + logger.error("Error defining test domain") > + return FAIL > + > + # ein KVM_ComputerSystem > + _class = get_typed_class(virt, "ComputerSystem") > + computer_system_names = [i for i in cim.EnumerateInstanceNames(_class) if i["Name"] == domain.name] > + > + logger.info("ComputerSystem Names\n%s", computer_system_names) > + > + if not computer_system_names: > + logger.info("Host has no domains defined") > + return SKIP > + > + # ain -ac KVM_SystemDevice -arc KVM_NetworkPort > + a_class = get_typed_class(virt, "SystemDevice") > + r_class = get_typed_class(virt, "NetworkPort") > + network_port_names = [] > + > + for inst_name in computer_system_names: > + assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class) > + network_port_names.extend(assoc_names) > + > + logger.info("NetworkPort Names\n%s", network_port_names) > + > + if not network_port_names: > + logger.info("No NetworkPort instances returned") > + return XFAIL > + > + # ai -arc KVM_NetResourceAllocationSettingData > + r_class = get_typed_class(virt, "NetResourceAllocationSettingData") > + net_rasd_names = [] > + > + for inst_name in network_port_names: > + assoc_names = cim.AssociatorNames(inst_name, ResultClass=r_class) > + net_rasd_names.extend(assoc_names) > + > + logger.info("NetRASD names\n%s", net_rasd_names) > + > + if not net_rasd_names: > + logger.info("No NetRASD instances returned") > + return XFAIL > + > + for subtype in ["virtio", "",]: > + logger.info("Setting ResourceSubType to '%s'", subtype) > + > + modified_net_rasd_names = [] > + > + for inst_name in net_rasd_names: > + # Get current instance data > + inst = cim.GetInstance(inst_name) > + cur_id = inst["InstanceID"] > + cur_subtype = inst["ResourceSubType"] > + logger.info("Current ResourceSubType of %s: '%s'", cur_id, cur_subtype) > + > + # Invoke ModifyResourceSettings > + val = resource_settings(inst, virt, subtype) > + ret = cim.InvokeMethod("ModifyResourceSettings", sys_mgmt_service, **{"ResourceSettings": [val,],}) > + > + if ret[0]: > + logger.error("ERROR Setting ResourceSubtype to '%s': %s", subtype, ret) > + return FAIL > + > + modified_net_rasd_names.extend(ret[1]["ResultingResourceSettings"]) > + > + # Get modified instance data > + inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) > + new_id = inst["InstanceID"] > + new_subtype = inst["ResourceSubType"] > + > + logger.info("Modified ResourceSubType of %s: '%s'", new_id, new_subtype) > + > + if cur_id != new_id: > + logger.error("Current '%s' and new '%s' InstanceID differ", cur_id, new_id) > + return FAIL > + > + if new_subtype != subtype: > + logger.error("Current '%s' and expected '%s' ResourceSubType differ", new_subtype, subtype) > + return FAIL > + # for inst_name... > + > + net_rasd_names = modified_net_rasd_names > + #for subtype... > + > + return PASS > +#main() > + > +if __name__ == "__main__": > + ret = main() > + > + if domain: > + domain.destroy() > + domain.undefine() > + > + sys.exit(ret) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com _______________________________________________ Libvirt-cim mailing list Libvirt-cim at redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: From xiawenc at linux.vnet.ibm.com Thu Oct 13 08:30:55 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 13 Oct 2011 16:30:55 +0800 Subject: [Libvirt-cim] [PATCH] Add support for libvirt CPU cgroup for active KVM guests In-Reply-To: <2c9a378e141c23eae0b9.1317635530@rhel6> References: <2c9a378e141c23eae0b9.1317635530@rhel6> Message-ID: <4E96A1BF.9020500@linux.vnet.ibm.com> Tested on my laptop with libvirt 0.9.4, this version have cgroup feature added for inactive guest, but the libvirt-cim also acts as expected. Tested-by: Wayne Xia ? 2011-10-3 17:52, Gareth S. Bestor ??: > # HG changeset patch > # User Gareth S. Bestor > # Date 1317635486 25200 > # Node ID 2c9a378e141c23eae0b96b2f021adbd14cfb8ef2 > # Parent fb09136deb494008eb3aacee420ad74da7d7c294 > Add support for libvirt CPU cgroup for active KVM guests > Add support for setting and retreiving the CPU cgroup setting for an active KVM guest > using libivirt scheduling parameter support. Presently this patches only supports earlier > libvirt versions' support of this feature, which only support setting these scheduling > params for *active* guests only, and uses libivrt's earlier scheduling APIs; a subsequent > patch will support both and the newer APIs (version dependent). > A guest's CPU cgroup setting it exposed via the KVM_ProcResourceAllocationSettingData.Weight > property. > Minimum, maximum, Increment and Default weights are exposed appropriately via > the respective Processor pool. > Weight for new guest can be passed in on DefineSystem[] > Weigh for existing (active) guest can be changed via ModifyResourceSettings[] > Signed-off-by: Gareth S. Bestor > > diff -r fb09136deb49 -r 2c9a378e141c libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/libxkutil/device_parsing.c Mon Oct 03 02:51:26 2011 -0700 > @@ -1297,6 +1297,24 @@ > { > int ret; > > + /* Change vcpu cgroup cpu_shares */ > + if (dev->dev.vcpu.weight> 0) { > + virSchedParameter param; > + > + strncpy(param.field, "cpu_shares", VIR_DOMAIN_SCHED_FIELD_LENGTH); > + param.type = VIR_DOMAIN_SCHED_FIELD_ULLONG; > + param.value.ul = dev->dev.vcpu.weight; > + > + if (virDomainSetSchedulerParameters(dom,¶m, 1) != 0) { > + CU_DEBUG("Failed to set scheduler params for domain"); > + return 0; > + } > + > + CU_DEBUG("Changed %s vcpu cgroup cpu_shares to %i", > + virDomainGetName(dom), > + dev->dev.vcpu.weight); > + } > + > if (dev->dev.vcpu.quantity<= 0) { > CU_DEBUG("Unable to set VCPU count to %i", > dev->dev.vcpu.quantity); > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_ComputerSystem.c > --- a/src/Virt_ComputerSystem.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_ComputerSystem.c Mon Oct 03 02:51:26 2011 -0700 > @@ -858,6 +858,30 @@ > return 0; > } > > +static int kvm_scheduler_params(struct infostore_ctx *ctx, > + virSchedParameter **params) > +{ > + unsigned long long value; > + > + *params = calloc(1, sizeof(virSchedParameter)); > + if (*params == NULL) > + return -1; > + > + value = infostore_get_u64(ctx, "weight"); > + > + if (value != 0) { > + strncpy((*params)[0].field, > + "cpu_shares", > + VIR_DOMAIN_SCHED_FIELD_LENGTH); > + (*params)[0].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; > + (*params)[0].value.ul = value; > + > + return 1; > + } > + > + return 0; > +} > + > static void set_scheduler_params(virDomainPtr dom) > { > struct infostore_ctx *ctx; > @@ -881,6 +905,8 @@ > count = xen_scheduler_params(ctx,¶ms); > else if (STREQC(virConnectGetType(conn), "lxc")) > count = lxc_scheduler_params(ctx,¶ms); > + else if (STREQC(virConnectGetType(conn), "QEMU")) > + count = kvm_scheduler_params(ctx,¶ms); > else { > CU_DEBUG("Not setting sched params for type %s", > virConnectGetType(conn)); > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_RASD.c > --- a/src/Virt_RASD.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_RASD.c Mon Oct 03 02:51:26 2011 -0700 > @@ -110,7 +110,7 @@ > virConnectPtr conn = NULL; > virDomainPtr dom = NULL; > struct infostore_ctx *info = NULL; > - uint32_t weight; > + uint32_t weight = 0; > uint64_t limit; > uint64_t count; > > @@ -147,7 +147,45 @@ > goto out; > } > > - weight = (uint32_t)infostore_get_u64(info, "weight"); > + /* Currently only support CPU cgroups for running KVM guests */ > + if (domain_online(dom)&& STREQC(virConnectGetType(conn), "QEMU")) { > + char *sched; > + int nparams; > + unsigned int i; > + virSchedParameter *params; > + > + /* First find the number of scheduler params, in order malloc space for them all */ > + sched = virDomainGetSchedulerType(dom,&nparams); > + if (sched == NULL) { > + CU_DEBUG("Failed to get scheduler type"); > + goto out; > + } > + CU_DEBUG("domain has %d scheduler params", nparams); > + free(sched); > + > + /* Now retrieve all the scheduler params for this domain */ > + params = calloc(nparams, sizeof(virSchedParameter)); > + if (virDomainGetSchedulerParameters(dom, params,&nparams) != 0) { > + CU_DEBUG("Failed to get scheduler params for domain"); > + goto out; > + } > + > + /* Look for the CPU cgroup scheduler parameter, called 'cpu_shares' */ > + for (i = 0 ; i< nparams ; i++) { > + CU_DEBUG("scheduler param #%d name is %s (type %d)", > + i, params[i].field, params[i].type); > + if (STREQ(params[i].field, "cpu_shares")&& > + (params[i].type == VIR_DOMAIN_SCHED_FIELD_ULLONG)) { > + CU_DEBUG("scheduler param %s = %d", > + params[i].field, params[i].value.ul); > + weight = (uint32_t)params[i].value.ul; > + break; /* Found it! */ > + } > + } > + free(params); > + } > + else > + weight = (uint32_t)infostore_get_u64(info, "weight"); > limit = infostore_get_u64(info, "limit"); > > CMSetProperty(inst, "Weight", > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_SettingsDefineCapabilities.c Mon Oct 03 02:51:26 2011 -0700 > @@ -410,7 +410,10 @@ > case SDC_RASD_MIN: > num_procs = 0; > limit = 1; > - weight = MIN_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = MIN_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = MIN_KVM_WEIGHT; > id = "Minimum"; > break; > case SDC_RASD_MAX: > @@ -418,19 +421,28 @@ > if (!ret) > goto out; > limit = 0; > - weight = MAX_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = MAX_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = MAX_KVM_WEIGHT; > id = "Maximum"; > break; > case SDC_RASD_INC: > num_procs = 1; > limit = 50; > - weight = INC_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = INC_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = INC_KVM_WEIGHT; > id = "Increment"; > break; > case SDC_RASD_DEF: > num_procs = 1; > limit = 0; > - weight = DEFAULT_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = DEFAULT_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = DEFAULT_KVM_WEIGHT; > id = "Default"; > break; > default: > @@ -455,6 +467,10 @@ > CMSetProperty(inst, "Weight", > (CMPIValue *)&weight, CMPI_uint32); > } > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) { > + CMSetProperty(inst, "Weight", > + (CMPIValue *)&weight, CMPI_uint32); > + } > > inst_list_add(list, inst); > > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 03 02:51:26 2011 -0700 > @@ -1012,6 +1012,8 @@ > > if (STARTS_WITH(CLASSNAME(op), "Xen")) > def_weight = DEFAULT_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(op), "QEMU")) > + def_weight = DEFAULT_KVM_WEIGHT; > > rc = cu_get_u64_prop(inst, "Limit",&dev->dev.vcpu.limit); > if (rc != CMPI_RC_OK) > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_VirtualSystemManagementService.h > --- a/src/Virt_VirtualSystemManagementService.h Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_VirtualSystemManagementService.h Mon Oct 03 02:51:26 2011 -0700 > @@ -24,6 +24,11 @@ > #define INC_XEN_WEIGHT MAX_XEN_WEIGHT / 2 > #define DEFAULT_XEN_WEIGHT 1024 > > +#define MIN_KVM_WEIGHT 2 > +#define MAX_KVM_WEIGHT 262144 > +#define INC_KVM_WEIGHT 1 > +#define DEFAULT_KVM_WEIGHT 1024 > + > CMPIStatus get_vsms(const CMPIObjectPath *reference, > CMPIInstance **_inst, > const CMPIBroker *broker, > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From cvincent at linux.vnet.ibm.com Thu Oct 13 12:19:48 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 13 Oct 2011 08:19:48 -0400 Subject: [Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService In-Reply-To: References: Message-ID: <4E96D764.2040106@linux.vnet.ibm.com> Sound reasonable. THanks, Pushed. On 10/12/2011 01:01 PM, Gareth S Bestor wrote: > > This fix is in tog-pegasus-2.12, so yes you probably have this bug in > your version (unless its been patched) > > Ideally, the cimom type (sfcb vs pegasus) and version shouldn't matter > in most instances, with the excpetion of perhaps actual *new* features, > like reliable indications, embeeded instance support, etc... I think > having a cimom check in the cimtest suites would be OK for such things. > But I dont think adding explicit checks for what are ostensibly > occasional bugs in a particular version of a particular packages is a > path we really want to go down... (eg this bug popped up only in pegasus > 2.10/2.11; this worked back in 2.9 days). Eduardo's testcase is valid; > this is just a test that will fail when run against a particular version > of (unpatched) pegasus. That should be noted somewhere, but I dont think > we necessarily need to 'work around it'... > > just my $0.02 > > - G > > Dr. Gareth S. Bestor > IBM Senior Software Engineer > Systems & Technology Group - Systems Management Standards > 971-285-6375 (mobile) > bestor at us.ibm.com > > > > *Re: [Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for > VirtualSystemManagementService* > > > *Chip Vincent * to: libvirt-cim > 10/12/11 08:04 AM > > > Sent by: *libvirt-cim-bounces at redhat.com* > > > *Please respond to cvincent, List for discussion and development of > libvirt CIM * > > > > > ------------------------------------------------------------------------ > > > > Using tog-pegasus-2.11.0-1, I see the following: > > -------------------------------------------------------------------- > VirtualSystemManagementService - 31_unset_netrasd.py: FAIL > ERROR - Current 'virtio' and expected '' ResourceSubType differ > -------------------------------------------------------------------- > > Does this mean my pegasus version has the bug? If so, should we check > the CIMOM version as part of this test? > > On 09/28/2011 09:41 AM, Eduardo Lima (Etrunko) wrote: > > > suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > | 193 ++++++++++ > > 1 files changed, 193 insertions(+), 0 deletions(-) > > > > > > # HG changeset patch > > # User Eduardo Lima (Etrunko) > > # Date 1317153134 10800 > > # Node ID eac4909ac68adc28cad9cb6389ea93a053b23aec > > # Parent 83921669cae17a4f0a18bb440ebec01de1a3e691 > > [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService > > > > This test case covers a recent bug found in Pegasus which makes > impossible for > > libvirt-cim to set a property values if the value is an empty string > via a > > ModifyResourceSettings call. > > > > Link to Pegasus bug follows: > > http://bugzilla.openpegasus.org/show_bug.cgi?id=9053 > > > > Signed-off-by: Eduardo Lima (Etrunko) > > > > diff --git > a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > > new file mode 100755 > > --- /dev/null > > +++ > b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > > @@ -0,0 +1,193 @@ > > +#!/usr/bin/env python > > + > > +# > > +# Copyright 2011 IBM Corp. > > +# > > +# Authors: > > +# Eduardo Lima (Etrunko) > > +# > > +# This library is free software; you can redistribute it and/or > > +# modify it under the terms of the GNU General Public > > +# License as published by the Free Software Foundation; either > > +# version 2.1 of the License, or (at your option) any later version. > > +# > > +# This library is distributed in the hope that it will be useful, > > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > +# General Public License for more details. > > +# > > +# You should have received a copy of the GNU General Public > > +# License along with this library; if not, write to the Free Software > > +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > 02111-1307 USA > > +# > > + > > +# > > +# ModifyResourceSettings call to set/unset NetRASD ResourceType property > > +# > > + > > +import sys > > +import pywbem > > + > > +from CimTest.ReturnCodes import PASS, FAIL > > +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS > > +from XenKvmLib.const import do_main > > +from XenKvmLib.classes import get_typed_class > > +from XenKvmLib.vxml import get_class > > + > > +supported = ['Xen', 'KVM', 'XenFV', 'LXC'] > > +domain = None > > + > > +class CIMDomain(object): > > + > > + def __init__(self, name, virt, server): > > + self.name = name > > + self.server = server > > + self._domain = get_class(virt)(name) > > + #__init__ > > + > > + def define(self): > > + return self._domain.cim_define(self.server) > > + # define > > + > > + def undefine(self): > > + return self._domain.undefine(self.server) > > + # undefine > > + > > + def destroy(self): > > + return self._domain.cim_destroy(self.server) > > + #destroy > > +# CIMDomain > > + > > + > > +def resource_settings(inst, virt, resource_subtype): > > + return """ > > +instance of %s { > > + InstanceID="%s"; > > + ResourceType=%d; > > + Address="%s"; > > + VirtualQuantityUnits="%s"; > > + NetworkType="%s"; > > + NetworkName="%s"; > > + ResourceSubType="%s"; > > +};""" % (get_typed_class(virt, "NetResourceAllocationSettingData"), > > + inst["InstanceID"], > > + inst["ResourceType"], > > + inst["Address"], > > + inst["VirtualQuantityUnits"], > > + inst["NetworkType"], > > + inst["NetworkName"], > > + resource_subtype) > > +# resource_settings() > > + > > + > > + at do_main(supported) > > +def main(): > > + # init > > + options = main.options > > + server = options.ip > > + virt = options.virt > > + > > + server_url = "http://%s" % server > > + cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS) > > + > > + _class = get_typed_class(virt, "VirtualSystemManagementService") > > + sys_mgmt_service = cim.EnumerateInstanceNames(_class)[0] > > + > > + # Create new domain > > + global domain > > + domain = CIMDomain("cimtest_unset_netrasd", virt, server) > > + if not domain.define(): > > + logger.error("Error defining test domain") > > + return FAIL > > + > > + # ein KVM_ComputerSystem > > + _class = get_typed_class(virt, "ComputerSystem") > > + computer_system_names = [i for i in > cim.EnumerateInstanceNames(_class) if i["Name"] == domain.name] > > + > > + logger.info("ComputerSystem Names\n%s", computer_system_names) > > + > > + if not computer_system_names: > > + logger.info("Host has no domains defined") > > + return SKIP > > + > > + # ain -ac KVM_SystemDevice -arc KVM_NetworkPort > > + a_class = get_typed_class(virt, "SystemDevice") > > + r_class = get_typed_class(virt, "NetworkPort") > > + network_port_names = [] > > + > > + for inst_name in computer_system_names: > > + assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, > ResultClass=r_class) > > + network_port_names.extend(assoc_names) > > + > > + logger.info("NetworkPort Names\n%s", network_port_names) > > + > > + if not network_port_names: > > + logger.info("No NetworkPort instances returned") > > + return XFAIL > > + > > + # ai -arc KVM_NetResourceAllocationSettingData > > + r_class = get_typed_class(virt, "NetResourceAllocationSettingData") > > + net_rasd_names = [] > > + > > + for inst_name in network_port_names: > > + assoc_names = cim.AssociatorNames(inst_name, ResultClass=r_class) > > + net_rasd_names.extend(assoc_names) > > + > > + logger.info("NetRASD names\n%s", net_rasd_names) > > + > > + if not net_rasd_names: > > + logger.info("No NetRASD instances returned") > > + return XFAIL > > + > > + for subtype in ["virtio", "",]: > > + logger.info("Setting ResourceSubType to '%s'", subtype) > > + > > + modified_net_rasd_names = [] > > + > > + for inst_name in net_rasd_names: > > + # Get current instance data > > + inst = cim.GetInstance(inst_name) > > + cur_id = inst["InstanceID"] > > + cur_subtype = inst["ResourceSubType"] > > + logger.info("Current ResourceSubType of %s: '%s'", cur_id, cur_subtype) > > + > > + # Invoke ModifyResourceSettings > > + val = resource_settings(inst, virt, subtype) > > + ret = cim.InvokeMethod("ModifyResourceSettings", sys_mgmt_service, > **{"ResourceSettings": [val,],}) > > + > > + if ret[0]: > > + logger.error("ERROR Setting ResourceSubtype to '%s': %s", subtype, ret) > > + return FAIL > > + > > + modified_net_rasd_names.extend(ret[1]["ResultingResourceSettings"]) > > + > > + # Get modified instance data > > + inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) > > + new_id = inst["InstanceID"] > > + new_subtype = inst["ResourceSubType"] > > + > > + logger.info("Modified ResourceSubType of %s: '%s'", new_id, > new_subtype) > > + > > + if cur_id != new_id: > > + logger.error("Current '%s' and new '%s' InstanceID differ", cur_id, > new_id) > > + return FAIL > > + > > + if new_subtype != subtype: > > + logger.error("Current '%s' and expected '%s' ResourceSubType > differ", new_subtype, subtype) > > + return FAIL > > + # for inst_name... > > + > > + net_rasd_names = modified_net_rasd_names > > + #for subtype... > > + > > + return PASS > > +#main() > > + > > +if __name__ == "__main__": > > + ret = main() > > + > > + if domain: > > + domain.destroy() > > + domain.undefine() > > + > > + sys.exit(ret) > > > > _______________________________________________ > > Libvirt-cim mailing list > > Libvirt-cim at redhat.com > > https://www.redhat.com/mailman/listinfo/libvirt-cim > > > > -- > Chip Vincent > Open Virtualization > IBM Linux Technology Center > cvincent at linux.vnet.ibm.com > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Oct 13 12:37:45 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 13 Oct 2011 08:37:45 -0400 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: References: Message-ID: <4E96DB99.4060707@linux.vnet.ibm.com> # ll /var/lib/libvirt/images total 16844232 -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso After extracting the .iso files and applying both patches, I get the following error: Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not match expected '' ERROR - TypeError : 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "32_modify_cdrom_media.py", line 209, in main inst = modify_media(cim, inst, media_path) File "32_modify_cdrom_media.py", line 100, in modify_media val = set_device_addr(inst, addr) File "32_modify_cdrom_media.py", line 83, in set_device_addr inst["InstanceID"], TypeError: 'NoneType' object is unsubscriptable ERROR - None -------------------------------------------------------------------- On 09/30/2011 02:59 PM, Eduardo Lima (Etrunko) wrote: > suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + > suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 +++++++++++++++ > 2 files changed, 16 insertions(+), 0 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317408948 10800 > # Node ID f4bcd9833525c6914f61e29e9d2d8adbac240682 > # Parent eac4909ac68adc28cad9cb6389ea93a053b23aec > [TEST] XenKvmLib: Add cdrom device description to domain > > The default domain created by libvirt-cim did not include a cdrom device, > which is required by a new test for VirtualSystemManagementService. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py b/suites/libvirt-cim/lib/XenKvmLib/const.py > --- a/suites/libvirt-cim/lib/XenKvmLib/const.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py > @@ -87,6 +87,7 @@ > KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage') > KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND') > KVM_default_disk_dev = 'hda' > +KVM_default_cdrom_dev = 'hdc' > KVM_default_mac = '11:22:33:aa:bb:cc' > > # vxml.XenFVXML > diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py > --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py > @@ -628,6 +628,12 @@ > self.iasd = vsms.get_iasd_class(virt)(name=dom_name, > res_sub_type=irstype, > bus_type=btype) > + if virt == "KVM": > + dasd = vsms.get_dasd_class(virt) > + self.cdrom_dasd = dasd(dev=const.KVM_default_cdrom_dev, > + source="", > + name=dom_name, > + emu_type=1) > def cim_define(self, ip, ref_conf=None): > service = vsms.get_vsms_class(self.virt)(ip) > sys_settings = str(self.vssd) > @@ -645,6 +651,10 @@ > else: > res_settings.append(str(self.nasd)) > > + # CDROM device > + if self.virt == "KVM": > + res_settings.append(str(self.cdrom_dasd)) > + > curr_cim_rev, changeset = get_provider_version(self.virt, ip) > if curr_cim_rev>= vsms_graphics_sup: > if self.gasd is not None: > @@ -941,6 +951,11 @@ > disk = self.add_sub_node(devices, 'disk', type='file', device='disk') > self.add_sub_node(disk, 'source', file=disk_img) > self.add_sub_node(disk, 'target', dev=disk_dev) > + > + cdrom = self.add_sub_node(devices, 'disk', type='file', device='cdrom') > + self.add_sub_node(cdrom, 'source', file="") > + self.add_sub_node(cdrom, 'target', dev=const.KVM_default_cdrom_dev) > + > self.add_sub_node(devices, 'input', type='mouse', bus='ps2') > self.add_sub_node(devices, 'graphics', type='vnc', port='5900', > keymap='en-us') > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Oct 13 13:37:49 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 13 Oct 2011 09:37:49 -0400 Subject: [Libvirt-cim] [PATCH] Add support for libvirt CPU cgroup for active KVM guests In-Reply-To: <2c9a378e141c23eae0b9.1317635530@rhel6> References: <2c9a378e141c23eae0b9.1317635530@rhel6> Message-ID: <4E96E9AD.1030704@linux.vnet.ibm.com> Default: wbemcli -nl -arc KVM_ProcResourceAllocationSettingData ai 'local/root/virt:KVM_Processor.CreationClassName="KVM_Processor",DeviceID="WinXP10/0",SystemCreationClassName="KVM_ComputerSystem",SystemName="WinXP10"' oc0840652111.ibm.com/root /virt:KVM_ProcResourceAllocationSettingData.InstanceID="WinXP10/proc" -Caption= -Description= -Generation= -InstanceID="WinXP10/proc" -ElementName= -ConfigurationName= -ChangeableType= -ResourceType=3 -OtherResourceType= -ResourceSubType= -PoolID= -ConsumerVisibility= -HostResource= -AllocationUnits= -VirtualQuantity=1 -Reservation= -Limit=0 -Weight=1024 -AutomaticAllocation= -AutomaticDeallocation= -Parent= -Connection= -Address= -MappingBehavior= -AddressOnParent= -VirtualQuantityUnits="count" Change CPU share outside of CIM: # virsh schedinfo --set cpu_shares=512 WinXP10 Scheduler : posix cpu_shares : 512 # wbemcli -nl -arc KVM_ProcResourceAllocationSettingData ai 'local/root/virt:KVM_Processor.CreationClassName="KVM_Processor",DeviceID="WinXP10/0",SystemCreationClassName="KVM_ComputerSystem",SystemName="WinXP10"' oc0840652111.ibm.com/root/virt:KVM_ProcResourceAllocationSettingData.InstanceID="WinXP10/proc" -Caption= -Description= -Generation= -InstanceID="WinXP10/proc" -ElementName= -ConfigurationName= -ChangeableType= -ResourceType=3 -OtherResourceType= -ResourceSubType= -PoolID= -ConsumerVisibility= -HostResource= -AllocationUnits= -VirtualQuantity=1 -Reservation= -Limit=0 -Weight=512 -AutomaticAllocation= -AutomaticDeallocation= -Parent= -Connection= -Address= -MappingBehavior= -AddressOnParent= -VirtualQuantityUnits="count" I'm getting the following error when I try to modify via CIM. HTTP/1.1 401 Unauthorized content-length: 0000000000 WWW-Authenticate: Basic realm="oc0840652111.ibm.com" But I think that is a problem with my configuration, not the patch. +1. Thanks, Gareth. On 10/03/2011 05:52 AM, Gareth S. Bestor wrote: > # HG changeset patch > # User Gareth S. Bestor > # Date 1317635486 25200 > # Node ID 2c9a378e141c23eae0b96b2f021adbd14cfb8ef2 > # Parent fb09136deb494008eb3aacee420ad74da7d7c294 > Add support for libvirt CPU cgroup for active KVM guests > Add support for setting and retreiving the CPU cgroup setting for an active KVM guest > using libivirt scheduling parameter support. Presently this patches only supports earlier > libvirt versions' support of this feature, which only support setting these scheduling > params for *active* guests only, and uses libivrt's earlier scheduling APIs; a subsequent > patch will support both and the newer APIs (version dependent). > A guest's CPU cgroup setting it exposed via the KVM_ProcResourceAllocationSettingData.Weight > property. > Minimum, maximum, Increment and Default weights are exposed appropriately via > the respective Processor pool. > Weight for new guest can be passed in on DefineSystem[] > Weigh for existing (active) guest can be changed via ModifyResourceSettings[] > Signed-off-by: Gareth S. Bestor > > diff -r fb09136deb49 -r 2c9a378e141c libxkutil/device_parsing.c > --- a/libxkutil/device_parsing.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/libxkutil/device_parsing.c Mon Oct 03 02:51:26 2011 -0700 > @@ -1297,6 +1297,24 @@ > { > int ret; > > + /* Change vcpu cgroup cpu_shares */ > + if (dev->dev.vcpu.weight> 0) { > + virSchedParameter param; > + > + strncpy(param.field, "cpu_shares", VIR_DOMAIN_SCHED_FIELD_LENGTH); > + param.type = VIR_DOMAIN_SCHED_FIELD_ULLONG; > + param.value.ul = dev->dev.vcpu.weight; > + > + if (virDomainSetSchedulerParameters(dom,¶m, 1) != 0) { > + CU_DEBUG("Failed to set scheduler params for domain"); > + return 0; > + } > + > + CU_DEBUG("Changed %s vcpu cgroup cpu_shares to %i", > + virDomainGetName(dom), > + dev->dev.vcpu.weight); > + } > + > if (dev->dev.vcpu.quantity<= 0) { > CU_DEBUG("Unable to set VCPU count to %i", > dev->dev.vcpu.quantity); > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_ComputerSystem.c > --- a/src/Virt_ComputerSystem.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_ComputerSystem.c Mon Oct 03 02:51:26 2011 -0700 > @@ -858,6 +858,30 @@ > return 0; > } > > +static int kvm_scheduler_params(struct infostore_ctx *ctx, > + virSchedParameter **params) > +{ > + unsigned long long value; > + > + *params = calloc(1, sizeof(virSchedParameter)); > + if (*params == NULL) > + return -1; > + > + value = infostore_get_u64(ctx, "weight"); > + > + if (value != 0) { > + strncpy((*params)[0].field, > + "cpu_shares", > + VIR_DOMAIN_SCHED_FIELD_LENGTH); > + (*params)[0].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; > + (*params)[0].value.ul = value; > + > + return 1; > + } > + > + return 0; > +} > + > static void set_scheduler_params(virDomainPtr dom) > { > struct infostore_ctx *ctx; > @@ -881,6 +905,8 @@ > count = xen_scheduler_params(ctx,¶ms); > else if (STREQC(virConnectGetType(conn), "lxc")) > count = lxc_scheduler_params(ctx,¶ms); > + else if (STREQC(virConnectGetType(conn), "QEMU")) > + count = kvm_scheduler_params(ctx,¶ms); > else { > CU_DEBUG("Not setting sched params for type %s", > virConnectGetType(conn)); > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_RASD.c > --- a/src/Virt_RASD.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_RASD.c Mon Oct 03 02:51:26 2011 -0700 > @@ -110,7 +110,7 @@ > virConnectPtr conn = NULL; > virDomainPtr dom = NULL; > struct infostore_ctx *info = NULL; > - uint32_t weight; > + uint32_t weight = 0; > uint64_t limit; > uint64_t count; > > @@ -147,7 +147,45 @@ > goto out; > } > > - weight = (uint32_t)infostore_get_u64(info, "weight"); > + /* Currently only support CPU cgroups for running KVM guests */ > + if (domain_online(dom)&& STREQC(virConnectGetType(conn), "QEMU")) { > + char *sched; > + int nparams; > + unsigned int i; > + virSchedParameter *params; > + > + /* First find the number of scheduler params, in order malloc space for them all */ > + sched = virDomainGetSchedulerType(dom,&nparams); > + if (sched == NULL) { > + CU_DEBUG("Failed to get scheduler type"); > + goto out; > + } > + CU_DEBUG("domain has %d scheduler params", nparams); > + free(sched); > + > + /* Now retrieve all the scheduler params for this domain */ > + params = calloc(nparams, sizeof(virSchedParameter)); > + if (virDomainGetSchedulerParameters(dom, params,&nparams) != 0) { > + CU_DEBUG("Failed to get scheduler params for domain"); > + goto out; > + } > + > + /* Look for the CPU cgroup scheduler parameter, called 'cpu_shares' */ > + for (i = 0 ; i< nparams ; i++) { > + CU_DEBUG("scheduler param #%d name is %s (type %d)", > + i, params[i].field, params[i].type); > + if (STREQ(params[i].field, "cpu_shares")&& > + (params[i].type == VIR_DOMAIN_SCHED_FIELD_ULLONG)) { > + CU_DEBUG("scheduler param %s = %d", > + params[i].field, params[i].value.ul); > + weight = (uint32_t)params[i].value.ul; > + break; /* Found it! */ > + } > + } > + free(params); > + } > + else > + weight = (uint32_t)infostore_get_u64(info, "weight"); > limit = infostore_get_u64(info, "limit"); > > CMSetProperty(inst, "Weight", > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_SettingsDefineCapabilities.c Mon Oct 03 02:51:26 2011 -0700 > @@ -410,7 +410,10 @@ > case SDC_RASD_MIN: > num_procs = 0; > limit = 1; > - weight = MIN_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = MIN_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = MIN_KVM_WEIGHT; > id = "Minimum"; > break; > case SDC_RASD_MAX: > @@ -418,19 +421,28 @@ > if (!ret) > goto out; > limit = 0; > - weight = MAX_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = MAX_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = MAX_KVM_WEIGHT; > id = "Maximum"; > break; > case SDC_RASD_INC: > num_procs = 1; > limit = 50; > - weight = INC_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = INC_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = INC_KVM_WEIGHT; > id = "Increment"; > break; > case SDC_RASD_DEF: > num_procs = 1; > limit = 0; > - weight = DEFAULT_XEN_WEIGHT; > + if (STARTS_WITH(CLASSNAME(ref), "Xen")) > + weight = DEFAULT_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) > + weight = DEFAULT_KVM_WEIGHT; > id = "Default"; > break; > default: > @@ -455,6 +467,10 @@ > CMSetProperty(inst, "Weight", > (CMPIValue *)&weight, CMPI_uint32); > } > + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) { > + CMSetProperty(inst, "Weight", > + (CMPIValue *)&weight, CMPI_uint32); > + } > > inst_list_add(list, inst); > > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 03 02:51:26 2011 -0700 > @@ -1012,6 +1012,8 @@ > > if (STARTS_WITH(CLASSNAME(op), "Xen")) > def_weight = DEFAULT_XEN_WEIGHT; > + else if (STARTS_WITH(CLASSNAME(op), "QEMU")) > + def_weight = DEFAULT_KVM_WEIGHT; > > rc = cu_get_u64_prop(inst, "Limit",&dev->dev.vcpu.limit); > if (rc != CMPI_RC_OK) > diff -r fb09136deb49 -r 2c9a378e141c src/Virt_VirtualSystemManagementService.h > --- a/src/Virt_VirtualSystemManagementService.h Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_VirtualSystemManagementService.h Mon Oct 03 02:51:26 2011 -0700 > @@ -24,6 +24,11 @@ > #define INC_XEN_WEIGHT MAX_XEN_WEIGHT / 2 > #define DEFAULT_XEN_WEIGHT 1024 > > +#define MIN_KVM_WEIGHT 2 > +#define MAX_KVM_WEIGHT 262144 > +#define INC_KVM_WEIGHT 1 > +#define DEFAULT_KVM_WEIGHT 1024 > + > CMPIStatus get_vsms(const CMPIObjectPath *reference, > CMPIInstance **_inst, > const CMPIBroker *broker, > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Thu Oct 13 13:39:18 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 13 Oct 2011 09:39:18 -0400 Subject: [Libvirt-cim] [PATCH] Add support for libvirt CPU cgroup for active KVM guests In-Reply-To: <4E96A1BF.9020500@linux.vnet.ibm.com> References: <2c9a378e141c23eae0b9.1317635530@rhel6> <4E96A1BF.9020500@linux.vnet.ibm.com> Message-ID: <4E96EA06.2030907@linux.vnet.ibm.com> Thanks. Pushed. On 10/13/2011 04:30 AM, Wayne Xia wrote: > Tested on my laptop with libvirt 0.9.4, this version have cgroup > feature added for inactive guest, but the libvirt-cim also acts as > expected. > > Tested-by: Wayne Xia > > > ? 2011-10-3 17:52, Gareth S. Bestor ??: >> # HG changeset patch >> # User Gareth S. Bestor >> # Date 1317635486 25200 >> # Node ID 2c9a378e141c23eae0b96b2f021adbd14cfb8ef2 >> # Parent fb09136deb494008eb3aacee420ad74da7d7c294 >> Add support for libvirt CPU cgroup for active KVM guests >> Add support for setting and retreiving the CPU cgroup setting for an >> active KVM guest >> using libivirt scheduling parameter support. Presently this patches >> only supports earlier >> libvirt versions' support of this feature, which only support setting >> these scheduling >> params for *active* guests only, and uses libivrt's earlier scheduling >> APIs; a subsequent >> patch will support both and the newer APIs (version dependent). >> A guest's CPU cgroup setting it exposed via the >> KVM_ProcResourceAllocationSettingData.Weight >> property. >> Minimum, maximum, Increment and Default weights are exposed >> appropriately via >> the respective Processor pool. >> Weight for new guest can be passed in on DefineSystem[] >> Weigh for existing (active) guest can be changed via >> ModifyResourceSettings[] >> Signed-off-by: Gareth S. Bestor >> >> diff -r fb09136deb49 -r 2c9a378e141c libxkutil/device_parsing.c >> --- a/libxkutil/device_parsing.c Tue Aug 30 08:48:36 2011 -0700 >> +++ b/libxkutil/device_parsing.c Mon Oct 03 02:51:26 2011 -0700 >> @@ -1297,6 +1297,24 @@ >> { >> int ret; >> >> + /* Change vcpu cgroup cpu_shares */ >> + if (dev->dev.vcpu.weight> 0) { >> + virSchedParameter param; >> + >> + strncpy(param.field, "cpu_shares", VIR_DOMAIN_SCHED_FIELD_LENGTH); >> + param.type = VIR_DOMAIN_SCHED_FIELD_ULLONG; >> + param.value.ul = dev->dev.vcpu.weight; >> + >> + if (virDomainSetSchedulerParameters(dom,¶m, 1) != 0) { >> + CU_DEBUG("Failed to set scheduler params for domain"); >> + return 0; >> + } >> + >> + CU_DEBUG("Changed %s vcpu cgroup cpu_shares to %i", >> + virDomainGetName(dom), >> + dev->dev.vcpu.weight); >> + } >> + >> if (dev->dev.vcpu.quantity<= 0) { >> CU_DEBUG("Unable to set VCPU count to %i", >> dev->dev.vcpu.quantity); >> diff -r fb09136deb49 -r 2c9a378e141c src/Virt_ComputerSystem.c >> --- a/src/Virt_ComputerSystem.c Tue Aug 30 08:48:36 2011 -0700 >> +++ b/src/Virt_ComputerSystem.c Mon Oct 03 02:51:26 2011 -0700 >> @@ -858,6 +858,30 @@ >> return 0; >> } >> >> +static int kvm_scheduler_params(struct infostore_ctx *ctx, >> + virSchedParameter **params) >> +{ >> + unsigned long long value; >> + >> + *params = calloc(1, sizeof(virSchedParameter)); >> + if (*params == NULL) >> + return -1; >> + >> + value = infostore_get_u64(ctx, "weight"); >> + >> + if (value != 0) { >> + strncpy((*params)[0].field, >> + "cpu_shares", >> + VIR_DOMAIN_SCHED_FIELD_LENGTH); >> + (*params)[0].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; >> + (*params)[0].value.ul = value; >> + >> + return 1; >> + } >> + >> + return 0; >> +} >> + >> static void set_scheduler_params(virDomainPtr dom) >> { >> struct infostore_ctx *ctx; >> @@ -881,6 +905,8 @@ >> count = xen_scheduler_params(ctx,¶ms); >> else if (STREQC(virConnectGetType(conn), "lxc")) >> count = lxc_scheduler_params(ctx,¶ms); >> + else if (STREQC(virConnectGetType(conn), "QEMU")) >> + count = kvm_scheduler_params(ctx,¶ms); >> else { >> CU_DEBUG("Not setting sched params for type %s", >> virConnectGetType(conn)); >> diff -r fb09136deb49 -r 2c9a378e141c src/Virt_RASD.c >> --- a/src/Virt_RASD.c Tue Aug 30 08:48:36 2011 -0700 >> +++ b/src/Virt_RASD.c Mon Oct 03 02:51:26 2011 -0700 >> @@ -110,7 +110,7 @@ >> virConnectPtr conn = NULL; >> virDomainPtr dom = NULL; >> struct infostore_ctx *info = NULL; >> - uint32_t weight; >> + uint32_t weight = 0; >> uint64_t limit; >> uint64_t count; >> >> @@ -147,7 +147,45 @@ >> goto out; >> } >> >> - weight = (uint32_t)infostore_get_u64(info, "weight"); >> + /* Currently only support CPU cgroups for running KVM guests */ >> + if (domain_online(dom)&& STREQC(virConnectGetType(conn), "QEMU")) { >> + char *sched; >> + int nparams; >> + unsigned int i; >> + virSchedParameter *params; >> + >> + /* First find the number of scheduler params, in order malloc space >> for them all */ >> + sched = virDomainGetSchedulerType(dom,&nparams); >> + if (sched == NULL) { >> + CU_DEBUG("Failed to get scheduler type"); >> + goto out; >> + } >> + CU_DEBUG("domain has %d scheduler params", nparams); >> + free(sched); >> + >> + /* Now retrieve all the scheduler params for this domain */ >> + params = calloc(nparams, sizeof(virSchedParameter)); >> + if (virDomainGetSchedulerParameters(dom, params,&nparams) != 0) { >> + CU_DEBUG("Failed to get scheduler params for domain"); >> + goto out; >> + } >> + >> + /* Look for the CPU cgroup scheduler parameter, called 'cpu_shares' */ >> + for (i = 0 ; i< nparams ; i++) { >> + CU_DEBUG("scheduler param #%d name is %s (type %d)", >> + i, params[i].field, params[i].type); >> + if (STREQ(params[i].field, "cpu_shares")&& >> + (params[i].type == VIR_DOMAIN_SCHED_FIELD_ULLONG)) { >> + CU_DEBUG("scheduler param %s = %d", >> + params[i].field, params[i].value.ul); >> + weight = (uint32_t)params[i].value.ul; >> + break; /* Found it! */ >> + } >> + } >> + free(params); >> + } >> + else >> + weight = (uint32_t)infostore_get_u64(info, "weight"); >> limit = infostore_get_u64(info, "limit"); >> >> CMSetProperty(inst, "Weight", >> diff -r fb09136deb49 -r 2c9a378e141c >> src/Virt_SettingsDefineCapabilities.c >> --- a/src/Virt_SettingsDefineCapabilities.c Tue Aug 30 08:48:36 2011 >> -0700 >> +++ b/src/Virt_SettingsDefineCapabilities.c Mon Oct 03 02:51:26 2011 >> -0700 >> @@ -410,7 +410,10 @@ >> case SDC_RASD_MIN: >> num_procs = 0; >> limit = 1; >> - weight = MIN_XEN_WEIGHT; >> + if (STARTS_WITH(CLASSNAME(ref), "Xen")) >> + weight = MIN_XEN_WEIGHT; >> + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) >> + weight = MIN_KVM_WEIGHT; >> id = "Minimum"; >> break; >> case SDC_RASD_MAX: >> @@ -418,19 +421,28 @@ >> if (!ret) >> goto out; >> limit = 0; >> - weight = MAX_XEN_WEIGHT; >> + if (STARTS_WITH(CLASSNAME(ref), "Xen")) >> + weight = MAX_XEN_WEIGHT; >> + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) >> + weight = MAX_KVM_WEIGHT; >> id = "Maximum"; >> break; >> case SDC_RASD_INC: >> num_procs = 1; >> limit = 50; >> - weight = INC_XEN_WEIGHT; >> + if (STARTS_WITH(CLASSNAME(ref), "Xen")) >> + weight = INC_XEN_WEIGHT; >> + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) >> + weight = INC_KVM_WEIGHT; >> id = "Increment"; >> break; >> case SDC_RASD_DEF: >> num_procs = 1; >> limit = 0; >> - weight = DEFAULT_XEN_WEIGHT; >> + if (STARTS_WITH(CLASSNAME(ref), "Xen")) >> + weight = DEFAULT_XEN_WEIGHT; >> + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) >> + weight = DEFAULT_KVM_WEIGHT; >> id = "Default"; >> break; >> default: >> @@ -455,6 +467,10 @@ >> CMSetProperty(inst, "Weight", >> (CMPIValue *)&weight, CMPI_uint32); >> } >> + else if (STARTS_WITH(CLASSNAME(ref), "KVM")) { >> + CMSetProperty(inst, "Weight", >> + (CMPIValue *)&weight, CMPI_uint32); >> + } >> >> inst_list_add(list, inst); >> >> diff -r fb09136deb49 -r 2c9a378e141c >> src/Virt_VirtualSystemManagementService.c >> --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 >> 2011 -0700 >> +++ b/src/Virt_VirtualSystemManagementService.c Mon Oct 03 02:51:26 >> 2011 -0700 >> @@ -1012,6 +1012,8 @@ >> >> if (STARTS_WITH(CLASSNAME(op), "Xen")) >> def_weight = DEFAULT_XEN_WEIGHT; >> + else if (STARTS_WITH(CLASSNAME(op), "QEMU")) >> + def_weight = DEFAULT_KVM_WEIGHT; >> >> rc = cu_get_u64_prop(inst, "Limit",&dev->dev.vcpu.limit); >> if (rc != CMPI_RC_OK) >> diff -r fb09136deb49 -r 2c9a378e141c >> src/Virt_VirtualSystemManagementService.h >> --- a/src/Virt_VirtualSystemManagementService.h Tue Aug 30 08:48:36 >> 2011 -0700 >> +++ b/src/Virt_VirtualSystemManagementService.h Mon Oct 03 02:51:26 >> 2011 -0700 >> @@ -24,6 +24,11 @@ >> #define INC_XEN_WEIGHT MAX_XEN_WEIGHT / 2 >> #define DEFAULT_XEN_WEIGHT 1024 >> >> +#define MIN_KVM_WEIGHT 2 >> +#define MAX_KVM_WEIGHT 262144 >> +#define INC_KVM_WEIGHT 1 >> +#define DEFAULT_KVM_WEIGHT 1024 >> + >> CMPIStatus get_vsms(const CMPIObjectPath *reference, >> CMPIInstance **_inst, >> const CMPIBroker *broker, >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From xiawenc at linux.vnet.ibm.com Fri Oct 14 07:50:53 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Fri, 14 Oct 2011 15:50:53 +0800 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: <4E96DB99.4060707@linux.vnet.ibm.com> References: <4E96DB99.4060707@linux.vnet.ibm.com> Message-ID: <4E97E9DD.4010200@linux.vnet.ibm.com> ? 2011-10-13 20:37, Chip Vincent ??: > # ll /var/lib/libvirt/images > total 16844232 > -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso > -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso > > > After extracting the .iso files and applying both patches, I get the > following error: > > Testing KVM hypervisor > -------------------------------------------------------------------- > VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL > ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not match > expected '' > ERROR - TypeError : 'NoneType' object is unsubscriptable > Traceback (most recent call last): > File > "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", > line 141, in do_try > rc = f() > File "32_modify_cdrom_media.py", line 209, in main > inst = modify_media(cim, inst, media_path) > File "32_modify_cdrom_media.py", line 100, in modify_media > val = set_device_addr(inst, addr) > File "32_modify_cdrom_media.py", line 83, in set_device_addr > inst["InstanceID"], > TypeError: 'NoneType' object is unsubscriptable > ERROR - None > -------------------------------------------------------------------- > strange, I think the case failed in the switch phase: cdrom01.iso->empty->cdrom2.iso. ERROR - TypeError : 'NoneType' object is unsubscriptable seems related to a python grammar issue, maybe it is caused by python version, what is it on your PC? Mine version: python 2.6.6 Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) Kernel: 2.6.32-71.el6.x86_64 libvirt: 0.9.4 Hypervisor: QEMU 0.14.50 CIMOM: Pegasus 2.9.1 Libvirt-cim revision: 1152 Libvirt-cim changeset: 2714b9a5e842+ Cimtest revision: 881 Cimtest changeset: a550ae7da806 > > On 09/30/2011 02:59 PM, Eduardo Lima (Etrunko) wrote: >> suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + >> suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 +++++++++++++++ >> 2 files changed, 16 insertions(+), 0 deletions(-) >> >> >> # HG changeset patch >> # User Eduardo Lima (Etrunko) >> # Date 1317408948 10800 >> # Node ID f4bcd9833525c6914f61e29e9d2d8adbac240682 >> # Parent eac4909ac68adc28cad9cb6389ea93a053b23aec >> [TEST] XenKvmLib: Add cdrom device description to domain >> >> The default domain created by libvirt-cim did not include a cdrom device, >> which is required by a new test for VirtualSystemManagementService. >> >> Signed-off-by: Eduardo Lima (Etrunko) >> >> diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py >> b/suites/libvirt-cim/lib/XenKvmLib/const.py >> --- a/suites/libvirt-cim/lib/XenKvmLib/const.py >> +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py >> @@ -87,6 +87,7 @@ >> KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage') >> KVM_secondary_disk_path = os.path.join(_image_dir, >> 'default-kvm-dimage.2ND') >> KVM_default_disk_dev = 'hda' >> +KVM_default_cdrom_dev = 'hdc' >> KVM_default_mac = '11:22:33:aa:bb:cc' >> >> # vxml.XenFVXML >> diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py >> b/suites/libvirt-cim/lib/XenKvmLib/vxml.py >> --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py >> +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py >> @@ -628,6 +628,12 @@ >> self.iasd = vsms.get_iasd_class(virt)(name=dom_name, >> res_sub_type=irstype, >> bus_type=btype) >> + if virt == "KVM": >> + dasd = vsms.get_dasd_class(virt) >> + self.cdrom_dasd = dasd(dev=const.KVM_default_cdrom_dev, >> + source="", >> + name=dom_name, >> + emu_type=1) >> def cim_define(self, ip, ref_conf=None): >> service = vsms.get_vsms_class(self.virt)(ip) >> sys_settings = str(self.vssd) >> @@ -645,6 +651,10 @@ >> else: >> res_settings.append(str(self.nasd)) >> >> + # CDROM device >> + if self.virt == "KVM": >> + res_settings.append(str(self.cdrom_dasd)) >> + >> curr_cim_rev, changeset = get_provider_version(self.virt, ip) >> if curr_cim_rev>= vsms_graphics_sup: >> if self.gasd is not None: >> @@ -941,6 +951,11 @@ >> disk = self.add_sub_node(devices, 'disk', type='file', device='disk') >> self.add_sub_node(disk, 'source', file=disk_img) >> self.add_sub_node(disk, 'target', dev=disk_dev) >> + >> + cdrom = self.add_sub_node(devices, 'disk', type='file', device='cdrom') >> + self.add_sub_node(cdrom, 'source', file="") >> + self.add_sub_node(cdrom, 'target', dev=const.KVM_default_cdrom_dev) >> + >> self.add_sub_node(devices, 'input', type='mouse', bus='ps2') >> self.add_sub_node(devices, 'graphics', type='vnc', port='5900', >> keymap='en-us') >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From cvincent at linux.vnet.ibm.com Fri Oct 14 11:25:01 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 14 Oct 2011 07:25:01 -0400 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: <4E97E9DD.4010200@linux.vnet.ibm.com> References: <4E96DB99.4060707@linux.vnet.ibm.com> <4E97E9DD.4010200@linux.vnet.ibm.com> Message-ID: <4E981C0D.60501@linux.vnet.ibm.com> On 10/14/2011 03:50 AM, Wayne Xia wrote: > ? 2011-10-13 20:37, Chip Vincent ??: [snip] > strange, I think the case failed in the switch phase: > cdrom01.iso->empty->cdrom2.iso. > > ERROR - TypeError : 'NoneType' object is unsubscriptable > seems related to a python grammar issue, maybe it is caused by > python version, what is it on your PC? > > Mine version: > python 2.6.6 > Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) > Kernel: 2.6.32-71.el6.x86_64 > libvirt: 0.9.4 > Hypervisor: QEMU 0.14.50 > CIMOM: Pegasus 2.9.1 > Libvirt-cim revision: 1152 > Libvirt-cim changeset: 2714b9a5e842+ > Cimtest revision: 881 > Cimtest changeset: a550ae7da806 > python-2.6.5-3 Red Hat Enterprise Linux Workstation release 6.0 (Santiago) Kernel: 2.6.32-71.29.1 libvirt: libvirt-0.8.7-18 qemu: qemu-kvm-0.12.1.2-2.113 pegasus: tog-pegasus-2.11.0-1 Libvirt-cim changeset: 2714b9a5e842 Cimtest changeset: 5934d6b1d016 (latest) plus both cdrom patches -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Fri Oct 14 15:53:25 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 14 Oct 2011 12:53:25 -0300 Subject: [Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService In-Reply-To: References: Message-ID: <4E985AF5.2020506@linux.vnet.ibm.com> On 10/12/2011 02:01 PM, Gareth S Bestor wrote: > > This fix is in tog-pegasus-2.12, so yes you probably have this bug in > your version (unless its been patched) > > Ideally, the cimom type (sfcb vs pegasus) and version shouldn't matter > in most instances, with the excpetion of perhaps actual *new* features, > like reliable indications, embeeded instance support, etc... I think > having a cimom check in the cimtest suites would be OK for such things. > But I dont think adding explicit checks for what are ostensibly > occasional bugs in a particular version of a particular packages is a > path we really want to go down... (eg this bug popped up only in pegasus > 2.10/2.11; this worked back in 2.9 days). Eduardo's testcase is valid; > this is just a test that will fail when run against a particular version > of (unpatched) pegasus. That should be noted somewhere, but I dont think > we necessarily need to 'work around it'... > Indeed, this test case basically tests this functionality to issue a ModifyResourceSettings call with an empty as argument. This bug was reported in pegasus bugzilla[1] and fixed as per version 2.11.1. If the test fails, then it exposes that pegasus bug, which means you need to upgrade your packages. [1] http://bugzilla.openpegasus.org/show_bug.cgi?id=9053 -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From eblima at linux.vnet.ibm.com Fri Oct 14 15:58:40 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 14 Oct 2011 12:58:40 -0300 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: <4E96DB99.4060707@linux.vnet.ibm.com> References: <4E96DB99.4060707@linux.vnet.ibm.com> Message-ID: <4E985C30.5060005@linux.vnet.ibm.com> On 10/13/2011 09:37 AM, Chip Vincent wrote: > # ll /var/lib/libvirt/images > total 16844232 > -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso > -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso > > > After extracting the .iso files and applying both patches, I get the > following error: > > Testing KVM hypervisor > -------------------------------------------------------------------- > VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL > ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not > match expected '' This may be related to the version of pegasus you have installed in your machine. This test case is very similar to the 31_unset_netrasd that I have posted. It will issue a ModifyResourceSettings call with an empty string to eject the media. See my previous email on the thread about the unset_netrasd patch. > ERROR - TypeError : 'NoneType' object is unsubscriptable > Traceback (most recent call last): > File > "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", > line 141, in do_try > rc = f() > File "32_modify_cdrom_media.py", line 209, in main > inst = modify_media(cim, inst, media_path) > File "32_modify_cdrom_media.py", line 100, in modify_media > val = set_device_addr(inst, addr) > File "32_modify_cdrom_media.py", line 83, in set_device_addr > inst["InstanceID"], > TypeError: 'NoneType' object is unsubscriptable > ERROR - None > -------------------------------------------------------------------- Now about this error, I see an oportunity of an extra check for None in order to avoid this traceback. There are also a few small syntax fixes elsewhere that I will post later on today. Best regards, Etrunko -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From cvincent at linux.vnet.ibm.com Fri Oct 14 18:38:02 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 14 Oct 2011 14:38:02 -0400 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: <4E985C30.5060005@linux.vnet.ibm.com> References: <4E96DB99.4060707@linux.vnet.ibm.com> <4E985C30.5060005@linux.vnet.ibm.com> Message-ID: <4E98818A.7040708@linux.vnet.ibm.com> +1. With tog-pegasus-2.11.1 I get the following: Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: PASS -------------------------------------------------------------------- NOTE: If you're not already on tog-pegasus-2.11.1, please move to it. On 10/14/2011 11:58 AM, Eduardo Lima (Etrunko) wrote: > On 10/13/2011 09:37 AM, Chip Vincent wrote: >> # ll /var/lib/libvirt/images >> total 16844232 >> -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso >> -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso >> >> >> After extracting the .iso files and applying both patches, I get the >> following error: >> >> Testing KVM hypervisor >> -------------------------------------------------------------------- >> VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL >> ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not >> match expected '' > > This may be related to the version of pegasus you have installed in your > machine. This test case is very similar to the 31_unset_netrasd that I > have posted. It will issue a ModifyResourceSettings call with an empty > string to eject the media. See my previous email on the thread about the > unset_netrasd patch. > >> ERROR - TypeError : 'NoneType' object is unsubscriptable >> Traceback (most recent call last): >> File >> "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", >> line 141, in do_try >> rc = f() >> File "32_modify_cdrom_media.py", line 209, in main >> inst = modify_media(cim, inst, media_path) >> File "32_modify_cdrom_media.py", line 100, in modify_media >> val = set_device_addr(inst, addr) >> File "32_modify_cdrom_media.py", line 83, in set_device_addr >> inst["InstanceID"], >> TypeError: 'NoneType' object is unsubscriptable >> ERROR - None >> -------------------------------------------------------------------- > > Now about this error, I see an oportunity of an extra check for None in > order to avoid this traceback. There are also a few small syntax fixes > elsewhere that I will post later on today. > > Best regards, Etrunko > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From cvincent at linux.vnet.ibm.com Fri Oct 14 18:43:17 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Fri, 14 Oct 2011 14:43:17 -0400 Subject: [Libvirt-cim] [PATCH 0 of 2] [TEST] VSMS: ModifyResourceSettings to change cdrom media In-Reply-To: References: Message-ID: <4E9882C5.1060209@linux.vnet.ibm.com> Pushed. On 09/30/2011 02:59 PM, Eduardo Lima (Etrunko) wrote: > This series introduces a new test case which covers a requirement to change the > media in the CDROM using libvirt-cim, done via a ModifyResourceSettings call. > > Also changes the default domain created by cimtest to include a cdrom device. > > Signed-off-by: Eduardo Lima (Etrunko) > > suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py | 221 ++++++++++ > suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + > suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 + > 3 files changed, 237 insertions(+), 0 deletions(-) > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Fri Oct 14 20:27:48 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 14 Oct 2011 17:27:48 -0300 Subject: [Libvirt-cim] [PATCH] [TEST] Fix syntax errors, small tweaks Message-ID: suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py | 6 +++--- suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py | 2 +- suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py | 8 +++++++- suites/libvirt-cim/main.py | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1317410876 10800 # Node ID d8ac04bdc4806aecd1e5f28636a09ce501e36639 # Parent d9741a8b5eb7ccebf21d69f3cde72729bb60ad22 [TEST] Fix syntax errors, small tweaks suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py: - Unecessary virt param suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py: - Undefined symbols XFAIL, SKIP suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py: - Check for None return when ejecting media suites/libvirt-cim/main.py - options referenced in except block without being defined Signed-off-by: Eduardo Lima (Etrunko) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py @@ -47,7 +47,7 @@ new_int += 1 new_mac2 = "11:%s:22:%s:33:%s" % (new_int, new_int, new_int) -def cleanup_env(ip, virt, cxml): +def cleanup_env(ip, cxml): cxml.destroy(ip) cxml.undefine(ip) @@ -82,13 +82,13 @@ ret = cxml.cim_define(options.ip) if not ret: logger.error("Failed to define the dom: %s", default_dom) - cleanup_env(options.ip, options.virt, cxml) + cleanup_env(options.ip, cxml) return FAIL if case == "start": ret = cxml.start(options.ip) if not ret: logger.error("Failed to start the dom: %s", default_dom) - cleanup_env(options.ip, options.virt, cxml) + cleanup_env(options.ip, cxml) return FAIL status = vsms_util.mod_vcpu_res(options.ip, service, cxml, pasd, ncpu, diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py @@ -28,7 +28,7 @@ import sys import pywbem -from CimTest.ReturnCodes import PASS, FAIL +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS from XenKvmLib.const import do_main from XenKvmLib.classes import get_typed_class diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py @@ -105,8 +105,12 @@ return None inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) + + if not inst: + logger.error("Unable to get CDROM device instance after ModifyResourceSettings") + return None + new_addr = inst["Address"] - if new_addr != addr: logger.error("New media '%s' does not match expected '%s'", new_addr, addr) return None @@ -204,6 +208,8 @@ # Need to eject first? if media and old_media: inst = modify_media(cim, inst, "") + if not inst: + return FAIL media_path = os.path.join(_image_dir, media) inst = modify_media(cim, inst, media_path) diff --git a/suites/libvirt-cim/main.py b/suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py +++ b/suites/libvirt-cim/main.py @@ -306,8 +306,8 @@ if __name__ == '__main__': ret = -1 + options, args = parser.parse_args() try: - options, args = parser.parse_args() ret = main(options, args) except (KeyboardInterrupt, SystemExit): print "\nKeyboardInterrupt. Cleaning up..." From snmishra at us.ibm.com Mon Oct 17 17:30:36 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Mon, 17 Oct 2011 10:30:36 -0700 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: <4E981C0D.60501@linux.vnet.ibm.com> References: <4E96DB99.4060707@linux.vnet.ibm.com> <4E97E9DD.4010200@linux.vnet.ibm.com> <4E981C0D.60501@linux.vnet.ibm.com> Message-ID: Chip, Are you seeing the "NoneType" object error only when running this test case? Other tests on the machine are passing/running? Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM Chip Vincent To Sent by: libvirt-cim at redhat.com libvirt-cim-bounc cc es at redhat.com Subject Re: [Libvirt-cim] [PATCH 2 of 2] 10/14/2011 04:25 [TEST] XenKvmLib: Add cdrom device AM description to domain Please respond to cvincent at linux.vn et.ibm.com; Please respond to List for discussion and development of libvirt CIM On 10/14/2011 03:50 AM, Wayne Xia wrote: > ? 2011-10-13 20:37, Chip Vincent ??: [snip] > strange, I think the case failed in the switch phase: > cdrom01.iso->empty->cdrom2.iso. > > ERROR - TypeError : 'NoneType' object is unsubscriptable > seems related to a python grammar issue, maybe it is caused by > python version, what is it on your PC? > > Mine version: > python 2.6.6 > Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) > Kernel: 2.6.32-71.el6.x86_64 > libvirt: 0.9.4 > Hypervisor: QEMU 0.14.50 > CIMOM: Pegasus 2.9.1 > Libvirt-cim revision: 1152 > Libvirt-cim changeset: 2714b9a5e842+ > Cimtest revision: 881 > Cimtest changeset: a550ae7da806 > python-2.6.5-3 Red Hat Enterprise Linux Workstation release 6.0 (Santiago) Kernel: 2.6.32-71.29.1 libvirt: libvirt-0.8.7-18 qemu: qemu-kvm-0.12.1.2-2.113 pegasus: tog-pegasus-2.11.0-1 Libvirt-cim changeset: 2714b9a5e842 Cimtest changeset: 5934d6b1d016 (latest) plus both cdrom patches -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com _______________________________________________ Libvirt-cim mailing list Libvirt-cim at redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: graycol.gif Type: image/gif Size: 105 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pic06979.gif Type: image/gif Size: 1255 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ecblank.gif Type: image/gif Size: 45 bytes Desc: not available URL: From cvincent at us.ibm.com Mon Oct 17 18:13:48 2011 From: cvincent at us.ibm.com (Chip Vincent) Date: Mon, 17 Oct 2011 14:13:48 -0400 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: References: <4E96DB99.4060707@linux.vnet.ibm.com> <4E97E9DD.4010200@linux.vnet.ibm.com> <4E981C0D.60501@linux.vnet.ibm.com> Message-ID: I did not see any errors once I upgraded to tog-pegasus-2.11.1. Chip Vincent Open Virtualization, Linux Technology Center IBM Systems & Technology Group phone: 919-254-4482, T/L 444-4482 email: cvincent at us.ibm.com From: Sharad Mishra/Beaverton/IBM at IBMUS To: Date: 10/17/2011 01:57 PM Subject: Re: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain Sent by: libvirt-cim-bounces at redhat.com Chip, Are you seeing the "NoneType" object error only when running this test case? Other tests on the machine are passing/running? Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM Inactive hide details for Chip Vincent ---10/14/2011 04:27:59 AM---On 10/14/2011 03:50 AM, Wayne Xia wrote:Chip Vincent ---10/14/2011 04:27:59 AM---On 10/14/2011 03:50 AM, Wayne Xia wrote: Chip Vincent Sent by: libvirt-cim at redhat.com libvirt- cim-boun cc ces at redh at.com Subject 10/14/20 Re: [Libvirt-cim] [PATCH 2 of 2] 11 04:25 [TEST] XenKvmLib: Add cdrom AM device description to domain Please respond to cvincent at linux.vnet.ibm.com; Please respond to List for discussion and development of libvirt CIM On 10/14/2011 03:50 AM, Wayne Xia wrote: > ? 2011-10-13 20:37, Chip Vincent ??: [snip] > strange, I think the case failed in the switch phase: > cdrom01.iso->empty->cdrom2.iso. > > ERROR - TypeError : 'NoneType' object is unsubscriptable > seems related to a python grammar issue, maybe it is caused by > python version, what is it on your PC? > > Mine version: > python 2.6.6 > Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) > Kernel: 2.6.32-71.el6.x86_64 > libvirt: 0.9.4 > Hypervisor: QEMU 0.14.50 > CIMOM: Pegasus 2.9.1 > Libvirt-cim revision: 1152 > Libvirt-cim changeset: 2714b9a5e842+ > Cimtest revision: 881 > Cimtest changeset: a550ae7da806 > python-2.6.5-3 Red Hat Enterprise Linux Workstation release 6.0 (Santiago) Kernel: 2.6.32-71.29.1 libvirt: libvirt-0.8.7-18 qemu: qemu-kvm-0.12.1.2-2.113 pegasus: tog-pegasus-2.11.0-1 Libvirt-cim changeset: 2714b9a5e842 Cimtest changeset: 5934d6b1d016 (latest) plus both cdrom patches -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com _______________________________________________ Libvirt-cim mailing list Libvirt-cim at redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim[attachment "pic06979.gif" deleted by Chip Vincent/Raleigh/IBM] _______________________________________________ Libvirt-cim mailing list Libvirt-cim at redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: graycol.gif Type: image/gif Size: 105 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ecblank.gif Type: image/gif Size: 45 bytes Desc: not available URL: From eblima at linux.vnet.ibm.com Mon Oct 17 21:12:55 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Mon, 17 Oct 2011 19:12:55 -0200 Subject: [Libvirt-cim] [PATCH 0 of 2] [TEST] VSMS: ModifyResourceSettings to change cdrom media In-Reply-To: <4E9882C5.1060209@linux.vnet.ibm.com> References: <4E9882C5.1060209@linux.vnet.ibm.com> Message-ID: <4E9C9A57.5070102@linux.vnet.ibm.com> On 10/14/2011 03:43 PM, Chip Vincent wrote: > Pushed. > I have just found that the patch that adds a cdrom device to the default domain causes some collateral effects on the whole suite. My bad. Working on the fix. Best regards, Eduardo -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From snmishra at us.ibm.com Wed Oct 19 14:32:35 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 19 Oct 2011 07:32:35 -0700 Subject: [Libvirt-cim] [PATCH] SROV support in libvirt-cim Message-ID: > # HG changeset patch > # User Sharad Mishra > # Date 1318954618 25200 > # Node ID d07f99a0279030e62046bbdc3ac378f9dc6473af > # Parent fb09136deb494008eb3aacee420ad74da7d7c294 > SROV support in libvirt-cim > > This patch is the patch to add SRIOV support in libvirt-cim. > This patch is not complete. Work on it was halted since the > exploiter of this feature is not ready to consume it. And there > are other features that need to be added which are in demand in > near future. > > SRIOV support adds Enumeration of node devices to see what is > available. Then it adds Virtual Functions (VFs), removes VFs and > modifies VFs. It also adds support to detach a node. This link > shows the steps - > > http://docs.fedoraproject.org/en-US/Fedora/13/html/ > Virtualization_Guide/sect-Para-virtualized_Windows_Drivers_Guide- > How_SR_IOV_Libvirt_Works.html > > Step 6 above is for enum node devices. > Step 8 is detach VF. > Step 9 is add VF to guest. > Similar to step 9 will be removeVF and modifyVF. > > So far, we have "sorta" implemented enum node device. > > Signed-off-by: Sharad Mishra > > diff -r fb09136deb49 -r d07f99a02790 Makefile.am > --- a/Makefile.am Tue Aug 30 08:48:36 2011 -0700 > +++ b/Makefile.am Tue Oct 18 09:16:58 2011 -0700 > @@ -29,6 +29,7 @@ > schema/ComputerSystemIndication.mof \ > schema/ResourceAllocationSettingDataIndication.mof \ > schema/SwitchService.mof \ > + schema/VirtualSystemPCIDevice.mof \ > schema/ComputerSystemMigrationIndication.mof \ > schema/Virt_ResourceAllocationSettingData.mof \ > schema/ResourceAllocationSettingData.mof \ > @@ -116,6 +117,7 @@ > schema/ComputerSystemIndication.registration \ > schema/ResourceAllocationSettingDataIndication.registration \ > schema/SwitchService.registration \ > + schema/VirtualSystemPCIDevice.registration \ > schema/ComputerSystemMigrationIndication.registration \ > schema/ResourceAllocationSettingData.registration \ > schema/ResourcePoolConfigurationService.registration \ > diff -r fb09136deb49 -r d07f99a02790 libxkutil/Makefile.am > --- a/libxkutil/Makefile.am Tue Aug 30 08:48:36 2011 -0700 > +++ b/libxkutil/Makefile.am Tue Oct 18 09:16:58 2011 -0700 > @@ -5,12 +5,14 @@ > -DLIBVIRTCIM_CONF=\"@sysconfdir@/@PACKAGE at .conf\" > > noinst_HEADERS = cs_util.h misc_util.h device_parsing.h xmlgen.h > infostore.h \ > - pool_parsing.h acl_parsing.h > + pool_parsing.h acl_parsing.h node_parsing.h > > lib_LTLIBRARIES = libxkutil.la > > libxkutil_la_SOURCES = cs_util_instance.c misc_util.c device_parsing.c \ > - xmlgen.c infostore.c pool_parsing.c acl_parsing.c > + xmlgen.c infostore.c pool_parsing.c acl_parsing.c \ > + node_parsing.c > + > libxkutil_la_LDFLAGS = -version-info @VERSION_INFO@ > libxkutil_la_LIBADD = @LIBVIRT_LIBS@ \ > @LIBUUID_LIBS@ > diff -r fb09136deb49 -r d07f99a02790 libxkutil/node_parsing.c > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/libxkutil/node_parsing.c Tue Oct 18 09:16:58 2011 -0700 > @@ -0,0 +1,184 @@ > +/* > + * Copyright IBM Corp. 2011 > + * > + * Authors: > + * Sharad Mishra > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "misc_util.h" > + > +#include > + > +#include "node_parsing.h" > + > +static void cleanup_pci_device(struct pci_device pci) { > + > + free(pci.product); > + free(pci.vendor); > +} > + > +void cleanup_node_device(struct node_device **node) > +{ > + struct node_device *_node = *node; > + > + if ((node == NULL) || (*node == NULL)) > + return; > + > + if (XSTREQ(_node->capability, "pci")) > + cleanup_pci_device(_node->device_info.pci); > + > + free(_node->name); > + free(_node->parent); > + free(_node->capability); > + free(_node); > + > + *node = NULL; > +} > + > +CMPIStatus get_node_from_xml(const CMPIBroker *broker, > + const CMPIObjectPath *reference, > + virConnectPtr conn, > + char *xml, > + CMPIInstance **_inst) > +{ > + int len; > + xmlDoc *xmldoc; > + xmlXPathContext *xpathctx; > + xmlXPathObject *xpathobj; > + const xmlChar *xpathstr = (xmlChar *)"/device"; > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + CMPIInstance *inst = NULL; > + char *val = NULL; > + char *tmpstr = NULL; > + xmlNode **nodes = NULL; > + xmlNode *child; > + uint8_t ival; > + > + CU_DEBUG("Node XML : %s", xml); > + len = strlen(xml) + 1; > + > + inst = get_typed_instance(broker, > + pfx_from_conn(conn), > + "VirtualSystemPCIDevice", > + NAMESPACE(reference)); > + if (inst == NULL) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_FAILED, > + "Unable to init VirtualSystemPCIDevice instance"); > + goto err1; > + } > + > + > + if ((xmldoc = xmlParseMemory(xml, len)) == NULL) { > + CU_DEBUG("xmlParseMemory failed"); > + goto err1; > + } > + > + if ((xpathctx = xmlXPathNewContext(xmldoc)) == NULL) { > + CU_DEBUG("xmlXPathNewContext failed"); > + goto err2; > + } > + > + if ((xpathobj = xmlXPathEvalExpression(xpathstr, xpathctx))== NULL) { > + CU_DEBUG("xmlXPathEvalExpression failed"); > + goto err3; > + } > + > + nodes = xpathobj->nodesetval->nodeTab; > + > + for (child = nodes[0]->children; child != NULL; child = > child->next) { > + if (XSTREQ(child->name, "name")) { > + val = get_node_content(child); > +CU_DEBUG("val is %s", val); > + if (val != NULL) > + s = CMSetProperty(inst, "Name", > + (CMPIValue *)val, > + CMPI_chars); > + } else if (XSTREQ(child->name, "capability")) { > + child = child->children; > +CU_DEBUG("found capabi s.rc is %d, s.msg is %s", s.rc, s.msg); > + continue; > + } else if (XSTREQ(child->name, "bus")) { > +CU_DEBUG("found bus"); > + val = get_node_content(child); > +CU_DEBUG("val is %s", val); > +ival = atoi(val); > +CU_DEBUG("len is %d", ival); > + s = CMSetProperty(inst, "BusNumber", > + (CMPIValue *)&ival, > + CMPI_uint8); > + } else if (XSTREQ(child->name, "slot")) { > +CU_DEBUG("found slot rs is %d msg is %s", s.rc, s.msg); > + val = get_node_content(child); > +CU_DEBUG("val is %s", val); > +ival = atoi(val); > +CU_DEBUG("len is %d", ival); > + s = CMSetProperty(inst, "DeviceNumber", > + (CMPIValue *)&ival, > + CMPI_uint8); > + } else if (XSTREQ(child->name, "function")) { > +CU_DEBUG("found function rc is %d, msg is %s", s.rc, s.msg); > + val = get_node_content(child); > +CU_DEBUG("val is %s", val); > +ival = atoi(val); > +CU_DEBUG("len_16 is %d", ival); > + s = CMSetProperty(inst, "FunctionNumber", > + (CMPIValue *)&ival, > + CMPI_uint8); > + } else if (XSTREQ(child->name, "vendor")) { > +CU_DEBUG("found vendor rc is %d msg is %s", s.rc, s.msg); > + val = get_attr_value(child, "id"); > +CU_DEBUG("val is %s", val); > +sprintf(tmpstr, "%*2s", val); > +CU_DEBUG("tmpstr is %s", tmpstr); > +uint16_t val16 = atoi(tmpstr); > +CU_DEBUG("len is %d", val16); > + s = CMSetProperty(inst, "VendorID", > + (CMPIValue *)&val16, > + CMPI_uint16); > + } > + } > + > + *_inst = inst; > + > + xmlXPathFreeObject(xpathobj); > + err3: > + xmlXPathFreeContext(xpathctx); > + err2: > + xmlFreeDoc(xmldoc); > + err1: > + return s; > +} > + > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ > + > diff -r fb09136deb49 -r d07f99a02790 libxkutil/node_parsing.h > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/libxkutil/node_parsing.h Tue Oct 18 09:16:58 2011 -0700 > @@ -0,0 +1,63 @@ > +/* > + * Copyright IBM Corp. 2011 > + * > + * Authors: > + * Sharad Mishra > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > + */ > + > + > +#include "cmpidt.h" > +#include "cmpift.h" > +#include "cmpimacs.h" > +#include "device_parsing.h" > + > +struct pci_device { > + int domain; > + int bus; > + int slot; > + int function; > + char *product; > + char *vendor; > +}; > + > +/* USB and other node devices can be added later. */ > +struct node_device { > + char *name; > + char *parent; > + char *capability; > + union { > + struct pci_device pci; > + } device_info; > +}; > + > +void cleanup_node_device(struct node_device **node); > +CMPIStatus get_node_from_xml(const CMPIBroker *broker, > + const CMPIObjectPath *reference, > + virConnectPtr conn, > + char *xml, > + CMPIInstance **_inst); > + > + > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ > diff -r fb09136deb49 -r d07f99a02790 schema/VirtualSystemPCIDevice.mof > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/schema/VirtualSystemPCIDevice.mof Tue Oct 18 09:16:58 2011 -0700 > @@ -0,0 +1,14 @@ > +// Copyright IBM Corp. 2011 > + > +[Provider("cmpi::Virt_VirtualSystemPCIDevice")] > +class Xen_VirtualSystemPCIDevice : CIM_PCIDevice { > +}; > + > +[Provider("cmpi::Virt_VirtualSystemPCIDevice")] > +class KVM_VirtualSystemPCIDevice : CIM_PCIDevice { > +}; > + > +[Provider("cmpi::Virt_VirtualSystemPCIDevice")] > +class LXC_VirtualSystemPCIDevice : CIM_PCIDevice { > +}; > + > diff -r fb09136deb49 -r d07f99a02790 schema/ > VirtualSystemPCIDevice.registration > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/schema/VirtualSystemPCIDevice.registration Tue Oct 18 09:16: > 58 2011 -0700 > @@ -0,0 +1,5 @@ > +# Copyright IBM Corp. 2011 > +# Classname Namespace ProviderName ProviderModule ProviderTypes > +Xen_VirtualSystemPCIDevice root/virt Virt_VirtualSystemPCIDevice > Virt_VirtualSystemPCIDevice instance method > +KVM_VirtualSystemPCIDevice root/virt Virt_VirtualSystemPCIDevice > Virt_VirtualSystemPCIDevice instance method > +LXC_VirtualSystemPCIDevice root/virt Virt_VirtualSystemPCIDevice > Virt_VirtualSystemPCIDevice instance method > diff -r fb09136deb49 -r d07f99a02790 src/Makefile.am > --- a/src/Makefile.am Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Makefile.am Tue Oct 18 09:16:58 2011 -0700 > @@ -17,6 +17,7 @@ > Virt_VSSD.h \ > Virt_VSMigrationCapabilities.h \ > Virt_VSMigrationService.h \ > + Virt_VirtualSystemPCIDevice.h \ > Virt_AllocationCapabilities.h \ > Virt_VirtualSystemSnapshotService.h \ > Virt_VirtualSystemSnapshotServiceCapabilities.h \ > @@ -53,6 +54,7 @@ > libVirt_ComputerSystemIndication.la \ > libVirt_ResourceAllocationSettingDataIndication.la \ > libVirt_SwitchService.la \ > + libVirt_VirtualSystemPCIDevice.la \ > libVirt_ComputerSystemMigrationIndication.la \ > libVirt_VirtualSystemManagementCapabilities.la \ > libVirt_AllocationCapabilities.la \ > @@ -105,6 +107,9 @@ > libVirt_SwitchService_la_SOURCES = Virt_SwitchService.c > libVirt_SwitchService_la_LIBADD = -lVirt_ComputerSystem > > +libVirt_VirtualSystemPCIDevice = libVirt_ComputerSystem.la > +libVirt_VirtualSystemPCIDevice_la_SOURCES = Virt_VirtualSystemPCIDevice.c > + > libVirt_ComputerSystemMigrationIndication_la_DEPENDENCIES = > libVirt_ComputerSystem.la > libVirt_ComputerSystemMigrationIndication_la_SOURCES = > Virt_ComputerSystemMigrationIndication.c > libVirt_ComputerSystemMigrationIndication_la_LIBADD = -lVirt_ComputerSystem > diff -r fb09136deb49 -r d07f99a02790 src/Virt_VirtualSystemPCIDevice.c > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/src/Virt_VirtualSystemPCIDevice.c Tue Oct 18 09:16:58 2011 -0700 > @@ -0,0 +1,295 @@ > +/* > + * Copyright IBM Corp. 2011 > + * > + * Authors: > + * Sharad Mishra > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include > + > +#include > +#include > +#include > + > +#include > +#include "misc_util.h" > +#include "node_parsing.h" > +#include > +#include > +#include > + > +#include "Virt_VSMigrationService.h" > +#include "Virt_HostSystem.h" > +#include "Virt_ComputerSystem.h" > +#include "Virt_VSMigrationSettingData.h" > +#include "svpc_types.h" > +#include "libxkutil/infostore.h" > + > +#include "config.h" > + > +#include "Virt_VirtualSystemPCIDevice.h" > + > +const static CMPIBroker *_BROKER; > + > +static CMPIStatus add_sriov_vf(CMPIMethodMI *self, > + const CMPIContext *ctx, > + const CMPIResult *results, > + const CMPIObjectPath *ref, > + const CMPIArgs *argsin, > + CMPIArgs *argsout) > +{ > + > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + > + return s; > +} > + > +static CMPIStatus remove_sriov_vf(CMPIMethodMI *self, > + const CMPIContext *ctx, > + const CMPIResult *results, > + const CMPIObjectPath *ref, > + const CMPIArgs *argsin, > + CMPIArgs *argsout) > +{ > + > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + > + return s; > +} > + > +static CMPIStatus modify_sriov_vf(CMPIMethodMI *self, > + const CMPIContext *ctx, > + const CMPIResult *results, > + const CMPIObjectPath *ref, > + const CMPIArgs *argsin, > + CMPIArgs *argsout) > +{ > + > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + > + return s; > +} > + > +static struct method_handler AddSriovVf = { > + .name = "AddSriovVf", > + .handler = add_sriov_vf, > + .args = {{"ComputerSystem", CMPI_ref, false}, > + {"DestinationSystem", CMPI_ref, false}, > + {"MigrationSettingData", CMPI_instance, true}, > + {"NewSystemSettingData", CMPI_instance, true}, > + {"NewResourceSettingData", CMPI_instanceA, true}, > + ARG_END > + } > +}; > + > +static struct method_handler RemoveSriovVf = { > + .name = "RemoveSriovVf", > + .handler = remove_sriov_vf, > + .args = {{"ComputerSystem", CMPI_ref, false}, > + {"DestinationHost", CMPI_string, false}, > + {"MigrationSettingData", CMPI_instance, true}, > + {"NewSystemSettingData", CMPI_instance, true}, > + {"NewResourceSettingData", CMPI_instanceA, true}, > + ARG_END > + } > +}; > + > +static struct method_handler ModifySriovVf = { > + .name = "ModifySriovVf", > + .handler = modify_sriov_vf, > + .args = {{"ComputerSystem", CMPI_ref, false}, > + {"DestinationSystem", CMPI_ref, false}, > + {"MigrationSettingData", CMPI_instance, true}, > + {"NewSystemSettingData", CMPI_instance, true}, > + {"NewResourceSettingData", CMPI_instanceA, true}, > + ARG_END > + } > +}; > + > +static struct method_handler *my_handlers[] = { > + &AddSriovVf, > + &RemoveSriovVf, > + &ModifySriovVf, > + NULL > +}; > + > +STDIM_MethodMIStub(, Virt_VSMigrationService, _BROKER, > + libvirt_cim_init(), my_handlers); > + > + > +static CMPIStatus enum_pci(const CMPIBroker *broker, > + const CMPIObjectPath *ref, > + struct inst_list *instlist) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + virConnectPtr conn = NULL; > + char **names = NULL; > + char *nodeXML; > + int count; > + int i; > + > + conn = connect_by_classname(broker, CLASSNAME(ref), &s); > + if (conn == NULL) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to connect to Hypervisor"); > + goto out; > + } > + > + count = virNodeNumOfDevices(conn, "pci", 0); > + if (count < 1) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to find a PCI device"); > + goto out; > + } > + > + names = calloc(count, sizeof(char *)); > + if (names == NULL) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to allocate memory"); > + goto out; > + } > + > + > + i = virNodeListDevices(conn, "pci", names, count, 0); > + if (i == -1) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to get PCI devices"); > + goto out; > + } > + > + for (i=0; i < count; i++) { > + CMPIInstance *inst = NULL; > + > + virNodeDevicePtr nptr = virNodeDeviceLookupByName(conn, > + names [i]); > + if (nptr == NULL) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to lookup PCI device by name"); > + continue; > + } > + > + nodeXML = virNodeDeviceGetXMLDesc(nptr, 0); > + if (nodeXML == NULL) { > + cu_statusf(broker, &s, > + CMPI_RC_ERR_NOT_FOUND, > + "Failed to get PCI Device XML > Description"); > + continue; > + } > + > + CU_DEBUG("PCI Device node xml is %s", nodeXML); > + > + CMPIStatus stat = get_node_from_xml(broker, ref, conn, > + nodeXML, &inst); > + if (stat.rc != CMPI_RC_OK) > + continue; > + > + inst_list_add(instlist, inst); > + } > + > + out: > + virConnectClose(conn); > + > + return s; > +} > + > +static CMPIStatus return_pci(const CMPIContext *context, > + const CMPIObjectPath *ref, > + const CMPIResult *results, > + bool name_only, > + bool is_get_inst) > +{ > + struct inst_list list; > + CMPIStatus s; > + > + inst_list_init(&list); > + s = enum_pci(_BROKER, ref, &list); > + if (s.rc != CMPI_RC_OK) > + goto out; > + > + if (name_only) > + cu_return_instance_names(results, &list); > + else > + cu_return_instances(results, &list); > + out: > + inst_list_free(&list); > + return s; > +} > + > +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *ref) > +{ > + return return_pci(context, ref, results, true, false); > +} > + > +static CMPIStatus EnumInstances(CMPIInstanceMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *ref, > + const char **properties) > +{ > + > + return return_pci(context, ref, results, false, false); > +} > + > + > +static CMPIStatus GetInstance(CMPIInstanceMI *self, > + const CMPIContext *context, > + const CMPIResult *results, > + const CMPIObjectPath *ref, > + const char **properties) > +{ > + return return_pci(context, ref, results, false, true); > +} > + > +DEFAULT_CI(); > +DEFAULT_MI(); > +DEFAULT_DI(); > +DEFAULT_EQ(); > +DEFAULT_INST_CLEANUP(); > + > +STD_InstanceMIStub(, > + Virt_VirtualSystemPCIDevice, > + _BROKER, > + libvirt_cim_init()); > +/* > + * Local Variables: > + * mode: C > + * c-set-style: "K&R" > + * tab-width: 8 > + * c-basic-offset: 8 > + * indent-tabs-mode: nil > + * End: > + */ -------------- next part -------------- An HTML attachment was scrubbed... URL: From snmishra at us.ibm.com Fri Oct 21 16:57:58 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Fri, 21 Oct 2011 09:57:58 -0700 Subject: [Libvirt-cim] [PATCH] /dev/null should not be passed as source dev for cdrom device. Message-ID: /dev/null should not be passed as source dev for cdrom device. This patch verifies that source dev only has non null and non /dev/null values for cdrom device. Signed-off-by: Sharad Mishra diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 343dc9e..ee20895 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -65,10 +65,12 @@ static char *disk_block_xml(xmlNodePtr root, struct disk_device *dev) xmlNewProp(tmp, BAD_CAST "cache", BAD_CAST dev-> cache); } - tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); - if (tmp == NULL) - return XML_ERROR; - xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->source); + if ((dev->source != NULL) && (!XSTREQ(dev->source, "/dev/null"))) { + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); + if (tmp == NULL) + return XML_ERROR; + xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST dev->source); + } tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); if (tmp == NULL) -------------- next part -------------- An HTML attachment was scrubbed... URL: From eblima at linux.vnet.ibm.com Tue Oct 25 13:30:16 2011 From: eblima at linux.vnet.ibm.com (eblima at linux.vnet.ibm.com) Date: Tue, 25 Oct 2011 11:30:16 -0200 Subject: [Libvirt-cim] [PATCH] [TEST] Fix VSMS/32_modify_cdrom_media.py Message-ID: <1319549416-30992-1-git-send-email-eblima@linux.vnet.ibm.com> From: Eduardo Lima (Etrunko) This test depended on some modifications in the core classes that resulted in many other tests failing. This patch fixed this issue by moving the necessary bits to the testcase itself. Signed-off-by: Eduardo Lima (Etrunko) --- .../32_modify_cdrom_media.py | 16 +++++++++++++++- suites/libvirt-cim/lib/XenKvmLib/vxml.py | 17 +++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py index 9b42831..ff9d034 100755 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py @@ -32,9 +32,10 @@ import pywbem from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS -from XenKvmLib.const import do_main, _image_dir +from XenKvmLib.const import do_main, _image_dir, KVM_default_cdrom_dev from XenKvmLib.classes import get_typed_class from XenKvmLib.vxml import get_class +from XenKvmLib import vsms supported = ['KVM',] @@ -49,6 +50,19 @@ class CIMDomain(object): self.server = server self.virt = virt self._domain = get_class(virt)(name) + + # CIM Instance for cdrom + dasd = vsms.get_dasd_class(virt) + cdrom_dasd = dasd(dev=KVM_default_cdrom_dev, source="", + name=name, emu_type=1) + self._domain.res_settings.append(str(cdrom_dasd)) + + # cdrom XML description + devices = self._domain.get_node('/domain/devices') + cdrom = self._domain.add_sub_node(devices, 'disk', type='file', + device='cdrom') + self._domain.add_sub_node(cdrom, 'source', file="") + self._domain.add_sub_node(cdrom, 'target', dev=KVM_default_cdrom_dev) #__init__ def define(self): diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py index 6790036..15859c1 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py @@ -628,17 +628,13 @@ class VirtCIM: self.iasd = vsms.get_iasd_class(virt)(name=dom_name, res_sub_type=irstype, bus_type=btype) - if virt == "KVM": - dasd = vsms.get_dasd_class(virt) - self.cdrom_dasd = dasd(dev=const.KVM_default_cdrom_dev, - source="", - name=dom_name, - emu_type=1) + self.res_settings = [] + def cim_define(self, ip, ref_conf=None): service = vsms.get_vsms_class(self.virt)(ip) sys_settings = str(self.vssd) - res_settings = [] + res_settings = self.res_settings if self.dasd is not None: res_settings.append(str(self.dasd)) if self.pasd is not None: @@ -651,10 +647,6 @@ class VirtCIM: else: res_settings.append(str(self.nasd)) - # CDROM device - if self.virt == "KVM": - res_settings.append(str(self.cdrom_dasd)) - curr_cim_rev, changeset = get_provider_version(self.virt, ip) if curr_cim_rev >= vsms_graphics_sup: if self.gasd is not None: @@ -952,9 +944,6 @@ class KVMXML(VirtXML, VirtCIM): self.add_sub_node(disk, 'source', file=disk_img) self.add_sub_node(disk, 'target', dev=disk_dev) - cdrom = self.add_sub_node(devices, 'disk', type='file', device='cdrom') - self.add_sub_node(cdrom, 'source', file="") - self.add_sub_node(cdrom, 'target', dev=const.KVM_default_cdrom_dev) self.add_sub_node(devices, 'input', type='mouse', bus='ps2') self.add_sub_node(devices, 'graphics', type='vnc', port='5900', -- 1.7.4.4 From eblima at linux.vnet.ibm.com Tue Oct 25 13:30:43 2011 From: eblima at linux.vnet.ibm.com (eblima at linux.vnet.ibm.com) Date: Tue, 25 Oct 2011 11:30:43 -0200 Subject: [Libvirt-cim] [PATCH] [TEST] Fix syntax errors in VSMS/09_procrasd_persist.py Message-ID: <1319549443-31041-1-git-send-email-eblima@linux.vnet.ibm.com> From: Eduardo Lima (Etrunko) Traceback (most recent call last): File "/usr/lib64/python2.7/logging/__init__.py", line 838, in emit msg = self.format(record) File "/usr/lib64/python2.7/logging/__init__.py", line 715, in format return fmt.format(record) File "/usr/lib64/python2.7/logging/__init__.py", line 464, in format record.message = record.getMessage() File "/usr/lib64/python2.7/logging/__init__.py", line 328, in getMessage msg = msg % self.args TypeError: %d format: a number is required, not NoneType Signed-off-by: Eduardo Lima (Etrunko) --- .../09_procrasd_persist.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py index cc5b71b..91415dd 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py @@ -91,19 +91,19 @@ def check_proc_sched(server, virt, cn_name): return FAIL if proc_rasd["VirtualQuantity"] != nvcpu and virt != 'KVM': - logger.error("VirtualQuantity is %i, expected %i", + logger.error("VirtualQuantity is %s, expected %s", proc_rasd["VirtualQuantity"], nvcpu) return FAIL elif proc_rasd["VirtualQuantity"] != nvcpu and virt == "KVM": return XFAIL_RC(libvirt_bug) if proc_rasd["Limit"] != limit: - logger.error("Limit is %i, expected %i", + logger.error("Limit is %s, expected %s", proc_rasd["Limit"], limit) return FAIL if proc_rasd["Weight"] != weight: - logger.error("Weight is %i, expected %i", + logger.error("Weight is %s, expected %s", proc_rasd["Weight"], weight) return FAIL -- 1.7.4.4 From snmishra at us.ibm.com Wed Oct 26 17:20:09 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Wed, 26 Oct 2011 10:20:09 -0700 Subject: [Libvirt-cim] [PATCH] [TEST] Fix syntax errors, small tweaks In-Reply-To: References: Message-ID: +1 Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 10/14/2011 01:27:48 PM: > "Eduardo Lima \(Etrunko\)" > Sent by: libvirt-cim-bounces at redhat.com > > 10/14/2011 01:27 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] [TEST] Fix syntax errors, small tweaks > > suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 08_modifyresource.py | 6 +++--- > suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 31_unset_netrasd.py | 2 +- > suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 32_modify_cdrom_media.py | 8 +++++++- > suites/libvirt-cim/main.py | 2 +- > 4 files changed, 12 insertions(+), 6 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1317410876 10800 > # Node ID d8ac04bdc4806aecd1e5f28636a09ce501e36639 > # Parent d9741a8b5eb7ccebf21d69f3cde72729bb60ad22 > [TEST] Fix syntax errors, small tweaks > > suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 08_modifyresource.py: > - Unecessary virt param > > suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py: > - Undefined symbols XFAIL, SKIP > > suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 32_modify_cdrom_media.py: > - Check for None return when ejecting media > > suites/libvirt-cim/main.py > - options referenced in except block without being defined > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/suites/libvirt-cim/cimtest/ > VirtualSystemManagementService/08_modifyresource.py b/suites/ > libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 08_modifyresource.py > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 08_modifyresource.py > @@ -47,7 +47,7 @@ > new_int += 1 > new_mac2 = "11:%s:22:%s:33:%s" % (new_int, new_int, new_int) > > -def cleanup_env(ip, virt, cxml): > +def cleanup_env(ip, cxml): > cxml.destroy(ip) > cxml.undefine(ip) > > @@ -82,13 +82,13 @@ > ret = cxml.cim_define(options.ip) > if not ret: > logger.error("Failed to define the dom: %s", default_dom) > - cleanup_env(options.ip, options.virt, cxml) > + cleanup_env(options.ip, cxml) > return FAIL > if case == "start": > ret = cxml.start(options.ip) > if not ret: > logger.error("Failed to start the dom: %s", default_dom) > - cleanup_env(options.ip, options.virt, cxml) > + cleanup_env(options.ip, cxml) > return FAIL > > status = vsms_util.mod_vcpu_res(options.ip, service, cxml, > pasd, ncpu, > diff --git a/suites/libvirt-cim/cimtest/ > VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt- > cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 31_unset_netrasd.py > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 31_unset_netrasd.py > @@ -28,7 +28,7 @@ > import sys > import pywbem > > -from CimTest.ReturnCodes import PASS, FAIL > +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP > from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS > from XenKvmLib.const import do_main > from XenKvmLib.classes import get_typed_class > diff --git a/suites/libvirt-cim/cimtest/ > VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/ > libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 32_modify_cdrom_media.py > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ > 32_modify_cdrom_media.py > @@ -105,8 +105,12 @@ > return None > > inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) > + > + if not inst: > + logger.error("Unable to get CDROM device instance after > ModifyResourceSettings") > + return None > + > new_addr = inst["Address"] > - > if new_addr != addr: > logger.error("New media '%s' does not match expected '%s'", > new_addr, addr) > return None > @@ -204,6 +208,8 @@ > # Need to eject first? > if media and old_media: > inst = modify_media(cim, inst, "") > + if not inst: > + return FAIL > > media_path = os.path.join(_image_dir, media) > inst = modify_media(cim, inst, media_path) > diff --git a/suites/libvirt-cim/main.py b/suites/libvirt-cim/main.py > --- a/suites/libvirt-cim/main.py > +++ b/suites/libvirt-cim/main.py > @@ -306,8 +306,8 @@ > > if __name__ == '__main__': > ret = -1 > + options, args = parser.parse_args() > try: > - options, args = parser.parse_args() > ret = main(options, args) > except (KeyboardInterrupt, SystemExit): > print "\nKeyboardInterrupt. Cleaning up..." > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bestor at us.ibm.com Wed Oct 26 10:42:21 2011 From: bestor at us.ibm.com (Gareth S. Bestor) Date: Wed, 26 Oct 2011 03:42:21 -0700 Subject: [Libvirt-cim] [PATCH] Patch to add network qos (bandwidth) support for KVM guests using tc Message-ID: <862bcd60ae449932205b.1319625741@rhel6> # HG changeset patch # User Gareth S. Bestor # Date 1319625716 25200 # Node ID 862bcd60ae449932205b15ba42b37e06e6834de4 # Parent 2714b9a5e842cc1e8c2ae182c2adef083cc1ef1a Patch to add network qos (bandwidth) support for KVM guests using tc This patch adds network qos support into libvirt-cim for setting network bandwidth limits on KVM guests' MAC addrs, using existing tc (traffic control) host support. Patch is a bit hack-ish because it is mostly for older versions of libvirt which do not have any qos support in libvirt itself. I am finishing a new, and cleaner, patch to libvirt-cim that will exploit the native support for qos present in latest libvirt versions. Patch is a bit ugly because (1) it must manage all the qos data associated with KVM guest's network device completely *outside* of libvirt (since no support and existing mgmt data available to handle this in older libvirts). And (2) because the tc commands themselves needed to query, retreive, add and delete tc bandwidth setting for a MAC addr are themselves quite messy scripts. This patch assume all the necessary tc performance classes have been setup externally. Because it must screen-scrape tc command output to get performance class and associated bandwith values, this patch will be very sensitive to change in output format of tc commands. It has been tested successfully on RHEL6.1. I dont not recommend exploiting this new feature unless you know what you are doing... Signed-off-by: Gareth Bestor diff -r 2714b9a5e842 -r 862bcd60ae44 src/Virt_RASD.c --- a/src/Virt_RASD.c Mon Oct 03 02:51:26 2011 -0700 +++ b/src/Virt_RASD.c Wed Oct 26 03:41:56 2011 -0700 @@ -39,6 +39,16 @@ #include "svpc_types.h" #include "Virt_Device.h" +/* Network QoS support */ +#define QOSCMD_MAC2BANDWIDTH "_ROOT=$(tc class show dev %s | awk '($4==\"root\")\ +{print $3}')\n _ID=$(tc filter show dev %s | awk 'BEGIN {RS=\"\\nfilter\"} (NR>2)\ +{m1=substr($24,1,2);m2=substr($24,3,2);m3=substr($24,5,2);m4=substr($24,7,2);\ +m5=substr($20,1,2);m6=substr($20,3,2);printf(\"%%s:%%s:%%s:%%s:%%s:%%s %%s\\n\",\ +m1,m2,m3,m4,m5,m6,$18)}' | awk -v mm=%s '($1==mm){print $2}')\n \ +if [[ -n \"$_ID\" ]]; then\n tc class show dev %s | awk -v rr=$_ROOT -v id=$_ID \ +'($4==\"parent\" && $5==rr && $3==id){print \ +substr($13,1,(index($13,\"Kbit\")-1))}'\n fi\n" + const static CMPIBroker *_BROKER; static struct virt_device *_find_dev(struct virt_device *list, @@ -449,7 +459,11 @@ const struct virt_device *dev, CMPIInstance *inst) { + FILE *pipe = NULL; + char *cmd = NULL; + uint64_t val = 0; CMPIStatus s = {CMPI_RC_OK, NULL}; + int i; CMSetProperty(inst, "NetworkType", @@ -467,6 +481,33 @@ (CMPIValue *)dev->dev.net.source, CMPI_chars); + /* Network QoS support */ + if ((dev->dev.net.mac != NULL) && (dev->dev.net.source != NULL)) { + /* Get tc performance class bandwidth for this MAC addr */ + i = asprintf(&cmd, QOSCMD_MAC2BANDWIDTH, dev->dev.net.source, + dev->dev.net.source, + dev->dev.net.mac, + dev->dev.net.source); + if (i == -1) + goto out; + + if ((pipe = popen(cmd, "r")) != NULL) { + if (fscanf(pipe, "%u", (unsigned int *)&val) == 1) { + CU_DEBUG("pipe read. val = %d", val); + + CMSetProperty(inst, + "Reservation", + (CMPIValue *)&val, CMPI_uint64); + CMSetProperty(inst, + "AllocationUnits", + (CMPIValue *)"KiloBits per Second", + CMPI_chars); + } + pclose(pipe); + } + free(cmd); + } + if ((dev->dev.net.source != NULL) && (STREQ(dev->dev.net.type, "direct"))) CMSetProperty(inst, @@ -498,6 +539,7 @@ (CMPIValue *)dev->dev.net.poolid, CMPI_chars); +out: return s; } diff -r 2714b9a5e842 -r 862bcd60ae44 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Oct 03 02:51:26 2011 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Wed Oct 26 03:41:56 2011 -0700 @@ -73,6 +73,11 @@ #define POOL_RASD 1 #define NEW_VOL_RASD 2 +/* QoS Network support */ +#define QOSCMD_LISTCLASSES "_ROOT=$(tc class show dev %s | awk '($4==\"root\")\ +{print $3}')\n tc class show dev %s | awk -v rr=$_ROOT \ +'($4==\"parent\" && $5==rr){print $3\" \"$13}'\n" + static bool system_has_vt(virConnectPtr conn) { char *caps = NULL; @@ -726,7 +731,7 @@ } static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, - const char *id, + char *id, uint16_t pool_type, struct inst_list *list) { @@ -738,6 +743,7 @@ const char *ip_stop = "192.168.122.254"; int dev_count; int i; + char *tmp_str = NULL; /* Isolated network pools don't have a forward device */ if (pool_type == NETPOOL_FORWARD_NONE) @@ -750,7 +756,33 @@ if ((inst == NULL) || (s.rc != CMPI_RC_OK)) goto out; - CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); + + tmp_str = strtok(id, " "); + if (tmp_str == NULL) { + CU_DEBUG("Cannot set InstanceID"); + goto out; + } + + CU_DEBUG("InstanceID = %s", tmp_str); + + CMSetProperty(inst, "InstanceID", (CMPIValue *)tmp_str, + CMPI_chars); + tmp_str = strtok('\0', " "); + if (tmp_str == NULL) { + CU_DEBUG("Cannot set Reservation"); + goto out; + } + + CU_DEBUG("Reservation = %s", tmp_str); + + uint64_t val = atoi(tmp_str); + + CMSetProperty(inst, "Reservation", + (CMPIValue *)&val, CMPI_uint64); + + CMSetProperty(inst, "AllocationUnits", + (CMPIValue *)"Kilobits per Second", + CMPI_chars); CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars); @@ -779,11 +811,112 @@ return s; } +static char * get_bridge_name(virConnectPtr conn, const char *name) +{ + char *bridge = NULL; + virNetworkPtr network = NULL; + + if (++name == NULL) + goto out; + + CU_DEBUG("looking for network `%s'", name); + network = virNetworkLookupByName(conn, name); + if (network == NULL) { + CU_DEBUG("Could not find network"); + goto out; + } + + bridge = virNetworkGetBridgeName(network); + if (bridge == NULL) { + CU_DEBUG("Could not find bridge"); + } + + virNetworkFree(network); + + out: + return bridge; +} + +/* QoS Network support */ +static CMPIStatus qos_hack( + const CMPIObjectPath *ref, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + FILE *pipe = NULL; + char buffer[1024]; + char *bridge = NULL; + char *cmd = NULL; + const char *val = NULL; + int i; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (s.rc != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get connection"); + goto out; + } + + if (cu_get_str_path(ref, "InstanceID", &val) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Could not get InstanceID"); + goto out; + } + + CU_DEBUG("InstanceID is %s", val); + + bridge = get_bridge_name(conn, strstr(val, "/")); + if (bridge == NULL) + goto out; + + i = asprintf(&cmd, QOSCMD_LISTCLASSES, bridge, bridge); + if (i == -1) + goto out; + + CU_DEBUG("qos_hack() cmd = %s", cmd); + + if ((pipe = popen(cmd, "r")) != NULL) { + CU_DEBUG("pipe open"); + while (fgets(buffer, sizeof(buffer), pipe) != NULL) { + char *name = NULL; + char *p = strstr(buffer, "Kbit"); + + /* trim string */ + if (p) + *p = '\0'; + + CU_DEBUG("qos hack buffer = %s", buffer); + + i = asprintf(&name, "Point/%s", buffer); + if (i != -1) { + s = set_net_pool_props(ref, name, + NETPOOL_FORWARD_NONE, list); + + free(name); + } + } + + pclose(pipe); + CU_DEBUG("pipe close"); + } + + out: + free(cmd); + free(bridge); + virConnectClose(conn); + + return s; +} + + static CMPIStatus net_pool_template(const CMPIObjectPath *ref, int template_type, struct inst_list *list) { - const char *id; + char *id; CMPIStatus s = {CMPI_RC_OK, NULL}; int type[3] = {NETPOOL_FORWARD_NONE, NETPOOL_FORWARD_NAT, @@ -1949,7 +2082,10 @@ goto out; } } - + + if (type == CIM_RES_TYPE_NET) + s = qos_hack(ref, list); + out: return s; } @@ -2055,7 +2191,7 @@ { CMPIInstance *ref_inst = NULL; uint16_t valuerole = SDC_ROLE_SUPPORTED; - uint16_t valuerange; + uint16_t valuerange = SDC_RANGE_POINT; uint16_t ppolicy = SDC_POLICY_INDEPENDENT; const char *iid = NULL; diff -r 2714b9a5e842 -r 862bcd60ae44 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Mon Oct 03 02:51:26 2011 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Wed Oct 26 03:41:56 2011 -0700 @@ -68,6 +68,35 @@ #define RASD_IND_DELETED "ResourceAllocationSettingDataDeletedIndication" #define RASD_IND_MODIFIED "ResourceAllocationSettingDataModifiedIndication" +/* Network QoS support */ +#define QOSCMD_BANDWIDTH2ID "_ROOT=$(tc class show dev %s | awk '($4==\"root\")\ +{print $3}')\n tc class show dev %s | awk -v rr=$_ROOT -v bw=%uKbit \ +'($4==\"parent\" && $5==rr && $13==bw){print $3}'\n" + +#define QOSCMD_RMVM "MAC=%s; ME1=$(echo $MAC | awk -F ':' '{ print $1$2$3$4 }'); \ +ME2=$(echo $MAC | awk -F ':' '{ print $5$6 }'); MI1=$(echo $MAC | awk -F ':' \ +'{ print $1$2 }'); MI2=$(echo $MAC | awk -F ':' '{ print $3$4$5$6 }'); \ +HDL=$(tc filter show dev %s | awk 'BEGIN {RS=\"\\nfilter\"} (NR>2)\ +{m1=substr($24,1,2);m2=substr($24,3,2);m3=substr($24,5,2);m4=substr($24,7,2);\ +m5=substr($20,1,2);m6=substr($20,3,2);printf(\"%%s:%%s:%%s:%%s:%%s:%%s %%s\\n\",\ +m1,m2,m3,m4,m5,m6,$9)}' | awk -v mm=%s '($1==mm){print $2}'); \ +U32=\"tc filter del dev %s protocol ip parent 1:0 prio 1 handle $HDL u32\"; \ +$U32 match u16 0x0800 0xFFFF at -2 match u16 0x$ME2 0xFFFF at -4 match u32 \ +0x$ME1 0xFFFFFFFF at -8 flowid %s; U32=\"tc filter del dev %s protocol ip parent \ +ffff: prio 50 u32\"; $U32 match u16 0x0800 0xFFFF at -2 match u32 0x$MI2 \ +0xFFFFFFFF at -12 match u16 0x$MI1 0xFFFF at -14 police rate %uKbit burst 15k \ +drop\n" + +#define QOSCMD_ADDVM "MAC=%s; ME1=$(echo $MAC | awk -F ':' '{ print $1$2$3$4 }'); \ +ME2=$(echo $MAC | awk -F ':' '{ print $5$6 }'); MI1=$(echo $MAC | awk -F ':' \ +'{ print $1$2 }'); MI2=$(echo $MAC | awk -F ':' '{ print $3$4$5$6 }'); \ +U32=\"tc filter add dev %s protocol ip parent 1:0 prio 1 u32\"; \ +$U32 match u16 0x0800 0xFFFF at -2 match u16 0x$ME2 0xFFFF at -4 match u32 \ +0x$ME1 0xFFFFFFFF at -8 flowid %s; U32=\"tc filter add dev %s protocol ip parent \ +ffff: prio 50 u32\"; $U32 match u16 0x0800 0xFFFF at -2 match u32 0x$MI2 \ +0xFFFFFFFF at -12 match u16 0x$MI1 0xFFFF at -14 police rate %uKbit burst 15k \ +drop\n" + const static CMPIBroker *_BROKER; enum ResourceAction { @@ -76,6 +105,104 @@ RESOURCE_MOD, }; +/* Network QoS support */ +static CMPIStatus add_qos_for_mac(const uint64_t qos, + const char *mac, + const char *bridge) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + char *cmd = NULL; + int j; + FILE *pipe = NULL; + char id[16] = ""; /* should be adequate to hold short tc class ids... */ + + /* Find tc performance class id which matches requested qos bandwidth */ + j = asprintf(&cmd, QOSCMD_BANDWIDTH2ID, bridge, + bridge, + (unsigned int)qos); + if (j == -1) + goto out; + CU_DEBUG("add_qos_for_mac(): cmd = %s", cmd); + + if ((pipe = popen(cmd, "r")) != NULL) { + if (fgets(id, sizeof(id), pipe) != NULL) { + /* Strip off trailing newline */ + char *p = index(id, '\n'); + if (p) *p = '\0'; + } + pclose(pipe); + } + free(cmd); + CU_DEBUG("qos id = '%s'", id); + + /* Add tc performance class id for this MAC addr */ + j = asprintf(&cmd, QOSCMD_ADDVM, mac, + bridge, + id, + bridge, + (unsigned int)qos); + if (j == -1) + goto out; + CU_DEBUG("add_qos_for_mac(): cmd = %s", cmd); + + if (WEXITSTATUS(system(cmd)) != 0) + CU_DEBUG("add_qos_for_mac(): qos add failed."); + + out: + free(cmd); + return s; +} + +/* Network QoS support */ +static CMPIStatus remove_qos_for_mac(const uint64_t qos, + const char *mac, + const char *bridge) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + char *cmd = NULL; + int j; + FILE *pipe = NULL; + char id[16] = ""; /* should be adequate to hold short tc class ids... */ + + /* Find tc performance class id which matches requested qos bandwidth */ + j = asprintf(&cmd, QOSCMD_BANDWIDTH2ID, bridge, + bridge, + (unsigned int)qos); + if (j == -1) + goto out; + CU_DEBUG("remove_qos_for_mac(): cmd = %s", cmd); + + if ((pipe = popen(cmd, "r")) != NULL) { + if (fgets(id, sizeof(id), pipe) != NULL) { + /* Strip off trailing newline */ + char *p = index(id, '\n'); + if (p) *p = '\0'; + } + pclose(pipe); + } + free(cmd); + CU_DEBUG("qos id = '%s'", id); + + /* Remove tc perf class id for this MAC; ignore errors when none exists */ + j = asprintf(&cmd, QOSCMD_RMVM, mac, + bridge, + mac, + bridge, + id, + bridge, + (unsigned int)qos); + if (j == -1) + goto out; + CU_DEBUG("remove_qos_for_mac(): cmd = %s", cmd); + + if (WEXITSTATUS(system(cmd)) != 0) + CU_DEBUG("remove_qos_for_mac(): qos remove failed; ignoring..."); + + out: + free(cmd); + return s; +} + static CMPIStatus check_uuid_in_use(const CMPIObjectPath *ref, struct domain *domain) { @@ -1518,6 +1645,8 @@ } else if (type == CIM_RES_TYPE_NET) { struct virt_device dev; int ncount = count + domain->dev_net_ct; + uint64_t qos_val = 0; + const char *qos_unitstr; memset(&dev, 0, sizeof(dev)); msg = rasd_to_vdev(inst, @@ -1529,6 +1658,20 @@ domain->dev_net, ncount, &domain->dev_net_ct); + + /* Network QoS support */ + if (((&dev)->dev.net.mac != NULL) && + ((&dev)->dev.net.source != NULL) && + (cu_get_u64_prop(inst, "Reservation", &qos_val) == CMPI_RC_OK) && + (cu_get_str_prop(inst, "AllocationUnits", &qos_unitstr) == CMPI_RC_OK) && + STREQ(qos_unitstr,"KiloBits per Second")) { + remove_qos_for_mac(qos_val, + (&dev)->dev.net.mac, + (&dev)->dev.net.source); + add_qos_for_mac(qos_val, + (&dev)->dev.net.mac, + (&dev)->dev.net.source); + } } else if (type == CIM_RES_TYPE_GRAPHICS) { struct virt_device dev; int gcount = count + domain->dev_graphics_ct; @@ -2590,10 +2733,28 @@ (type == CIM_RES_TYPE_INPUT)) cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); else { + uint64_t qos_val = 0; + const char *qos_unitstr; + s = _resource_dynamic(dominfo, dev, RESOURCE_MOD, CLASSNAME(op)); + + /* Network QoS support */ + if ((type == CIM_RES_TYPE_NET) && + (dev->dev.net.mac != NULL) && + (dev->dev.net.source != NULL) && + (cu_get_u64_prop(rasd, "Reservation", &qos_val) == CMPI_RC_OK) && + (cu_get_str_prop(rasd, "AllocationUnits", &qos_unitstr) == CMPI_RC_OK) && + STREQ(qos_unitstr,"KiloBits per Second")) { + remove_qos_for_mac(qos_val, + dev->dev.net.mac, + dev->dev.net.source); + s = add_qos_for_mac(qos_val, + dev->dev.net.mac, + dev->dev.net.source); + } } break; } From eblima at linux.vnet.ibm.com Thu Oct 27 12:27:55 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 27 Oct 2011 10:27:55 -0200 Subject: [Libvirt-cim] [PATCH] [TEST] Fix syntax errors, small tweaks In-Reply-To: References: Message-ID: <4EA94E4B.9030004@linux.vnet.ibm.com> Just found a small issue with this patch. Sending a new version soon. Best regards, Eduardo On 10/26/2011 03:20 PM, Sharad Mishra wrote: > +1 > > Sharad Mishra > Open Virtualization > Linux Technology Center > IBM > > libvirt-cim-bounces at redhat.com wrote on 10/14/2011 01:27:48 PM: > >> "Eduardo Lima \(Etrunko\)" >> Sent by: libvirt-cim-bounces at redhat.com >> >> 10/14/2011 01:27 PM >> >> Please respond to >> List for discussion and development of libvirt CIM > >> >> To >> >> libvirt-cim at redhat.com >> >> cc >> >> Subject >> >> [Libvirt-cim] [PATCH] [TEST] Fix syntax errors, small tweaks >> >> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 08_modifyresource.py | 6 +++--- >> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 31_unset_netrasd.py | 2 +- >> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 32_modify_cdrom_media.py | 8 +++++++- >> suites/libvirt-cim/main.py > | 2 +- >> 4 files changed, 12 insertions(+), 6 deletions(-) >> >> >> # HG changeset patch >> # User Eduardo Lima (Etrunko) >> # Date 1317410876 10800 >> # Node ID d8ac04bdc4806aecd1e5f28636a09ce501e36639 >> # Parent d9741a8b5eb7ccebf21d69f3cde72729bb60ad22 >> [TEST] Fix syntax errors, small tweaks >> >> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 08_modifyresource.py: >> - Unecessary virt param >> >> > suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py: >> - Undefined symbols XFAIL, SKIP >> >> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 32_modify_cdrom_media.py: >> - Check for None return when ejecting media >> >> suites/libvirt-cim/main.py >> - options referenced in except block without being defined >> >> Signed-off-by: Eduardo Lima (Etrunko) >> >> diff --git a/suites/libvirt-cim/cimtest/ >> VirtualSystemManagementService/08_modifyresource.py b/suites/ >> libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py >> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 08_modifyresource.py >> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 08_modifyresource.py >> @@ -47,7 +47,7 @@ >> new_int += 1 >> new_mac2 = "11:%s:22:%s:33:%s" % (new_int, new_int, new_int) >> >> -def cleanup_env(ip, virt, cxml): >> +def cleanup_env(ip, cxml): >> cxml.destroy(ip) >> cxml.undefine(ip) >> >> @@ -82,13 +82,13 @@ >> ret = cxml.cim_define(options.ip) >> if not ret: >> logger.error("Failed to define the dom: %s", default_dom) >> - cleanup_env(options.ip, options.virt, cxml) >> + cleanup_env(options.ip, cxml) >> return FAIL >> if case == "start": >> ret = cxml.start(options.ip) >> if not ret: >> logger.error("Failed to start the dom: %s", default_dom) >> - cleanup_env(options.ip, options.virt, cxml) >> + cleanup_env(options.ip, cxml) >> return FAIL >> >> status = vsms_util.mod_vcpu_res(options.ip, service, cxml, >> pasd, ncpu, >> diff --git a/suites/libvirt-cim/cimtest/ >> VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt- >> cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py >> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 31_unset_netrasd.py >> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 31_unset_netrasd.py >> @@ -28,7 +28,7 @@ >> import sys >> import pywbem >> >> -from CimTest.ReturnCodes import PASS, FAIL >> +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP >> from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS >> from XenKvmLib.const import do_main >> from XenKvmLib.classes import get_typed_class >> diff --git a/suites/libvirt-cim/cimtest/ >> VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/ >> > libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py >> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 32_modify_cdrom_media.py >> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >> 32_modify_cdrom_media.py >> @@ -105,8 +105,12 @@ >> return None >> >> inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) >> + >> + if not inst: >> + logger.error("Unable to get CDROM device instance after >> ModifyResourceSettings") >> + return None >> + >> new_addr = inst["Address"] >> - >> if new_addr != addr: >> logger.error("New media '%s' does not match expected '%s'", >> new_addr, addr) >> return None >> @@ -204,6 +208,8 @@ >> # Need to eject first? >> if media and old_media: >> inst = modify_media(cim, inst, "") >> + if not inst: >> + return FAIL >> >> media_path = os.path.join(_image_dir, media) >> inst = modify_media(cim, inst, media_path) >> diff --git a/suites/libvirt-cim/main.py b/suites/libvirt-cim/main.py >> --- a/suites/libvirt-cim/main.py >> +++ b/suites/libvirt-cim/main.py >> @@ -306,8 +306,8 @@ >> >> if __name__ == '__main__': >> ret = -1 >> + options, args = parser.parse_args() >> try: >> - options, args = parser.parse_args() >> ret = main(options, args) >> except (KeyboardInterrupt, SystemExit): >> print "\nKeyboardInterrupt. Cleaning up..." >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim >> > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From cvincent at linux.vnet.ibm.com Thu Oct 27 14:01:02 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 27 Oct 2011 10:01:02 -0400 Subject: [Libvirt-cim] [PATCH] [TEST] Fix syntax errors, small tweaks In-Reply-To: <4EA94E4B.9030004@linux.vnet.ibm.com> References: <4EA94E4B.9030004@linux.vnet.ibm.com> Message-ID: <4EA9641E.3030204@linux.vnet.ibm.com> Doh... okay :-) On 10/27/2011 08:27 AM, Eduardo Lima (Etrunko) wrote: > Just found a small issue with this patch. Sending a new version soon. > > Best regards, Eduardo > > On 10/26/2011 03:20 PM, Sharad Mishra wrote: >> +1 >> >> Sharad Mishra >> Open Virtualization >> Linux Technology Center >> IBM >> >> libvirt-cim-bounces at redhat.com wrote on 10/14/2011 01:27:48 PM: >> >>> "Eduardo Lima \(Etrunko\)" >>> Sent by: libvirt-cim-bounces at redhat.com >>> >>> 10/14/2011 01:27 PM >>> >>> Please respond to >>> List for discussion and development of libvirt CIM >> >>> >>> To >>> >>> libvirt-cim at redhat.com >>> >>> cc >>> >>> Subject >>> >>> [Libvirt-cim] [PATCH] [TEST] Fix syntax errors, small tweaks >>> >>> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 08_modifyresource.py | 6 +++--- >>> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 31_unset_netrasd.py | 2 +- >>> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 32_modify_cdrom_media.py | 8 +++++++- >>> suites/libvirt-cim/main.py >> | 2 +- >>> 4 files changed, 12 insertions(+), 6 deletions(-) >>> >>> >>> # HG changeset patch >>> # User Eduardo Lima (Etrunko) >>> # Date 1317410876 10800 >>> # Node ID d8ac04bdc4806aecd1e5f28636a09ce501e36639 >>> # Parent d9741a8b5eb7ccebf21d69f3cde72729bb60ad22 >>> [TEST] Fix syntax errors, small tweaks >>> >>> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 08_modifyresource.py: >>> - Unecessary virt param >>> >>> >> suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py: >>> - Undefined symbols XFAIL, SKIP >>> >>> suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 32_modify_cdrom_media.py: >>> - Check for None return when ejecting media >>> >>> suites/libvirt-cim/main.py >>> - options referenced in except block without being defined >>> >>> Signed-off-by: Eduardo Lima (Etrunko) >>> >>> diff --git a/suites/libvirt-cim/cimtest/ >>> VirtualSystemManagementService/08_modifyresource.py b/suites/ >>> libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py >>> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 08_modifyresource.py >>> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 08_modifyresource.py >>> @@ -47,7 +47,7 @@ >>> new_int += 1 >>> new_mac2 = "11:%s:22:%s:33:%s" % (new_int, new_int, new_int) >>> >>> -def cleanup_env(ip, virt, cxml): >>> +def cleanup_env(ip, cxml): >>> cxml.destroy(ip) >>> cxml.undefine(ip) >>> >>> @@ -82,13 +82,13 @@ >>> ret = cxml.cim_define(options.ip) >>> if not ret: >>> logger.error("Failed to define the dom: %s", default_dom) >>> - cleanup_env(options.ip, options.virt, cxml) >>> + cleanup_env(options.ip, cxml) >>> return FAIL >>> if case == "start": >>> ret = cxml.start(options.ip) >>> if not ret: >>> logger.error("Failed to start the dom: %s", default_dom) >>> - cleanup_env(options.ip, options.virt, cxml) >>> + cleanup_env(options.ip, cxml) >>> return FAIL >>> >>> status = vsms_util.mod_vcpu_res(options.ip, service, cxml, >>> pasd, ncpu, >>> diff --git a/suites/libvirt-cim/cimtest/ >>> VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt- >>> cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py >>> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 31_unset_netrasd.py >>> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 31_unset_netrasd.py >>> @@ -28,7 +28,7 @@ >>> import sys >>> import pywbem >>> >>> -from CimTest.ReturnCodes import PASS, FAIL >>> +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP >>> from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS >>> from XenKvmLib.const import do_main >>> from XenKvmLib.classes import get_typed_class >>> diff --git a/suites/libvirt-cim/cimtest/ >>> VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/ >>> >> libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py >>> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 32_modify_cdrom_media.py >>> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/ >>> 32_modify_cdrom_media.py >>> @@ -105,8 +105,12 @@ >>> return None >>> >>> inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) >>> + >>> + if not inst: >>> + logger.error("Unable to get CDROM device instance after >>> ModifyResourceSettings") >>> + return None >>> + >>> new_addr = inst["Address"] >>> - >>> if new_addr != addr: >>> logger.error("New media '%s' does not match expected '%s'", >>> new_addr, addr) >>> return None >>> @@ -204,6 +208,8 @@ >>> # Need to eject first? >>> if media and old_media: >>> inst = modify_media(cim, inst, "") >>> + if not inst: >>> + return FAIL >>> >>> media_path = os.path.join(_image_dir, media) >>> inst = modify_media(cim, inst, media_path) >>> diff --git a/suites/libvirt-cim/main.py b/suites/libvirt-cim/main.py >>> --- a/suites/libvirt-cim/main.py >>> +++ b/suites/libvirt-cim/main.py >>> @@ -306,8 +306,8 @@ >>> >>> if __name__ == '__main__': >>> ret = -1 >>> + options, args = parser.parse_args() >>> try: >>> - options, args = parser.parse_args() >>> ret = main(options, args) >>> except (KeyboardInterrupt, SystemExit): >>> print "\nKeyboardInterrupt. Cleaning up..." >>> >>> _______________________________________________ >>> Libvirt-cim mailing list >>> Libvirt-cim at redhat.com >>> https://www.redhat.com/mailman/listinfo/libvirt-cim >>> >> >> >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim > > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Thu Oct 27 14:34:59 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 27 Oct 2011 12:34:59 -0200 Subject: [Libvirt-cim] [PATCHv2] [TEST] Fix syntax errors, small tweaks Message-ID: <1319726099-9856-1-git-send-email-eblima@linux.vnet.ibm.com> From: Eduardo Lima (Etrunko) suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py: - Unecessary virt param suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py: - Undefined symbols XFAIL, SKIP suites/libvirt-cim/main.py - options referenced in except block without being defined Signed-off-by: Eduardo Lima (Etrunko) --- .../08_modifyresource.py | 8 ++++---- .../31_unset_netrasd.py | 2 +- suites/libvirt-cim/main.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py index 6661ef3..df58d1f 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py @@ -47,7 +47,7 @@ new_mac1 = "11:%s:22:%s:33:%s" % (new_int, new_int, new_int) new_int += 1 new_mac2 = "11:%s:22:%s:33:%s" % (new_int, new_int, new_int) -def cleanup_env(ip, virt, cxml): +def cleanup_env(ip, cxml): cxml.destroy(ip) cxml.undefine(ip) @@ -82,13 +82,13 @@ def main(): ret = cxml.cim_define(options.ip) if not ret: logger.error("Failed to define the dom: %s", default_dom) - cleanup_env(options.ip, options.virt, cxml) + cleanup_env(options.ip, cxml) return FAIL if case == "start": ret = cxml.start(options.ip) if not ret: logger.error("Failed to start the dom: %s", default_dom) - cleanup_env(options.ip, options.virt, cxml) + cleanup_env(options.ip, cxml) return FAIL status = vsms_util.mod_vcpu_res(options.ip, service, cxml, pasd, ncpu, @@ -114,7 +114,7 @@ def main(): if status != PASS: break - cleanup_env(options.ip, options.virt, cxml) + cleanup_env(options.ip, cxml) return status diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py index 417ad7f..9c78eb8 100755 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py @@ -28,7 +28,7 @@ import sys import pywbem -from CimTest.ReturnCodes import PASS, FAIL +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS from XenKvmLib.const import do_main from XenKvmLib.classes import get_typed_class diff --git a/suites/libvirt-cim/main.py b/suites/libvirt-cim/main.py index 4e7d621..a4e33e6 100644 --- a/suites/libvirt-cim/main.py +++ b/suites/libvirt-cim/main.py @@ -306,8 +306,8 @@ def main(options, args): if __name__ == '__main__': ret = -1 + options, args = parser.parse_args() try: - options, args = parser.parse_args() ret = main(options, args) except (KeyboardInterrupt, SystemExit): print "\nKeyboardInterrupt. Cleaning up..." -- 1.7.4.4 From cvincent at linux.vnet.ibm.com Thu Oct 27 14:50:48 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 27 Oct 2011 10:50:48 -0400 Subject: [Libvirt-cim] [PATCH] /dev/null should not be passed as source dev for cdrom device. Message-ID: <4EA96FC8.4060106@linux.vnet.ibm.com> For some reason this patch did not get forwarded to my email. +1 and pushed, but I'd like to see a follow-on patch that removes the need to strip the '/dev/null' before generating the XML. That is, I think we need the code to simply handle a dev->source == NULL rather than keep the 'null placeholder.' -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From snmishra at us.ibm.com Thu Oct 27 14:54:56 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 27 Oct 2011 07:54:56 -0700 Subject: [Libvirt-cim] cimtest results. In-Reply-To: <4EA94BF6.5070300@linux.vnet.ibm.com> References: <4EA94BF6.5070300@linux.vnet.ibm.com> Message-ID: "Eduardo Lima (Etrunko)" wrote on 10/27/2011 05:17:58 AM: > "Eduardo Lima (Etrunko)" > 10/27/2011 05:17 AM > > Please respond to > eblima at br.ibm.com > > To > > Sharad Mishra/Beaverton/IBM at IBMUS > > cc > > eblima at br.ibm.com, Chip Vincent/Raleigh/IBM at IBMUS, wayne > , Gareth S Bestor/Poughkeepsie/IBM at IBMUS > > Subject > > Re: cimtest results. > > On 10/26/2011 08:07 PM, snmishra at us.ibm.com wrote: > > Hi, > > > > I see bunch of tests failing after I get cimtest from upstream and apply > > the following patches - > > > > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00051.html > > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00052.html > > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00045.html > > > > > > If I run cimtest from rev 879 (which is upstream minus latest 4 patches) > > and compare the results with the run using latest upstream plus above > > three patches I see following extra failures - > > > > VirtualSystemManagementService - 08_modifyresource.py: FAIL > > VirtualSystemManagementService - 09_procrasd_persist.py: FAIL > > VirtualSystemManagementService - 11_define_memrasdunits.py: FAIL > > VirtualSystemManagementService - 31_unset_netrasd.py: FAIL > > VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL > > KVMRedirectionSAP - 01_enum_KVMredSAP.py: FAIL > > > > I understand that 31_* and 32_* are new tests and that is the reason I > > did not see them in my run with older rev. But we need to figure out why > > these tests are failing. > > > > The buggy patch is 883 ([TEST] XenKvmLib: Add cdrom device description > to domain) and it looks weird that you actually ran revision 879 as it > should not include VSMS 31 and 32. Can you try again with revision 882? When I wrote "older rev" above, I meant rev 879. I did not see 31_ and 32_ in rev 879 and that is understandable since those tests were added in later rev. I am trying to understand why above tests are failing with 883 + cimtest patches on list (the three I pointed out above)? -Sharad > > Best regards, Etrunko > > -- > Eduardo de Barros Lima > Software Engineer, Open Virtualization > Linux Technology Center - IBM/Brazil > eblima at br.ibm.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Thu Oct 27 15:07:46 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 27 Oct 2011 11:07:46 -0400 Subject: [Libvirt-cim] [PATCH] Patch to add network qos (bandwidth) support for KVM guests using tc In-Reply-To: <862bcd60ae449932205b.1319625741@rhel6> References: <862bcd60ae449932205b.1319625741@rhel6> Message-ID: <4EA973C2.7080108@linux.vnet.ibm.com> On 10/26/2011 06:42 AM, Gareth S. Bestor wrote: > # HG changeset patch > # User Gareth S. Bestor > # Date 1319625716 25200 > # Node ID 862bcd60ae449932205b15ba42b37e06e6834de4 > # Parent 2714b9a5e842cc1e8c2ae182c2adef083cc1ef1a hg? Well, since not everyone is aware we've moved to git... > Patch to add network qos (bandwidth) support for KVM guests using tc nit: good to have a space here. > This patch adds network qos support into libvirt-cim for setting network > bandwidth limits on KVM guests' MAC addrs, using existing tc (traffic control) > host support. Patch is a bit hack-ish because it is mostly for older versions > of libvirt which do not have any qos support in libvirt itself. I am finishing > a new, and cleaner, patch to libvirt-cim that will exploit the native support > for qos present in latest libvirt versions. > Patch is a bit ugly because (1) it must manage all the qos data associated with > KVM guest's network device completely *outside* of libvirt (since no support > and existing mgmt data available to handle this in older libvirts). > And (2) because the tc commands themselves needed to query, retreive, add and > delete tc bandwidth setting for a MAC addr are themselves quite messy scripts. > This patch assume all the necessary tc performance classes have been setup > externally. > Because it must screen-scrape tc command output to get > performance class and associated bandwith values, this patch will be very > sensitive to change in output format of tc commands. It has been tested > successfully on RHEL6.1. > I dont not recommend exploiting this new feature unless you know > what you are doing... nit: some of these lines appear >80 > > Signed-off-by: Gareth Bestor > > diff -r 2714b9a5e842 -r 862bcd60ae44 src/Virt_RASD.c > --- a/src/Virt_RASD.c Mon Oct 03 02:51:26 2011 -0700 > +++ b/src/Virt_RASD.c Wed Oct 26 03:41:56 2011 -0700 > @@ -39,6 +39,16 @@ > #include "svpc_types.h" > #include "Virt_Device.h" > > +/* Network QoS support */ > +#define QOSCMD_MAC2BANDWIDTH "_ROOT=$(tc class show dev %s | awk '($4==\"root\")\ > +{print $3}')\n _ID=$(tc filter show dev %s | awk 'BEGIN {RS=\"\\nfilter\"} (NR>2)\ > +{m1=substr($24,1,2);m2=substr($24,3,2);m3=substr($24,5,2);m4=substr($24,7,2);\ > +m5=substr($20,1,2);m6=substr($20,3,2);printf(\"%%s:%%s:%%s:%%s:%%s:%%s %%s\\n\",\ > +m1,m2,m3,m4,m5,m6,$18)}' | awk -v mm=%s '($1==mm){print $2}')\n \ > +if [[ -n \"$_ID\" ]]; then\n tc class show dev %s | awk -v rr=$_ROOT -v id=$_ID \ > +'($4==\"parent\"&& $5==rr&& $3==id){print \ > +substr($13,1,(index($13,\"Kbit\")-1))}'\n fi\n" > + It would be great to see a better comment for the above, but I have no idea what you might say to make that clearer. Since this patch has a limited life time, fine as-is. > const static CMPIBroker *_BROKER; > > static struct virt_device *_find_dev(struct virt_device *list, > @@ -449,7 +459,11 @@ > const struct virt_device *dev, > CMPIInstance *inst) > { > + FILE *pipe = NULL; > + char *cmd = NULL; > + uint64_t val = 0; > CMPIStatus s = {CMPI_RC_OK, NULL}; > + int i; > > CMSetProperty(inst, > "NetworkType", > @@ -467,6 +481,33 @@ > (CMPIValue *)dev->dev.net.source, > CMPI_chars); > > + /* Network QoS support */ > + if ((dev->dev.net.mac != NULL)&& (dev->dev.net.source != NULL)) { > + /* Get tc performance class bandwidth for this MAC addr */ > + i = asprintf(&cmd, QOSCMD_MAC2BANDWIDTH, dev->dev.net.source, > + dev->dev.net.source, > + dev->dev.net.mac, > + dev->dev.net.source); > + if (i == -1) > + goto out; > + > + if ((pipe = popen(cmd, "r")) != NULL) { > + if (fscanf(pipe, "%u", (unsigned int *)&val) == 1) { > + CU_DEBUG("pipe read. val = %d", val); > + > + CMSetProperty(inst, > + "Reservation", > + (CMPIValue *)&val, CMPI_uint64); > + CMSetProperty(inst, > + "AllocationUnits", > + (CMPIValue *)"KiloBits per Second", > + CMPI_chars); > + } > + pclose(pipe); > + } > + free(cmd); > + } > + > if ((dev->dev.net.source != NULL)&& > (STREQ(dev->dev.net.type, "direct"))) > CMSetProperty(inst, > @@ -498,6 +539,7 @@ > (CMPIValue *)dev->dev.net.poolid, > CMPI_chars); > > +out: > return s; > } > > diff -r 2714b9a5e842 -r 862bcd60ae44 src/Virt_SettingsDefineCapabilities.c > --- a/src/Virt_SettingsDefineCapabilities.c Mon Oct 03 02:51:26 2011 -0700 > +++ b/src/Virt_SettingsDefineCapabilities.c Wed Oct 26 03:41:56 2011 -0700 > @@ -73,6 +73,11 @@ > #define POOL_RASD 1 > #define NEW_VOL_RASD 2 > > +/* QoS Network support */ > +#define QOSCMD_LISTCLASSES "_ROOT=$(tc class show dev %s | awk '($4==\"root\")\ > +{print $3}')\n tc class show dev %s | awk -v rr=$_ROOT \ > +'($4==\"parent\"&& $5==rr){print $3\" \"$13}'\n" > + > static bool system_has_vt(virConnectPtr conn) > { > char *caps = NULL; > @@ -726,7 +731,7 @@ > } > > static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, > - const char *id, > + char *id, > uint16_t pool_type, > struct inst_list *list) > { > @@ -738,6 +743,7 @@ > const char *ip_stop = "192.168.122.254"; > int dev_count; > int i; > + char *tmp_str = NULL; > > /* Isolated network pools don't have a forward device */ > if (pool_type == NETPOOL_FORWARD_NONE) > @@ -750,7 +756,33 @@ > if ((inst == NULL) || (s.rc != CMPI_RC_OK)) > goto out; > > - CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); > + > + tmp_str = strtok(id, " "); > + if (tmp_str == NULL) { > + CU_DEBUG("Cannot set InstanceID"); > + goto out; > + } > + > + CU_DEBUG("InstanceID = %s", tmp_str); > + > + CMSetProperty(inst, "InstanceID", (CMPIValue *)tmp_str, > + CMPI_chars); > + tmp_str = strtok('\0', " "); > + if (tmp_str == NULL) { > + CU_DEBUG("Cannot set Reservation"); > + goto out; > + } > + > + CU_DEBUG("Reservation = %s", tmp_str); > + > + uint64_t val = atoi(tmp_str); > + > + CMSetProperty(inst, "Reservation", > + (CMPIValue *)&val, CMPI_uint64); > + > + CMSetProperty(inst, "AllocationUnits", > + (CMPIValue *)"Kilobits per Second", > + CMPI_chars); > > CMSetProperty(inst, "Address", > (CMPIValue *)addr, CMPI_chars); > @@ -779,11 +811,112 @@ > return s; > } > > +static char * get_bridge_name(virConnectPtr conn, const char *name) > +{ > + char *bridge = NULL; > + virNetworkPtr network = NULL; > + > + if (++name == NULL) > + goto out; > + > + CU_DEBUG("looking for network `%s'", name); > + network = virNetworkLookupByName(conn, name); > + if (network == NULL) { > + CU_DEBUG("Could not find network"); > + goto out; > + } > + > + bridge = virNetworkGetBridgeName(network); > + if (bridge == NULL) { > + CU_DEBUG("Could not find bridge"); > + } > + > + virNetworkFree(network); > + > + out: > + return bridge; > +} > + > +/* QoS Network support */ > +static CMPIStatus qos_hack( > + const CMPIObjectPath *ref, > + struct inst_list *list) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + virConnectPtr conn = NULL; > + FILE *pipe = NULL; > + char buffer[1024]; > + char *bridge = NULL; > + char *cmd = NULL; > + const char *val = NULL; > + int i; > + > + conn = connect_by_classname(_BROKER, CLASSNAME(ref),&s); > + if (s.rc != CMPI_RC_OK) { > + cu_statusf(_BROKER,&s, > + CMPI_RC_ERR_FAILED, > + "Could not get connection"); > + goto out; > + } > + > + if (cu_get_str_path(ref, "InstanceID",&val) != CMPI_RC_OK) { > + cu_statusf(_BROKER,&s, > + CMPI_RC_ERR_FAILED, > + "Could not get InstanceID"); > + goto out; > + } > + > + CU_DEBUG("InstanceID is %s", val); > + > + bridge = get_bridge_name(conn, strstr(val, "/")); > + if (bridge == NULL) > + goto out; > + > + i = asprintf(&cmd, QOSCMD_LISTCLASSES, bridge, bridge); > + if (i == -1) > + goto out; > + > + CU_DEBUG("qos_hack() cmd = %s", cmd); > + > + if ((pipe = popen(cmd, "r")) != NULL) { > + CU_DEBUG("pipe open"); > + while (fgets(buffer, sizeof(buffer), pipe) != NULL) { > + char *name = NULL; > + char *p = strstr(buffer, "Kbit"); > + > + /* trim string */ > + if (p) > + *p = '\0'; > + > + CU_DEBUG("qos hack buffer = %s", buffer); > + > + i = asprintf(&name, "Point/%s", buffer); > + if (i != -1) { > + s = set_net_pool_props(ref, name, > + NETPOOL_FORWARD_NONE, list); > + > + free(name); > + } > + } > + > + pclose(pipe); > + CU_DEBUG("pipe close"); > + } > + > + out: > + free(cmd); > + free(bridge); > + virConnectClose(conn); > + > + return s; > +} > + > + > static CMPIStatus net_pool_template(const CMPIObjectPath *ref, > int template_type, > struct inst_list *list) > { > - const char *id; > + char *id; > CMPIStatus s = {CMPI_RC_OK, NULL}; > int type[3] = {NETPOOL_FORWARD_NONE, > NETPOOL_FORWARD_NAT, > @@ -1949,7 +2082,10 @@ > goto out; > } > } > - > + > + if (type == CIM_RES_TYPE_NET) > + s = qos_hack(ref, list); > + > out: > return s; > } > @@ -2055,7 +2191,7 @@ > { > CMPIInstance *ref_inst = NULL; > uint16_t valuerole = SDC_ROLE_SUPPORTED; > - uint16_t valuerange; > + uint16_t valuerange = SDC_RANGE_POINT; > uint16_t ppolicy = SDC_POLICY_INDEPENDENT; > const char *iid = NULL; > > diff -r 2714b9a5e842 -r 862bcd60ae44 src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Mon Oct 03 02:51:26 2011 -0700 > +++ b/src/Virt_VirtualSystemManagementService.c Wed Oct 26 03:41:56 2011 -0700 > @@ -68,6 +68,35 @@ > #define RASD_IND_DELETED "ResourceAllocationSettingDataDeletedIndication" > #define RASD_IND_MODIFIED "ResourceAllocationSettingDataModifiedIndication" > > +/* Network QoS support */ > +#define QOSCMD_BANDWIDTH2ID "_ROOT=$(tc class show dev %s | awk '($4==\"root\")\ > +{print $3}')\n tc class show dev %s | awk -v rr=$_ROOT -v bw=%uKbit \ > +'($4==\"parent\"&& $5==rr&& $13==bw){print $3}'\n" > + > +#define QOSCMD_RMVM "MAC=%s; ME1=$(echo $MAC | awk -F ':' '{ print $1$2$3$4 }'); \ > +ME2=$(echo $MAC | awk -F ':' '{ print $5$6 }'); MI1=$(echo $MAC | awk -F ':' \ > +'{ print $1$2 }'); MI2=$(echo $MAC | awk -F ':' '{ print $3$4$5$6 }'); \ > +HDL=$(tc filter show dev %s | awk 'BEGIN {RS=\"\\nfilter\"} (NR>2)\ > +{m1=substr($24,1,2);m2=substr($24,3,2);m3=substr($24,5,2);m4=substr($24,7,2);\ > +m5=substr($20,1,2);m6=substr($20,3,2);printf(\"%%s:%%s:%%s:%%s:%%s:%%s %%s\\n\",\ > +m1,m2,m3,m4,m5,m6,$9)}' | awk -v mm=%s '($1==mm){print $2}'); \ > +U32=\"tc filter del dev %s protocol ip parent 1:0 prio 1 handle $HDL u32\"; \ > +$U32 match u16 0x0800 0xFFFF at -2 match u16 0x$ME2 0xFFFF at -4 match u32 \ > +0x$ME1 0xFFFFFFFF at -8 flowid %s; U32=\"tc filter del dev %s protocol ip parent \ > +ffff: prio 50 u32\"; $U32 match u16 0x0800 0xFFFF at -2 match u32 0x$MI2 \ > +0xFFFFFFFF at -12 match u16 0x$MI1 0xFFFF at -14 police rate %uKbit burst 15k \ > +drop\n" > + > +#define QOSCMD_ADDVM "MAC=%s; ME1=$(echo $MAC | awk -F ':' '{ print $1$2$3$4 }'); \ > +ME2=$(echo $MAC | awk -F ':' '{ print $5$6 }'); MI1=$(echo $MAC | awk -F ':' \ > +'{ print $1$2 }'); MI2=$(echo $MAC | awk -F ':' '{ print $3$4$5$6 }'); \ > +U32=\"tc filter add dev %s protocol ip parent 1:0 prio 1 u32\"; \ > +$U32 match u16 0x0800 0xFFFF at -2 match u16 0x$ME2 0xFFFF at -4 match u32 \ > +0x$ME1 0xFFFFFFFF at -8 flowid %s; U32=\"tc filter add dev %s protocol ip parent \ > +ffff: prio 50 u32\"; $U32 match u16 0x0800 0xFFFF at -2 match u32 0x$MI2 \ > +0xFFFFFFFF at -12 match u16 0x$MI1 0xFFFF at -14 police rate %uKbit burst 15k \ > +drop\n" > + ouch! > const static CMPIBroker *_BROKER; > > enum ResourceAction { > @@ -76,6 +105,104 @@ > RESOURCE_MOD, > }; > > +/* Network QoS support */ > +static CMPIStatus add_qos_for_mac(const uint64_t qos, > + const char *mac, > + const char *bridge) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + char *cmd = NULL; > + int j; > + FILE *pipe = NULL; > + char id[16] = ""; /* should be adequate to hold short tc class ids... */ > + > + /* Find tc performance class id which matches requested qos bandwidth */ > + j = asprintf(&cmd, QOSCMD_BANDWIDTH2ID, bridge, > + bridge, > + (unsigned int)qos); > + if (j == -1) > + goto out; > + CU_DEBUG("add_qos_for_mac(): cmd = %s", cmd); > + > + if ((pipe = popen(cmd, "r")) != NULL) { > + if (fgets(id, sizeof(id), pipe) != NULL) { > + /* Strip off trailing newline */ > + char *p = index(id, '\n'); > + if (p) *p = '\0'; > + } > + pclose(pipe); > + } > + free(cmd); > + CU_DEBUG("qos id = '%s'", id); > + > + /* Add tc performance class id for this MAC addr */ > + j = asprintf(&cmd, QOSCMD_ADDVM, mac, > + bridge, > + id, > + bridge, > + (unsigned int)qos); > + if (j == -1) > + goto out; > + CU_DEBUG("add_qos_for_mac(): cmd = %s", cmd); > + > + if (WEXITSTATUS(system(cmd)) != 0) > + CU_DEBUG("add_qos_for_mac(): qos add failed."); > + > + out: > + free(cmd); > + return s; > +} > + > +/* Network QoS support */ > +static CMPIStatus remove_qos_for_mac(const uint64_t qos, > + const char *mac, > + const char *bridge) > +{ > + CMPIStatus s = {CMPI_RC_OK, NULL}; > + char *cmd = NULL; > + int j; > + FILE *pipe = NULL; > + char id[16] = ""; /* should be adequate to hold short tc class ids... */ > + > + /* Find tc performance class id which matches requested qos bandwidth */ > + j = asprintf(&cmd, QOSCMD_BANDWIDTH2ID, bridge, > + bridge, > + (unsigned int)qos); > + if (j == -1) > + goto out; > + CU_DEBUG("remove_qos_for_mac(): cmd = %s", cmd); > + > + if ((pipe = popen(cmd, "r")) != NULL) { > + if (fgets(id, sizeof(id), pipe) != NULL) { > + /* Strip off trailing newline */ > + char *p = index(id, '\n'); > + if (p) *p = '\0'; > + } > + pclose(pipe); > + } > + free(cmd); > + CU_DEBUG("qos id = '%s'", id); > + > + /* Remove tc perf class id for this MAC; ignore errors when none exists */ > + j = asprintf(&cmd, QOSCMD_RMVM, mac, > + bridge, > + mac, > + bridge, > + id, > + bridge, > + (unsigned int)qos); > + if (j == -1) > + goto out; > + CU_DEBUG("remove_qos_for_mac(): cmd = %s", cmd); > + > + if (WEXITSTATUS(system(cmd)) != 0) > + CU_DEBUG("remove_qos_for_mac(): qos remove failed; ignoring..."); > + > + out: > + free(cmd); > + return s; > +} > + > static CMPIStatus check_uuid_in_use(const CMPIObjectPath *ref, > struct domain *domain) > { > @@ -1518,6 +1645,8 @@ > } else if (type == CIM_RES_TYPE_NET) { > struct virt_device dev; > int ncount = count + domain->dev_net_ct; > + uint64_t qos_val = 0; > + const char *qos_unitstr; > > memset(&dev, 0, sizeof(dev)); > msg = rasd_to_vdev(inst, > @@ -1529,6 +1658,20 @@ > domain->dev_net, > ncount, > &domain->dev_net_ct); > + > + /* Network QoS support */ > + if (((&dev)->dev.net.mac != NULL)&& > + ((&dev)->dev.net.source != NULL)&& > + (cu_get_u64_prop(inst, "Reservation",&qos_val) == CMPI_RC_OK)&& > + (cu_get_str_prop(inst, "AllocationUnits",&qos_unitstr) == CMPI_RC_OK)&& > + STREQ(qos_unitstr,"KiloBits per Second")) { > + remove_qos_for_mac(qos_val, > + (&dev)->dev.net.mac, > + (&dev)->dev.net.source); > + add_qos_for_mac(qos_val, > + (&dev)->dev.net.mac, > + (&dev)->dev.net.source); > + } > } else if (type == CIM_RES_TYPE_GRAPHICS) { > struct virt_device dev; > int gcount = count + domain->dev_graphics_ct; > @@ -2590,10 +2733,28 @@ > (type == CIM_RES_TYPE_INPUT)) > cu_statusf(_BROKER,&s, CMPI_RC_OK, ""); > else { > + uint64_t qos_val = 0; > + const char *qos_unitstr; > + > s = _resource_dynamic(dominfo, > dev, > RESOURCE_MOD, > CLASSNAME(op)); > + > + /* Network QoS support */ > + if ((type == CIM_RES_TYPE_NET)&& > + (dev->dev.net.mac != NULL)&& > + (dev->dev.net.source != NULL)&& > + (cu_get_u64_prop(rasd, "Reservation",&qos_val) == CMPI_RC_OK)&& > + (cu_get_str_prop(rasd, "AllocationUnits",&qos_unitstr) == CMPI_RC_OK)&& > + STREQ(qos_unitstr,"KiloBits per Second")) { > + remove_qos_for_mac(qos_val, > + dev->dev.net.mac, > + dev->dev.net.source); > + s = add_qos_for_mac(qos_val, > + dev->dev.net.mac, > + dev->dev.net.source); > + } > } > break; > } > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > +1 and pushed. Gareth, please post some cimtests for this so we can ensure the function performs the same from this version to the future version based on libvirt APIs. Thanks. -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Thu Oct 27 17:42:17 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 27 Oct 2011 15:42:17 -0200 Subject: [Libvirt-cim] cimtest results. In-Reply-To: References: <4EA94BF6.5070300@linux.vnet.ibm.com> Message-ID: <4EA997F9.1000403@linux.vnet.ibm.com> On 10/27/2011 12:54 PM, Sharad Mishra wrote: >> >> On 10/26/2011 08:07 PM, snmishra at us.ibm.com wrote: >> > Hi, >> > >> > I see bunch of tests failing after I get cimtest from upstream and apply >> > the following patches - >> > >> > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00051.html >> > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00052.html >> > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00045.html >> > >> > >> > If I run cimtest from rev 879 (which is upstream minus latest 4 patches) >> > and compare the results with the run using latest upstream plus above >> > three patches I see following extra failures - >> > >> > VirtualSystemManagementService - 08_modifyresource.py: FAIL >> > VirtualSystemManagementService - 09_procrasd_persist.py: FAIL >> > VirtualSystemManagementService - 11_define_memrasdunits.py: FAIL >> > VirtualSystemManagementService - 31_unset_netrasd.py: FAIL >> > VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL >> > KVMRedirectionSAP - 01_enum_KVMredSAP.py: FAIL >> > >> > I understand that 31_* and 32_* are new tests and that is the reason I >> > did not see them in my run with older rev. But we need to figure out why >> > these tests are failing. >> > >> >> The buggy patch is 883 ([TEST] XenKvmLib: Add cdrom device description >> to domain) and it looks weird that you actually ran revision 879 as it >> should not include VSMS 31 and 32. Can you try again with revision 882? > > When I wrote "older rev" above, I meant rev 879. > I did not see 31_ and 32_ in rev 879 and that is understandable since > those tests were added in later rev. > I am trying to understand why above tests are failing with 883 + cimtest > patches on list (the three I pointed out above)? So you are saying that in rev 879 the other tests (08, 09 and 11) pass? And can you provide the log when they fail? Best regards, Eduardo. -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From snmishra at us.ibm.com Thu Oct 27 18:25:57 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 27 Oct 2011 11:25:57 -0700 Subject: [Libvirt-cim] cimtest results. In-Reply-To: <4EA997F9.1000403@linux.vnet.ibm.com> References: <4EA94BF6.5070300@linux.vnet.ibm.com> <4EA997F9.1000403@linux.vnet.ibm.com> Message-ID: Here are the short logs on failures. I would suggest running cimtest with latest upstream + patches on list and make sure that these patches are not breaking existing tests. In general, before posting any patch, complete cimtest should be run and it should be verified that new patch is not breaking any cimtest. ++++++++++++++++ VirtualSystemManagementService - 09_procrasd_persist.py: FAIL ERROR - Got CIM error CIM_ERR_FAILED: ResourceSettings Error: VirtualDevice property must be unique for each DiskResourceAllocationSettingData in a single guest with return code 1 ERROR - Unable to define procrasd_persist_dom InvokeMethod(DefineSystem): CIM_ERR_FAILED: ResourceSettings Error: VirtualDevice property must be unique for each DiskResourceAllocationSettingData in a single guest VirtualSystemManagementService - 11_define_memrasdunits.py: FAIL ERROR - Got CIM error CIM_ERR_FAILED: ResourceSettings Error: VirtualDevice property must be unique for each DiskResourceAllocationSettingData in a single guest with return code 1 ERROR - DefineSystem with (KiloBytes) units failed InvokeMethod(DefineSystem): CIM_ERR_FAILED: ResourceSettings Error: VirtualDevice property must be unique for each DiskResourceAllocationSettingData in a single guest VirtualSystemManagementService - 31_unset_netrasd.py: FAIL ERROR - Current 'virtio' and expected '' ResourceSubType differ VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL ERROR - New media '/dev/null' does not match expected '' ERROR - TypeError : 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/home/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "32_modify_cdrom_media.py", line 223, in main inst = modify_media(cim, inst, media_path) File "32_modify_cdrom_media.py", line 114, in modify_media val = set_device_addr(inst, addr) File "32_modify_cdrom_media.py", line 97, in set_device_addr inst["InstanceID"], TypeError: 'NoneType' object is unsubscriptable ERROR - None VirtualSystemManagementService - 08_modifyresource.py: FAIL ERROR - (4, u'CIM_ERR_INVALID_PARAMETER: Missing InstanceID in RASD') ERROR - Error invoking ModifyRS: mod_disk_res ERROR - ModifyResourceSettings call failed InvokeMethod(ModifyResourceSettings): CIM_ERR_INVALID_PARAMETER: Missing InstanceID in RASD Sharad Mishra Open Virtualization Linux Technology Center IBM "Eduardo Lima (Etrunko)" wrote on 10/27/2011 10:42:17 AM: > "Eduardo Lima (Etrunko)" > 10/27/2011 10:42 AM > > Please respond to > eblima at br.ibm.com > > To > > List for discussion and development of libvirt CIM > > cc > > Sharad Mishra/Beaverton/IBM at IBMUS, eblima at br.ibm.com > > Subject > > Re: [Libvirt-cim] cimtest results. > > On 10/27/2011 12:54 PM, Sharad Mishra wrote: > >> > >> On 10/26/2011 08:07 PM, snmishra at us.ibm.com wrote: > >> > Hi, > >> > > >> > I see bunch of tests failing after I get cimtest from upstream and apply > >> > the following patches - > >> > > >> > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00051.html > >> > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00052.html > >> > https://www.redhat.com/archives/libvirt-cim/2011-October/msg00045.html > >> > > >> > > >> > If I run cimtest from rev 879 (which is upstream minus latest 4 patches) > >> > and compare the results with the run using latest upstream plus above > >> > three patches I see following extra failures - > >> > > >> > VirtualSystemManagementService - 08_modifyresource.py: FAIL > >> > VirtualSystemManagementService - 09_procrasd_persist.py: FAIL > >> > VirtualSystemManagementService - 11_define_memrasdunits.py: FAIL > >> > VirtualSystemManagementService - 31_unset_netrasd.py: FAIL > >> > VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL > >> > KVMRedirectionSAP - 01_enum_KVMredSAP.py: FAIL > >> > > >> > I understand that 31_* and 32_* are new tests and that is the reason I > >> > did not see them in my run with older rev. But we need to figure out why > >> > these tests are failing. > >> > > >> > >> The buggy patch is 883 ([TEST] XenKvmLib: Add cdrom device description > >> to domain) and it looks weird that you actually ran revision 879 as it > >> should not include VSMS 31 and 32. Can you try again with revision 882? > > > > When I wrote "older rev" above, I meant rev 879. > > I did not see 31_ and 32_ in rev 879 and that is understandable since > > those tests were added in later rev. > > I am trying to understand why above tests are failing with 883 + cimtest > > patches on list (the three I pointed out above)? > > So you are saying that in rev 879 the other tests (08, 09 and 11) pass? > And can you provide the log when they fail? > > Best regards, Eduardo. > > -- > Eduardo de Barros Lima > Software Engineer, Open Virtualization > Linux Technology Center - IBM/Brazil > eblima at br.ibm.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eblima at linux.vnet.ibm.com Thu Oct 27 20:16:38 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 27 Oct 2011 18:16:38 -0200 Subject: [Libvirt-cim] cimtest results. In-Reply-To: References: <4EA94BF6.5070300@linux.vnet.ibm.com> <4EA997F9.1000403@linux.vnet.ibm.com> Message-ID: <4EA9BC26.7020603@linux.vnet.ibm.com> On 10/27/2011 04:25 PM, Sharad Mishra wrote: > Here are the short logs on failures. > > I would suggest running cimtest with latest upstream + patches on list > and make sure that these patches are not breaking existing tests. > In general, before posting any patch, complete cimtest should be run and > it should be verified that new patch is not breaking any cimtest. > Sorry, I will pay more attention on this from now on. I am using the latest HEAD plus patches I've sent to revert the changes on XenKvmLib/vxml.py. Those patches are in the branch for-review of my cimtest tree in gitorious. git://gitorious.org/~eblima/libvirt-cim/etrunko-cimtest.git > ++++++++++++++++ > > VirtualSystemManagementService - 09_procrasd_persist.py: FAIL > ERROR - Got CIM error CIM_ERR_FAILED: ResourceSettings Error: > VirtualDevice property must be unique for each > DiskResourceAllocationSettingData in a single guest with return code 1 > ERROR - Unable to define procrasd_persist_dom > InvokeMethod(DefineSystem): CIM_ERR_FAILED: ResourceSettings Error: > VirtualDevice property must be unique for each > DiskResourceAllocationSettingData in a single guest > In my case this one fails with a different message: ====09_procrasd_persist.py Log==== Limit is None, expected 512 > > VirtualSystemManagementService - 11_define_memrasdunits.py: FAIL > ERROR - Got CIM error CIM_ERR_FAILED: ResourceSettings Error: > VirtualDevice property must be unique for each > DiskResourceAllocationSettingData in a single guest with return code 1 > ERROR - DefineSystem with (KiloBytes) units failed > InvokeMethod(DefineSystem): CIM_ERR_FAILED: ResourceSettings Error: > VirtualDevice property must be unique for each > DiskResourceAllocationSettingData in a single guest > > This one matches: ====11_define_memrasdunits.py Log==== Defining with Bytes = 2147483648 Verified 2097152 KB Defining with KiloBytes = 2097152 Got CIM error CIM_ERR_FAILED: ResourceSettings Error: VirtualDevice property must be unique for each DiskResourceAllocationSettingData in a single guest with return code 1 DefineSystem with (KiloBytes) units failed This test worked fine until the patch that introduced the changes in XenKvmLib/vxml.py was integrated. What is really weird is that even reverting those changes it still fails. :/ > VirtualSystemManagementService - 31_unset_netrasd.py: FAIL > ERROR - Current 'virtio' and expected '' ResourceSubType differ > > > VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL > ERROR - New media '/dev/null' does not match expected '' > ERROR - TypeError : 'NoneType' object is unsubscriptable > Traceback (most recent call last): > File "/home/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line > 141, in do_try > rc = f() > File "32_modify_cdrom_media.py", line 223, in main > inst = modify_media(cim, inst, media_path) > File "32_modify_cdrom_media.py", line 114, in modify_media > val = set_device_addr(inst, addr) > File "32_modify_cdrom_media.py", line 97, in set_device_addr > inst["InstanceID"], > TypeError: 'NoneType' object is unsubscriptable > ERROR - None 31 and 32 expose a bug in pegasus version 2.10 and 2.11.0. Make sure you have either 2.9 or 2.11.1. > > > VirtualSystemManagementService - 08_modifyresource.py: FAIL > ERROR - (4, u'CIM_ERR_INVALID_PARAMETER: Missing InstanceID in RASD') > ERROR - Error invoking ModifyRS: mod_disk_res > ERROR - ModifyResourceSettings call failed > InvokeMethod(ModifyResourceSettings): CIM_ERR_INVALID_PARAMETER: Missing > InstanceID in RASD > This one works for me.... :/ Would be nice to have results from the others as well. I am investigating and will post a fix asap. Sorry for -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From snmishra at us.ibm.com Thu Oct 27 20:29:09 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 27 Oct 2011 13:29:09 -0700 Subject: [Libvirt-cim] cimtest results. In-Reply-To: <4EA9BC26.7020603@linux.vnet.ibm.com> References: <4EA94BF6.5070300@linux.vnet.ibm.com> <4EA997F9.1000403@linux.vnet.ibm.com> <4EA9BC26.7020603@linux.vnet.ibm.com> Message-ID: No problem Eduardo. In my eagerness to close a defect I have posted patches without first running all cimtests. So, this was a reminder to me too. Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM "Eduardo Lima (Etrunko)" wrote on 10/27/2011 01:16:38 PM: > "Eduardo Lima (Etrunko)" > 10/27/2011 01:16 PM > > Please respond to > eblima at br.ibm.com > > To > > Sharad Mishra/Beaverton/IBM at IBMUS > > cc > > eblima at br.ibm.com, List for discussion and development of libvirt > CIM > > Subject > > Re: [Libvirt-cim] cimtest results. > > On 10/27/2011 04:25 PM, Sharad Mishra wrote: > > Here are the short logs on failures. > > > > I would suggest running cimtest with latest upstream + patches on list > > and make sure that these patches are not breaking existing tests. > > In general, before posting any patch, complete cimtest should be run and > > it should be verified that new patch is not breaking any cimtest. > > > > Sorry, I will pay more attention on this from now on. I am using the > latest HEAD plus patches I've sent to revert the changes on > XenKvmLib/vxml.py. Those patches are in the branch for-review of my > cimtest tree in gitorious. > > git://gitorious.org/~eblima/libvirt-cim/etrunko-cimtest.git > > > > ++++++++++++++++ > > > > VirtualSystemManagementService - 09_procrasd_persist.py: FAIL > > ERROR - Got CIM error CIM_ERR_FAILED: ResourceSettings Error: > > VirtualDevice property must be unique for each > > DiskResourceAllocationSettingData in a single guest with return code 1 > > ERROR - Unable to define procrasd_persist_dom > > InvokeMethod(DefineSystem): CIM_ERR_FAILED: ResourceSettings Error: > > VirtualDevice property must be unique for each > > DiskResourceAllocationSettingData in a single guest > > > > In my case this one fails with a different message: > > ====09_procrasd_persist.py Log==== > Limit is None, expected 512 > > > > > VirtualSystemManagementService - 11_define_memrasdunits.py: FAIL > > ERROR - Got CIM error CIM_ERR_FAILED: ResourceSettings Error: > > VirtualDevice property must be unique for each > > DiskResourceAllocationSettingData in a single guest with return code 1 > > ERROR - DefineSystem with (KiloBytes) units failed > > InvokeMethod(DefineSystem): CIM_ERR_FAILED: ResourceSettings Error: > > VirtualDevice property must be unique for each > > DiskResourceAllocationSettingData in a single guest > > > > > > This one matches: > > ====11_define_memrasdunits.py Log==== > Defining with Bytes = 2147483648 > Verified 2097152 KB > Defining with KiloBytes = 2097152 > Got CIM error CIM_ERR_FAILED: ResourceSettings Error: VirtualDevice > property must be unique for each DiskResourceAllocationSettingData in a > single guest with return code 1 > DefineSystem with (KiloBytes) units failed > > This test worked fine until the patch that introduced the changes in > XenKvmLib/vxml.py was integrated. What is really weird is that even > reverting those changes it still fails. :/ > > > VirtualSystemManagementService - 31_unset_netrasd.py: FAIL > > ERROR - Current 'virtio' and expected '' ResourceSubType differ > > > > > > VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL > > ERROR - New media '/dev/null' does not match expected '' > > ERROR - TypeError : 'NoneType' object is unsubscriptable > > Traceback (most recent call last): > > File "/home/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line > > 141, in do_try > > rc = f() > > File "32_modify_cdrom_media.py", line 223, in main > > inst = modify_media(cim, inst, media_path) > > File "32_modify_cdrom_media.py", line 114, in modify_media > > val = set_device_addr(inst, addr) > > File "32_modify_cdrom_media.py", line 97, in set_device_addr > > inst["InstanceID"], > > TypeError: 'NoneType' object is unsubscriptable > > ERROR - None > > 31 and 32 expose a bug in pegasus version 2.10 and 2.11.0. Make sure you > have either 2.9 or 2.11.1. > > > > > > > VirtualSystemManagementService - 08_modifyresource.py: FAIL > > ERROR - (4, u'CIM_ERR_INVALID_PARAMETER: Missing InstanceID in RASD') > > ERROR - Error invoking ModifyRS: mod_disk_res > > ERROR - ModifyResourceSettings call failed > > InvokeMethod(ModifyResourceSettings): CIM_ERR_INVALID_PARAMETER: Missing > > InstanceID in RASD > > > > This one works for me.... :/ Would be nice to have results from the > others as well. > > I am investigating and will post a fix asap. Sorry for > > -- > Eduardo de Barros Lima > Software Engineer, Open Virtualization > Linux Technology Center - IBM/Brazil > eblima at br.ibm.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eblima at linux.vnet.ibm.com Thu Oct 27 21:07:30 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 27 Oct 2011 19:07:30 -0200 Subject: [Libvirt-cim] [PATCH] [TEST] Fix VSMS 09_procrasd_persist and 11_define_memrasdunits Message-ID: <1319749650-29641-1-git-send-email-eblima@linux.vnet.ibm.com> From: Eduardo Lima (Etrunko) Both tests were failing due to reusing an instance of the class for defining domains in a loop. The error message was the following: ERROR - Got CIM error CIM_ERR_FAILED: ResourceSettings Error: VirtualDevice property must be unique for each DiskResourceAllocationSettingData in a single guest with return code 1 A recent change in XenKvmLib/vxml.py necessary for the new test 32_modify_cdrom_media.py triggered this bug. To avoid this error we simply create a new instance of that class in each iteration of the loop. Signed-off-by: Eduardo Lima (Etrunko) --- .../09_procrasd_persist.py | 3 ++- .../11_define_memrasdunits.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py index 91415dd..a53c5ac 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py @@ -119,11 +119,12 @@ def main(): virt = options.virt server = options.ip - cxml = get_class(virt)(test_dom) + cxml = None prasd_cn = get_typed_class(virt, "ProcResourceAllocationSettingData") dom_define = dom_start = False try: for count in range(3): + cxml = get_class(virt)(test_dom) status = setup_guest(server, virt, cxml, prasd_cn) if status != PASS: return status diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py index 8c032c2..3f54ff4 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py @@ -113,8 +113,7 @@ def check_value(options): def main(): options = main.options - cxml = get_class(options.virt)(default_dom) - + cxml = None status = FAIL guest_is_undefined = None @@ -123,6 +122,7 @@ def main(): value = mem_bytes >> shift + cxml = get_class(options.virt)(default_dom) status = try_define(options, units, value, cxml) if status != PASS: break -- 1.7.4.4 From eblima at linux.vnet.ibm.com Thu Oct 27 21:09:46 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 27 Oct 2011 19:09:46 -0200 Subject: [Libvirt-cim] cimtest results. In-Reply-To: References: <4EA94BF6.5070300@linux.vnet.ibm.com> <4EA997F9.1000403@linux.vnet.ibm.com> <4EA9BC26.7020603@linux.vnet.ibm.com> Message-ID: <4EA9C89A.2050200@linux.vnet.ibm.com> On 10/27/2011 06:29 PM, Sharad Mishra wrote: > No problem Eduardo. > In my eagerness to close a defect I have posted patches without first > running all cimtests. So, this was a reminder to me too. > I have just submitted a patch to fix 09 and 11. The patch is also in the for-review branch in my gitorious tree. Please let me know if there are any other issues left. Best Regards, >> >> git://gitorious.org/~eblima/libvirt-cim/etrunko-cimtest.git >> -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From xiawenc at linux.vnet.ibm.com Fri Oct 28 02:43:34 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Fri, 28 Oct 2011 10:43:34 +0800 Subject: [Libvirt-cim] [PATCH] Patch to add network qos (bandwidth) support for KVM guests using tc In-Reply-To: <4EA973C2.7080108@linux.vnet.ibm.com> References: <862bcd60ae449932205b.1319625741@rhel6> <4EA973C2.7080108@linux.vnet.ibm.com> Message-ID: <4EAA16D6.2020600@linux.vnet.ibm.com> ? 2011-10-27 23:07, Chip Vincent ??: > > > On 10/26/2011 06:42 AM, Gareth S. Bestor wrote: >> # HG changeset patch >> # User Gareth S. Bestor >> # Date 1319625716 25200 >> # Node ID 862bcd60ae449932205b15ba42b37e06e6834de4 >> # Parent 2714b9a5e842cc1e8c2ae182c2adef083cc1ef1a > > hg? Well, since not everyone is aware we've moved to git... > >> Patch to add network qos (bandwidth) support for KVM guests using tc > > nit: good to have a space here. > >> This patch adds network qos support into libvirt-cim for setting network >> bandwidth limits on KVM guests' MAC addrs, using existing tc (traffic >> control) >> host support. Patch is a bit hack-ish because it is mostly for older >> versions >> of libvirt which do not have any qos support in libvirt itself. I am >> finishing >> a new, and cleaner, patch to libvirt-cim that will exploit the native >> support >> for qos present in latest libvirt versions. >> Patch is a bit ugly because (1) it must manage all the qos data >> associated with >> KVM guest's network device completely *outside* of libvirt (since no >> support >> and existing mgmt data available to handle this in older libvirts). >> And (2) because the tc commands themselves needed to query, retreive, >> add and >> delete tc bandwidth setting for a MAC addr are themselves quite messy >> scripts. >> This patch assume all the necessary tc performance classes have been >> setup >> externally. >> Because it must screen-scrape tc command output to get >> performance class and associated bandwith values, this patch will be very >> sensitive to change in output format of tc commands. It has been tested >> successfully on RHEL6.1. >> I dont not recommend exploiting this new feature unless you know >> what you are doing... > > nit: some of these lines appear >80 > the code seems not that nice because code was not devided for CIM model and hos command. Later I would post some code in Libxkutil for executing commands on host, which is also needed for VLAN. >> >> Signed-off-by: Gareth Bestor >> >> diff -r 2714b9a5e842 -r 862bcd60ae44 src/Virt_RASD.c >> --- a/src/Virt_RASD.c Mon Oct 03 02:51:26 2011 -0700 >> +++ b/src/Virt_RASD.c Wed Oct 26 03:41:56 2011 -0700 >> @@ -39,6 +39,16 @@ >> #include "svpc_types.h" >> #include "Virt_Device.h" >> >> +/* Network QoS support */ >> +#define QOSCMD_MAC2BANDWIDTH "_ROOT=$(tc class show dev %s | awk >> '($4==\"root\")\ >> +{print $3}')\n _ID=$(tc filter show dev %s | awk 'BEGIN >> {RS=\"\\nfilter\"} (NR>2)\ >> +{m1=substr($24,1,2);m2=substr($24,3,2);m3=substr($24,5,2);m4=substr($24,7,2);\ >> >> +m5=substr($20,1,2);m6=substr($20,3,2);printf(\"%%s:%%s:%%s:%%s:%%s:%%s %%s\\n\",\ >> >> +m1,m2,m3,m4,m5,m6,$18)}' | awk -v mm=%s '($1==mm){print $2}')\n \ >> +if [[ -n \"$_ID\" ]]; then\n tc class show dev %s | awk -v rr=$_ROOT >> -v id=$_ID \ >> +'($4==\"parent\"&& $5==rr&& $3==id){print \ >> +substr($13,1,(index($13,\"Kbit\")-1))}'\n fi\n" >> + > > It would be great to see a better comment for the above, but I have no > idea what you might say to make that clearer. Since this patch has a > limited life time, fine as-is. > >> const static CMPIBroker *_BROKER; >> >> static struct virt_device *_find_dev(struct virt_device *list, >> @@ -449,7 +459,11 @@ >> const struct virt_device *dev, >> CMPIInstance *inst) >> { >> + FILE *pipe = NULL; >> + char *cmd = NULL; >> + uint64_t val = 0; >> CMPIStatus s = {CMPI_RC_OK, NULL}; >> + int i; >> >> CMSetProperty(inst, >> "NetworkType", >> @@ -467,6 +481,33 @@ >> (CMPIValue *)dev->dev.net.source, >> CMPI_chars); >> >> + /* Network QoS support */ >> + if ((dev->dev.net.mac != NULL)&& (dev->dev.net.source != NULL)) { >> + /* Get tc performance class bandwidth for this MAC addr */ >> + i = asprintf(&cmd, QOSCMD_MAC2BANDWIDTH, dev->dev.net.source, >> + dev->dev.net.source, >> + dev->dev.net.mac, >> + dev->dev.net.source); >> + if (i == -1) >> + goto out; >> + >> + if ((pipe = popen(cmd, "r")) != NULL) { >> + if (fscanf(pipe, "%u", (unsigned int *)&val) == 1) { >> + CU_DEBUG("pipe read. val = %d", val); >> + >> + CMSetProperty(inst, >> + "Reservation", >> + (CMPIValue *)&val, CMPI_uint64); >> + CMSetProperty(inst, >> + "AllocationUnits", >> + (CMPIValue *)"KiloBits per Second", >> + CMPI_chars); >> + } >> + pclose(pipe); >> + } >> + free(cmd); >> + } >> + >> if ((dev->dev.net.source != NULL)&& >> (STREQ(dev->dev.net.type, "direct"))) >> CMSetProperty(inst, >> @@ -498,6 +539,7 @@ >> (CMPIValue *)dev->dev.net.poolid, >> CMPI_chars); >> >> +out: >> return s; >> } >> >> diff -r 2714b9a5e842 -r 862bcd60ae44 >> src/Virt_SettingsDefineCapabilities.c >> --- a/src/Virt_SettingsDefineCapabilities.c Mon Oct 03 02:51:26 2011 >> -0700 >> +++ b/src/Virt_SettingsDefineCapabilities.c Wed Oct 26 03:41:56 2011 >> -0700 >> @@ -73,6 +73,11 @@ >> #define POOL_RASD 1 >> #define NEW_VOL_RASD 2 >> >> +/* QoS Network support */ >> +#define QOSCMD_LISTCLASSES "_ROOT=$(tc class show dev %s | awk >> '($4==\"root\")\ >> +{print $3}')\n tc class show dev %s | awk -v rr=$_ROOT \ >> +'($4==\"parent\"&& $5==rr){print $3\" \"$13}'\n" >> + >> static bool system_has_vt(virConnectPtr conn) >> { >> char *caps = NULL; >> @@ -726,7 +731,7 @@ >> } >> >> static CMPIStatus set_net_pool_props(const CMPIObjectPath *ref, >> - const char *id, >> + char *id, >> uint16_t pool_type, >> struct inst_list *list) >> { >> @@ -738,6 +743,7 @@ >> const char *ip_stop = "192.168.122.254"; >> int dev_count; >> int i; >> + char *tmp_str = NULL; >> >> /* Isolated network pools don't have a forward device */ >> if (pool_type == NETPOOL_FORWARD_NONE) >> @@ -750,7 +756,33 @@ >> if ((inst == NULL) || (s.rc != CMPI_RC_OK)) >> goto out; >> >> - CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); >> + >> + tmp_str = strtok(id, " "); >> + if (tmp_str == NULL) { >> + CU_DEBUG("Cannot set InstanceID"); >> + goto out; >> + } >> + >> + CU_DEBUG("InstanceID = %s", tmp_str); >> + >> + CMSetProperty(inst, "InstanceID", (CMPIValue *)tmp_str, >> + CMPI_chars); >> + tmp_str = strtok('\0', " "); >> + if (tmp_str == NULL) { >> + CU_DEBUG("Cannot set Reservation"); >> + goto out; >> + } >> + >> + CU_DEBUG("Reservation = %s", tmp_str); >> + >> + uint64_t val = atoi(tmp_str); >> + >> + CMSetProperty(inst, "Reservation", >> + (CMPIValue *)&val, CMPI_uint64); >> + >> + CMSetProperty(inst, "AllocationUnits", >> + (CMPIValue *)"Kilobits per Second", >> + CMPI_chars); >> >> CMSetProperty(inst, "Address", >> (CMPIValue *)addr, CMPI_chars); >> @@ -779,11 +811,112 @@ >> return s; >> } >> >> +static char * get_bridge_name(virConnectPtr conn, const char *name) >> +{ >> + char *bridge = NULL; >> + virNetworkPtr network = NULL; >> + >> + if (++name == NULL) >> + goto out; >> + >> + CU_DEBUG("looking for network `%s'", name); >> + network = virNetworkLookupByName(conn, name); >> + if (network == NULL) { >> + CU_DEBUG("Could not find network"); >> + goto out; >> + } >> + >> + bridge = virNetworkGetBridgeName(network); >> + if (bridge == NULL) { >> + CU_DEBUG("Could not find bridge"); >> + } >> + >> + virNetworkFree(network); >> + >> + out: >> + return bridge; >> +} >> + >> +/* QoS Network support */ >> +static CMPIStatus qos_hack( >> + const CMPIObjectPath *ref, >> + struct inst_list *list) >> +{ >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> + virConnectPtr conn = NULL; >> + FILE *pipe = NULL; >> + char buffer[1024]; >> + char *bridge = NULL; >> + char *cmd = NULL; >> + const char *val = NULL; >> + int i; >> + >> + conn = connect_by_classname(_BROKER, CLASSNAME(ref),&s); >> + if (s.rc != CMPI_RC_OK) { >> + cu_statusf(_BROKER,&s, >> + CMPI_RC_ERR_FAILED, >> + "Could not get connection"); >> + goto out; >> + } >> + >> + if (cu_get_str_path(ref, "InstanceID",&val) != CMPI_RC_OK) { >> + cu_statusf(_BROKER,&s, >> + CMPI_RC_ERR_FAILED, >> + "Could not get InstanceID"); >> + goto out; >> + } >> + >> + CU_DEBUG("InstanceID is %s", val); >> + >> + bridge = get_bridge_name(conn, strstr(val, "/")); >> + if (bridge == NULL) >> + goto out; >> + >> + i = asprintf(&cmd, QOSCMD_LISTCLASSES, bridge, bridge); >> + if (i == -1) >> + goto out; >> + >> + CU_DEBUG("qos_hack() cmd = %s", cmd); >> + >> + if ((pipe = popen(cmd, "r")) != NULL) { >> + CU_DEBUG("pipe open"); >> + while (fgets(buffer, sizeof(buffer), pipe) != NULL) { >> + char *name = NULL; >> + char *p = strstr(buffer, "Kbit"); >> + >> + /* trim string */ >> + if (p) >> + *p = '\0'; >> + >> + CU_DEBUG("qos hack buffer = %s", buffer); >> + >> + i = asprintf(&name, "Point/%s", buffer); >> + if (i != -1) { >> + s = set_net_pool_props(ref, name, >> + NETPOOL_FORWARD_NONE, list); >> + >> + free(name); >> + } >> + } >> + >> + pclose(pipe); >> + CU_DEBUG("pipe close"); >> + } >> + >> + out: >> + free(cmd); >> + free(bridge); >> + virConnectClose(conn); >> + >> + return s; >> +} >> + >> + >> static CMPIStatus net_pool_template(const CMPIObjectPath *ref, >> int template_type, >> struct inst_list *list) >> { >> - const char *id; >> + char *id; >> CMPIStatus s = {CMPI_RC_OK, NULL}; >> int type[3] = {NETPOOL_FORWARD_NONE, >> NETPOOL_FORWARD_NAT, >> @@ -1949,7 +2082,10 @@ >> goto out; >> } >> } >> - >> + >> + if (type == CIM_RES_TYPE_NET) >> + s = qos_hack(ref, list); >> + >> out: >> return s; >> } >> @@ -2055,7 +2191,7 @@ >> { >> CMPIInstance *ref_inst = NULL; >> uint16_t valuerole = SDC_ROLE_SUPPORTED; >> - uint16_t valuerange; >> + uint16_t valuerange = SDC_RANGE_POINT; >> uint16_t ppolicy = SDC_POLICY_INDEPENDENT; >> const char *iid = NULL; >> >> diff -r 2714b9a5e842 -r 862bcd60ae44 >> src/Virt_VirtualSystemManagementService.c >> --- a/src/Virt_VirtualSystemManagementService.c Mon Oct 03 02:51:26 >> 2011 -0700 >> +++ b/src/Virt_VirtualSystemManagementService.c Wed Oct 26 03:41:56 >> 2011 -0700 >> @@ -68,6 +68,35 @@ >> #define RASD_IND_DELETED "ResourceAllocationSettingDataDeletedIndication" >> #define RASD_IND_MODIFIED >> "ResourceAllocationSettingDataModifiedIndication" >> >> +/* Network QoS support */ >> +#define QOSCMD_BANDWIDTH2ID "_ROOT=$(tc class show dev %s | awk >> '($4==\"root\")\ >> +{print $3}')\n tc class show dev %s | awk -v rr=$_ROOT -v bw=%uKbit \ >> +'($4==\"parent\"&& $5==rr&& $13==bw){print $3}'\n" >> + >> +#define QOSCMD_RMVM "MAC=%s; ME1=$(echo $MAC | awk -F ':' '{ print >> $1$2$3$4 }'); \ >> +ME2=$(echo $MAC | awk -F ':' '{ print $5$6 }'); MI1=$(echo $MAC | awk >> -F ':' \ >> +'{ print $1$2 }'); MI2=$(echo $MAC | awk -F ':' '{ print $3$4$5$6 }'); \ >> +HDL=$(tc filter show dev %s | awk 'BEGIN {RS=\"\\nfilter\"} (NR>2)\ >> +{m1=substr($24,1,2);m2=substr($24,3,2);m3=substr($24,5,2);m4=substr($24,7,2);\ >> >> +m5=substr($20,1,2);m6=substr($20,3,2);printf(\"%%s:%%s:%%s:%%s:%%s:%%s %%s\\n\",\ >> >> +m1,m2,m3,m4,m5,m6,$9)}' | awk -v mm=%s '($1==mm){print $2}'); \ >> +U32=\"tc filter del dev %s protocol ip parent 1:0 prio 1 handle $HDL >> u32\"; \ >> +$U32 match u16 0x0800 0xFFFF at -2 match u16 0x$ME2 0xFFFF at -4 >> match u32 \ >> +0x$ME1 0xFFFFFFFF at -8 flowid %s; U32=\"tc filter del dev %s >> protocol ip parent \ >> +ffff: prio 50 u32\"; $U32 match u16 0x0800 0xFFFF at -2 match u32 >> 0x$MI2 \ >> +0xFFFFFFFF at -12 match u16 0x$MI1 0xFFFF at -14 police rate %uKbit >> burst 15k \ >> +drop\n" >> + >> +#define QOSCMD_ADDVM "MAC=%s; ME1=$(echo $MAC | awk -F ':' '{ print >> $1$2$3$4 }'); \ >> +ME2=$(echo $MAC | awk -F ':' '{ print $5$6 }'); MI1=$(echo $MAC | awk >> -F ':' \ >> +'{ print $1$2 }'); MI2=$(echo $MAC | awk -F ':' '{ print $3$4$5$6 }'); \ >> +U32=\"tc filter add dev %s protocol ip parent 1:0 prio 1 u32\"; \ >> +$U32 match u16 0x0800 0xFFFF at -2 match u16 0x$ME2 0xFFFF at -4 >> match u32 \ >> +0x$ME1 0xFFFFFFFF at -8 flowid %s; U32=\"tc filter add dev %s >> protocol ip parent \ >> +ffff: prio 50 u32\"; $U32 match u16 0x0800 0xFFFF at -2 match u32 >> 0x$MI2 \ >> +0xFFFFFFFF at -12 match u16 0x$MI1 0xFFFF at -14 police rate %uKbit >> burst 15k \ >> +drop\n" >> + > > ouch! > an example of text used here would be good to say what it is doing. >> const static CMPIBroker *_BROKER; >> >> enum ResourceAction { >> @@ -76,6 +105,104 @@ >> RESOURCE_MOD, >> }; >> >> +/* Network QoS support */ >> +static CMPIStatus add_qos_for_mac(const uint64_t qos, >> + const char *mac, >> + const char *bridge) >> +{ >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> + char *cmd = NULL; >> + int j; >> + FILE *pipe = NULL; >> + char id[16] = ""; /* should be adequate to hold short tc class >> ids... */ >> + >> + /* Find tc performance class id which matches requested qos >> bandwidth */ >> + j = asprintf(&cmd, QOSCMD_BANDWIDTH2ID, bridge, >> + bridge, >> + (unsigned int)qos); >> + if (j == -1) >> + goto out; >> + CU_DEBUG("add_qos_for_mac(): cmd = %s", cmd); >> + >> + if ((pipe = popen(cmd, "r")) != NULL) { >> + if (fgets(id, sizeof(id), pipe) != NULL) { >> + /* Strip off trailing newline */ >> + char *p = index(id, '\n'); >> + if (p) *p = '\0'; >> + } >> + pclose(pipe); >> + } >> + free(cmd); >> + CU_DEBUG("qos id = '%s'", id); >> + >> + /* Add tc performance class id for this MAC addr */ >> + j = asprintf(&cmd, QOSCMD_ADDVM, mac, >> + bridge, >> + id, >> + bridge, >> + (unsigned int)qos); >> + if (j == -1) >> + goto out; >> + CU_DEBUG("add_qos_for_mac(): cmd = %s", cmd); >> + >> + if (WEXITSTATUS(system(cmd)) != 0) >> + CU_DEBUG("add_qos_for_mac(): qos add failed."); >> + >> + out: >> + free(cmd); >> + return s; >> +} >> + >> +/* Network QoS support */ >> +static CMPIStatus remove_qos_for_mac(const uint64_t qos, >> + const char *mac, >> + const char *bridge) >> +{ >> + CMPIStatus s = {CMPI_RC_OK, NULL}; >> + char *cmd = NULL; >> + int j; >> + FILE *pipe = NULL; >> + char id[16] = ""; /* should be adequate to hold short tc class >> ids... */ >> + >> + /* Find tc performance class id which matches requested qos >> bandwidth */ >> + j = asprintf(&cmd, QOSCMD_BANDWIDTH2ID, bridge, >> + bridge, >> + (unsigned int)qos); >> + if (j == -1) >> + goto out; >> + CU_DEBUG("remove_qos_for_mac(): cmd = %s", cmd); >> + >> + if ((pipe = popen(cmd, "r")) != NULL) { >> + if (fgets(id, sizeof(id), pipe) != NULL) { >> + /* Strip off trailing newline */ >> + char *p = index(id, '\n'); >> + if (p) *p = '\0'; >> + } >> + pclose(pipe); >> + } >> + free(cmd); >> + CU_DEBUG("qos id = '%s'", id); >> + >> + /* Remove tc perf class id for this MAC; ignore errors when none >> exists */ >> + j = asprintf(&cmd, QOSCMD_RMVM, mac, >> + bridge, >> + mac, >> + bridge, >> + id, >> + bridge, >> + (unsigned int)qos); >> + if (j == -1) >> + goto out; >> + CU_DEBUG("remove_qos_for_mac(): cmd = %s", cmd); >> + >> + if (WEXITSTATUS(system(cmd)) != 0) >> + CU_DEBUG("remove_qos_for_mac(): qos remove failed; ignoring..."); >> + >> + out: >> + free(cmd); >> + return s; >> +} >> + >> static CMPIStatus check_uuid_in_use(const CMPIObjectPath *ref, >> struct domain *domain) >> { >> @@ -1518,6 +1645,8 @@ >> } else if (type == CIM_RES_TYPE_NET) { >> struct virt_device dev; >> int ncount = count + domain->dev_net_ct; >> + uint64_t qos_val = 0; >> + const char *qos_unitstr; >> >> memset(&dev, 0, sizeof(dev)); >> msg = rasd_to_vdev(inst, >> @@ -1529,6 +1658,20 @@ >> domain->dev_net, >> ncount, >> &domain->dev_net_ct); >> + >> + /* Network QoS support */ >> + if (((&dev)->dev.net.mac != NULL)&& >> + ((&dev)->dev.net.source != NULL)&& >> + (cu_get_u64_prop(inst, "Reservation",&qos_val) == CMPI_RC_OK)&& >> + (cu_get_str_prop(inst, "AllocationUnits",&qos_unitstr) == CMPI_RC_OK)&& >> + STREQ(qos_unitstr,"KiloBits per Second")) { >> + remove_qos_for_mac(qos_val, >> + (&dev)->dev.net.mac, >> + (&dev)->dev.net.source); >> + add_qos_for_mac(qos_val, >> + (&dev)->dev.net.mac, >> + (&dev)->dev.net.source); >> + } >> } else if (type == CIM_RES_TYPE_GRAPHICS) { >> struct virt_device dev; >> int gcount = count + domain->dev_graphics_ct; >> @@ -2590,10 +2733,28 @@ >> (type == CIM_RES_TYPE_INPUT)) >> cu_statusf(_BROKER,&s, CMPI_RC_OK, ""); >> else { >> + uint64_t qos_val = 0; >> + const char *qos_unitstr; >> + >> s = _resource_dynamic(dominfo, >> dev, >> RESOURCE_MOD, >> CLASSNAME(op)); >> + >> + /* Network QoS support */ >> + if ((type == CIM_RES_TYPE_NET)&& >> + (dev->dev.net.mac != NULL)&& >> + (dev->dev.net.source != NULL)&& >> + (cu_get_u64_prop(rasd, "Reservation",&qos_val) == CMPI_RC_OK)&& >> + (cu_get_str_prop(rasd, "AllocationUnits",&qos_unitstr) == CMPI_RC_OK)&& >> + STREQ(qos_unitstr,"KiloBits per Second")) { >> + remove_qos_for_mac(qos_val, >> + dev->dev.net.mac, >> + dev->dev.net.source); >> + s = add_qos_for_mac(qos_val, >> + dev->dev.net.mac, >> + dev->dev.net.source); >> + } >> } >> break; >> } >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim >> > > +1 and pushed. Gareth, please post some cimtests for this so we can > ensure the function performs the same from this version to the future > version based on libvirt APIs. > > Thanks. > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From dpkshetty at gmail.com Fri Oct 28 12:58:37 2011 From: dpkshetty at gmail.com (Deepak Shetty) Date: Fri, 28 Oct 2011 18:28:37 +0530 Subject: [Libvirt-cim] Unable to compile libvirt-cim : getting libgcrypt.la error Message-ID: Hi, I am getting the below error in trying to compile libvirt-cim I m on a Ubuntu 11.04 desktop system. dpkshetty at deepak-ThinkPad-T60p:~/work/libvirt-cim/libvirt-cim$ make make all-recursive make[1]: Entering directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim' Making all in libxkutil make[2]: Entering directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/libxkutil' Making all in tests make[3]: Entering directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/libxkutil/tests' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/libxkutil/tests' make[3]: Entering directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/libxkutil' CC cs_util_instance.lo CC misc_util.lo CC device_parsing.lo CC xmlgen.lo CC infostore.lo CC pool_parsing.lo CC acl_parsing.lo CCLD libxkutil.la /bin/sed: can't read /lib/i386-linux-gnu/libgcrypt.la: No such file or directory libtool: link: `/lib/i386-linux-gnu/libgcrypt.la' is not a valid libtool archive make[3]: *** [libxkutil.la] Error 1 make[3]: Leaving directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/libxkutil' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/libxkutil' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim' make: *** [all] Error 2 It first looked like the problem mentioned here @ https://bugs.launchpad.net/ubuntu/+source/libgcrypt11/+bug/751142 But trying to update libgcrypt via apt-get says I already have the latest library installed and apt-get does nothing. I also put this obs and some workarounds I tried to get over this issue in the launchpad defect, hoping to see some response. I would like to know if anybody can point me to what i am missing thanx, deepak -------------- next part -------------- An HTML attachment was scrubbed... URL: From eblima at linux.vnet.ibm.com Fri Oct 28 20:03:57 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 28 Oct 2011 18:03:57 -0200 Subject: [Libvirt-cim] [PATCH] Avoid connection to libvirt if previous attempt fails Message-ID: <1319832237-22515-1-git-send-email-eblima@linux.vnet.ibm.com> From: Eduardo Lima (Etrunko) This is a workaround to avoid libvirt flooding error messages in syslog. This happens often if a client submits queries for CIM_ superclasses, which then will translate to a query for each registered class. In our case KVM_, LXC_ and XEN_. Ideally, there should be a way to ask libvirt if a given URI or hypervisor is enabled/supported. A patch for that feature is on the works, and as soon as it is integrated to libvirt tree this feature will be updated. Signed-off-by: Eduardo Lima (Etrunko) --- libxkutil/misc_util.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index c2cc204..61893c3 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -53,6 +54,46 @@ static int libvirt_initialized = 0; #define URI_ENV "HYPURI" +struct _hypervisor_status_t { + const char *name; + bool enabled; +}; + +typedef struct _hypervisor_status_t hypervisor_status_t; + +static hypervisor_status_t hypervisor_list[] = { + { "xen", true }, + { "kvm", true }, + { "lxc", true }, + { NULL }, +}; + +static bool get_hypervisor_enabled(const char *hypervisor) +{ + hypervisor_status_t *h; + + for (h = &hypervisor_list[0]; h != NULL; h++) { + if (strncasecmp(hypervisor, h->name, strlen(h->name)) == 0) { + return h->enabled; + } + } + + return false; +} + +static void set_hypervisor_disabled(const char *hypervisor) +{ + hypervisor_status_t *h; + + for (h = &hypervisor_list[0]; h != NULL; h++) { + if (strncasecmp(hypervisor, h->name, strlen(h->name)) == 0) { + CU_DEBUG("Setting '%s' hypervisor as DISABLED", h->name); + h->enabled = false; + return; + } + } +} + static const char *cn_to_uri(const char *classname) { if (STARTS_WITH(classname, "Xen")) @@ -117,6 +158,9 @@ virConnectPtr connect_by_classname(const CMPIBroker *broker, return NULL; } + if (!get_hypervisor_enabled(classname)) + return NULL; + CU_DEBUG("Connecting to libvirt with uri `%s'", uri); pthread_mutex_lock(&libvirt_mutex); @@ -129,6 +173,10 @@ virConnectPtr connect_by_classname(const CMPIBroker *broker, pthread_mutex_unlock(&libvirt_mutex); if (!conn) { + virErrorPtr error = virGetLastError(); + if (error->code == VIR_ERR_NO_CONNECT) + set_hypervisor_disabled(classname); + CU_DEBUG("Unable to connect to `%s'", uri); return NULL; } -- 1.7.4.4 From snmishra at us.ibm.com Fri Oct 28 21:47:56 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Fri, 28 Oct 2011 14:47:56 -0700 Subject: [Libvirt-cim] [PATCH] Avoid connection to libvirt if previous attempt fails In-Reply-To: <1319832237-22515-1-git-send-email-eblima@linux.vnet.ibm.com> References: <1319832237-22515-1-git-send-email-eblima@linux.vnet.ibm.com> Message-ID: I have not tested this patch, this patch should help prevent excessive libvirt connection failure messages clogging the logs. +1 Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 10/28/2011 01:03:57 PM: > "Eduardo Lima (Etrunko)" > Sent by: libvirt-cim-bounces at redhat.com > > 10/28/2011 01:03 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > "Eduardo Lima \(Etrunko\)" > > Subject > > [Libvirt-cim] [PATCH] Avoid connection to libvirt if previous attempt fails > > From: Eduardo Lima (Etrunko) > > This is a workaround to avoid libvirt flooding error messages in syslog. This > happens often if a client submits queries for CIM_ superclasses, > which then will > translate to a query for each registered class. In our case KVM_, > LXC_ and XEN_. > > Ideally, there should be a way to ask libvirt if a given URI or hypervisor is > enabled/supported. A patch for that feature is on the works, and as soon as it > is integrated to libvirt tree this feature will be updated. > > Signed-off-by: Eduardo Lima (Etrunko) > --- > libxkutil/misc_util.c | 48 +++++++++++++++++++++++++++++++++++++++++++ +++++ > 1 files changed, 48 insertions(+), 0 deletions(-) > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > index c2cc204..61893c3 100644 > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -24,6 +24,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -53,6 +54,46 @@ static int libvirt_initialized = 0; > > #define URI_ENV "HYPURI" > > +struct _hypervisor_status_t { > + const char *name; > + bool enabled; > +}; > + > +typedef struct _hypervisor_status_t hypervisor_status_t; > + > +static hypervisor_status_t hypervisor_list[] = { > + { "xen", true }, > + { "kvm", true }, > + { "lxc", true }, > + { NULL }, > +}; > + > +static bool get_hypervisor_enabled(const char *hypervisor) > +{ > + hypervisor_status_t *h; > + > + for (h = &hypervisor_list[0]; h != NULL; h++) { > + if (strncasecmp(hypervisor, h->name, strlen(h->name)) == 0) { > + return h->enabled; > + } > + } > + > + return false; > +} > + > +static void set_hypervisor_disabled(const char *hypervisor) > +{ > + hypervisor_status_t *h; > + > + for (h = &hypervisor_list[0]; h != NULL; h++) { > + if (strncasecmp(hypervisor, h->name, strlen(h->name)) == 0) { > + CU_DEBUG("Setting '%s' hypervisor as > DISABLED", h->name); > + h->enabled = false; > + return; > + } > + } > +} > + > static const char *cn_to_uri(const char *classname) > { > if (STARTS_WITH(classname, "Xen")) > @@ -117,6 +158,9 @@ virConnectPtr connect_by_classname(const > CMPIBroker *broker, > return NULL; > } > > + if (!get_hypervisor_enabled(classname)) > + return NULL; > + > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > pthread_mutex_lock(&libvirt_mutex); > @@ -129,6 +173,10 @@ virConnectPtr connect_by_classname(const > CMPIBroker *broker, > pthread_mutex_unlock(&libvirt_mutex); > > if (!conn) { > + virErrorPtr error = virGetLastError(); > + if (error->code == VIR_ERR_NO_CONNECT) > + set_hypervisor_disabled(classname); > + > CU_DEBUG("Unable to connect to `%s'", uri); > return NULL; > } > -- > 1.7.4.4 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dpkshetty at gmail.com Sat Oct 29 11:46:52 2011 From: dpkshetty at gmail.com (Deepak Shetty) Date: Sat, 29 Oct 2011 17:16:52 +0530 Subject: [Libvirt-cim] Error doing make install for libvirt-cim Message-ID: Hi, I am getting the following error while doing ' make install' for libvirt-cim. Can someone pls help provide some pointers on what could be wrong here ? .... .... test -z "/home/dpkshetty/usr/lib/cmpi" || /bin/mkdir -p "/home/dpkshetty/usr/lib/cmpi" /bin/bash ../libtool --mode=install /usr/bin/install -c libVirt_ComputerSystem.la libVirt_Device.la libVirt_RASD.la libVirt_HostSystem.la libVirt_VSSD.la libVirt_EnabledLogicalElementCapabilities.la libVirt_DevicePool.la libVirt_RegisteredProfile.la libVirt_VSMigrationCapabilities.la libVirt_VSMigrationSettingData.la libVirt_VirtualSystemSnapshotServiceCapabilities.la libVirt_SystemDevice.la libVirt_ComputerSystemIndication.la libVirt_ResourceAllocationSettingDataIndication.la libVirt_SwitchService.la libVirt_ComputerSystemMigrationIndication.la libVirt_VirtualSystemManagementCapabilities.la libVirt_AllocationCapabilities.la libVirt_ReferencedProfile.la libVirt_VirtualSystemSnapshotService.la libVirt_VirtualSystemManagementService.la libVirt_ResourcePoolConfigurationService.la libVirt_ResourcePoolConfigurationCapabilities.la libVirt_VSMigrationService.la libVirt_ConsoleRedirectionService.la libVirt_ConsoleRedirectionServiceCapabilities.la libVirt_KVMRedirectionSAP.la libVirt_SettingsDefineCapabilities.la libVirt_HostedDependency.la libVirt_ElementConformsToProfile.la libVirt_HostedResourcePool.la libVirt_ElementCapabilities.la libVirt_VSSDComponent.la libVirt_SettingsDefineState.la libVirt_ResourceAllocationFromPool.la libVirt_ElementAllocatedFromPool.la libVirt_HostedService.la libVirt_ElementSettingData.la libVirt_ConcreteComponent.la libVirt_ServiceAffectsElement.la libVirt_HostedAccessPoint.la libVirt_ServiceAccessBySAP.la libVirt_SAPAvailableForElement.la libVirt_FilterList.la libVirt_FilterEntry.la libVirt_EntriesInFilterList.la libVirt_NestedFilterList.la libVirt_HostedFilterList.la libVirt_AppliedFilterList.la '/home/dpkshetty/usr/lib/cmpi' *libtool: install: warning: relinking `libVirt_ComputerSystem.la'* libtool: install: (cd /home/dpkshetty/work/libvirt-cim/libvirt-cim/src; /bin/bash /home/dpkshetty/work/libvirt-cim/libvirt-cim/libtool --silent --tag CC --mode=relink gcc -g -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-format-y2k -Wcast-align -Wno-unused-value -DLIBVIRT_CIM_CS=\"2714b9a5e842\" -DLIBVIRT_CIM_RV=\"1151\" -I../libxkutil ../libxkutil/libxkutil.la -version-info 5:14:5 -L/home/dpkshetty/usr/lib -lvirt -ldl -L/home/dpkshetty/usr/lib -lcmpiutil -L/usr/lib/i386-linux-gnu -luuid -o libVirt_ComputerSystem.la -rpath /home/dpkshetty/usr/lib/cmpi Virt_ComputerSystem.lo -lVirt_VirtualSystemSnapshotService ) */usr/bin/ld: cannot find -lVirt_VirtualSystemSnapshotService* collect2: ld returned 1 exit status libtool: install: error: relink `libVirt_ComputerSystem.la' with the above command before installing it make[2]: *** [install-providerLTLIBRARIES] Error 1 make[2]: Leaving directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/src' make[1]: *** [install-am] Error 2 make[1]: Leaving directory `/home/dpkshetty/work/libvirt-cim/libvirt-cim/src' make: *** [install-recursive] Error 1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From xiawenc at linux.vnet.ibm.com Mon Oct 31 01:54:00 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Mon, 31 Oct 2011 09:54:00 +0800 Subject: [Libvirt-cim] Error doing make install for libvirt-cim In-Reply-To: References: Message-ID: <4EADFFB8.1040009@linux.vnet.ibm.com> pls have a try for following commands with CIMOM tog-pegasus installed: ./autoconfiscate.sh ./configure make rpm ? 2011-10-29 19:46, Deepak Shetty ??: > Hi, > I am getting the following error while doing ' make install' for > libvirt-cim. Can someone pls help provide some pointers on what could be > wrong here ? > > .... > .... > > test -z "/home/dpkshetty/usr/lib/cmpi" || /bin/mkdir -p > "/home/dpkshetty/usr/lib/cmpi" > /bin/bash ../libtool --mode=install /usr/bin/install -c > libVirt_ComputerSystem.la libVirt_Device.la libVirt_RASD.la > libVirt_HostSystem.la libVirt_VSSD.la > libVirt_EnabledLogicalElementCapabilities.la libVirt_DevicePool.la > libVirt_RegisteredProfile.la libVirt_VSMigrationCapabilities.la > libVirt_VSMigrationSettingData.la > libVirt_VirtualSystemSnapshotServiceCapabilities.la > libVirt_SystemDevice.la libVirt_ComputerSystemIndication.la > libVirt_ResourceAllocationSettingDataIndication.la > libVirt_SwitchService.la libVirt_ComputerSystemMigrationIndication.la > libVirt_VirtualSystemManagementCapabilities.la > libVirt_AllocationCapabilities.la libVirt_ReferencedProfile.la > libVirt_VirtualSystemSnapshotService.la > libVirt_VirtualSystemManagementService.la > libVirt_ResourcePoolConfigurationService.la > libVirt_ResourcePoolConfigurationCapabilities.la > libVirt_VSMigrationService.la libVirt_ConsoleRedirectionService.la > libVirt_ConsoleRedirectionServiceCapabilities.la > libVirt_KVMRedirectionSAP.la libVirt_SettingsDefineCapabilities.la > libVirt_HostedDependency.la libVirt_ElementConformsToProfile.la > libVirt_HostedResourcePool.la libVirt_ElementCapabilities.la > libVirt_VSSDComponent.la libVirt_SettingsDefineState.la > libVirt_ResourceAllocationFromPool.la > libVirt_ElementAllocatedFromPool.la libVirt_HostedService.la > libVirt_ElementSettingData.la libVirt_ConcreteComponent.la > libVirt_ServiceAffectsElement.la libVirt_HostedAccessPoint.la > libVirt_ServiceAccessBySAP.la libVirt_SAPAvailableForElement.la > libVirt_FilterList.la libVirt_FilterEntry.la > libVirt_EntriesInFilterList.la libVirt_NestedFilterList.la > libVirt_HostedFilterList.la libVirt_AppliedFilterList.la > '/home/dpkshetty/usr/lib/cmpi' > *libtool: install: warning: relinking `libVirt_ComputerSystem.la'* > libtool: install: (cd /home/dpkshetty/work/libvirt-cim/libvirt-cim/src; > /bin/bash /home/dpkshetty/work/libvirt-cim/libvirt-cim/libtool --silent > --tag CC --mode=relink gcc -g -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE > -D_LARGEFILE64_SOURCE -Wall -Wmissing-prototypes -Wmissing-declarations > -Wstrict-prototypes -Wpointer-arith -Wformat=2 -Wformat-security > -Wformat-nonliteral -Wno-format-y2k -Wcast-align -Wno-unused-value > -DLIBVIRT_CIM_CS=\"2714b9a5e842\" -DLIBVIRT_CIM_RV=\"1151\" > -I../libxkutil ../libxkutil/libxkutil.la > -version-info 5:14:5 -L/home/dpkshetty/usr/lib -lvirt -ldl > -L/home/dpkshetty/usr/lib -lcmpiutil -L/usr/lib/i386-linux-gnu -luuid -o > libVirt_ComputerSystem.la -rpath /home/dpkshetty/usr/lib/cmpi > Virt_ComputerSystem.lo -lVirt_VirtualSystemSnapshotService ) > */usr/bin/ld: cannot find -lVirt_VirtualSystemSnapshotService* > collect2: ld returned 1 exit status > libtool: install: error: relink `libVirt_ComputerSystem.la' with the > above command before installing it > make[2]: *** [install-providerLTLIBRARIES] Error 1 > make[2]: Leaving directory > `/home/dpkshetty/work/libvirt-cim/libvirt-cim/src' > make[1]: *** [install-am] Error 2 > make[1]: Leaving directory > `/home/dpkshetty/work/libvirt-cim/libvirt-cim/src' > make: *** [install-recursive] Error 1 > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From dpkshetty at gmail.com Mon Oct 31 05:15:45 2011 From: dpkshetty at gmail.com (Deepak Shetty) Date: Mon, 31 Oct 2011 10:45:45 +0530 Subject: [Libvirt-cim] Error doing make install for libvirt-cim In-Reply-To: <4EADFFB8.1040009@linux.vnet.ibm.com> References: <4EADFFB8.1040009@linux.vnet.ibm.com> Message-ID: Hello Wayne, Thanks for the pointer , will try. But i am on Ubuntu and did not understand why I should be doing a 'make rpm'. Also i have sfcb ( Lite weight broker ) installed, will that not work with libvirt-cim ? Is CIMOM pegasus a must ? On Mon, Oct 31, 2011 at 7:24 AM, Wayne Xia wrote: > pls have a try for following commands with CIMOM tog-pegasus installed: > ./autoconfiscate.sh > ./configure > make rpm > > > > ? 2011-10-29 19:46, Deepak Shetty ??: > >> Hi, >> I am getting the following error while doing ' make install' for >> libvirt-cim. Can someone pls help provide some pointers on what could be >> wrong here ? >> >> .... >> .... >> >> test -z "/home/dpkshetty/usr/lib/cmpi" || /bin/mkdir -p >> "/home/dpkshetty/usr/lib/cmpi" >> /bin/bash ../libtool --mode=install /usr/bin/install -c >> libVirt_ComputerSystem.la libVirt_Device.la libVirt_RASD.la >> libVirt_HostSystem.la libVirt_VSSD.la >> libVirt_**EnabledLogicalElementCapabilit**ies.la libVirt_DevicePool.la >> libVirt_RegisteredProfile.la libVirt_**VSMigrationCapabilities.la >> libVirt_**VSMigrationSettingData.la >> libVirt_**VirtualSystemSnapshotServiceCa**pabilities.la >> libVirt_SystemDevice.la libVirt_**ComputerSystemIndication.la >> libVirt_**ResourceAllocationSettingDataI**ndication.la >> libVirt_SwitchService.la libVirt_**ComputerSystemMigrationIndicat**ion.la >> libVirt_**VirtualSystemManagementCapabil**ities.la >> libVirt_**AllocationCapabilities.la libVirt_ReferencedProfile.la >> libVirt_**VirtualSystemSnapshotService.**la >> libVirt_**VirtualSystemManagementService**.la >> libVirt_**ResourcePoolConfigurationServi**ce.la >> libVirt_**ResourcePoolConfigurationCapab**ilities.la >> libVirt_VSMigrationService.la libVirt_**ConsoleRedirectionService.la >> libVirt_**ConsoleRedirectionServiceCapab**ilities.la >> libVirt_KVMRedirectionSAP.la libVirt_**SettingsDefineCapabilities.la >> libVirt_HostedDependency.la libVirt_**ElementConformsToProfile.la >> libVirt_HostedResourcePool.la libVirt_ElementCapabilities.la >> libVirt_VSSDComponent.la libVirt_SettingsDefineState.la >> libVirt_**ResourceAllocationFromPool.la >> libVirt_**ElementAllocatedFromPool.la libVirt_HostedService.la >> libVirt_ElementSettingData.la libVirt_ConcreteComponent.la >> libVirt_ServiceAffectsElement.**la libVirt_HostedAccessPoint.la >> libVirt_ServiceAccessBySAP.la libVirt_**SAPAvailableForElement.la >> libVirt_FilterList.la libVirt_FilterEntry.la >> libVirt_EntriesInFilterList.la libVirt_NestedFilterList.la >> libVirt_HostedFilterList.la libVirt_AppliedFilterList.la >> '/home/dpkshetty/usr/lib/cmpi' >> *libtool: install: warning: relinking `libVirt_ComputerSystem.la'* >> >> libtool: install: (cd /home/dpkshetty/work/libvirt-**cim/libvirt-cim/src; >> /bin/bash /home/dpkshetty/work/libvirt-**cim/libvirt-cim/libtool >> --silent >> --tag CC --mode=relink gcc -g -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE >> -D_LARGEFILE64_SOURCE -Wall -Wmissing-prototypes -Wmissing-declarations >> -Wstrict-prototypes -Wpointer-arith -Wformat=2 -Wformat-security >> -Wformat-nonliteral -Wno-format-y2k -Wcast-align -Wno-unused-value >> -DLIBVIRT_CIM_CS=\"**2714b9a5e842\" -DLIBVIRT_CIM_RV=\"1151\" >> -I../libxkutil ../libxkutil/libxkutil.la >> >> -version-info 5:14:5 -L/home/dpkshetty/usr/lib -lvirt -ldl >> -L/home/dpkshetty/usr/lib -lcmpiutil -L/usr/lib/i386-linux-gnu -luuid -o >> libVirt_ComputerSystem.la -rpath /home/dpkshetty/usr/lib/cmpi >> Virt_ComputerSystem.lo -lVirt_**VirtualSystemSnapshotService ) >> */usr/bin/ld: cannot find -lVirt_**VirtualSystemSnapshotService* >> >> collect2: ld returned 1 exit status >> libtool: install: error: relink `libVirt_ComputerSystem.la' with the >> above command before installing it >> make[2]: *** [install-providerLTLIBRARIES] Error 1 >> make[2]: Leaving directory >> `/home/dpkshetty/work/libvirt-**cim/libvirt-cim/src' >> make[1]: *** [install-am] Error 2 >> make[1]: Leaving directory >> `/home/dpkshetty/work/libvirt-**cim/libvirt-cim/src' >> make: *** [install-recursive] Error 1 >> >> >> >> ______________________________**_________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/**mailman/listinfo/libvirt-cim >> > > > -- > Best Regards > > Wayne Xia > mail:xiawenc at linux.vnet.ibm.**com > tel:86-010-82450803 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dpkshetty at gmail.com Mon Oct 31 08:21:26 2011 From: dpkshetty at gmail.com (Deepak Shetty) Date: Mon, 31 Oct 2011 13:51:26 +0530 Subject: [Libvirt-cim] Error doing make install for libvirt-cim In-Reply-To: References: <4EADFFB8.1040009@linux.vnet.ibm.com> Message-ID: It looks like there is a bug in the ' make install' I had to manually do the steps below to copy the library onto the right path, before make install could succed Took clues from the libxkutil.a library install that happens just before this error. cd /home/dpkshetty/work/libvirt-cim/libvirt-cim/src/ 1) /usr/bin/install -c .libs/libVirt_VirtualSystemSnapshotService.so.0.5.14 /home/dpkshetty/usr/lib/cmpi/libVirt_VirtualSystemSnapshotService.so.0.5.14 2) cd /home/dpkshetty/usr/lib/cmpi/ 3) ln -s -f libVirt_VirtualSystemSnapshotService.so.0.5.14 libVirt_VirtualSystemSnapshotService.so.0 4) ln -s -f libVirt_VirtualSystemSnapshotService.so.0.5.14 libVirt_VirtualSystemSnapshotService.so 5) cd /home/dpkshetty/work/libvirt-cim/libvirt-cim/src/ 6) /usr/bin/install -c .libs/libVirt_VirtualSystemSnapshotService.lai /home/dpkshetty/usr/lib/cmpi/libVirt_VirtualSystemSnapshotService.la 7) /usr/bin/install -c .libs/libVirt_VirtualSystemSnapshotService.a /home/dpkshetty/usr/lib/cmpi/libVirt_VirtualSystemSnapshotService.a 8) chmod 644 /home/dpkshetty/usr/lib/cmpi/libVirt_VirtualSystemSnapshotService.a 9) ranlib /home/dpkshetty/usr/lib/cmpi/libVirt_VirtualSystemSnapshotService.a 10) ldconfig -n /home/dpkshetty/usr/lib/cmpi After this 'make install' worked fine. On Mon, Oct 31, 2011 at 10:45 AM, Deepak Shetty wrote: > Hello Wayne, > Thanks for the pointer , will try. > But i am on Ubuntu and did not understand why I should be doing a 'make > rpm'. > Also i have sfcb ( Lite weight broker ) installed, will that not work with > libvirt-cim ? Is CIMOM pegasus a must ? > > > On Mon, Oct 31, 2011 at 7:24 AM, Wayne Xia wrote: > >> pls have a try for following commands with CIMOM tog-pegasus installed: >> ./autoconfiscate.sh >> ./configure >> make rpm >> >> >> >> ? 2011-10-29 19:46, Deepak Shetty ??: >> >>> Hi, >>> I am getting the following error while doing ' make install' for >>> libvirt-cim. Can someone pls help provide some pointers on what could be >>> wrong here ? >>> >>> .... >>> .... >>> >>> test -z "/home/dpkshetty/usr/lib/cmpi" || /bin/mkdir -p >>> "/home/dpkshetty/usr/lib/cmpi" >>> /bin/bash ../libtool --mode=install /usr/bin/install -c >>> libVirt_ComputerSystem.la libVirt_Device.la libVirt_RASD.la >>> libVirt_HostSystem.la libVirt_VSSD.la >>> libVirt_**EnabledLogicalElementCapabilit**ies.la libVirt_DevicePool.la >>> libVirt_RegisteredProfile.la libVirt_**VSMigrationCapabilities.la >>> libVirt_**VSMigrationSettingData.la >>> libVirt_**VirtualSystemSnapshotServiceCa**pabilities.la >>> libVirt_SystemDevice.la libVirt_**ComputerSystemIndication.la >>> libVirt_**ResourceAllocationSettingDataI**ndication.la >>> libVirt_SwitchService.la libVirt_**ComputerSystemMigrationIndicat** >>> ion.la >>> libVirt_**VirtualSystemManagementCapabil**ities.la >>> libVirt_**AllocationCapabilities.la libVirt_ReferencedProfile.la >>> libVirt_**VirtualSystemSnapshotService.**la >>> libVirt_**VirtualSystemManagementService**.la >>> libVirt_**ResourcePoolConfigurationServi**ce.la >>> libVirt_**ResourcePoolConfigurationCapab**ilities.la >>> libVirt_VSMigrationService.la libVirt_**ConsoleRedirectionService.la >>> libVirt_**ConsoleRedirectionServiceCapab**ilities.la >>> libVirt_KVMRedirectionSAP.la libVirt_**SettingsDefineCapabilities.la >>> libVirt_HostedDependency.la libVirt_**ElementConformsToProfile.la >>> libVirt_HostedResourcePool.la libVirt_ElementCapabilities.la >>> libVirt_VSSDComponent.la libVirt_SettingsDefineState.la >>> libVirt_**ResourceAllocationFromPool.la >>> libVirt_**ElementAllocatedFromPool.la libVirt_HostedService.la >>> libVirt_ElementSettingData.la libVirt_ConcreteComponent.la >>> libVirt_ServiceAffectsElement.**la libVirt_HostedAccessPoint.la >>> libVirt_ServiceAccessBySAP.la libVirt_**SAPAvailableForElement.la >>> libVirt_FilterList.la libVirt_FilterEntry.la >>> libVirt_EntriesInFilterList.la libVirt_NestedFilterList.la >>> libVirt_HostedFilterList.la libVirt_AppliedFilterList.la >>> '/home/dpkshetty/usr/lib/cmpi' >>> *libtool: install: warning: relinking `libVirt_ComputerSystem.la'* >>> >>> libtool: install: (cd /home/dpkshetty/work/libvirt-** >>> cim/libvirt-cim/src; >>> /bin/bash /home/dpkshetty/work/libvirt-**cim/libvirt-cim/libtool >>> --silent >>> --tag CC --mode=relink gcc -g -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE >>> -D_LARGEFILE64_SOURCE -Wall -Wmissing-prototypes -Wmissing-declarations >>> -Wstrict-prototypes -Wpointer-arith -Wformat=2 -Wformat-security >>> -Wformat-nonliteral -Wno-format-y2k -Wcast-align -Wno-unused-value >>> -DLIBVIRT_CIM_CS=\"**2714b9a5e842\" -DLIBVIRT_CIM_RV=\"1151\" >>> -I../libxkutil ../libxkutil/libxkutil.la >>> >>> -version-info 5:14:5 -L/home/dpkshetty/usr/lib -lvirt -ldl >>> -L/home/dpkshetty/usr/lib -lcmpiutil -L/usr/lib/i386-linux-gnu -luuid -o >>> libVirt_ComputerSystem.la -rpath /home/dpkshetty/usr/lib/cmpi >>> Virt_ComputerSystem.lo -lVirt_**VirtualSystemSnapshotService ) >>> */usr/bin/ld: cannot find -lVirt_**VirtualSystemSnapshotService* >>> >>> collect2: ld returned 1 exit status >>> libtool: install: error: relink `libVirt_ComputerSystem.la' with the >>> above command before installing it >>> make[2]: *** [install-providerLTLIBRARIES] Error 1 >>> make[2]: Leaving directory >>> `/home/dpkshetty/work/libvirt-**cim/libvirt-cim/src' >>> make[1]: *** [install-am] Error 2 >>> make[1]: Leaving directory >>> `/home/dpkshetty/work/libvirt-**cim/libvirt-cim/src' >>> make: *** [install-recursive] Error 1 >>> >>> >>> >>> ______________________________**_________________ >>> Libvirt-cim mailing list >>> Libvirt-cim at redhat.com >>> https://www.redhat.com/**mailman/listinfo/libvirt-cim >>> >> >> >> -- >> Best Regards >> >> Wayne Xia >> mail:xiawenc at linux.vnet.ibm.**com >> tel:86-010-82450803 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bestor at us.ibm.com Mon Oct 31 08:37:07 2011 From: bestor at us.ibm.com (Gareth S. Bestor) Date: Mon, 31 Oct 2011 01:37:07 -0700 Subject: [Libvirt-cim] [PATCH] Fix qos bug when retrieving SettingsDefineCapabilites RASDs for primordial Network/0 pool Message-ID: # HG changeset patch # User Gareth S. Bestor # Date 1320049754 25200 # Node ID e1660ac9b5fc44b863b438b6b483edf66784453e # Parent 862bcd60ae449932205b15ba42b37e06e6834de4 Fix qos bug when retrieving SettingsDefineCapabilites RASDs for primordial Network/0 pool For some reason, when retreiving at SettingsDefinesCapabilites for only the primordial network pool 'Network/0' the qos code is called for the 'Minimum' RASDs (?!), which because the associated ID is a constant causes the string substitution code for renaming the qos 'Point/...' RASDs to crash. This patch fixes this qos code so that the InstanceID string is only manipulated for Point RASDs. "Signed-off-by: Gareth S. Bestor " diff -r 862bcd60ae44 -r e1660ac9b5fc src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Wed Oct 26 03:41:56 2011 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Mon Oct 31 01:29:14 2011 -0700 @@ -756,34 +756,37 @@ if ((inst == NULL) || (s.rc != CMPI_RC_OK)) goto out; + if (strncmp("Point", id, 5) != 0) + CMSetProperty(inst, "InstanceID", (CMPIValue *)id, CMPI_chars); + else { + tmp_str = strtok(id, " "); + if (tmp_str == NULL) { + CU_DEBUG("Cannot set InstanceID"); + goto out; + } - tmp_str = strtok(id, " "); - if (tmp_str == NULL) { - CU_DEBUG("Cannot set InstanceID"); - goto out; + CU_DEBUG("InstanceID = %s", tmp_str); + + CMSetProperty(inst, "InstanceID", (CMPIValue *)tmp_str, + CMPI_chars); + tmp_str = strtok('\0', " "); + if (tmp_str == NULL) { + CU_DEBUG("Cannot set Reservation"); + goto out; + } + + CU_DEBUG("Reservation = %s", tmp_str); + + uint64_t val = atoi(tmp_str); + + CMSetProperty(inst, "Reservation", + (CMPIValue *)&val, CMPI_uint64); + + CMSetProperty(inst, "AllocationUnits", + (CMPIValue *)"Kilobits per Second", + CMPI_chars); } - CU_DEBUG("InstanceID = %s", tmp_str); - - CMSetProperty(inst, "InstanceID", (CMPIValue *)tmp_str, - CMPI_chars); - tmp_str = strtok('\0', " "); - if (tmp_str == NULL) { - CU_DEBUG("Cannot set Reservation"); - goto out; - } - - CU_DEBUG("Reservation = %s", tmp_str); - - uint64_t val = atoi(tmp_str); - - CMSetProperty(inst, "Reservation", - (CMPIValue *)&val, CMPI_uint64); - - CMSetProperty(inst, "AllocationUnits", - (CMPIValue *)"Kilobits per Second", - CMPI_chars); - CMSetProperty(inst, "Address", (CMPIValue *)addr, CMPI_chars);