From xiawenc at linux.vnet.ibm.com Thu Sep 8 07:22:10 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 08 Sep 2011 15:22:10 +0800 Subject: [Libvirt-cim] [PATCH] [Draft] add ethernetport device type, do you think this style is acceptable? Message-ID: <5554a150cc764fb1799d.1315466530@localhost6.localdomain6> # HG changeset patch # User Wayne Xia # Date 1313744037 -28800 # Node ID 5554a150cc764fb1799d86bfd4e201cee9edfedd # Parent c54aafd0b2c6414f91b96bc30e2f148bb78d5c59 [Draft] add ethernetport device type, do you think this style is acceptable? This patch is a draft for virtual LAN management. According to the DSP file ethernetport class is needed, but currently we only have networkport class. In this patch, additional information is added to net device representing the cim class, because ethernetport is the subclass of networkport, and they should share the same xml parsing procedure but show as different instances. To achieve this, some functions are changed to add one more parameter stands for the cim class it wants. Also some association mapping is changed to add ethernetport. Signed-off-by: Wayne Xia diff -r c54aafd0b2c6 -r 5554a150cc76 Makefile.am --- a/Makefile.am Tue Aug 30 08:48:36 2011 -0700 +++ b/Makefile.am Fri Aug 19 16:53:57 2011 +0800 @@ -63,7 +63,8 @@ schema/EntriesInFilterList.mof \ schema/NestedFilterList.mof \ schema/AppliedFilterList.mof \ - schema/HostedFilterList.mof + schema/HostedFilterList.mof \ + schema/EthernetPort.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -150,7 +151,8 @@ schema/EntriesInFilterList.registration \ schema/NestedFilterList.registration \ schema/AppliedFilterList.registration \ - schema/HostedFilterList.registration + schema/HostedFilterList.registration \ + schema/EthernetPort.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r c54aafd0b2c6 -r 5554a150cc76 libvirt-cim.spec.in --- a/libvirt-cim.spec.in Tue Aug 30 08:48:36 2011 -0700 +++ b/libvirt-cim.spec.in Fri Aug 19 16:53:57 2011 +0800 @@ -10,12 +10,12 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root URL: http://libvirt.org/CIM/ Requires: libxml2 >= 2.6.0 -Requires: libvirt >= 0.6.3 +#Requires: libvirt >= 0.6.3 Requires: unzip Requires: tog-pegasus BuildRequires: libcmpiutil >= 0.5.4 BuildRequires: tog-pegasus-devel -BuildRequires: libvirt-devel >= 0.6.3 +#BuildRequires: libvirt-devel >= 0.6.3 # In RHEL5 uuid-devel is provided by e2fsprogs %if 0%{?el5} diff -r c54aafd0b2c6 -r 5554a150cc76 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Tue Aug 30 08:48:36 2011 -0700 +++ b/libxkutil/device_parsing.c Fri Aug 19 16:53:57 2011 +0800 @@ -81,6 +81,7 @@ free(dev->device); free(dev->net_mode); free(dev->filter_ref); + cleanup_vsi_device(&dev->vsi); } static void cleanup_emu_device(struct emu_device *dev) @@ -427,7 +428,6 @@ vdev->id = strdup(ndev->mac); *vdevs = vdev; - return 1; err: cleanup_net_device(ndev); @@ -653,8 +653,9 @@ return true; } -static int do_parse(xmlNodeSet *nsv, int type, struct virt_device **l) +static int do_parse_subclass(xmlNodeSet *nsv, int type, int subclass, struct virt_device **l) { + CU_DEBUG("cim subclass is %d", subclass); int devidx; int lstidx = 0; int count = 0; @@ -698,6 +699,11 @@ if (devices <= 0) continue; + /* attach additional info about the requested CIM model */ + if (type == CIM_RES_TYPE_NET) { + tmp_list->dev.net.ciminfo.cim_subclass = subclass; + } + if (!resize_devlist(&list, lstidx + devices)) { /* Skip these devices and try again for the * next cycle, which will probably fail, but @@ -723,7 +729,7 @@ /* do nothing, just swallow the message. */ } -static int parse_devices(const char *xml, struct virt_device **_list, int type) +static int parse_devices_subclass(const char *xml, struct virt_device **_list, int type, int subclass) { int len = 0; int count = 0; @@ -764,7 +770,7 @@ == NULL) goto err3; - count = do_parse(xpathObj->nodesetval, type, _list); + count = do_parse_subclass(xpathObj->nodesetval, type, subclass, _list); xmlSetGenericErrorFunc(NULL, NULL); xmlXPathFreeObject(xpathObj); @@ -776,6 +782,11 @@ return count; } +static int parse_devices(const char *xml, struct virt_device **_list, int type) +{ + return parse_devices_subclass(xml, _list, type, CIM_RES_SUBTYPE_BASE); +} + #define DUP_FIELD(d, s, f) do { \ if ((s)->f != NULL) \ (d)->f = strdup((s)->f); \ @@ -808,6 +819,7 @@ DUP_FIELD(dev, _dev, dev.net.vsi.instance_id); DUP_FIELD(dev, _dev, dev.net.vsi.filter_ref); DUP_FIELD(dev, _dev, dev.net.vsi.profile_id); + dev->dev.net.ciminfo = _dev->dev.net.ciminfo; } else if (dev->type == CIM_RES_TYPE_DISK) { DUP_FIELD(dev, _dev, dev.disk.type); DUP_FIELD(dev, _dev, dev.disk.device); @@ -906,6 +918,11 @@ int get_devices(virDomainPtr dom, struct virt_device **list, int type) { + return get_devices_subclass(dom, list, type, CIM_RES_SUBTYPE_BASE); +} + +int get_devices_subclass(virDomainPtr dom, struct virt_device **list, int type, int subclass) +{ char *xml; int ret; @@ -918,13 +935,14 @@ else if (type == CIM_RES_TYPE_PROC) ret = _get_proc_device(xml, list); else - ret = parse_devices(xml, list, type); + ret = parse_devices_subclass(xml, list, type, subclass); free(xml); return ret; } + char *get_fq_devid(char *host, char *_devid) { char *devid; diff -r c54aafd0b2c6 -r 5554a150cc76 libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Tue Aug 30 08:48:36 2011 -0700 +++ b/libxkutil/device_parsing.h Fri Aug 19 16:53:57 2011 +0800 @@ -33,6 +33,10 @@ #include "../src/svpc_types.h" +struct cim_info { + int cim_subclass; /* pls make sure it is initialized as 0 */ +}; + struct vsi_device { char *vsi_type; char *manager_id; @@ -67,6 +71,7 @@ char *net_mode; char *filter_ref; struct vsi_device vsi; + struct cim_info ciminfo; }; struct mem_device { @@ -201,6 +206,7 @@ void cleanup_dominfo(struct domain **dominfo); int get_devices(virDomainPtr dom, struct virt_device **list, int type); +int get_devices_subclass(virDomainPtr dom, struct virt_device **list, int type, int subclasstype); void cleanup_virt_device(struct virt_device *dev); void cleanup_virt_devices(struct virt_device **devs, int count); diff -r c54aafd0b2c6 -r 5554a150cc76 schema/EthernetPort.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/EthernetPort.mof Fri Aug 19 16:53:57 2011 +0800 @@ -0,0 +1,4 @@ +// Copyright IBM Corp. 2011 +class KVM_EthernetPort : CIM_EthernetPort +{ +}; diff -r c54aafd0b2c6 -r 5554a150cc76 schema/EthernetPort.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/EthernetPort.registration Fri Aug 19 16:53:57 2011 +0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2011 +# Classname Namespace ProviderName ProviderModule ProviderTypes +# KVM_EthernetPort root/virt Virt_EthernetPort Virt_EthernetPort instance +KVM_EthernetPort root/virt Virt_Device Virt_Device instance diff -r c54aafd0b2c6 -r 5554a150cc76 src/Makefile.am --- a/src/Makefile.am Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Makefile.am Fri Aug 19 16:53:57 2011 +0800 @@ -25,7 +25,8 @@ Virt_ConsoleRedirectionServiceCapabilities.h \ Virt_KVMRedirectionSAP.h \ Virt_FilterList.h \ - Virt_FilterEntry.h + Virt_FilterEntry.h \ + Virt_VLANDefines.h XKUADD = $(top_builddir)/libxkutil/libxkutil.la @@ -36,7 +37,7 @@ providerdir = $(PROVIDERDIR) -# When adding new provider libraries, be sure place it in the list +# When adding new provider libraries, be sure place it in the list # after any dependant libraries. provider_LTLIBRARIES = libVirt_ComputerSystem.la \ libVirt_Device.la \ diff -r c54aafd0b2c6 -r 5554a150cc76 src/Virt_Device.c --- a/src/Virt_Device.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_Device.c Fri Aug 19 16:53:57 2011 +0800 @@ -36,6 +36,7 @@ #include "device_parsing.h" #include "Virt_Device.h" +#include "Virt_VLANDefines.h" #define CIM_NET_UNKNOWN 0 #define CIM_NET_ETHERNET 2 @@ -96,10 +97,17 @@ CMPIInstance *inst; virConnectPtr conn; + char* classname = NULL; + if (dev->ciminfo.cim_subclass == CIM_RES_SUBTYPE_NET_ETHERNETPORT) { + classname = "EthernetPort"; + } else { + classname = "NetworkPort"; + } + conn = virDomainGetConnect(dom); inst = get_typed_instance(broker, pfx_from_conn(conn), - "NetworkPort", + classname, ns); if (!net_set_type(inst, dev)) @@ -111,6 +119,129 @@ return inst; } +/* this function returns the virtual switch name, just like a domain */ +static char* VLAN_get_vs_name(char* switchname) +{ + char* retname = NULL; + if (switchname == NULL) { + return NULL; + } + char* prefix = VS_PREFIX_CHAR; + if (asprintf(&retname, "%s%s", prefix, switchname) == -1) { + return NULL; + } else { + return retname; + } +} + +/* following function are used for ethernetport attached to vitual switch */ +static int ethernetport_set_hwaddr_vs(CMPIInstance *instance, + struct net_device *dev, + const CMPIBroker *broker) +{ + CMPIArray *array; + CMPIStatus s; + CMPIString *str; + + array = CMNewArray(broker, 1, CMPI_string, &s); + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(array))) + return 0; + + str = CMNewString(broker, "Unknown", &s); + if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) + return 0; + + CMSetArrayElementAt(array, 0, &str, CMPI_string); + + CMSetProperty(instance, "NetworkAddresses", + (CMPIValue *)&array, CMPI_stringA); + + return 1; +} + +static int ethernetport_set_devid_vs(CMPIInstance *instance, + struct virt_device *dev, + const virDomainPtr dom) +{ + char *id; + char *vsname = VLAN_get_vs_name(dev->dev.net.source); + if (vsname == NULL) { + CU_DEBUG("Failed to get vsname"); + return 0; + } + + id = get_fq_devid(vsname, dev->dev.net.device); + free(vsname); + + if (id == NULL) + return 0; + + CMSetProperty(instance, "DeviceID", + (CMPIValue *)id, CMPI_chars); + + free(id); + + return 1; +} + +static int ethernetport_set_systemname_vs(CMPIInstance *instance, + struct virt_device *dev, + const virDomainPtr dom) +{ + virConnectPtr conn = NULL; + + char *vsname = VLAN_get_vs_name(dev->dev.net.source); + if (vsname == NULL) { + CU_DEBUG("Failed to get vsname"); + return 0; + } + CMSetProperty(instance, "SystemName", + vsname, CMPI_chars); + free(vsname); + + conn = virDomainGetConnect(dom); + if (conn) { + char *sccn = NULL; + sccn = get_typed_class(pfx_from_conn(conn), "ComputerSystem"); + if (sccn != NULL) + CMSetProperty(instance, "SystemCreationClassName", + (CMPIValue *)sccn, CMPI_chars); + free(sccn); + } + + return 1; +} + +static CMPIInstance *ethernetport_instance_vs(const CMPIBroker *broker, + struct net_device *dev, + const virDomainPtr dom, + const char *ns) +{ + CMPIInstance *inst; + virConnectPtr conn; + + if ((dev->source == NULL)||(dev->device == NULL)) { + CU_DEBUG("no source or device in netdev found, vm's dev mac %s," + " maybe this vm is not started", dev->mac); + return NULL; + } + + + conn = virDomainGetConnect(dom); + inst = get_typed_instance(broker, + pfx_from_conn(conn), + "EthernetPort", + ns); + + if (!net_set_type(inst, dev)) + return NULL; + + if (!ethernetport_set_hwaddr_vs(inst, dev, broker)) + return NULL; + + return inst; +} + static int disk_set_name(CMPIInstance *instance, struct disk_device *dev) { @@ -468,10 +599,27 @@ if (!instance) return false; - + device_set_devid(instance, dev, dom); device_set_systemname(instance, dom); inst_list_add(list, instance); + + /* add ethernetports */ + if ((dev->type == CIM_RES_TYPE_NET) && + (dev->dev.net.ciminfo.cim_subclass == CIM_RES_SUBTYPE_NET_ETHERNETPORT)) { + /* add instance as ethernetport on virtual switch */ + instance = ethernetport_instance_vs(broker, + &dev->dev.net, + dom, + ns); + if (!instance) { + continue; + } + + ethernetport_set_devid_vs(instance, dev, dom); + ethernetport_set_systemname_vs(instance, dev, dom); + inst_list_add(list, instance); + } } if (proc_count) { @@ -489,6 +637,8 @@ { if (strstr(classname, "NetworkPort")) return CIM_RES_TYPE_NET; + else if (strstr(classname, "EthernetPort")) + return CIM_RES_TYPE_NET; else if (strstr(classname, "LogicalDisk")) return CIM_RES_TYPE_DISK; else if (strstr(classname, "Memory")) @@ -503,10 +653,19 @@ return CIM_RES_TYPE_UNKNOWN; } +uint16_t cim_subclass_from_device_classname(const char *classname) +{ + if (strstr(classname, "EthernetPort")) + return CIM_RES_SUBTYPE_NET_ETHERNETPORT; + else + return CIM_RES_SUBTYPE_BASE; +} + static CMPIStatus _get_devices(const CMPIBroker *broker, const CMPIObjectPath *reference, const virDomainPtr dom, const uint16_t type, + const uint16_t subclass, struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -514,7 +673,7 @@ bool rc; struct virt_device *devs = NULL; - count = get_devices(dom, &devs, type); + count = get_devices_subclass(dom, &devs, type, subclass); if (count <= 0) goto out; @@ -542,6 +701,7 @@ const CMPIObjectPath *reference, const virDomainPtr dom, const uint16_t type, + const uint16_t subclass, struct inst_list *list) { CMPIStatus s; @@ -553,6 +713,7 @@ reference, dom, cim_res_types[i], + CIM_RES_SUBTYPE_BASE, list); } else @@ -560,6 +721,7 @@ reference, dom, type, + subclass, list); return s; @@ -571,6 +733,16 @@ const uint16_t type, struct inst_list *list) { + return enum_devices_subclass(broker, reference, domain, type, CIM_RES_SUBTYPE_BASE, list); +} + +CMPIStatus enum_devices_subclass(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *domain, + const uint16_t type, + const uint16_t subclass, + struct inst_list *list) +{ CMPIStatus s = {CMPI_RC_OK, NULL}; virConnectPtr conn = NULL; virDomainPtr *doms = NULL; @@ -593,6 +765,7 @@ reference, doms[i], type, + subclass, list); virDomainFree(doms[i]); @@ -617,10 +790,11 @@ inst_list_init(&list); - s = enum_devices(_BROKER, + s = enum_devices_subclass(_BROKER, reference, - NULL, + NULL, res_type_from_device_classname(CLASSNAME(reference)), + cim_subclass_from_device_classname(CLASSNAME(reference)), &list); if (s.rc != CMPI_RC_OK) goto out; @@ -673,16 +847,17 @@ return quantity; } -static struct virt_device *find_dom_dev(virDomainPtr dom, +static struct virt_device *find_dom_dev(virDomainPtr dom, char *device, - int type) + int type, + int subclass) { struct virt_device *list = NULL; struct virt_device *dev = NULL; int count; int i; - count = get_devices(dom, &list, type); + count = get_devices_subclass(dom, &list, type, subclass); if (!count) { CU_DEBUG("No devices for %i", type); goto out; @@ -719,6 +894,16 @@ const uint16_t type, CMPIInstance **_inst) { + return get_device_by_name_subclass(broker, reference, name, type, CIM_RES_SUBTYPE_BASE, _inst); +} + +CMPIStatus get_device_by_name_subclass(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + const uint16_t subclass, + CMPIInstance **_inst) +{ CMPIStatus s = {CMPI_RC_OK, NULL}; char *domain = NULL; char *device = NULL; @@ -741,7 +926,7 @@ if (parse_devid(name, &domain, &device) != 1) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, - "No such instance (bad id %s)", + "No such instance (bad id %s)", name); goto out; } @@ -756,7 +941,7 @@ goto err; } - dev = find_dom_dev(dom, device, type); + dev = find_dom_dev(dom, device, type, subclass); if (!dev) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, @@ -768,7 +953,7 @@ if (type == CIM_RES_TYPE_PROC) { int ret; int dev_id_num; - + ret = sscanf(dev->id, "%d", &dev_id_num); rc = vcpu_inst(broker, @@ -777,11 +962,11 @@ dev_id_num, &tmp_list); } else { - - rc = device_instances(broker, - dev, + + rc = device_instances(broker, + dev, 1, - dom, + dom, NAMESPACE(reference), &tmp_list); } @@ -799,8 +984,8 @@ inst_list_free(&tmp_list); virConnectClose(conn); - return s; -} + return s; +} CMPIStatus get_device_by_ref(const CMPIBroker *broker, const CMPIObjectPath *reference, @@ -817,10 +1002,11 @@ goto out; } - s = get_device_by_name(broker, - reference, - name, - res_type_from_device_classname(CLASSNAME(reference)), + s = get_device_by_name_subclass(broker, + reference, + name, + res_type_from_device_classname(CLASSNAME(reference)), + cim_subclass_from_device_classname(CLASSNAME(reference)), &inst); if (s.rc != CMPI_RC_OK) goto out; diff -r c54aafd0b2c6 -r 5554a150cc76 src/Virt_Device.h --- a/src/Virt_Device.h Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_Device.h Fri Aug 19 16:53:57 2011 +0800 @@ -40,6 +40,14 @@ const uint16_t type, struct inst_list *list); +/* the same as above, but added cim sublcass info */ +CMPIStatus enum_devices_subclass(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *domain, + const uint16_t type, + const uint16_t subclass, + struct inst_list *list); + /** * Returns the device instance defined by the reference * @@ -69,8 +77,18 @@ const uint16_t type, CMPIInstance **_inst); +/* the same as above, but added CIM sublcass info */ +CMPIStatus get_device_by_name_subclass(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *name, + const uint16_t type, + const uint16_t subclass, + CMPIInstance **_inst); + uint16_t res_type_from_device_classname(const char *classname); +uint16_t cim_subclass_from_device_classname(const char *classname); + int get_input_dev_caption(const char *type, const char *bus, char **cap); diff -r c54aafd0b2c6 -r 5554a150cc76 src/Virt_SettingsDefineState.c --- a/src/Virt_SettingsDefineState.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_SettingsDefineState.c Fri Aug 19 16:53:57 2011 +0800 @@ -331,6 +331,7 @@ "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", + "KVM_EthernetPort", "KVM_LogicalDisk", "KVM_DisplayController", "KVM_PointingDevice", @@ -353,6 +354,7 @@ "KVM_DiskResourceAllocationSettingData", "KVM_MemResourceAllocationSettingData", "KVM_NetResourceAllocationSettingData", + "KVM_NetResourceAllocationSettingData", "KVM_ProcResourceAllocationSettingData", "KVM_GraphicsResourceAllocationSettingData", "KVM_InputResourceAllocationSettingData", diff -r c54aafd0b2c6 -r 5554a150cc76 src/Virt_SystemDevice.c --- a/src/Virt_SystemDevice.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_SystemDevice.c Fri Aug 19 16:53:57 2011 +0800 @@ -139,6 +139,7 @@ "KVM_Processor", "KVM_Memory", "KVM_NetworkPort", + "KVM_EthernetPort", "KVM_LogicalDisk", "KVM_DisplayController", "KVM_PointingDevice", diff -r c54aafd0b2c6 -r 5554a150cc76 src/Virt_VLANDefines.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VLANDefines.h Fri Aug 19 16:53:57 2011 +0800 @@ -0,0 +1,6 @@ +#ifndef VLANDEFINES_H +#define VLANDEFINES_H + +#define VS_PREFIX_CHAR ("VS_") + +#endif diff -r c54aafd0b2c6 -r 5554a150cc76 src/svpc_types.h --- a/src/svpc_types.h Tue Aug 30 08:48:36 2011 -0700 +++ b/src/svpc_types.h Fri Aug 19 16:53:57 2011 +0800 @@ -36,6 +36,13 @@ #define CIM_RES_TYPE_IMAGE 32768 #define CIM_RES_TYPE_COUNT 6 + +/* Subtype representing the class in CIM model */ +#define CIM_RES_SUBTYPE_BASE 0 +/* NetworkPort subtypes */ +#define CIM_RES_SUBTYPE_NET_NETWORKPORT CIM_RES_SUBTYPE_BASE +#define CIM_RES_SUBTYPE_NET_ETHERNETPORT 1 + const static int cim_res_types[CIM_RES_TYPE_COUNT] = {CIM_RES_TYPE_NET, CIM_RES_TYPE_DISK, From xiawenc at linux.vnet.ibm.com Thu Sep 8 07:37:13 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 08 Sep 2011 15:37:13 +0800 Subject: [Libvirt-cim] Libvirt-cim] [PATCH] [Draft] add ethernetport device type, testing result Message-ID: <4E6870A9.9000506@linux.vnet.ibm.com> this patch also made ethernetport a bit different from networkport: ethernetport would include the ports on the bridge/switch, not only the ports on the VMs. The bridge/swtich is named with a prefix "VS_". testing result: A VM "test1" with 2 ports, is started, then: wbemcli -nl ein 'http://root:123456xwc at localhost:5988/root/virt:KVM_EthernetPort' localhost:5988/root/virt:KVM_EthernetPort.CreationClassName="KVM_EthernetPort",DeviceID="test/52:54:00:74:bf:1f",SystemCreationClassName="KVM_ComputerSystem",SystemName="test" localhost:5988/root/virt:KVM_EthernetPort.CreationClassName="KVM_EthernetPort",DeviceID="test1/52:54:00:6e:0c:0b",SystemCreationClassName="KVM_ComputerSystem",SystemName="test1" localhost:5988/root/virt:KVM_EthernetPort.CreationClassName="KVM_EthernetPort",DeviceID="VS_br0/vnet0",SystemCreationClassName="KVM_ComputerSystem",SystemName="VS_br0" localhost:5988/root/virt:KVM_EthernetPort.CreationClassName="KVM_EthernetPort",DeviceID="test1/52:54:00:a5:60:4a",SystemCreationClassName="KVM_ComputerSystem",SystemName="test1" localhost:5988/root/virt:KVM_EthernetPort.CreationClassName="KVM_EthernetPort",DeviceID="VS_default/vnet1",SystemCreationClassName="KVM_ComputerSystem",SystemName="VS_default" -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From snmishra at us.ibm.com Fri Sep 9 15:18:46 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Fri, 9 Sep 2011 08:18:46 -0700 Subject: [Libvirt-cim] [PATCH] (#2) Workaround to fix race condition around libvirt init In-Reply-To: <4E5E3A24.3060906@linux.vnet.ibm.com> References: <4E5E3A24.3060906@linux.vnet.ibm.com> Message-ID: pushed Sharad Mishra Open Virtualization Linux Technology Center IBM "Eduardo Lima (Etrunko)" wrote on 08/31/2011 06:41:56 AM: > "Eduardo Lima (Etrunko)" > 08/31/2011 06:41 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 > > Subject > > Re: [Libvirt-cim] [PATCH] (#2) Workaround to fix race condition > around libvirt init > > On 08/30/2011 02:14 PM, Sharad Mishra wrote: > > # HG changeset patch > > # User Sharad Mishra > > # Date 1314719316 25200 > > # Node ID c54aafd0b2c6414f91b96bc30e2f148bb78d5c59 > > # Parent 277b56b3863b5f81a3faa18aeb7b9951b963b489 > > (#2) Workaround to fix race condition around libvirt init. > > > > This patch fixes the race condition caused when mutiple > > threads try to start VMs at the same time. This patch > > also fixes the issue of incorrect mem allocation for > > VSSD property - emulator. > > > > #2: included Edurdo's patch for make_space > > took care of coding guidelines. > > > > Signed-off-by: Sharad Mishra > > > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > > --- a/libxkutil/misc_util.c > > +++ b/libxkutil/misc_util.c > > @@ -28,6 +28,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -45,6 +46,9 @@ > > #include "misc_util.h" > > #include "cs_util.h" > > > > +static pthread_mutex_t libvirt_mutex = PTHREAD_MUTEX_INITIALIZER; > > +/* libvirt library not initialized */ > > +static int libvirt_initialized = 0; > > > > #define URI_ENV "HYPURI" > > > > @@ -114,11 +118,15 @@ > > > > CU_DEBUG("Connecting to libvirt with uri `%s'", uri); > > > > + pthread_mutex_lock(&libvirt_mutex); > > + > > if (is_read_only()) > > conn = virConnectOpenReadOnly(uri); > > else > > conn = virConnectOpen(uri); > > > > + pthread_mutex_unlock(&libvirt_mutex); > > + > > if (!conn) { > > CU_DEBUG("Unable to connect to `%s'", uri); > > return NULL; > > @@ -530,7 +538,19 @@ > > > > bool libvirt_cim_init(void) > > { > > - return virInitialize() == 0; > > + int ret = 0; > > + > > + /* double-check lock pattern used for performance reasons */ > > + if (libvirt_initialized == 0) { > > + pthread_mutex_lock(&libvirt_mutex); > > + if (libvirt_initialized == 0) { > > + ret = virInitialize(); > > + if (ret == 0) > > + libvirt_initialized = 1; > > + } > > + pthread_mutex_unlock(&libvirt_mutex); > > + } > > + return (ret == 0); > > } > > > > bool check_refs_pfx_match(const CMPIObjectPath *refa, > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/ > Virt_VirtualSystemManagementService.c > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -188,6 +188,24 @@ > > return 1; > > } > > > > +static bool make_space(struct virt_device **list, int cur, int new) > > +{ > > + struct virt_device *tmp; > > + > > + tmp = calloc(cur + new, sizeof(*tmp)); > > + if (tmp == NULL) > > + return false; > > + > > + if (*list) { > > + memcpy(tmp, *list, sizeof(*tmp) * cur); > > + free(*list); > > + } > > + > > + *list = tmp; > > + > > + return true; > > +} > > + > > static bool fv_set_emulator(struct domain *domain, > > const char *emu) > > { > > @@ -198,6 +216,11 @@ > > if (emu == NULL) > > return true; > > > > + if (!make_space(&domain->dev_emu, 0, 1)) { > > + CU_DEBUG("Failed to alloc disk list"); > > + return false; > > + } > > + > > cleanup_virt_device(domain->dev_emu); > > > > domain->dev_emu->type = CIM_RES_TYPE_EMU; > > @@ -1369,24 +1392,6 @@ > > return msg; > > } > > > > -static bool make_space(struct virt_device **list, int cur, int new) > > -{ > > - struct virt_device *tmp; > > - > > - tmp = calloc(cur + new, sizeof(*tmp)); > > - if (tmp == NULL) > > - return false; > > - > > - if (*list) { > > - memcpy(tmp, *list, sizeof(*tmp) * cur); > > - free(*list); > > - } > > - > > - *list = tmp; > > - > > - return true; > > -} > > - > > static char *add_device_nodup(struct virt_device *dev, > > struct virt_device *list, > > int max, > > > > +1. Tricky stuff. :) > > -- > 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 snmishra at us.ibm.com Fri Sep 9 15:21:25 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Fri, 9 Sep 2011 08:21:25 -0700 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet another possible leak In-Reply-To: <4E552FA6.502@linux.vnet.ibm.com> References: <277b56b3863b5f81a3fa.1314112339@etrunko-t410.br.ibm.com> <4E552FA6.502@linux.vnet.ibm.com> Message-ID: pushed Sharad Mishra Open Virtualization Linux Technology Center IBM "Eduardo Lima (Etrunko)" wrote on 08/24/2011 10:06:46 AM: > "Eduardo Lima (Etrunko)" > 08/24/2011 10:06 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 > > Subject > > Re: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet > another possible leak > > On 08/24/2011 01:58 PM, Sharad Mishra wrote: > > +1 > > > > Eduardo, I remember you telling me that you have run cimtests > > successfully with this patch, correct? > > > Yes, I checked it before posting to the mailing list. :) > > > Sharad Mishra > > Open Virtualization > > Linux Technology Center > > IBM > > > > libvirt-cim-bounces at redhat.com wrote on 08/23/2011 08:12:19 AM: > > > > > "Eduardo Lima \(Etrunko\)" > > > Sent by: libvirt-cim-bounces at redhat.com > > > > > > 08/23/11 08:12 AM > > > > > > Please respond to > > > List for discussion and development of libvirt CIM > > > > > > > > To > > > > > > libvirt-cim at redhat.com > > > > > > cc > > > > > > Subject > > > > > > [Libvirt-cim] [PATCH] VirtualSystemManagementService: Fix yet > > > another possible leak > > > > > > # HG changeset patch > > > # User Eduardo Lima (Etrunko) > > > # Date 1314112289 10800 > > > # Node ID 277b56b3863b5f81a3faa18aeb7b9951b963b489 > > > # Parent a346baf140d64177a9dc1066677c307ee6518236 > > > VirtualSystemManagementService: Fix yet another possible leak > > > > > > 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 > > > @@ -1377,7 +1377,11 @@ > > > if (tmp == NULL) > > > return false; > > > > > > - memcpy(tmp, *list, sizeof(*tmp) * cur); > > > + if (*list) { > > > + memcpy(tmp, *list, sizeof(*tmp) * cur); > > > + free(*list); > > > + } > > > + > > > *list = tmp; > > > > > > return true; > > > > > > _______________________________________________ > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cvincent at linux.vnet.ibm.com Thu Sep 15 18:10:07 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 15 Sep 2011 14:10:07 -0400 Subject: [Libvirt-cim] Better to Add Code to check "End of line" character in schema file In-Reply-To: <4E5C4BFE.8060602@linux.vnet.ibm.com> References: <4E5B5D5C.7090406@linux.vnet.ibm.com> <4E5C4BFE.8060602@linux.vnet.ibm.com> Message-ID: <4E723F7F.4000302@linux.vnet.ibm.com> Wayne, Venkateswara R Puvvada works on Pegasus and can help determine if this is a known issue, and perhaps address via Pegasus Bugzilla, if necessary. If this is a known limitation, perhaps we can run something like dos2unix on .mof and .registration files when building the rpm. On 08/29/2011 10:33 PM, Wayne Xia wrote: > In the case of using "\t\n" in .mof and .registration file, after the > libvirt-cim' rpm was made and installed, the libs was found by pegasus, > but seems it was not correctly done. > > situation: > > tried to add class KVM_EthernetPort, then > wbemcli -nl ein > http://root:123456xwc at localhost:5988/root/virt:KVM_EthernetPort > nothing returned. > > then delete Virt_EthernetPort.so*. > wbemcli -nl ein > http://root:123456xwc at localhost:5988/root/virt:KVM_EthernetPort > nothing returned. It did not say the lib was missing. > > After rewrite the .mof and .registration file, problem resolved. > So I think there is some problem in the lib searching of pegasus, in > this situation. > > > 2011-8-30 0:37, Sharad Mishra: >> Wayne, >> >> Are you saying that after you install libvirt-cim RPM it does not find >> libvirt-cim libs? >> I have not seen this issue, I always uninstall (rpm -e) libvirt-cim >> before installing (rpm -i) the new version. >> >> Sharad Mishra >> Open Virtualization >> Linux Technology Center >> IBM >> >> Inactive hide details for Wayne Xia ---08/29/2011 02:37:10 AM---When I >> try add new class to libvirt-cim, I found that if the "eWayne Xia >> ---08/29/2011 02:37:10 AM---When I try add new class to libvirt-cim, I >> found that if the "end of >> >> *Wayne Xia * >> >> 08/29/11 02:35 AM >> >> >> >> To >> >> Chip Vincent , "Eduardo Lima (Etrunko)" >> , Sharad Mishra/Beaverton/IBM at IBMUS, Gareth S >> Bestor/Poughkeepsie/IBM at IBMUS, List for discussion and development of >> libvirt CIM >> >> cc >> >> >> Subject >> >> Better to Add Code to check "End of line" character in schema file >> >> >> >> >> When I try add new class to libvirt-cim, I found that if the "end of >> line" character use the windows format(\t\n), then the rpm making would >> succeed, but the pegasus would not find the correct .so file, indeed >> pegasus seems to linked to a wrong file. >> >> It takes me a long time to find the reason, so I think it is better to >> add some scripts to check this, or show a warning for it. >> >> >> >> >> >> -- >> Best Regards >> >> Wayne Xia >> mail:xiawenc at linux.vnet.ibm.com >> tel:86-010-82450803 >> >> > > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From xiawenc at linux.vnet.ibm.com Fri Sep 16 06:58:09 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Fri, 16 Sep 2011 14:58:09 +0800 Subject: [Libvirt-cim] [PATCH] Fix the problem that libvirt-cim can't find cdrom device that do not have disk Message-ID: <04b73e1cdc3087a390b9.1316156289@localhost6.localdomain6> # HG changeset patch # User Wayne Xia # Date 1316154275 -28800 # Node ID 04b73e1cdc3087a390b9790c13b42ebacbc5d5ba # Parent fb09136deb494008eb3aacee420ad74da7d7c294 Fix the problem that libvirt-cim can't find cdrom device that do not have disk This patch would allow define a system with a 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. Signed-off-by: Wayne Xia diff -r fb09136deb49 -r 04b73e1cdc30 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Tue Aug 30 08:48:36 2011 -0700 +++ b/libxkutil/device_parsing.c Fri Sep 16 14:24:35 2011 +0800 @@ -287,6 +287,12 @@ ddev->shareable = true; } } + + 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 fb09136deb49 -r 04b73e1cdc30 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Tue Aug 30 08:48:36 2011 -0700 +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 @@ -110,10 +110,15 @@ 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, ""))) { + /* do nothing */ + } 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 fb09136deb49 -r 04b73e1cdc30 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 2011 +0800 @@ -879,6 +879,12 @@ dev->dev.disk.device = strdup("disk"); else if (type == VIRT_DISK_TYPE_CDROM) { dev->dev.disk.device = strdup("cdrom"); + if ((XSTREQ(dev->dev.disk.source, "/dev/null")) || + (XSTREQ(dev->dev.disk.source, ""))) { + 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; } From eblima at linux.vnet.ibm.com Mon Sep 19 20:33:12 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Mon, 19 Sep 2011 17:33:12 -0300 Subject: [Libvirt-cim] [PATCH] Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: <04b73e1cdc3087a390b9.1316156289@localhost6.localdomain6> References: <04b73e1cdc3087a390b9.1316156289@localhost6.localdomain6> Message-ID: <4E77A708.1040309@linux.vnet.ibm.com> On 09/16/2011 03:58 AM, Wayne Xia wrote: [snip] > diff -r fb09136deb49 -r 04b73e1cdc30 libxkutil/xmlgen.c > --- a/libxkutil/xmlgen.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 > @@ -110,10 +110,15 @@ > 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, ""))) { > + /* do nothing */ > + } else { > + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); > + if (tmp == NULL) > + return XML_ERROR; > + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); > + } Well, I don't really like these types of conditionals where you actually only do something in the else block, especially because you can always achieve the same results by denying things. > > tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); > if (tmp == NULL) > diff -r fb09136deb49 -r 04b73e1cdc30 src/Virt_VirtualSystemManagementService.c > --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 2011 +0800 > @@ -879,6 +879,12 @@ > dev->dev.disk.device = strdup("disk"); > else if (type == VIRT_DISK_TYPE_CDROM) { > dev->dev.disk.device = strdup("cdrom"); > + if ((XSTREQ(dev->dev.disk.source, "/dev/null")) || > + (XSTREQ(dev->dev.disk.source, ""))) { > + 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; > } All in all the patch delivers the funcionality, so if you fix that logic I give you a +1. 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 Sep 20 02:47:20 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Tue, 20 Sep 2011 10:47:20 +0800 Subject: [Libvirt-cim] [PATCH] Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: <4E77A708.1040309@linux.vnet.ibm.com> References: <04b73e1cdc3087a390b9.1316156289@localhost6.localdomain6> <4E77A708.1040309@linux.vnet.ibm.com> Message-ID: <4E77FEB8.1000805@linux.vnet.ibm.com> Thanks for the comments. ? 2011-9-20 4:33, Eduardo Lima (Etrunko) ??: > On 09/16/2011 03:58 AM, Wayne Xia wrote: > [snip] > >> diff -r fb09136deb49 -r 04b73e1cdc30 libxkutil/xmlgen.c >> --- a/libxkutil/xmlgen.c Tue Aug 30 08:48:36 2011 -0700 >> +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 >> @@ -110,10 +110,15 @@ >> 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, ""))) { >> + /* do nothing */ >> + } else { >> + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); >> + if (tmp == NULL) >> + return XML_ERROR; >> + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); >> + } > > Well, I don't really like these types of conditionals where you actually > only do something in the else block, especially because you can always > achieve the same results by denying things. Maybe in this style it tells clearly the code exclude the situation that device is a "cdrom" without "disk". > >> >> tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); >> if (tmp == NULL) >> diff -r fb09136deb49 -r 04b73e1cdc30 src/Virt_VirtualSystemManagementService.c >> --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 08:48:36 2011 -0700 >> +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 14:24:35 2011 +0800 >> @@ -879,6 +879,12 @@ >> dev->dev.disk.device = strdup("disk"); >> else if (type == VIRT_DISK_TYPE_CDROM) { >> dev->dev.disk.device = strdup("cdrom"); >> + if ((XSTREQ(dev->dev.disk.source, "/dev/null")) || >> + (XSTREQ(dev->dev.disk.source, ""))) { >> + 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; >> } > > All in all the patch delivers the funcionality, so if you fix that logic > I give you a +1. > This patch tried to provide libvirt-cim the capability to show instance of empty cdrom, so it used many "if" , tried consider only the situation about cdrom and its disk, to avoid effecting other functionalities. > Best regards, Etrunko > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From eblima at linux.vnet.ibm.com Tue Sep 20 12:46:08 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 20 Sep 2011 09:46:08 -0300 Subject: [Libvirt-cim] [PATCH] Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: <4E77FEB8.1000805@linux.vnet.ibm.com> References: <04b73e1cdc3087a390b9.1316156289@localhost6.localdomain6> <4E77A708.1040309@linux.vnet.ibm.com> <4E77FEB8.1000805@linux.vnet.ibm.com> Message-ID: <4E788B10.3060303@linux.vnet.ibm.com> On 09/19/2011 11:47 PM, Wayne Xia wrote: > Thanks for the comments. > > ? 2011-9-20 4:33, Eduardo Lima (Etrunko) ??: >> On 09/16/2011 03:58 AM, Wayne Xia wrote: >> [snip] >> >>> diff -r fb09136deb49 -r 04b73e1cdc30 libxkutil/xmlgen.c >>> --- a/libxkutil/xmlgen.c Tue Aug 30 08:48:36 2011 -0700 >>> +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 >>> @@ -110,10 +110,15 @@ >>> 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, ""))) { >>> + /* do nothing */ >>> + } else { >>> + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); >>> + if (tmp == NULL) >>> + return XML_ERROR; >>> + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); >>> + } >> >> Well, I don't really like these types of conditionals where you actually >> only do something in the else block, especially because you can always >> achieve the same results by denying things. > > Maybe in this style it tells clearly the code exclude the situation > that device is a "cdrom" without "disk". So maybe it is the case to let it explicit comment block. > >> >>> >>> tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); >>> if (tmp == NULL) >>> diff -r fb09136deb49 -r 04b73e1cdc30 >>> src/Virt_VirtualSystemManagementService.c >>> --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 >>> 08:48:36 2011 -0700 >>> +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 >>> 14:24:35 2011 +0800 >>> @@ -879,6 +879,12 @@ >>> dev->dev.disk.device = strdup("disk"); >>> else if (type == VIRT_DISK_TYPE_CDROM) { >>> dev->dev.disk.device = strdup("cdrom"); >>> + if ((XSTREQ(dev->dev.disk.source, "/dev/null")) || >>> + (XSTREQ(dev->dev.disk.source, ""))) { >>> + dev->dev.disk.disk_type = DISK_FILE; >>> + free(dev->dev.disk.source); >>> + dev->dev.disk.source = strdup(""); >>> + } I have only seen this now, but it could be improved in the case of source being empty. Now you free and strdup it to the same value. >>> if (dev->dev.disk.disk_type == DISK_UNKNOWN) >>> dev->dev.disk.disk_type = DISK_PHY; >>> } >> >> All in all the patch delivers the funcionality, so if you fix that logic >> I give you a +1. >> > This patch tried to provide libvirt-cim the capability to show instance > of empty cdrom, so it used many "if" , tried consider only the > situation about cdrom and its disk, to avoid effecting other > functionalities. I understand, but IMO, we should always try to follow the "keep it simple" principle, with clearer code and also as performatic as possible. > >> 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 Tue Sep 20 20:53:00 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 20 Sep 2011 17:53:00 -0300 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Always update domain device information Message-ID: <25c6de6ebf094bf602e9.1316551980@etrunko-t410.br.ibm.com> src/Virt_VirtualSystemManagementService.c | 9 --------- 1 files changed, 0 insertions(+), 9 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1316551891 10800 # Node ID 25c6de6ebf094bf602e95ddf01dd39a6c5c1804a # Parent 9a59a56e226f3f800ff7214b81ab5f2fe6362fcc VirtualSystemManagementService: Always update domain device information I noticed that a call to ModifyResourceSettings was causing devices description to be lost. It happens that there was an explicit check in the code that resulted in the device information to be updated only if the specified domain was running. This patch removes that block and now the resulting domain xml after the ModifyResourceSettings call will keep the device information. 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 @@ -2349,15 +2349,6 @@ update_dominfo(dominfo, refcn); - if (!domain_online(dom)) { - CU_DEBUG("VS `%s' not online; skipping dynamic update", - dominfo->name); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - goto out; - } - CU_DEBUG("Doing dynamic device update for `%s'", dominfo->name); if (func(dom, dev) == 0) { From cvincent at linux.vnet.ibm.com Tue Sep 20 21:08:50 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 20 Sep 2011 17:08:50 -0400 Subject: [Libvirt-cim] [PATCH] ACL: Add 'Action' property to KVM_{IPHeaders, Hdr8021}Filter In-Reply-To: <4d837e60bb82daa73bba.1314203208@etrunko-t410.br.ibm.com> References: <4d837e60bb82daa73bba.1314203208@etrunko-t410.br.ibm.com> Message-ID: <4E7900E2.90309@linux.vnet.ibm.com> +1. Pushed. On 08/24/2011 12:26 PM, Eduardo Lima (Etrunko) wrote: > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1311872160 10800 > # Node ID 4d837e60bb82daa73bba8e13bbab9041fc7632ee > # Parent 277b56b3863b5f81a3faa18aeb7b9951b963b489 > ACL: Add 'Action' property to KVM_{IPHeaders,Hdr8021}Filter > > This property should be defined in the CIM_FilterEntryBase parent class > (would also apply to 'Direction' and 'Priority' properties), considering > the fact that, according to libvirt documentation, the 'action' attribute > of a rule is mandatory. For reference please check: > > http://libvirt.org/formatnwfilter.html#nwfelemsRules > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/schema/FilterEntry.mof b/schema/FilterEntry.mof > --- a/schema/FilterEntry.mof > +++ b/schema/FilterEntry.mof > @@ -2,6 +2,14 @@ > [Provider("cmpi::Virt_FilterEntry")] > class KVM_Hdr8021Filter : CIM_Hdr8021Filter > { > + [Description ( > + "This defines whether the action should be to forward or " > + "deny traffic meeting the match condition specified in " > + "this filter." ), > + ValueMap { "1", "2" }, > + Values { "Permit", "Deny" }] > + uint16 Action; > + > [Description("This defines whether the Filter is used for input, " > "output, or both input and output filtering. All values are " > "used with respect to the interface for which the Filter " > @@ -32,6 +40,14 @@ > [Provider("cmpi::Virt_FilterEntry")] > class KVM_IPHeadersFilter : CIM_IPHeadersFilter > { > + [Description ( > + "This defines whether the action should be to forward or " > + "deny traffic meeting the match condition specified in " > + "this filter." ), > + ValueMap { "1", "2" }, > + Values { "Permit", "Deny" }] > + uint16 Action; > + > [Description("This defines whether the Filter is used for input, " > "output, or both input and output filtering. All values are " > "used with respect to the interface for which the Filter " > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -159,6 +159,19 @@ > return priority; > } > > +static int convert_action(const char *s) > +{ > + enum {NONE=0, ACCEPT, DENY} action = NONE; > + > + if (s != NULL) { > + if (STREQC(s, "accept")) > + action = ACCEPT; > + else if (STREQC(s, "drop") || STREQC(s, "reject")) > + action = DENY; > + } > + return action; > +} > + > static CMPIInstance *convert_mac_rule_to_instance( > struct acl_rule *rule, > const CMPIBroker *broker, > @@ -169,7 +182,7 @@ > CMPIInstance *inst = NULL; > const char *sys_name = NULL; > const char *sys_ccname = NULL; > - int direction, priority = 0; > + int action, direction, priority = 0; > unsigned int bytes[48]; > unsigned int size = 0; > CMPIArray *array = NULL; > @@ -203,6 +216,9 @@ > CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); > CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); > > + action = convert_action(rule->action); > + CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); > + > direction = convert_direction(rule->direction); > CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); > > @@ -259,7 +275,7 @@ > CMPIInstance *inst = NULL; > const char *sys_name = NULL; > const char *sys_ccname = NULL; > - int direction, priority = 0; > + int action, direction, priority = 0; > unsigned int bytes[48]; > unsigned int size = 0; > unsigned int n = 0; > @@ -293,6 +309,9 @@ > CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); > CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); > > + action = convert_action(rule->action); > + CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); > + > direction = convert_direction(rule->direction); > CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); > > > _______________________________________________ > 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 snmishra at us.ibm.com Tue Sep 20 21:33:35 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Tue, 20 Sep 2011 14:33:35 -0700 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Always update domain device information In-Reply-To: <25c6de6ebf094bf602e9.1316551980@etrunko-t410.br.ibm.com> References: <25c6de6ebf094bf602e9.1316551980@etrunko-t410.br.ibm.com> Message-ID: Eduardo, What happens when you try to do a dynamic update on a defined guest after applying this patch? I am guessing that libvirt should fail with similar message. In any case, libvirt-cim should not be doing any check like the one you patched. It should just call appropriate libvirt API. -Sharad libvirt-cim-bounces at redhat.com wrote on 09/20/2011 01:53:00 PM: > "Eduardo Lima \(Etrunko\)" > Sent by: libvirt-cim-bounces at redhat.com > > 09/20/2011 01:53 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] VirtualSystemManagementService: Always update > domain device information > > src/Virt_VirtualSystemManagementService.c | 9 --------- > 1 files changed, 0 insertions(+), 9 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1316551891 10800 > # Node ID 25c6de6ebf094bf602e95ddf01dd39a6c5c1804a > # Parent 9a59a56e226f3f800ff7214b81ab5f2fe6362fcc > VirtualSystemManagementService: Always update domain device information > > I noticed that a call to ModifyResourceSettings was causing devices > description > to be lost. It happens that there was an explicit check in the code that > resulted in the device information to be updated only if the specified domain > was running. > > This patch removes that block and now the resulting domain xml after the > ModifyResourceSettings call will keep the device information. > > 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 > @@ -2349,15 +2349,6 @@ > > update_dominfo(dominfo, refcn); > > - if (!domain_online(dom)) { > - CU_DEBUG("VS `%s' not online; skipping dynamic update", > - dominfo->name); > - cu_statusf(_BROKER, &s, > - CMPI_RC_OK, > - ""); > - goto out; > - } > - > CU_DEBUG("Doing dynamic device update for `%s'", dominfo->name); > > if (func(dom, dev) == 0) { > > _______________________________________________ > 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 cvincent at linux.vnet.ibm.com Tue Sep 20 22:33:54 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Tue, 20 Sep 2011 18:33:54 -0400 Subject: [Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of-process provider Message-ID: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1316557881 14400 # Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160 # Parent db809376d763493849c2a19f587969eaec619b75 Redirect stdout & stderr when run as out-of-process provider When a provider is loaded in-process by Pegasus, messages sent to stdout and stderr are suppressed. However, when loaded out-of-process, those same messages appear on the console. This happens excessively when libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends "libvir: error : no connection driver available for..." messages to stderr. In development, this can sometimes prevent console usage. Until a fix is made to Pegasus, we'll suppress console output during provider initialization when run in out-of-process mode. Signed-off-by: Chip Vincent diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -540,6 +541,17 @@ { int ret = 0; + /* The tog-pegasus out-of-process provider feature does not + * redirect stdout and stderr, so it's done here to prevent + * any messages from taking over the console. One example is + * verbose connection failures sent to stdout by libvirt. */ + if (strstr(program_invocation_short_name, "cimprovagt") != NULL) { + CU_DEBUG("Redirecting stdout and stderr"); + + stdout = freopen("/dev/null", "a", stdout); + stderr = freopen("/dev/null", "a", stderr); + } + /* double-check lock pattern used for performance reasons */ if (libvirt_initialized == 0) { pthread_mutex_lock(&libvirt_mutex); From xiawenc at linux.vnet.ibm.com Wed Sep 21 03:05:42 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Wed, 21 Sep 2011 11:05:42 +0800 Subject: [Libvirt-cim] [PATCH] Message-ID: # HG changeset patch # User Wayne Xia # Date 1316154275 -28800 # Node ID c30c9a42eb741aacbd00bf4f67775ea1542978f5 # 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 c30c9a42eb74 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 c30c9a42eb74 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 c30c9a42eb74 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; } From xiawenc at linux.vnet.ibm.com Wed Sep 21 03:10:45 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Wed, 21 Sep 2011 11:10:45 +0800 Subject: [Libvirt-cim] [PATCH] Fix the problem that libvirt-cim can't find cdrom device that do not have disk In-Reply-To: <4E788B10.3060303@linux.vnet.ibm.com> References: <04b73e1cdc3087a390b9.1316156289@localhost6.localdomain6> <4E77A708.1040309@linux.vnet.ibm.com> <4E77FEB8.1000805@linux.vnet.ibm.com> <4E788B10.3060303@linux.vnet.ibm.com> Message-ID: <4E7955B5.6040901@linux.vnet.ibm.com> ? 2011-9-20 20:46, Eduardo Lima (Etrunko) ??: > On 09/19/2011 11:47 PM, Wayne Xia wrote: >> Thanks for the comments. >> >> ? 2011-9-20 4:33, Eduardo Lima (Etrunko) ??: >>> On 09/16/2011 03:58 AM, Wayne Xia wrote: >>> [snip] >>> >>>> diff -r fb09136deb49 -r 04b73e1cdc30 libxkutil/xmlgen.c >>>> --- a/libxkutil/xmlgen.c Tue Aug 30 08:48:36 2011 -0700 >>>> +++ b/libxkutil/xmlgen.c Fri Sep 16 14:24:35 2011 +0800 >>>> @@ -110,10 +110,15 @@ >>>> 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, ""))) { >>>> + /* do nothing */ >>>> + } else { >>>> + tmp = xmlNewChild(disk, NULL, BAD_CAST "source", NULL); >>>> + if (tmp == NULL) >>>> + return XML_ERROR; >>>> + xmlNewProp(tmp, BAD_CAST "file", BAD_CAST dev->source); >>>> + } >>> >>> Well, I don't really like these types of conditionals where you actually >>> only do something in the else block, especially because you can always >>> achieve the same results by denying things. >> >> Maybe in this style it tells clearly the code exclude the situation >> that device is a "cdrom" without "disk". > > So maybe it is the case to let it explicit comment block. > I think comments would be good, but code like this: if ((!(XSTREQ(dev->device, "cdrom"))) || (!(XSTREQ(dev->source, "")))) { ...... } looks not so nice. Maybe keep the "if else" here and add comments would be better. >> >>> >>>> >>>> tmp = xmlNewChild(disk, NULL, BAD_CAST "target", NULL); >>>> if (tmp == NULL) >>>> diff -r fb09136deb49 -r 04b73e1cdc30 >>>> src/Virt_VirtualSystemManagementService.c >>>> --- a/src/Virt_VirtualSystemManagementService.c Tue Aug 30 >>>> 08:48:36 2011 -0700 >>>> +++ b/src/Virt_VirtualSystemManagementService.c Fri Sep 16 >>>> 14:24:35 2011 +0800 >>>> @@ -879,6 +879,12 @@ >>>> dev->dev.disk.device = strdup("disk"); >>>> else if (type == VIRT_DISK_TYPE_CDROM) { >>>> dev->dev.disk.device = strdup("cdrom"); >>>> + if ((XSTREQ(dev->dev.disk.source, "/dev/null")) || >>>> + (XSTREQ(dev->dev.disk.source, ""))) { >>>> + dev->dev.disk.disk_type = DISK_FILE; >>>> + free(dev->dev.disk.source); >>>> + dev->dev.disk.source = strdup(""); >>>> + } > > I have only seen this now, but it could be improved in the case of > source being empty. Now you free and strdup it to the same value. > changed to avoid strdup the same value. >>>> if (dev->dev.disk.disk_type == DISK_UNKNOWN) >>>> dev->dev.disk.disk_type = DISK_PHY; >>>> } >>> >>> All in all the patch delivers the funcionality, so if you fix that logic >>> I give you a +1. >>> >> This patch tried to provide libvirt-cim the capability to show instance >> of empty cdrom, so it used many "if" , tried consider only the >> situation about cdrom and its disk, to avoid effecting other >> functionalities. > > I understand, but IMO, we should always try to follow the "keep it > simple" principle, with clearer code and also as performatic as possible. > >> >>> Best regards, Etrunko >>> >> >> > > -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Wed Sep 21 03:14:54 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Wed, 21 Sep 2011 11:14:54 +0800 Subject: [Libvirt-cim] [PATCH] (#2) Fix the problem that libvirt-cim can't find cdrom device that do not have disk Message-ID: # 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; } From xiawenc at linux.vnet.ibm.com Wed Sep 21 03:36:39 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Wed, 21 Sep 2011 11:36:39 +0800 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Always update domain device information In-Reply-To: References: <25c6de6ebf094bf602e9.1316551980@etrunko-t410.br.ibm.com> Message-ID: <4E795BC7.8020802@linux.vnet.ibm.com> ? 2011-9-21 5:33, Sharad Mishra ??: > Eduardo, > > What happens when you try to do a dynamic update on a defined guest > after applying this patch? I am guessing that libvirt should fail with > similar message. > In any case, libvirt-cim should not be doing any check like the one you > patched. It should just call appropriate libvirt API. > > -Sharad > In which situation, a call to ModifyResourceSettings would causing devices description lost, I thought the xml definition would still be updated in the libvirt, could u give a tip how to produce it? > libvirt-cim-bounces at redhat.com wrote on 09/20/2011 01:53:00 PM: > > > "Eduardo Lima \(Etrunko\)" > > Sent by: libvirt-cim-bounces at redhat.com > > > > 09/20/2011 01:53 PM > > > > Please respond to > > List for discussion and development of libvirt CIM > > > > > To > > > > libvirt-cim at redhat.com > > > > cc > > > > Subject > > > > [Libvirt-cim] [PATCH] VirtualSystemManagementService: Always update > > domain device information > > > > src/Virt_VirtualSystemManagementService.c | 9 --------- > > 1 files changed, 0 insertions(+), 9 deletions(-) > > > > > > # HG changeset patch > > # User Eduardo Lima (Etrunko) > > # Date 1316551891 10800 > > # Node ID 25c6de6ebf094bf602e95ddf01dd39a6c5c1804a > > # Parent 9a59a56e226f3f800ff7214b81ab5f2fe6362fcc > > VirtualSystemManagementService: Always update domain device information > > > > I noticed that a call to ModifyResourceSettings was causing devices > > description > > to be lost. It happens that there was an explicit check in the code that > > resulted in the device information to be updated only if the > specified domain > > was running. > > > > This patch removes that block and now the resulting domain xml after the > > ModifyResourceSettings call will keep the device information. > > > > 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 > > @@ -2349,15 +2349,6 @@ > > > > update_dominfo(dominfo, refcn); > > > > - if (!domain_online(dom)) { > > - CU_DEBUG("VS `%s' not online; skipping dynamic update", > > - dominfo->name); > > - cu_statusf(_BROKER, &s, > > - CMPI_RC_OK, > > - ""); > > - goto out; > > - } > > - > > CU_DEBUG("Doing dynamic device update for `%s'", dominfo->name); > > > > if (func(dom, dev) == 0) { > > > > _______________________________________________ > > 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 eblima at linux.vnet.ibm.com Thu Sep 22 13:15:37 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 22 Sep 2011 10:15:37 -0300 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Always update domain device information In-Reply-To: <25c6de6ebf094bf602e9.1316551980@etrunko-t410.br.ibm.com> References: <25c6de6ebf094bf602e9.1316551980@etrunko-t410.br.ibm.com> Message-ID: <4E7B34F9.2070001@linux.vnet.ibm.com> On 09/20/2011 05:53 PM, Eduardo Lima (Etrunko) wrote: > src/Virt_VirtualSystemManagementService.c | 9 --------- > 1 files changed, 0 insertions(+), 9 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1316551891 10800 > # Node ID 25c6de6ebf094bf602e95ddf01dd39a6c5c1804a > # Parent 9a59a56e226f3f800ff7214b81ab5f2fe6362fcc > VirtualSystemManagementService: Always update domain device information > > I noticed that a call to ModifyResourceSettings was causing devices description > to be lost. It happens that there was an explicit check in the code that > resulted in the device information to be updated only if the specified domain > was running. > > This patch removes that block and now the resulting domain xml after the > ModifyResourceSettings call will keep the device information. Please ignore this patch, it is much like opening a can of worms due to the many other side effects it causes. I am investigating the true causes of the bug and will provide more appropriate solution. > > 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 > @@ -2349,15 +2349,6 @@ > > update_dominfo(dominfo, refcn); > > - if (!domain_online(dom)) { > - CU_DEBUG("VS `%s' not online; skipping dynamic update", > - dominfo->name); > - cu_statusf(_BROKER, &s, > - CMPI_RC_OK, > - ""); > - goto out; > - } > - > CU_DEBUG("Doing dynamic device update for `%s'", dominfo->name); > > if (func(dom, dev) == 0) { > > _______________________________________________ > 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 snmishra at us.ibm.com Thu Sep 22 18:04:34 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 22 Sep 2011 11:04:34 -0700 Subject: [Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of-process provider In-Reply-To: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> References: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> Message-ID: +1 Code looks fine. I have not built or tested it. Please run cimtests before pushing. Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM libvirt-cim-bounces at redhat.com wrote on 09/20/2011 03:33:54 PM: > Chip Vincent > Sent by: libvirt-cim-bounces at redhat.com > > 09/20/2011 03:33 PM > > Please respond to > List for discussion and development of libvirt CIM > > To > > libvirt-cim at redhat.com > > cc > > Subject > > [Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of- > process provider > > # HG changeset patch > # User Chip Vincent > # Date 1316557881 14400 > # Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160 > # Parent db809376d763493849c2a19f587969eaec619b75 > Redirect stdout & stderr when run as out-of-process provider > > When a provider is loaded in-process by Pegasus, messages sent to > stdout and stderr are suppressed. However, when loaded out-of-process, > those same messages appear on the console. This happens excessively when > libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends > "libvir: error : no connection driver available for..." messages to stderr. > In development, this can sometimes prevent console usage. Until a fix is > made to Pegasus, we'll suppress console output during provider initialization > when run in out-of-process mode. > > Signed-off-by: Chip Vincent > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -540,6 +541,17 @@ > { > int ret = 0; > > + /* The tog-pegasus out-of-process provider feature does not > + * redirect stdout and stderr, so it's done here to prevent > + * any messages from taking over the console. One example is > + * verbose connection failures sent to stdout by libvirt. */ > + if (strstr(program_invocation_short_name, "cimprovagt") != NULL) { > + CU_DEBUG("Redirecting stdout and stderr"); > + > + stdout = freopen("/dev/null", "a", stdout); > + stderr = freopen("/dev/null", "a", stderr); > + } > + > /* double-check lock pattern used for performance reasons */ > if (libvirt_initialized == 0) { > pthread_mutex_lock(&libvirt_mutex); > > _______________________________________________ > 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 cvincent at linux.vnet.ibm.com Thu Sep 22 18:34:57 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 22 Sep 2011 14:34:57 -0400 Subject: [Libvirt-cim] libvirt-cim migrating to git Message-ID: <4E7B7FD1.6090507@linux.vnet.ibm.com> libvirt-cim community, We'll be migrating the libvirt-cim source tree from hg to git in the very near future. Once complete, we'll keep the hg tree up for a while, but updates will only be made to the git tree. The intention of this migration is simply to be more consistent with other projects many of us work on, which, of course, uses git. I'm in the process now of doing some test migrations locally to ensure the tools work properly. If everything goes well, I hope everything up and running on libvirt.org sometime next week. I'll send a note to the once the docs are updated and the git tree is accessible, and another down the road sunsetting the hg tree. -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Thu Sep 22 19:05:20 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 22 Sep 2011 16:05:20 -0300 Subject: [Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of-process provider In-Reply-To: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> References: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> Message-ID: <4E7B86F0.4030403@linux.vnet.ibm.com> On 09/20/2011 07:33 PM, Chip Vincent wrote: > # HG changeset patch > # User Chip Vincent > # Date 1316557881 14400 > # Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160 > # Parent db809376d763493849c2a19f587969eaec619b75 > Redirect stdout & stderr when run as out-of-process provider > > When a provider is loaded in-process by Pegasus, messages sent to > stdout and stderr are suppressed. However, when loaded out-of-process, > those same messages appear on the console. This happens excessively when > libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends > "libvir: error : no connection driver available for..." messages to stderr. > In development, this can sometimes prevent console usage. Until a fix is > made to Pegasus, we'll suppress console output during provider initialization > when run in out-of-process mode. > > Signed-off-by: Chip Vincent > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include Why are you including errno.h? Is it because of freopen(), stdout and stderr? I guess you should be including stdio.h if that is the case. Best regards, Etrunko. > #include > #include > > @@ -540,6 +541,17 @@ > { > int ret = 0; > > + /* The tog-pegasus out-of-process provider feature does not > + * redirect stdout and stderr, so it's done here to prevent > + * any messages from taking over the console. One example is > + * verbose connection failures sent to stdout by libvirt. */ > + if (strstr(program_invocation_short_name, "cimprovagt") != NULL) { > + CU_DEBUG("Redirecting stdout and stderr"); > + > + stdout = freopen("/dev/null", "a", stdout); > + stderr = freopen("/dev/null", "a", stderr); > + } > + > /* double-check lock pattern used for performance reasons */ > if (libvirt_initialized == 0) { > pthread_mutex_lock(&libvirt_mutex); > > _______________________________________________ > 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 snmishra at us.ibm.com Thu Sep 22 18:33:52 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 22 Sep 2011 11:33:52 -0700 Subject: [Libvirt-cim] [PATCH] Return migration job status in CIM_ConcreteJob.ErrorCode Message-ID: <5a025903b3dec8d8d5f3.1316716432@elm3b151.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1316716303 25200 # Node ID 5a025903b3dec8d8d5f35e7117be67f095d5fe21 # Parent fb09136deb494008eb3aacee420ad74da7d7c294 Return migration job status in CIM_ConcreteJob.ErrorCode This patch returns migration job status using the ErrorCode property. A successful migration returns 0 and a non-zero value is returned on failed migration. Signed-off-by: Sharad Mishra diff -r fb09136deb49 -r 5a025903b3de src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_VSMigrationService.c Thu Sep 22 11:31:43 2011 -0700 @@ -930,6 +930,7 @@ static void migrate_job_set_state(struct migration_job *job, uint16_t state, + int error_code, const char *status) { CMPIInstance *inst; @@ -953,10 +954,13 @@ CMSetProperty(inst, "JobState", (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "ErrorCode", + (CMPIValue *)&error_code, CMPI_uint16); CMSetProperty(inst, "Status", (CMPIValue *)status, CMPI_chars); - CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); + CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i", + job->uuid, state, status, error_code); s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); if (s.rc != CMPI_RC_OK) @@ -1279,7 +1283,7 @@ CBAttachThread(_BROKER, job->context); CU_DEBUG("Migration Job %s started", job->uuid); - migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running"); + migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running"); s = migrate_vs(job); @@ -1287,10 +1291,12 @@ if (s.rc != CMPI_RC_OK) migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, CMGetCharPtr(s.msg)); else migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, "Completed"); raise_deleted_ind(job); From eblima at linux.vnet.ibm.com Thu Sep 22 21:30:45 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Thu, 22 Sep 2011 18:30:45 -0300 Subject: [Libvirt-cim] [PATCH] Return migration job status in CIM_ConcreteJob.ErrorCode In-Reply-To: <5a025903b3dec8d8d5f3.1316716432@elm3b151.beaverton.ibm.com> References: <5a025903b3dec8d8d5f3.1316716432@elm3b151.beaverton.ibm.com> Message-ID: <4E7BA905.1020206@linux.vnet.ibm.com> On 09/22/2011 03:33 PM, Sharad Mishra wrote: > # HG changeset patch > # User Sharad Mishra > # Date 1316716303 25200 > # Node ID 5a025903b3dec8d8d5f35e7117be67f095d5fe21 > # Parent fb09136deb494008eb3aacee420ad74da7d7c294 > Return migration job status in CIM_ConcreteJob.ErrorCode > > This patch returns migration job status using the ErrorCode > property. A successful migration returns 0 and a non-zero > value is returned on failed migration. > > Signed-off-by: Sharad Mishra > > diff -r fb09136deb49 -r 5a025903b3de src/Virt_VSMigrationService.c > --- a/src/Virt_VSMigrationService.c Tue Aug 30 08:48:36 2011 -0700 > +++ b/src/Virt_VSMigrationService.c Thu Sep 22 11:31:43 2011 -0700 > @@ -930,6 +930,7 @@ > > static void migrate_job_set_state(struct migration_job *job, > uint16_t state, > + int error_code, > const char *status) > { > CMPIInstance *inst; > @@ -953,10 +954,13 @@ > > CMSetProperty(inst, "JobState", > (CMPIValue *)&state, CMPI_uint16); > + CMSetProperty(inst, "ErrorCode", > + (CMPIValue *)&error_code, CMPI_uint16); > CMSetProperty(inst, "Status", > (CMPIValue *)status, CMPI_chars); > > - CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); > + CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i", > + job->uuid, state, status, error_code); > > s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); > if (s.rc != CMPI_RC_OK) > @@ -1279,7 +1283,7 @@ > CBAttachThread(_BROKER, job->context); > > CU_DEBUG("Migration Job %s started", job->uuid); > - migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running"); > + migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running"); > > s = migrate_vs(job); > > @@ -1287,10 +1291,12 @@ > if (s.rc != CMPI_RC_OK) > migrate_job_set_state(job, > CIM_JOBSTATE_COMPLETE, > + s.rc, > CMGetCharPtr(s.msg)); > else > migrate_job_set_state(job, > CIM_JOBSTATE_COMPLETE, > + s.rc, > "Completed"); > > raise_deleted_ind(job); > Yay for setting the properties as expected. ;) +1 -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com From bestor at us.ibm.com Thu Sep 22 22:22:06 2011 From: bestor at us.ibm.com (Gareth S Bestor) Date: Thu, 22 Sep 2011 15:22:06 -0700 Subject: [Libvirt-cim] [PATCH] Return migration job status in CIM_ConcreteJob.ErrorCode In-Reply-To: <5a025903b3dec8d8d5f3.1316716432@elm3b151.beaverton.ibm.com> Message-ID: thnx for the fast turnaround on this!! minor comment: migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, CMGetCharPtr(s.msg)); The fact we're using CMPIStatus return codes to set the CIM_Job's ErrorCode property should probably be documented somewhere explicitly; there is otherwise no actual correlation between this CIM property and CMPI's internal status definitions... In particular, it is just a cooincidence that CMPI_RC_OK=0, so probably below is perhaps a little better; change: else migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, "Completed"); to: else migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + 0, "Completed"); Because the CIM_Job mof is very explicit about this: [Description ( "A vendor-specific error code. The value must be set to " "zero if the Job completed without error. Note that this " "property is also present in the JobProcessingStatistics " "class. This class is necessary to capture the processing " "information for recurring Jobs, because only the \'last\' " "run error can be stored in this single-valued property." ), ModelCorrespondence { "CIM_Job.ErrorDescription" }] uint16 ErrorCode; Otherwise +1 - G Dr. Gareth S. Bestor IBM Senior Software Engineer Systems & Technology Group - Systems Management Standards 971-285-6375 (mobile) bestor at us.ibm.com [Libvirt-cim] [PATCH] Return migration job status in CIM_ConcreteJob.ErrorCode Sharad Mishra to: libvirt-cim 09/22/11 02:23 PM Sent by: libvirt-cim-bounces at redhat.com Please respond to List for discussion and development of libvirt CIM # HG changeset patch # User Sharad Mishra # Date 1316716303 25200 # Node ID 5a025903b3dec8d8d5f35e7117be67f095d5fe21 # Parent fb09136deb494008eb3aacee420ad74da7d7c294 Return migration job status in CIM_ConcreteJob.ErrorCode This patch returns migration job status using the ErrorCode property. A successful migration returns 0 and a non-zero value is returned on failed migration. Signed-off-by: Sharad Mishra diff -r fb09136deb49 -r 5a025903b3de src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Aug 30 08:48:36 2011 -0700 +++ b/src/Virt_VSMigrationService.c Thu Sep 22 11:31:43 2011 -0700 @@ -930,6 +930,7 @@ static void migrate_job_set_state(struct migration_job *job, uint16_t state, + int error_code, const char *status) { CMPIInstance *inst; @@ -953,10 +954,13 @@ CMSetProperty(inst, "JobState", (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "ErrorCode", + (CMPIValue *)&error_code, CMPI_uint16); CMSetProperty(inst, "Status", (CMPIValue *)status, CMPI_chars); - CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); + CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i", + job->uuid, state, status, error_code); s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); if (s.rc != CMPI_RC_OK) @@ -1279,7 +1283,7 @@ CBAttachThread(_BROKER, job->context); CU_DEBUG("Migration Job %s started", job->uuid); - migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running"); + migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running"); s = migrate_vs(job); @@ -1287,10 +1291,12 @@ if (s.rc != CMPI_RC_OK) migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, CMGetCharPtr(s.msg)); else migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, "Completed"); raise_deleted_ind(job); _______________________________________________ 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 Thu Sep 22 19:54:27 2011 From: snmishra at us.ibm.com (Sharad Mishra) Date: Thu, 22 Sep 2011 12:54:27 -0700 Subject: [Libvirt-cim] [PATCH] (#2) Return migration job status in CIM_ConcreteJob.ErrorCode Message-ID: <859a175208e057acfe69.1316721267@elm3b151.beaverton.ibm.com> # HG changeset patch # User Sharad Mishra # Date 1316721127 25200 # Node ID 859a175208e057acfe6980332abbfa8ca6075f67 # Parent db809376d763493849c2a19f587969eaec619b75 (#2) Return migration job status in CIM_ConcreteJob.ErrorCode This patch returns migration job status using the ErrorCode property. A successful migration returns 0 and a non-zero value is returned on failed migration. #2: Changed success return from CMPI_RC_OK to 0. Signed-off-by: Sharad Mishra diff -r db809376d763 -r 859a175208e0 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Thu Jul 28 13:56:00 2011 -0300 +++ b/src/Virt_VSMigrationService.c Thu Sep 22 12:52:07 2011 -0700 @@ -930,6 +930,7 @@ static void migrate_job_set_state(struct migration_job *job, uint16_t state, + int error_code, const char *status) { CMPIInstance *inst; @@ -953,10 +954,13 @@ CMSetProperty(inst, "JobState", (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "ErrorCode", + (CMPIValue *)&error_code, CMPI_uint16); CMSetProperty(inst, "Status", (CMPIValue *)status, CMPI_chars); - CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); + CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i", + job->uuid, state, status, error_code); s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); if (s.rc != CMPI_RC_OK) @@ -1279,7 +1283,7 @@ CBAttachThread(_BROKER, job->context); CU_DEBUG("Migration Job %s started", job->uuid); - migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running"); + migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running"); s = migrate_vs(job); @@ -1287,10 +1291,12 @@ if (s.rc != CMPI_RC_OK) migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, CMGetCharPtr(s.msg)); else migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + 0, "Completed"); raise_deleted_ind(job); From bestor at us.ibm.com Thu Sep 22 22:55:56 2011 From: bestor at us.ibm.com (Gareth S Bestor) Date: Thu, 22 Sep 2011 15:55:56 -0700 Subject: [Libvirt-cim] [PATCH] (#2) Return migration job status in CIM_ConcreteJob.ErrorCode In-Reply-To: <859a175208e057acfe69.1316721267@elm3b151.beaverton.ibm.com> Message-ID: +1 :-) thnx -G Dr. Gareth S. Bestor IBM Senior Software Engineer Systems & Technology Group - Systems Management Standards 971-285-6375 (mobile) bestor at us.ibm.com [Libvirt-cim] [PATCH] (#2) Return migration job status in CIM_ConcreteJob.ErrorCode Sharad Mishra to: libvirt-cim 09/22/11 03:49 PM Sent by: libvirt-cim-bounces at redhat.com Please respond to List for discussion and development of libvirt CIM # HG changeset patch # User Sharad Mishra # Date 1316721127 25200 # Node ID 859a175208e057acfe6980332abbfa8ca6075f67 # Parent db809376d763493849c2a19f587969eaec619b75 (#2) Return migration job status in CIM_ConcreteJob.ErrorCode This patch returns migration job status using the ErrorCode property. A successful migration returns 0 and a non-zero value is returned on failed migration. #2: Changed success return from CMPI_RC_OK to 0. Signed-off-by: Sharad Mishra diff -r db809376d763 -r 859a175208e0 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Thu Jul 28 13:56:00 2011 -0300 +++ b/src/Virt_VSMigrationService.c Thu Sep 22 12:52:07 2011 -0700 @@ -930,6 +930,7 @@ static void migrate_job_set_state(struct migration_job *job, uint16_t state, + int error_code, const char *status) { CMPIInstance *inst; @@ -953,10 +954,13 @@ CMSetProperty(inst, "JobState", (CMPIValue *)&state, CMPI_uint16); + CMSetProperty(inst, "ErrorCode", + (CMPIValue *)&error_code, CMPI_uint16); CMSetProperty(inst, "Status", (CMPIValue *)status, CMPI_chars); - CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); + CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i", + job->uuid, state, status, error_code); s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); if (s.rc != CMPI_RC_OK) @@ -1279,7 +1283,7 @@ CBAttachThread(_BROKER, job->context); CU_DEBUG("Migration Job %s started", job->uuid); - migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running"); + migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running"); s = migrate_vs(job); @@ -1287,10 +1291,12 @@ if (s.rc != CMPI_RC_OK) migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + s.rc, CMGetCharPtr(s.msg)); else migrate_job_set_state(job, CIM_JOBSTATE_COMPLETE, + 0, "Completed"); raise_deleted_ind(job); _______________________________________________ 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 cvincent at linux.vnet.ibm.com Thu Sep 22 23:43:10 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 22 Sep 2011 19:43:10 -0400 Subject: [Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of-process provider In-Reply-To: <4E7B86F0.4030403@linux.vnet.ibm.com> References: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> <4E7B86F0.4030403@linux.vnet.ibm.com> Message-ID: <4E7BC80E.1040602@linux.vnet.ibm.com> On 09/22/2011 03:05 PM, Eduardo Lima (Etrunko) wrote: > On 09/20/2011 07:33 PM, Chip Vincent wrote: >> # HG changeset patch >> # User Chip Vincent >> # Date 1316557881 14400 >> # Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160 >> # Parent db809376d763493849c2a19f587969eaec619b75 >> Redirect stdout& stderr when run as out-of-process provider >> >> When a provider is loaded in-process by Pegasus, messages sent to >> stdout and stderr are suppressed. However, when loaded out-of-process, >> those same messages appear on the console. This happens excessively when >> libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends >> "libvir: error : no connection driver available for..." messages to stderr. >> In development, this can sometimes prevent console usage. Until a fix is >> made to Pegasus, we'll suppress console output during provider initialization >> when run in out-of-process mode. >> >> Signed-off-by: Chip Vincent >> >> diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c >> --- a/libxkutil/misc_util.c >> +++ b/libxkutil/misc_util.c >> @@ -29,6 +29,7 @@ >> #include >> #include >> #include >> +#include > > Why are you including errno.h? Is it because of freopen(), stdout and > stderr? I guess you should be including stdio.h if that is the case. Without including anything new, I got a compilation error. I don't recall the details, but a quick google of the error pointed to errno.h. However, everything I search now points to stdio.h. I'll fix. > > Best regards, Etrunko. > >> #include >> #include >> >> @@ -540,6 +541,17 @@ >> { >> int ret = 0; >> >> + /* The tog-pegasus out-of-process provider feature does not >> + * redirect stdout and stderr, so it's done here to prevent >> + * any messages from taking over the console. One example is >> + * verbose connection failures sent to stdout by libvirt. */ >> + if (strstr(program_invocation_short_name, "cimprovagt") != NULL) { >> + CU_DEBUG("Redirecting stdout and stderr"); >> + >> + stdout = freopen("/dev/null", "a", stdout); >> + stderr = freopen("/dev/null", "a", stderr); >> + } >> + >> /* double-check lock pattern used for performance reasons */ >> if (libvirt_initialized == 0) { >> pthread_mutex_lock(&libvirt_mutex); >> >> _______________________________________________ >> 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 Fri Sep 23 00:05:21 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 22 Sep 2011 20:05:21 -0400 Subject: [Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of-process provider In-Reply-To: <4E7BC80E.1040602@linux.vnet.ibm.com> References: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> <4E7B86F0.4030403@linux.vnet.ibm.com> <4E7BC80E.1040602@linux.vnet.ibm.com> Message-ID: <4E7BCD41.9040907@linux.vnet.ibm.com> On 09/22/2011 07:43 PM, Chip Vincent wrote: > > > On 09/22/2011 03:05 PM, Eduardo Lima (Etrunko) wrote: >> On 09/20/2011 07:33 PM, Chip Vincent wrote: >>> # HG changeset patch >>> # User Chip Vincent >>> # Date 1316557881 14400 >>> # Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160 >>> # Parent db809376d763493849c2a19f587969eaec619b75 >>> Redirect stdout& stderr when run as out-of-process provider >>> >>> When a provider is loaded in-process by Pegasus, messages sent to >>> stdout and stderr are suppressed. However, when loaded out-of-process, >>> those same messages appear on the console. This happens excessively when >>> libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends >>> "libvir: error : no connection driver available for..." messages to >>> stderr. >>> In development, this can sometimes prevent console usage. Until a fix is >>> made to Pegasus, we'll suppress console output during provider >>> initialization >>> when run in out-of-process mode. >>> >>> Signed-off-by: Chip Vincent >>> >>> diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c >>> --- a/libxkutil/misc_util.c >>> +++ b/libxkutil/misc_util.c >>> @@ -29,6 +29,7 @@ >>> #include >>> #include >>> #include >>> +#include >> >> Why are you including errno.h? Is it because of freopen(), stdout and >> stderr? I guess you should be including stdio.h if that is the case. > > Without including anything new, I got a compilation error. I don't > recall the details, but a quick google of the error pointed to errno.h. > However, everything I search now points to stdio.h. I'll fix. I recall now. errno.h is for the ?program_invocation_short_name? varible. http://www.gnu.org/software/hello/manual/gnulib/Glibc-errno_002eh.html#Glibc-errno_002eh > >> >> Best regards, Etrunko. >> >>> #include >>> #include >>> >>> @@ -540,6 +541,17 @@ >>> { >>> int ret = 0; >>> >>> + /* The tog-pegasus out-of-process provider feature does not >>> + * redirect stdout and stderr, so it's done here to prevent >>> + * any messages from taking over the console. One example is >>> + * verbose connection failures sent to stdout by libvirt. */ >>> + if (strstr(program_invocation_short_name, "cimprovagt") != NULL) { >>> + CU_DEBUG("Redirecting stdout and stderr"); >>> + >>> + stdout = freopen("/dev/null", "a", stdout); >>> + stderr = freopen("/dev/null", "a", stderr); >>> + } >>> + >>> /* double-check lock pattern used for performance reasons */ >>> if (libvirt_initialized == 0) { >>> pthread_mutex_lock(&libvirt_mutex); >>> >>> _______________________________________________ >>> 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 Fri Sep 23 00:40:11 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 22 Sep 2011 20:40:11 -0400 Subject: [Libvirt-cim] [PATCH] (#2) Return migration job status in CIM_ConcreteJob.ErrorCode In-Reply-To: References: Message-ID: <4E7BD56B.40609@linux.vnet.ibm.com> Pushed. On 09/22/2011 06:55 PM, Gareth S Bestor wrote: > > +1 :-) thnx > > -G > > Dr. Gareth S. Bestor > IBM Senior Software Engineer > Systems & Technology Group - Systems Management Standards > 971-285-6375 (mobile) > bestor at us.ibm.com > > > > *[Libvirt-cim] [PATCH] (#2) Return migration job status in > CIM_ConcreteJob.ErrorCode* > > > *Sharad Mishra * to: libvirt-cim > 09/22/11 03:49 PM > > > Sent by: *libvirt-cim-bounces at redhat.com* > > > *Please respond to List for discussion and development of libvirt CIM * > > > > > ------------------------------------------------------------------------ > > > > # HG changeset patch > # User Sharad Mishra > # Date 1316721127 25200 > # Node ID 859a175208e057acfe6980332abbfa8ca6075f67 > # Parent db809376d763493849c2a19f587969eaec619b75 > (#2) Return migration job status in CIM_ConcreteJob.ErrorCode > > This patch returns migration job status using the ErrorCode > property. A successful migration returns 0 and a non-zero > value is returned on failed migration. > > #2: Changed success return from CMPI_RC_OK to 0. > > Signed-off-by: Sharad Mishra > > diff -r db809376d763 -r 859a175208e0 src/Virt_VSMigrationService.c > --- a/src/Virt_VSMigrationService.c Thu Jul 28 13:56:00 2011 -0300 > +++ b/src/Virt_VSMigrationService.c Thu Sep 22 12:52:07 2011 -0700 > @@ -930,6 +930,7 @@ > > static void migrate_job_set_state(struct migration_job *job, > uint16_t state, > + int error_code, > const char *status) > { > CMPIInstance *inst; > @@ -953,10 +954,13 @@ > > CMSetProperty(inst, "JobState", > (CMPIValue *)&state, CMPI_uint16); > + CMSetProperty(inst, "ErrorCode", > + (CMPIValue *)&error_code, CMPI_uint16); > CMSetProperty(inst, "Status", > (CMPIValue *)status, CMPI_chars); > > - CU_DEBUG("Modifying job %s (%i:%s)", job->uuid, state, status); > + CU_DEBUG("Modifying job %s (%i:%s) Error Code is %i", > + job->uuid, state, status, error_code); > > s = CBModifyInstance(_BROKER, job->context, op, inst, NULL); > if (s.rc != CMPI_RC_OK) > @@ -1279,7 +1283,7 @@ > CBAttachThread(_BROKER, job->context); > > CU_DEBUG("Migration Job %s started", job->uuid); > - migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, "Running"); > + migrate_job_set_state(job, CIM_JOBSTATE_RUNNING, 0, "Running"); > > s = migrate_vs(job); > > @@ -1287,10 +1291,12 @@ > if (s.rc != CMPI_RC_OK) > migrate_job_set_state(job, > CIM_JOBSTATE_COMPLETE, > + s.rc, > CMGetCharPtr(s.msg)); > else > migrate_job_set_state(job, > CIM_JOBSTATE_COMPLETE, > + 0, > "Completed"); > > raise_deleted_ind(job); > > _______________________________________________ > 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 cvincent at linux.vnet.ibm.com Fri Sep 23 01:14:24 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 22 Sep 2011 21:14:24 -0400 Subject: [Libvirt-cim] [PATCH] Redirect stdout & stderr when run as out-of-process provider In-Reply-To: <4E7BCD41.9040907@linux.vnet.ibm.com> References: <4d95f2e9f2d8eac15653.1316558034@oc0840652111.ibm.com> <4E7B86F0.4030403@linux.vnet.ibm.com> <4E7BC80E.1040602@linux.vnet.ibm.com> <4E7BCD41.9040907@linux.vnet.ibm.com> Message-ID: <4E7BDD70.6050005@linux.vnet.ibm.com> Pushed. On 09/22/2011 08:05 PM, Chip Vincent wrote: > > > On 09/22/2011 07:43 PM, Chip Vincent wrote: >> >> >> On 09/22/2011 03:05 PM, Eduardo Lima (Etrunko) wrote: >>> On 09/20/2011 07:33 PM, Chip Vincent wrote: >>>> # HG changeset patch >>>> # User Chip Vincent >>>> # Date 1316557881 14400 >>>> # Node ID 4d95f2e9f2d8eac1565307def96bd158f5dcf160 >>>> # Parent db809376d763493849c2a19f587969eaec619b75 >>>> Redirect stdout& stderr when run as out-of-process provider >>>> >>>> When a provider is loaded in-process by Pegasus, messages sent to >>>> stdout and stderr are suppressed. However, when loaded out-of-process, >>>> those same messages appear on the console. This happens excessively >>>> when >>>> libvirt-cim LXC_ and XEN_ classes are enumerated and libvirt sends >>>> "libvir: error : no connection driver available for..." messages to >>>> stderr. >>>> In development, this can sometimes prevent console usage. Until a >>>> fix is >>>> made to Pegasus, we'll suppress console output during provider >>>> initialization >>>> when run in out-of-process mode. >>>> >>>> Signed-off-by: Chip Vincent >>>> >>>> diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c >>>> --- a/libxkutil/misc_util.c >>>> +++ b/libxkutil/misc_util.c >>>> @@ -29,6 +29,7 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>> >>> Why are you including errno.h? Is it because of freopen(), stdout and >>> stderr? I guess you should be including stdio.h if that is the case. >> >> Without including anything new, I got a compilation error. I don't >> recall the details, but a quick google of the error pointed to errno.h. >> However, everything I search now points to stdio.h. I'll fix. > > I recall now. errno.h is for the ?program_invocation_short_name? varible. > > http://www.gnu.org/software/hello/manual/gnulib/Glibc-errno_002eh.html#Glibc-errno_002eh > > >> >>> >>> Best regards, Etrunko. >>> >>>> #include >>>> #include >>>> >>>> @@ -540,6 +541,17 @@ >>>> { >>>> int ret = 0; >>>> >>>> + /* The tog-pegasus out-of-process provider feature does not >>>> + * redirect stdout and stderr, so it's done here to prevent >>>> + * any messages from taking over the console. One example is >>>> + * verbose connection failures sent to stdout by libvirt. */ >>>> + if (strstr(program_invocation_short_name, "cimprovagt") != NULL) { >>>> + CU_DEBUG("Redirecting stdout and stderr"); >>>> + >>>> + stdout = freopen("/dev/null", "a", stdout); >>>> + stderr = freopen("/dev/null", "a", stderr); >>>> + } >>>> + >>>> /* double-check lock pattern used for performance reasons */ >>>> if (libvirt_initialized == 0) { >>>> pthread_mutex_lock(&libvirt_mutex); >>>> >>>> _______________________________________________ >>>> 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 Fri Sep 23 01:23:28 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 22 Sep 2011 21:23:28 -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: <4E7BDF90.6000301@linux.vnet.ibm.com> Built rpm for test team and awaiting results. 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 Fri Sep 23 01:25:19 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Thu, 22 Sep 2011 21:25:19 -0400 Subject: [Libvirt-cim] [PATCH] Fix MOF download location - URL permanently changed Message-ID: <8808b370a2e01b635567.1316741119@oc0840652111.ibm.com> # HG changeset patch # User Chip Vincent # Date 1316740924 14400 # Node ID 8808b370a2e01b6355678e8d3a079b0dcf907a81 # Parent adc78792781448aca7a1356bd253cbdd689839cb Fix MOF download location - URL permanently changed The MOF file download location has permanently changed as illustrated by the following message at build time: wget http://www.dmtf.org/standards/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip --2011-09-22 20:51:15-- http://www.dmtf.org/standards/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip Resolving www.dmtf.org... 72.47.221.139 Connecting to www.dmtf.org|72.47.221.139|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://www.dmtf.org/sites/default/files/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip [following] Signed-off-by: Chip Vincent diff --git a/base_schema/Makefile.am b/base_schema/Makefile.am --- a/base_schema/Makefile.am +++ b/base_schema/Makefile.am @@ -8,6 +8,6 @@ dist_pkgdata_SCRIPTS = install_base_schema.sh $(CIM_SCHEMA_ZIP): - wget http://www.dmtf.org/standards/cim/cim_schema_v$(CIM_SCHEMA_DIR)/$(CIM_SCHEMA_ZIP) + wget http://www.dmtf.org/sites/default/files/cim/cim_schema_v$(CIM_SCHEMA_DIR)/$(CIM_SCHEMA_ZIP) EXTRA_DIST = README.DMTF From eblima at linux.vnet.ibm.com Mon Sep 26 21:13:42 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Mon, 26 Sep 2011 18:13:42 -0300 Subject: [Libvirt-cim] [PATCH] ACL: Add KVM_FilterEntry class Message-ID: <9a59a56e226f3f800ff7.1317071622@eblima.br.ibm.com> schema/FilterEntry.mof | 30 ++++ schema/FilterEntry.registration | 1 + src/Virt_EntriesInFilterList.c | 1 + src/Virt_FilterEntry.c | 241 ++++++++++++++------------------------- 4 files changed, 120 insertions(+), 153 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1315334426 10800 # Node ID 9a59a56e226f3f800ff7214b81ab5f2fe6362fcc # Parent db809376d763493849c2a19f587969eaec619b75 ACL: Add KVM_FilterEntry class This is the generic rule meant to match simple rules such the one in 'allow-arp' filter. For instance: 15fea95d-4300-19ea-2685-5f1b14c6759b This patch also refactors the provider code to share the conversion of common properties between the various types of filter entries. Signed-off-by: Eduardo Lima (Etrunko) diff --git a/schema/FilterEntry.mof b/schema/FilterEntry.mof --- a/schema/FilterEntry.mof +++ b/schema/FilterEntry.mof @@ -74,3 +74,33 @@ MaxValue(1000)] uint16 Priority = 500; }; + +[Provider("cmpi::Virt_FilterEntry")] +class KVM_FilterEntry : CIM_FilterEntry +{ + [Description("This defines whether the Filter is used for input, " + "output, or both input and output filtering. All values are " + "used with respect to the interface for which the Filter " + "applies. \"Not Applicable\" (0) is used when there is no " + "direction applicable to the Filter. \"Input\" (1) is " + "used when the Filter applies to packets that are inbound " + "on the related interface. \"Output\" (2) is used when the " + "Filter applies to packets that are outbound on the " + "related interface. \"Both\" (3) is used to indicate that " + "the direction is immaterial, e.g., to filter on a source " + "subnet regardless of whether the flow is inbound or " + "outbound."), + ValueMap { "0", "1", "2", "3", "4" }, + Values { "Not Applicable", "Input, Output", "Both", "Mirrored" }] + uint16 Direction; + + [Description("The priority of the rule controls the order in which " + "the rule will be, instantiated relative to other rules. " + "Rules with lower value will be instantiated and therefore " + "evaluated before rules with higher value. Valid values are " + "in the range of 0 to 1000. If this attribute is not " + "provided, the value 500 will automatically be assigned."), + MinValue(0), + MaxValue(1000)] + uint16 Priority = 500; +}; diff --git a/schema/FilterEntry.registration b/schema/FilterEntry.registration --- a/schema/FilterEntry.registration +++ b/schema/FilterEntry.registration @@ -2,3 +2,4 @@ # Classname Namespace ProviderName ProviderModule ProviderTypes KVM_Hdr8021Filter root/virt Virt_FilterEntry Virt_FilterEntry instance KVM_IPHeadersFilter root/virt Virt_FilterEntry Virt_FilterEntry instance +KVM_FilterEntry root/virt Virt_FilterEntry Virt_FilterEntry instance diff --git a/src/Virt_EntriesInFilterList.c b/src/Virt_EntriesInFilterList.c --- a/src/Virt_EntriesInFilterList.c +++ b/src/Virt_EntriesInFilterList.c @@ -160,6 +160,7 @@ }; static char *part_component[] = { + "KVM_FilterEntry", "KVM_Hdr8021Filter", "KVM_IPHeadersFilter", NULL diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -36,23 +36,6 @@ const static CMPIBroker *_BROKER; -static bool is_mac_rule(int type) -{ - if (type == MAC_RULE || type == ARP_RULE) - return 1; - - return 0; -} - -static bool is_ip_rule(int type) -{ - if (type == IP_RULE || type == TCP_RULE || type == ICMP_RULE || - type == IGMP_RULE) - return 1; - - return 0; -} - static int octets_from_mac(const char * s, unsigned int *buffer, unsigned int size) { @@ -172,59 +155,15 @@ return action; } -static CMPIInstance *convert_mac_rule_to_instance( +static void convert_mac_rule_to_instance( struct acl_rule *rule, - const CMPIBroker *broker, - const CMPIContext *context, - const CMPIObjectPath *reference, - CMPIStatus *s) + CMPIInstance *inst, + const CMPIBroker *broker) { - CMPIInstance *inst = NULL; - const char *sys_name = NULL; - const char *sys_ccname = NULL; - int action, direction, priority = 0; unsigned int bytes[48]; unsigned int size = 0; CMPIArray *array = NULL; - inst = get_typed_instance(broker, - CLASSNAME(reference), - "Hdr8021Filter", - NAMESPACE(reference)); - if (inst == NULL) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get 8021 filter instance"); - - goto out; - } - - *s = get_host_system_properties(&sys_name, - &sys_ccname, - reference, - broker, - context); - - if (s->rc != CMPI_RC_OK) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get host attributes"); - goto out; - } - - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); - - action = convert_action(rule->action); - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); - - direction = convert_direction(rule->direction); - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); - - priority = convert_priority(rule->priority); - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); - memset(bytes, 0, sizeof(bytes)); size = octets_from_mac(rule->var.mac.srcmacaddr, bytes, sizeof(bytes)); @@ -260,64 +199,18 @@ if (array != NULL) CMSetProperty(inst, "HdrDestMACMask8021", (CMPIValue *) (CMPIValue *)&array, CMPI_uint8A); - - out: - return inst; } -static CMPIInstance *convert_ip_rule_to_instance( +static void convert_ip_rule_to_instance( struct acl_rule *rule, - const CMPIBroker *broker, - const CMPIContext *context, - const CMPIObjectPath *reference, - CMPIStatus *s) + CMPIInstance *inst, + const CMPIBroker *broker) { - CMPIInstance *inst = NULL; - const char *sys_name = NULL; - const char *sys_ccname = NULL; - int action, direction, priority = 0; unsigned int bytes[48]; unsigned int size = 0; unsigned int n = 0; CMPIArray *array = NULL; - inst = get_typed_instance(broker, - CLASSNAME(reference), - "IPHeadersFilter", - NAMESPACE(reference)); - if (inst == NULL) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get ip headers filter instance"); - goto out; - } - - *s = get_host_system_properties(&sys_name, - &sys_ccname, - reference, - broker, - context); - - if (s->rc != CMPI_RC_OK) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get host attributes"); - goto out; - } - - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); - - action = convert_action(rule->action); - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); - - direction = convert_direction(rule->direction); - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); - - priority = convert_priority(rule->priority); - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); - if (strstr(rule->protocol_id, "v6")) n = 6; else @@ -427,8 +320,6 @@ } } - out: - return inst; } static CMPIInstance *convert_rule_to_instance( @@ -439,25 +330,77 @@ CMPIStatus *s) { CMPIInstance *instance = NULL; + const char *sys_name = NULL; + const char *sys_ccname = NULL; + const char *basename = NULL; + int action, direction, priority = 0; + + void (*convert_func)(struct acl_rule*, CMPIInstance*, const CMPIBroker*); if (rule == NULL) return NULL; - if(is_mac_rule(rule->type)) { - instance = convert_mac_rule_to_instance(rule, - broker, - context, - reference, - s); - } - else if(is_ip_rule(rule->type)) { - instance = convert_ip_rule_to_instance(rule, - broker, - context, - reference, - s); + switch (rule->type) { + case MAC_RULE: + case ARP_RULE: + basename = "Hdr8021Filter"; + convert_func = convert_mac_rule_to_instance; + break; + case IP_RULE: + case TCP_RULE: + case ICMP_RULE: + case IGMP_RULE: + basename = "IPHeadersFilter"; + convert_func = convert_ip_rule_to_instance; + break; + default: + basename = "FilterEntry"; + convert_func = NULL; + break; } + instance = get_typed_instance(broker, + CLASSNAME(reference), + basename, + NAMESPACE(reference)); + + if (instance == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get filter entry instance"); + goto out; + } + + *s = get_host_system_properties(&sys_name, + &sys_ccname, + reference, + broker, + context); + + if (s->rc != CMPI_RC_OK) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(instance, "SystemName", sys_name, CMPI_chars); + CMSetProperty(instance, "SystemCreationClassName", sys_ccname, CMPI_chars); + CMSetProperty(instance, "Name", (CMPIValue *)rule->name, CMPI_chars); + + action = convert_action(rule->action); + CMSetProperty(instance, "Action", (CMPIValue *)&action, CMPI_uint16); + + direction = convert_direction(rule->direction); + CMSetProperty(instance, "Direction", (CMPIValue *)&direction, CMPI_uint16); + + priority = convert_priority(rule->priority); + CMSetProperty(instance, "Priority", (CMPIValue *)&priority, CMPI_uint16); + + if (convert_func) + convert_func(rule, instance, broker); + + out: return instance; } @@ -475,10 +418,19 @@ CU_DEBUG("Reference = %s", REF2STR(reference)); - if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) + if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) { class_type = MAC; - else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) + } else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) { class_type = IP; + } else if (STREQC(CLASSNAME(reference), "KVM_FilterEntry")) { + class_type = NONE; + } else { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unrecognized class type"); + goto out; + } + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) @@ -490,29 +442,12 @@ for (j = 0; j < filters[i].rule_ct; j++) { CMPIInstance *instance = NULL; - if (((class_type == NONE) || - (class_type == MAC)) && - is_mac_rule(filters[i].rules[j]->type)) { - instance = convert_mac_rule_to_instance( - filters[i].rules[j], - broker, - context, - reference, - &s); - } - else if (((class_type == NONE) || - (class_type == IP)) && - is_ip_rule(filters[i].rules[j]->type)) { - instance = convert_ip_rule_to_instance( - filters[i].rules[j], - broker, - context, - reference, - &s); - } - else - CU_DEBUG("Unrecognized rule type %u", - filters[i].rules[j]->type); + instance = convert_rule_to_instance( + filters[i].rules[j], + broker, + context, + reference, + &s); if (instance != NULL) inst_list_add(list, instance); From eblima at linux.vnet.ibm.com Tue Sep 27 19:52:24 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 27 Sep 2011 16:52:24 -0300 Subject: [Libvirt-cim] [PATCH] [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService Message-ID: <273559a7fec092be0699.1317153144@eblima.br.ibm.com> suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py | 192 ++++++++++ 1 files changed, 192 insertions(+), 0 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1317153134 10800 # Node ID 273559a7fec092be0699c486c591d3385bbf6df5 # 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,192 @@ +#!/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, resource_subtype): + return """ +instance of KVM_NetResourceAllocationSettingData { + InstanceID="%s"; + ResourceType=%d; + Address="%s"; + VirtualQuantityUnits="%s"; + NetworkType="%s"; + NetworkName="%s"; + ResourceSubType="%s"; +};""" % (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"] == dom_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, 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) From eblima at linux.vnet.ibm.com Tue Sep 27 21:47:32 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Tue, 27 Sep 2011 18:47:32 -0300 Subject: [Libvirt-cim] [PATCH] [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService In-Reply-To: <273559a7fec092be0699.1317153144@eblima.br.ibm.com> References: <273559a7fec092be0699.1317153144@eblima.br.ibm.com> Message-ID: <4E824474.1090904@linux.vnet.ibm.com> On 09/27/2011 04:52 PM, Eduardo Lima (Etrunko) wrote: [snip] > + > + > +def resource_settings(inst, resource_subtype): > + return """ > +instance of KVM_NetResourceAllocationSettingData { OOps here, should actually take the virtualization into account. Will fix and send a new patch soon. -- 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 Wed Sep 28 13:41:34 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 28 Sep 2011 10:41:34 -0300 Subject: [Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService Message-ID: 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) From eblima at linux.vnet.ibm.com Wed Sep 28 14:47:47 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 28 Sep 2011 11:47:47 -0300 Subject: [Libvirt-cim] [PATCH] Fix MOF download location - URL permanently changed In-Reply-To: <8808b370a2e01b635567.1316741119@oc0840652111.ibm.com> References: <8808b370a2e01b635567.1316741119@oc0840652111.ibm.com> Message-ID: <4E833393.8030306@linux.vnet.ibm.com> On 09/22/2011 10:25 PM, Chip Vincent wrote: > # HG changeset patch > # User Chip Vincent > # Date 1316740924 14400 > # Node ID 8808b370a2e01b6355678e8d3a079b0dcf907a81 > # Parent adc78792781448aca7a1356bd253cbdd689839cb > Fix MOF download location - URL permanently changed > > The MOF file download location has permanently changed as illustrated by > the following message at build time: > > wget http://www.dmtf.org/standards/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip > --2011-09-22 20:51:15-- http://www.dmtf.org/standards/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip > Resolving www.dmtf.org... 72.47.221.139 > Connecting to www.dmtf.org|72.47.221.139|:80... connected. > HTTP request sent, awaiting response... 301 Moved Permanently > Location: http://www.dmtf.org/sites/default/files/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip [following] > > Signed-off-by: Chip Vincent > > diff --git a/base_schema/Makefile.am b/base_schema/Makefile.am > --- a/base_schema/Makefile.am > +++ b/base_schema/Makefile.am > @@ -8,6 +8,6 @@ > dist_pkgdata_SCRIPTS = install_base_schema.sh > > $(CIM_SCHEMA_ZIP): > - wget http://www.dmtf.org/standards/cim/cim_schema_v$(CIM_SCHEMA_DIR)/$(CIM_SCHEMA_ZIP) > + wget http://www.dmtf.org/sites/default/files/cim/cim_schema_v$(CIM_SCHEMA_DIR)/$(CIM_SCHEMA_ZIP) > Again, this is another example of what I consider 'simple enough' and could be pushed without review. Patch would go to the list anyway, but more as a heads-up to other developers. +1 [etrunko at eblima base_schema]$ make wget http://www.dmtf.org/sites/default/files/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip --2011-09-28 11:43:25-- http://www.dmtf.org/sites/default/files/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip Resolving www.dmtf.org... 72.47.221.139 Connecting to www.dmtf.org|72.47.221.139|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1888838 (1.8M) [application/zip] Saving to: ?cim_schema_2.21.0Experimental-MOFs.zip? 100%[=========================================================================================================================================>] 1,888,838 632K/s in 2.9s 2011-09-28 11:43:29 (632 KB/s) - ?cim_schema_2.21.0Experimental-MOFs.zip? saved [1888838/1888838] -- 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 Wed Sep 28 14:54:42 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 28 Sep 2011 10:54:42 -0400 Subject: [Libvirt-cim] [PATCH] ACL: Add KVM_FilterEntry class In-Reply-To: <9a59a56e226f3f800ff7.1317071622@eblima.br.ibm.com> References: <9a59a56e226f3f800ff7.1317071622@eblima.br.ibm.com> Message-ID: <4E833532.1000607@linux.vnet.ibm.com> I'm still in the process of testing, but the changes appear reasonable. Only one nit (see below). On 09/26/2011 05:13 PM, Eduardo Lima (Etrunko) wrote: > schema/FilterEntry.mof | 30 ++++ > schema/FilterEntry.registration | 1 + > src/Virt_EntriesInFilterList.c | 1 + > src/Virt_FilterEntry.c | 241 ++++++++++++++------------------------- > 4 files changed, 120 insertions(+), 153 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1315334426 10800 > # Node ID 9a59a56e226f3f800ff7214b81ab5f2fe6362fcc > # Parent db809376d763493849c2a19f587969eaec619b75 > ACL: Add KVM_FilterEntry class > > This is the generic rule meant to match simple rules such the one in > 'allow-arp' filter. For instance: > > > 15fea95d-4300-19ea-2685-5f1b14c6759b > > > > This patch also refactors the provider code to share the conversion of > common properties between the various types of filter entries. > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/schema/FilterEntry.mof b/schema/FilterEntry.mof > --- a/schema/FilterEntry.mof > +++ b/schema/FilterEntry.mof > @@ -74,3 +74,33 @@ > MaxValue(1000)] > uint16 Priority = 500; > }; > + > +[Provider("cmpi::Virt_FilterEntry")] > +class KVM_FilterEntry : CIM_FilterEntry > +{ > + [Description("This defines whether the Filter is used for input, " > + "output, or both input and output filtering. All values are " > + "used with respect to the interface for which the Filter " > + "applies. \"Not Applicable\" (0) is used when there is no " > + "direction applicable to the Filter. \"Input\" (1) is " > + "used when the Filter applies to packets that are inbound " > + "on the related interface. \"Output\" (2) is used when the " > + "Filter applies to packets that are outbound on the " > + "related interface. \"Both\" (3) is used to indicate that " > + "the direction is immaterial, e.g., to filter on a source " > + "subnet regardless of whether the flow is inbound or " > + "outbound."), > + ValueMap { "0", "1", "2", "3", "4" }, > + Values { "Not Applicable", "Input, Output", "Both", "Mirrored" }] > + uint16 Direction; > + > + [Description("The priority of the rule controls the order in which " > + "the rule will be, instantiated relative to other rules. " > + "Rules with lower value will be instantiated and therefore " > + "evaluated before rules with higher value. Valid values are " > + "in the range of 0 to 1000. If this attribute is not " > + "provided, the value 500 will automatically be assigned."), > + MinValue(0), > + MaxValue(1000)] > + uint16 Priority = 500; > +}; > diff --git a/schema/FilterEntry.registration b/schema/FilterEntry.registration > --- a/schema/FilterEntry.registration > +++ b/schema/FilterEntry.registration > @@ -2,3 +2,4 @@ > # Classname Namespace ProviderName ProviderModule ProviderTypes > KVM_Hdr8021Filter root/virt Virt_FilterEntry Virt_FilterEntry instance > KVM_IPHeadersFilter root/virt Virt_FilterEntry Virt_FilterEntry instance > +KVM_FilterEntry root/virt Virt_FilterEntry Virt_FilterEntry instance > diff --git a/src/Virt_EntriesInFilterList.c b/src/Virt_EntriesInFilterList.c > --- a/src/Virt_EntriesInFilterList.c > +++ b/src/Virt_EntriesInFilterList.c > @@ -160,6 +160,7 @@ > }; > > static char *part_component[] = { > + "KVM_FilterEntry", > "KVM_Hdr8021Filter", > "KVM_IPHeadersFilter", > NULL > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -36,23 +36,6 @@ > > const static CMPIBroker *_BROKER; > > -static bool is_mac_rule(int type) > -{ > - if (type == MAC_RULE || type == ARP_RULE) > - return 1; > - > - return 0; > -} > - > -static bool is_ip_rule(int type) > -{ > - if (type == IP_RULE || type == TCP_RULE || type == ICMP_RULE || > - type == IGMP_RULE) > - return 1; > - > - return 0; > -} > - > static int octets_from_mac(const char * s, unsigned int *buffer, > unsigned int size) > { > @@ -172,59 +155,15 @@ > return action; > } > > -static CMPIInstance *convert_mac_rule_to_instance( > +static void convert_mac_rule_to_instance( > struct acl_rule *rule, > - const CMPIBroker *broker, > - const CMPIContext *context, > - const CMPIObjectPath *reference, > - CMPIStatus *s) > + CMPIInstance *inst, > + const CMPIBroker *broker) > { > - CMPIInstance *inst = NULL; > - const char *sys_name = NULL; > - const char *sys_ccname = NULL; > - int action, direction, priority = 0; > unsigned int bytes[48]; > unsigned int size = 0; > CMPIArray *array = NULL; > > - inst = get_typed_instance(broker, > - CLASSNAME(reference), > - "Hdr8021Filter", > - NAMESPACE(reference)); > - if (inst == NULL) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get 8021 filter instance"); > - > - goto out; > - } > - > - *s = get_host_system_properties(&sys_name, > -&sys_ccname, > - reference, > - broker, > - context); > - > - if (s->rc != CMPI_RC_OK) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get host attributes"); > - goto out; > - } > - > - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); > - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); > - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); > - > - action = convert_action(rule->action); > - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); > - > - direction = convert_direction(rule->direction); > - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); > - > - priority = convert_priority(rule->priority); > - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); > - > memset(bytes, 0, sizeof(bytes)); > size = octets_from_mac(rule->var.mac.srcmacaddr, > bytes, sizeof(bytes)); > @@ -260,64 +199,18 @@ > if (array != NULL) > CMSetProperty(inst, "HdrDestMACMask8021", (CMPIValue *) > (CMPIValue *)&array, CMPI_uint8A); > - > - out: > - return inst; > } > > -static CMPIInstance *convert_ip_rule_to_instance( > +static void convert_ip_rule_to_instance( > struct acl_rule *rule, > - const CMPIBroker *broker, > - const CMPIContext *context, > - const CMPIObjectPath *reference, > - CMPIStatus *s) > + CMPIInstance *inst, > + const CMPIBroker *broker) > { > - CMPIInstance *inst = NULL; > - const char *sys_name = NULL; > - const char *sys_ccname = NULL; > - int action, direction, priority = 0; > unsigned int bytes[48]; > unsigned int size = 0; > unsigned int n = 0; > CMPIArray *array = NULL; > > - inst = get_typed_instance(broker, > - CLASSNAME(reference), > - "IPHeadersFilter", > - NAMESPACE(reference)); > - if (inst == NULL) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get ip headers filter instance"); > - goto out; > - } > - > - *s = get_host_system_properties(&sys_name, > -&sys_ccname, > - reference, > - broker, > - context); > - > - if (s->rc != CMPI_RC_OK) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get host attributes"); > - goto out; > - } > - > - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); > - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); > - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); > - > - action = convert_action(rule->action); > - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); > - > - direction = convert_direction(rule->direction); > - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); > - > - priority = convert_priority(rule->priority); > - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); > - > if (strstr(rule->protocol_id, "v6")) > n = 6; > else > @@ -427,8 +320,6 @@ > } > } > > - out: > - return inst; > } > > static CMPIInstance *convert_rule_to_instance( > @@ -439,25 +330,77 @@ > CMPIStatus *s) > { > CMPIInstance *instance = NULL; > + const char *sys_name = NULL; > + const char *sys_ccname = NULL; > + const char *basename = NULL; > + int action, direction, priority = 0; > + > + void (*convert_func)(struct acl_rule*, CMPIInstance*, const CMPIBroker*); > > if (rule == NULL) > return NULL; > > - if(is_mac_rule(rule->type)) { > - instance = convert_mac_rule_to_instance(rule, > - broker, > - context, > - reference, > - s); > - } > - else if(is_ip_rule(rule->type)) { > - instance = convert_ip_rule_to_instance(rule, > - broker, > - context, > - reference, > - s); > + switch (rule->type) { > + case MAC_RULE: > + case ARP_RULE: > + basename = "Hdr8021Filter"; > + convert_func = convert_mac_rule_to_instance; > + break; > + case IP_RULE: > + case TCP_RULE: > + case ICMP_RULE: > + case IGMP_RULE: > + basename = "IPHeadersFilter"; > + convert_func = convert_ip_rule_to_instance; > + break; > + default: > + basename = "FilterEntry"; > + convert_func = NULL; > + break; > } > > + instance = get_typed_instance(broker, > + CLASSNAME(reference), > + basename, > + NAMESPACE(reference)); > + > + if (instance == NULL) { > + cu_statusf(broker, s, > + CMPI_RC_ERR_FAILED, > + "Unable to get filter entry instance"); > + goto out; > + } > + > + *s = get_host_system_properties(&sys_name, > +&sys_ccname, > + reference, > + broker, > + context); > + > + if (s->rc != CMPI_RC_OK) { > + cu_statusf(broker, s, > + CMPI_RC_ERR_FAILED, > + "Unable to get host attributes"); > + goto out; > + } > + > + CMSetProperty(instance, "SystemName", sys_name, CMPI_chars); > + CMSetProperty(instance, "SystemCreationClassName", sys_ccname, CMPI_chars); > + CMSetProperty(instance, "Name", (CMPIValue *)rule->name, CMPI_chars); > + > + action = convert_action(rule->action); > + CMSetProperty(instance, "Action", (CMPIValue *)&action, CMPI_uint16); > + > + direction = convert_direction(rule->direction); > + CMSetProperty(instance, "Direction", (CMPIValue *)&direction, CMPI_uint16); > + > + priority = convert_priority(rule->priority); > + CMSetProperty(instance, "Priority", (CMPIValue *)&priority, CMPI_uint16); > + > + if (convert_func) > + convert_func(rule, instance, broker); > + > + out: > return instance; > } There are some lines above that are longer than 80. > > @@ -475,10 +418,19 @@ > > CU_DEBUG("Reference = %s", REF2STR(reference)); > > - if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) > + if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) { > class_type = MAC; > - else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) > + } else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) { > class_type = IP; > + } else if (STREQC(CLASSNAME(reference), "KVM_FilterEntry")) { > + class_type = NONE; > + } else { > + cu_statusf(broker,&s, > + CMPI_RC_ERR_FAILED, > + "Unrecognized class type"); > + goto out; > + } > + > > conn = connect_by_classname(_BROKER, CLASSNAME(reference),&s); > if (conn == NULL) > @@ -490,29 +442,12 @@ > for (j = 0; j< filters[i].rule_ct; j++) { > CMPIInstance *instance = NULL; > > - if (((class_type == NONE) || > - (class_type == MAC))&& > - is_mac_rule(filters[i].rules[j]->type)) { > - instance = convert_mac_rule_to_instance( > - filters[i].rules[j], > - broker, > - context, > - reference, > -&s); > - } > - else if (((class_type == NONE) || > - (class_type == IP))&& > - is_ip_rule(filters[i].rules[j]->type)) { > - instance = convert_ip_rule_to_instance( > - filters[i].rules[j], > - broker, > - context, > - reference, > -&s); > - } > - else > - CU_DEBUG("Unrecognized rule type %u", > - filters[i].rules[j]->type); > + instance = convert_rule_to_instance( > + filters[i].rules[j], > + broker, > + context, > + reference, > +&s); > > if (instance != NULL) > inst_list_add(list, 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 eblima at linux.vnet.ibm.com Wed Sep 28 15:11:12 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 28 Sep 2011 12:11:12 -0300 Subject: [Libvirt-cim] [PATCH] ACL: Add KVM_FilterEntry class In-Reply-To: <4E833532.1000607@linux.vnet.ibm.com> References: <9a59a56e226f3f800ff7.1317071622@eblima.br.ibm.com> <4E833532.1000607@linux.vnet.ibm.com> Message-ID: <4E833910.9080308@linux.vnet.ibm.com> On 09/28/2011 11:54 AM, Chip Vincent wrote: > I'm still in the process of testing, but the changes appear reasonable. > Only one nit (see below). > [snip] > > There are some lines above that are longer than 80. > Oh, it was all too good to be true... I'm sending a new version right away. 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 Wed Sep 28 15:22:00 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 28 Sep 2011 11:22:00 -0400 Subject: [Libvirt-cim] [PATCH] Fix MOF download location - URL permanently changed In-Reply-To: <4E833393.8030306@linux.vnet.ibm.com> References: <8808b370a2e01b635567.1316741119@oc0840652111.ibm.com> <4E833393.8030306@linux.vnet.ibm.com> Message-ID: <4E833B98.6020502@linux.vnet.ibm.com> Pushed. On 09/28/2011 10:47 AM, Eduardo Lima (Etrunko) wrote: > On 09/22/2011 10:25 PM, Chip Vincent wrote: >> # HG changeset patch >> # User Chip Vincent >> # Date 1316740924 14400 >> # Node ID 8808b370a2e01b6355678e8d3a079b0dcf907a81 >> # Parent adc78792781448aca7a1356bd253cbdd689839cb >> Fix MOF download location - URL permanently changed >> >> The MOF file download location has permanently changed as illustrated by >> the following message at build time: >> >> wget http://www.dmtf.org/standards/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip >> --2011-09-22 20:51:15-- http://www.dmtf.org/standards/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip >> Resolving www.dmtf.org... 72.47.221.139 >> Connecting to www.dmtf.org|72.47.221.139|:80... connected. >> HTTP request sent, awaiting response... 301 Moved Permanently >> Location: http://www.dmtf.org/sites/default/files/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip [following] >> >> Signed-off-by: Chip Vincent >> >> diff --git a/base_schema/Makefile.am b/base_schema/Makefile.am >> --- a/base_schema/Makefile.am >> +++ b/base_schema/Makefile.am >> @@ -8,6 +8,6 @@ >> dist_pkgdata_SCRIPTS = install_base_schema.sh >> >> $(CIM_SCHEMA_ZIP): >> - wget http://www.dmtf.org/standards/cim/cim_schema_v$(CIM_SCHEMA_DIR)/$(CIM_SCHEMA_ZIP) >> + wget http://www.dmtf.org/sites/default/files/cim/cim_schema_v$(CIM_SCHEMA_DIR)/$(CIM_SCHEMA_ZIP) >> > > Again, this is another example of what I consider 'simple enough' and > could be pushed without review. Patch would go to the list anyway, but > more as a heads-up to other developers. > > +1 > > [etrunko at eblima base_schema]$ make > wget > http://www.dmtf.org/sites/default/files/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip > --2011-09-28 11:43:25-- > http://www.dmtf.org/sites/default/files/cim/cim_schema_v2210/cim_schema_2.21.0Experimental-MOFs.zip > Resolving www.dmtf.org... 72.47.221.139 > Connecting to www.dmtf.org|72.47.221.139|:80... connected. > HTTP request sent, awaiting response... 200 OK > Length: 1888838 (1.8M) [application/zip] > Saving to: ?cim_schema_2.21.0Experimental-MOFs.zip? > > 100%[=========================================================================================================================================>] > 1,888,838 632K/s in 2.9s > > 2011-09-28 11:43:29 (632 KB/s) - > ?cim_schema_2.21.0Experimental-MOFs.zip? saved [1888838/1888838] > -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent at linux.vnet.ibm.com From eblima at linux.vnet.ibm.com Wed Sep 28 15:41:41 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 28 Sep 2011 12:41:41 -0300 Subject: [Libvirt-cim] [PATCH] #2 ACL: Add KVM_FilterEntry class Message-ID: <536f49720a45b08e30d9.1317224501@eblima.br.ibm.com> schema/FilterEntry.mof | 30 ++++ schema/FilterEntry.registration | 1 + src/Virt_EntriesInFilterList.c | 1 + src/Virt_FilterEntry.c | 245 ++++++++++++++------------------------- 4 files changed, 122 insertions(+), 155 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) # Date 1315334426 10800 # Node ID 536f49720a45b08e30d97fc25ccad3a83e86bfb5 # Parent db809376d763493849c2a19f587969eaec619b75 ACL: Add KVM_FilterEntry class This is the generic rule meant to match simple rules such the one in 'allow-arp' filter. For instance: 15fea95d-4300-19ea-2685-5f1b14c6759b This patch also refactors the provider code to share the conversion of common properties between the various types of filter entries. Changes since #1: - Respect 80 columns limit Signed-off-by: Eduardo Lima (Etrunko) diff --git a/schema/FilterEntry.mof b/schema/FilterEntry.mof --- a/schema/FilterEntry.mof +++ b/schema/FilterEntry.mof @@ -74,3 +74,33 @@ MaxValue(1000)] uint16 Priority = 500; }; + +[Provider("cmpi::Virt_FilterEntry")] +class KVM_FilterEntry : CIM_FilterEntry +{ + [Description("This defines whether the Filter is used for input, " + "output, or both input and output filtering. All values are " + "used with respect to the interface for which the Filter " + "applies. \"Not Applicable\" (0) is used when there is no " + "direction applicable to the Filter. \"Input\" (1) is " + "used when the Filter applies to packets that are inbound " + "on the related interface. \"Output\" (2) is used when the " + "Filter applies to packets that are outbound on the " + "related interface. \"Both\" (3) is used to indicate that " + "the direction is immaterial, e.g., to filter on a source " + "subnet regardless of whether the flow is inbound or " + "outbound."), + ValueMap { "0", "1", "2", "3", "4" }, + Values { "Not Applicable", "Input, Output", "Both", "Mirrored" }] + uint16 Direction; + + [Description("The priority of the rule controls the order in which " + "the rule will be, instantiated relative to other rules. " + "Rules with lower value will be instantiated and therefore " + "evaluated before rules with higher value. Valid values are " + "in the range of 0 to 1000. If this attribute is not " + "provided, the value 500 will automatically be assigned."), + MinValue(0), + MaxValue(1000)] + uint16 Priority = 500; +}; diff --git a/schema/FilterEntry.registration b/schema/FilterEntry.registration --- a/schema/FilterEntry.registration +++ b/schema/FilterEntry.registration @@ -2,3 +2,4 @@ # Classname Namespace ProviderName ProviderModule ProviderTypes KVM_Hdr8021Filter root/virt Virt_FilterEntry Virt_FilterEntry instance KVM_IPHeadersFilter root/virt Virt_FilterEntry Virt_FilterEntry instance +KVM_FilterEntry root/virt Virt_FilterEntry Virt_FilterEntry instance diff --git a/src/Virt_EntriesInFilterList.c b/src/Virt_EntriesInFilterList.c --- a/src/Virt_EntriesInFilterList.c +++ b/src/Virt_EntriesInFilterList.c @@ -160,6 +160,7 @@ }; static char *part_component[] = { + "KVM_FilterEntry", "KVM_Hdr8021Filter", "KVM_IPHeadersFilter", NULL diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -36,23 +36,6 @@ const static CMPIBroker *_BROKER; -static bool is_mac_rule(int type) -{ - if (type == MAC_RULE || type == ARP_RULE) - return 1; - - return 0; -} - -static bool is_ip_rule(int type) -{ - if (type == IP_RULE || type == TCP_RULE || type == ICMP_RULE || - type == IGMP_RULE) - return 1; - - return 0; -} - static int octets_from_mac(const char * s, unsigned int *buffer, unsigned int size) { @@ -172,59 +155,15 @@ return action; } -static CMPIInstance *convert_mac_rule_to_instance( +static void convert_mac_rule_to_instance( struct acl_rule *rule, - const CMPIBroker *broker, - const CMPIContext *context, - const CMPIObjectPath *reference, - CMPIStatus *s) + CMPIInstance *inst, + const CMPIBroker *broker) { - CMPIInstance *inst = NULL; - const char *sys_name = NULL; - const char *sys_ccname = NULL; - int action, direction, priority = 0; unsigned int bytes[48]; unsigned int size = 0; CMPIArray *array = NULL; - inst = get_typed_instance(broker, - CLASSNAME(reference), - "Hdr8021Filter", - NAMESPACE(reference)); - if (inst == NULL) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get 8021 filter instance"); - - goto out; - } - - *s = get_host_system_properties(&sys_name, - &sys_ccname, - reference, - broker, - context); - - if (s->rc != CMPI_RC_OK) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get host attributes"); - goto out; - } - - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); - - action = convert_action(rule->action); - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); - - direction = convert_direction(rule->direction); - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); - - priority = convert_priority(rule->priority); - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); - memset(bytes, 0, sizeof(bytes)); size = octets_from_mac(rule->var.mac.srcmacaddr, bytes, sizeof(bytes)); @@ -260,64 +199,18 @@ if (array != NULL) CMSetProperty(inst, "HdrDestMACMask8021", (CMPIValue *) (CMPIValue *)&array, CMPI_uint8A); - - out: - return inst; } -static CMPIInstance *convert_ip_rule_to_instance( +static void convert_ip_rule_to_instance( struct acl_rule *rule, - const CMPIBroker *broker, - const CMPIContext *context, - const CMPIObjectPath *reference, - CMPIStatus *s) + CMPIInstance *inst, + const CMPIBroker *broker) { - CMPIInstance *inst = NULL; - const char *sys_name = NULL; - const char *sys_ccname = NULL; - int action, direction, priority = 0; unsigned int bytes[48]; unsigned int size = 0; unsigned int n = 0; CMPIArray *array = NULL; - inst = get_typed_instance(broker, - CLASSNAME(reference), - "IPHeadersFilter", - NAMESPACE(reference)); - if (inst == NULL) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get ip headers filter instance"); - goto out; - } - - *s = get_host_system_properties(&sys_name, - &sys_ccname, - reference, - broker, - context); - - if (s->rc != CMPI_RC_OK) { - cu_statusf(broker, s, - CMPI_RC_ERR_FAILED, - "Unable to get host attributes"); - goto out; - } - - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); - - action = convert_action(rule->action); - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); - - direction = convert_direction(rule->direction); - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); - - priority = convert_priority(rule->priority); - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); - if (strstr(rule->protocol_id, "v6")) n = 6; else @@ -427,8 +320,6 @@ } } - out: - return inst; } static CMPIInstance *convert_rule_to_instance( @@ -438,27 +329,79 @@ const CMPIObjectPath *reference, CMPIStatus *s) { - CMPIInstance *instance = NULL; + CMPIInstance *inst = NULL; + const char *sys_name = NULL; + const char *sys_ccname = NULL; + const char *basename = NULL; + int action, direction, priority = 0; + + void (*convert_f)(struct acl_rule*, CMPIInstance*, const CMPIBroker*); if (rule == NULL) return NULL; - if(is_mac_rule(rule->type)) { - instance = convert_mac_rule_to_instance(rule, - broker, - context, - reference, - s); - } - else if(is_ip_rule(rule->type)) { - instance = convert_ip_rule_to_instance(rule, - broker, - context, - reference, - s); + switch (rule->type) { + case MAC_RULE: + case ARP_RULE: + basename = "Hdr8021Filter"; + convert_f = convert_mac_rule_to_instance; + break; + case IP_RULE: + case TCP_RULE: + case ICMP_RULE: + case IGMP_RULE: + basename = "IPHeadersFilter"; + convert_f = convert_ip_rule_to_instance; + break; + default: + basename = "FilterEntry"; + convert_f = NULL; + break; } - return instance; + inst = get_typed_instance(broker, + CLASSNAME(reference), + basename, + NAMESPACE(reference)); + + if (inst == NULL) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get filter entry instance"); + goto out; + } + + *s = get_host_system_properties(&sys_name, + &sys_ccname, + reference, + broker, + context); + + if (s->rc != CMPI_RC_OK) { + cu_statusf(broker, s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; + } + + CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); + CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); + CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); + + action = convert_action(rule->action); + CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); + + direction = convert_direction(rule->direction); + CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); + + priority = convert_priority(rule->priority); + CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); + + if (convert_f) + convert_f(rule, inst, broker); + + out: + return inst; } CMPIStatus enum_filter_rules( @@ -475,10 +418,19 @@ CU_DEBUG("Reference = %s", REF2STR(reference)); - if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) + if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) { class_type = MAC; - else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) + } else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) { class_type = IP; + } else if (STREQC(CLASSNAME(reference), "KVM_FilterEntry")) { + class_type = NONE; + } else { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unrecognized class type"); + goto out; + } + conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s); if (conn == NULL) @@ -490,29 +442,12 @@ for (j = 0; j < filters[i].rule_ct; j++) { CMPIInstance *instance = NULL; - if (((class_type == NONE) || - (class_type == MAC)) && - is_mac_rule(filters[i].rules[j]->type)) { - instance = convert_mac_rule_to_instance( - filters[i].rules[j], - broker, - context, - reference, - &s); - } - else if (((class_type == NONE) || - (class_type == IP)) && - is_ip_rule(filters[i].rules[j]->type)) { - instance = convert_ip_rule_to_instance( - filters[i].rules[j], - broker, - context, - reference, - &s); - } - else - CU_DEBUG("Unrecognized rule type %u", - filters[i].rules[j]->type); + instance = convert_rule_to_instance( + filters[i].rules[j], + broker, + context, + reference, + &s); if (instance != NULL) inst_list_add(list, instance); From cvincent at linux.vnet.ibm.com Wed Sep 28 16:19:48 2011 From: cvincent at linux.vnet.ibm.com (Chip Vincent) Date: Wed, 28 Sep 2011 12:19:48 -0400 Subject: [Libvirt-cim] [PATCH] #2 ACL: Add KVM_FilterEntry class In-Reply-To: <536f49720a45b08e30d9.1317224501@eblima.br.ibm.com> References: <536f49720a45b08e30d9.1317224501@eblima.br.ibm.com> Message-ID: <4E834924.7060209@linux.vnet.ibm.com> +1 and pushed. On 09/28/2011 11:41 AM, Eduardo Lima (Etrunko) wrote: > schema/FilterEntry.mof | 30 ++++ > schema/FilterEntry.registration | 1 + > src/Virt_EntriesInFilterList.c | 1 + > src/Virt_FilterEntry.c | 245 ++++++++++++++------------------------- > 4 files changed, 122 insertions(+), 155 deletions(-) > > > # HG changeset patch > # User Eduardo Lima (Etrunko) > # Date 1315334426 10800 > # Node ID 536f49720a45b08e30d97fc25ccad3a83e86bfb5 > # Parent db809376d763493849c2a19f587969eaec619b75 > ACL: Add KVM_FilterEntry class > > This is the generic rule meant to match simple rules such the one in > 'allow-arp' filter. For instance: > > > 15fea95d-4300-19ea-2685-5f1b14c6759b > > > > This patch also refactors the provider code to share the conversion of > common properties between the various types of filter entries. > > Changes since #1: > - Respect 80 columns limit > > Signed-off-by: Eduardo Lima (Etrunko) > > diff --git a/schema/FilterEntry.mof b/schema/FilterEntry.mof > --- a/schema/FilterEntry.mof > +++ b/schema/FilterEntry.mof > @@ -74,3 +74,33 @@ > MaxValue(1000)] > uint16 Priority = 500; > }; > + > +[Provider("cmpi::Virt_FilterEntry")] > +class KVM_FilterEntry : CIM_FilterEntry > +{ > + [Description("This defines whether the Filter is used for input, " > + "output, or both input and output filtering. All values are " > + "used with respect to the interface for which the Filter " > + "applies. \"Not Applicable\" (0) is used when there is no " > + "direction applicable to the Filter. \"Input\" (1) is " > + "used when the Filter applies to packets that are inbound " > + "on the related interface. \"Output\" (2) is used when the " > + "Filter applies to packets that are outbound on the " > + "related interface. \"Both\" (3) is used to indicate that " > + "the direction is immaterial, e.g., to filter on a source " > + "subnet regardless of whether the flow is inbound or " > + "outbound."), > + ValueMap { "0", "1", "2", "3", "4" }, > + Values { "Not Applicable", "Input, Output", "Both", "Mirrored" }] > + uint16 Direction; > + > + [Description("The priority of the rule controls the order in which " > + "the rule will be, instantiated relative to other rules. " > + "Rules with lower value will be instantiated and therefore " > + "evaluated before rules with higher value. Valid values are " > + "in the range of 0 to 1000. If this attribute is not " > + "provided, the value 500 will automatically be assigned."), > + MinValue(0), > + MaxValue(1000)] > + uint16 Priority = 500; > +}; > diff --git a/schema/FilterEntry.registration b/schema/FilterEntry.registration > --- a/schema/FilterEntry.registration > +++ b/schema/FilterEntry.registration > @@ -2,3 +2,4 @@ > # Classname Namespace ProviderName ProviderModule ProviderTypes > KVM_Hdr8021Filter root/virt Virt_FilterEntry Virt_FilterEntry instance > KVM_IPHeadersFilter root/virt Virt_FilterEntry Virt_FilterEntry instance > +KVM_FilterEntry root/virt Virt_FilterEntry Virt_FilterEntry instance > diff --git a/src/Virt_EntriesInFilterList.c b/src/Virt_EntriesInFilterList.c > --- a/src/Virt_EntriesInFilterList.c > +++ b/src/Virt_EntriesInFilterList.c > @@ -160,6 +160,7 @@ > }; > > static char *part_component[] = { > + "KVM_FilterEntry", > "KVM_Hdr8021Filter", > "KVM_IPHeadersFilter", > NULL > diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c > --- a/src/Virt_FilterEntry.c > +++ b/src/Virt_FilterEntry.c > @@ -36,23 +36,6 @@ > > const static CMPIBroker *_BROKER; > > -static bool is_mac_rule(int type) > -{ > - if (type == MAC_RULE || type == ARP_RULE) > - return 1; > - > - return 0; > -} > - > -static bool is_ip_rule(int type) > -{ > - if (type == IP_RULE || type == TCP_RULE || type == ICMP_RULE || > - type == IGMP_RULE) > - return 1; > - > - return 0; > -} > - > static int octets_from_mac(const char * s, unsigned int *buffer, > unsigned int size) > { > @@ -172,59 +155,15 @@ > return action; > } > > -static CMPIInstance *convert_mac_rule_to_instance( > +static void convert_mac_rule_to_instance( > struct acl_rule *rule, > - const CMPIBroker *broker, > - const CMPIContext *context, > - const CMPIObjectPath *reference, > - CMPIStatus *s) > + CMPIInstance *inst, > + const CMPIBroker *broker) > { > - CMPIInstance *inst = NULL; > - const char *sys_name = NULL; > - const char *sys_ccname = NULL; > - int action, direction, priority = 0; > unsigned int bytes[48]; > unsigned int size = 0; > CMPIArray *array = NULL; > > - inst = get_typed_instance(broker, > - CLASSNAME(reference), > - "Hdr8021Filter", > - NAMESPACE(reference)); > - if (inst == NULL) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get 8021 filter instance"); > - > - goto out; > - } > - > - *s = get_host_system_properties(&sys_name, > -&sys_ccname, > - reference, > - broker, > - context); > - > - if (s->rc != CMPI_RC_OK) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get host attributes"); > - goto out; > - } > - > - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); > - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); > - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); > - > - action = convert_action(rule->action); > - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); > - > - direction = convert_direction(rule->direction); > - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); > - > - priority = convert_priority(rule->priority); > - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); > - > memset(bytes, 0, sizeof(bytes)); > size = octets_from_mac(rule->var.mac.srcmacaddr, > bytes, sizeof(bytes)); > @@ -260,64 +199,18 @@ > if (array != NULL) > CMSetProperty(inst, "HdrDestMACMask8021", (CMPIValue *) > (CMPIValue *)&array, CMPI_uint8A); > - > - out: > - return inst; > } > > -static CMPIInstance *convert_ip_rule_to_instance( > +static void convert_ip_rule_to_instance( > struct acl_rule *rule, > - const CMPIBroker *broker, > - const CMPIContext *context, > - const CMPIObjectPath *reference, > - CMPIStatus *s) > + CMPIInstance *inst, > + const CMPIBroker *broker) > { > - CMPIInstance *inst = NULL; > - const char *sys_name = NULL; > - const char *sys_ccname = NULL; > - int action, direction, priority = 0; > unsigned int bytes[48]; > unsigned int size = 0; > unsigned int n = 0; > CMPIArray *array = NULL; > > - inst = get_typed_instance(broker, > - CLASSNAME(reference), > - "IPHeadersFilter", > - NAMESPACE(reference)); > - if (inst == NULL) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get ip headers filter instance"); > - goto out; > - } > - > - *s = get_host_system_properties(&sys_name, > -&sys_ccname, > - reference, > - broker, > - context); > - > - if (s->rc != CMPI_RC_OK) { > - cu_statusf(broker, s, > - CMPI_RC_ERR_FAILED, > - "Unable to get host attributes"); > - goto out; > - } > - > - CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); > - CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); > - CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); > - > - action = convert_action(rule->action); > - CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); > - > - direction = convert_direction(rule->direction); > - CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); > - > - priority = convert_priority(rule->priority); > - CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); > - > if (strstr(rule->protocol_id, "v6")) > n = 6; > else > @@ -427,8 +320,6 @@ > } > } > > - out: > - return inst; > } > > static CMPIInstance *convert_rule_to_instance( > @@ -438,27 +329,79 @@ > const CMPIObjectPath *reference, > CMPIStatus *s) > { > - CMPIInstance *instance = NULL; > + CMPIInstance *inst = NULL; > + const char *sys_name = NULL; > + const char *sys_ccname = NULL; > + const char *basename = NULL; > + int action, direction, priority = 0; > + > + void (*convert_f)(struct acl_rule*, CMPIInstance*, const CMPIBroker*); > > if (rule == NULL) > return NULL; > > - if(is_mac_rule(rule->type)) { > - instance = convert_mac_rule_to_instance(rule, > - broker, > - context, > - reference, > - s); > - } > - else if(is_ip_rule(rule->type)) { > - instance = convert_ip_rule_to_instance(rule, > - broker, > - context, > - reference, > - s); > + switch (rule->type) { > + case MAC_RULE: > + case ARP_RULE: > + basename = "Hdr8021Filter"; > + convert_f = convert_mac_rule_to_instance; > + break; > + case IP_RULE: > + case TCP_RULE: > + case ICMP_RULE: > + case IGMP_RULE: > + basename = "IPHeadersFilter"; > + convert_f = convert_ip_rule_to_instance; > + break; > + default: > + basename = "FilterEntry"; > + convert_f = NULL; > + break; > } > > - return instance; > + inst = get_typed_instance(broker, > + CLASSNAME(reference), > + basename, > + NAMESPACE(reference)); > + > + if (inst == NULL) { > + cu_statusf(broker, s, > + CMPI_RC_ERR_FAILED, > + "Unable to get filter entry instance"); > + goto out; > + } > + > + *s = get_host_system_properties(&sys_name, > +&sys_ccname, > + reference, > + broker, > + context); > + > + if (s->rc != CMPI_RC_OK) { > + cu_statusf(broker, s, > + CMPI_RC_ERR_FAILED, > + "Unable to get host attributes"); > + goto out; > + } > + > + CMSetProperty(inst, "SystemName", sys_name, CMPI_chars); > + CMSetProperty(inst, "SystemCreationClassName", sys_ccname, CMPI_chars); > + CMSetProperty(inst, "Name", (CMPIValue *)rule->name, CMPI_chars); > + > + action = convert_action(rule->action); > + CMSetProperty(inst, "Action", (CMPIValue *)&action, CMPI_uint16); > + > + direction = convert_direction(rule->direction); > + CMSetProperty(inst, "Direction", (CMPIValue *)&direction, CMPI_uint16); > + > + priority = convert_priority(rule->priority); > + CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); > + > + if (convert_f) > + convert_f(rule, inst, broker); > + > + out: > + return inst; > } > > CMPIStatus enum_filter_rules( > @@ -475,10 +418,19 @@ > > CU_DEBUG("Reference = %s", REF2STR(reference)); > > - if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) > + if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) { > class_type = MAC; > - else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) > + } else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) { > class_type = IP; > + } else if (STREQC(CLASSNAME(reference), "KVM_FilterEntry")) { > + class_type = NONE; > + } else { > + cu_statusf(broker,&s, > + CMPI_RC_ERR_FAILED, > + "Unrecognized class type"); > + goto out; > + } > + > > conn = connect_by_classname(_BROKER, CLASSNAME(reference),&s); > if (conn == NULL) > @@ -490,29 +442,12 @@ > for (j = 0; j< filters[i].rule_ct; j++) { > CMPIInstance *instance = NULL; > > - if (((class_type == NONE) || > - (class_type == MAC))&& > - is_mac_rule(filters[i].rules[j]->type)) { > - instance = convert_mac_rule_to_instance( > - filters[i].rules[j], > - broker, > - context, > - reference, > -&s); > - } > - else if (((class_type == NONE) || > - (class_type == IP))&& > - is_ip_rule(filters[i].rules[j]->type)) { > - instance = convert_ip_rule_to_instance( > - filters[i].rules[j], > - broker, > - context, > - reference, > -&s); > - } > - else > - CU_DEBUG("Unrecognized rule type %u", > - filters[i].rules[j]->type); > + instance = convert_rule_to_instance( > + filters[i].rules[j], > + broker, > + context, > + reference, > +&s); > > if (instance != NULL) > inst_list_add(list, 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 eblima at linux.vnet.ibm.com Wed Sep 28 18:21:10 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 28 Sep 2011 15:21:10 -0300 Subject: [Libvirt-cim] [PATCH] device_parsing: Use default values for vnc graphics device Message-ID: <2313e472149a55714322.1317234070@eblima.br.ibm.com> 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"); From eblima at linux.vnet.ibm.com Wed Sep 28 20:44:07 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 28 Sep 2011 17:44:07 -0300 Subject: [Libvirt-cim] [PATCH] VirtualSystemManagementService: Avoid extra connection to libvirt Message-ID: 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); From eblima at linux.vnet.ibm.com Wed Sep 28 20:52:57 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Wed, 28 Sep 2011 17:52:57 -0300 Subject: [Libvirt-cim] [PATCH] device_parsing: Small code cleanup Message-ID: <4e1f0b6dc5e512d98b82.1317243177@eblima.br.ibm.com> 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); From xiawenc at linux.vnet.ibm.com Thu Sep 29 06:30:11 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 29 Sep 2011 14:30:11 +0800 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: <4E841073.6000902@linux.vnet.ibm.com> Seems fine, "-1" would let the VM itself find out which port it would use. in virsh, dumpxml could used to see the real port that vm have used, different from the definition xml with "-1", so I think in future some logic could be added if user want to see which port an active domain with "-1" port defintiion have used. Reviewed-by: Wayne Xia ? 2011-9-29 2:21, Eduardo Lima (Etrunko) ??: > 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 -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From xiawenc at linux.vnet.ibm.com Thu Sep 29 06:37:28 2011 From: xiawenc at linux.vnet.ibm.com (Wayne Xia) Date: Thu, 29 Sep 2011 14:37:28 +0800 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: <4E841228.50402@linux.vnet.ibm.com> seems fine, if compilation pass, there would be no more impact to other code for a static function changing. ? 2011-9-29 4:52, Eduardo Lima (Etrunko) ??: > 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 -- Best Regards Wayne Xia mail:xiawenc at linux.vnet.ibm.com tel:86-010-82450803 From eblima at linux.vnet.ibm.com Fri Sep 30 18:59:40 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 30 Sep 2011 15:59:40 -0300 Subject: [Libvirt-cim] [PATCH 0 of 2] [TEST] VSMS: ModifyResourceSettings to change cdrom media Message-ID: 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(-) From eblima at linux.vnet.ibm.com Fri Sep 30 18:59:42 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 30 Sep 2011 15:59:42 -0300 Subject: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain In-Reply-To: References: Message-ID: 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') From eblima at linux.vnet.ibm.com Fri Sep 30 18:59:41 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 30 Sep 2011 15:59:41 -0300 Subject: [Libvirt-cim] [PATCH 1 of 2] [TEST] 32_modify_cdrom_media.py: new test for VirtualSystemManagementService In-Reply-To: References: Message-ID: <85c624ef88f4e1487f95.1317409181@eblima.br.ibm.com> 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) From eblima at linux.vnet.ibm.com Fri Sep 30 19:09:24 2011 From: eblima at linux.vnet.ibm.com (Eduardo Lima (Etrunko)) Date: Fri, 30 Sep 2011 16:09:24 -0300 Subject: [Libvirt-cim] [PATCH 0 of 2] [TEST] VSMS: ModifyResourceSettings to change cdrom media In-Reply-To: References: Message-ID: <4E8613E4.4020601@linux.vnet.ibm.com> The iso files used in this test can be found attached to this email and must be placed in /var/lib/libvirt/images. Best regards, -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima at br.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: media.tar.bz2 Type: application/x-bzip Size: 1120 bytes Desc: not available URL: