From cngesaint at outlook.com Thu May 2 07:10:55 2013 From: cngesaint at outlook.com (Xu Wang) Date: Thu, 2 May 2013 15:10:55 +0800 Subject: [Libvirt-cim] [PATCH V2 0/3] libvirt-cim patches Message-ID: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> V2 updates: 1. adjust comments for force use qemu (disable kvm under nested kvm) 2. fix the problem of cdrom (with blank or null disk) VSMS patch caused in V1 3. fix syntax errors for comments 4. status return updates 5. add description about 8 maximum items limits about vsi support output Wenchao Xia (1): make force use qemu configurable Xu Wang (2): VSMS: tip error for invalid disk resource make lldptool command and support output configurable libvirt-cim.conf | 26 ++++++++++ libxkutil/misc_util.c | 26 ++++++++++ libxkutil/misc_util.h | 3 + src/Virt_SwitchService.c | 66 ++++++++++++++++++++---- src/Virt_VirtualSystemManagementService.c | 77 ++++++++++++++++++++++------- 5 files changed, 168 insertions(+), 30 deletions(-) From cngesaint at outlook.com Thu May 2 07:10:56 2013 From: cngesaint at outlook.com (Xu Wang) Date: Thu, 2 May 2013 15:10:56 +0800 Subject: [Libvirt-cim] [PATCH V2 1/3] make force use qemu configurable In-Reply-To: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> Message-ID: <1367478658-17026-2-git-send-email-cngesaint@outlook.com> From: Wenchao Xia Since in nested KVM, libvirt-cim doesn't handler it well now, so add this option to manually disable KVM and fall back to qemu. If there is something fail caused by nested KVM happend, please consider to set this option to be true for development and testing. Signed-off-by: Xu Wang --- libvirt-cim.conf | 10 ++++++++++ libxkutil/misc_util.c | 8 ++++++++ libxkutil/misc_util.h | 1 + src/Virt_VirtualSystemManagementService.c | 7 +++++++ 4 files changed, 26 insertions(+), 0 deletions(-) diff --git a/libvirt-cim.conf b/libvirt-cim.conf index 37d7b0f..f378e4c 100644 --- a/libvirt-cim.conf +++ b/libvirt-cim.conf @@ -30,3 +30,13 @@ # Default value: NULL, that is not set. # # migrate_ssh_temp_key = "/root/vm_migrate_tmp_id_rsa"; + +# force_use_qemu (bool) +# Since in nested KVM, libvirt-cim doesn't handler it well now, so add this +# option to manually disable KVM and fall back to qemu. If there is something +# fail caused by nested KVM happend, please consider to set this option to be +# true for development and testing. +# Possible values: {true,false} +# Default value: false +# +# force_use_qemu = false; diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 00eb4b1..4c0b0a1 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -227,6 +227,14 @@ static int is_read_only(void) return prop.value_bool; } +bool get_force_use_qemu(void) +{ + static LibvirtcimConfigProperty prop = { + "force_use_qemu", CONFIG_BOOL, {0}, 0}; + libvirt_cim_config_get(&prop); + return prop.value_bool; +} + const char *get_mig_ssh_tmp_key(void) { static LibvirtcimConfigProperty prop = { diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h index 0f52290..9e6b419 100644 --- a/libxkutil/misc_util.h +++ b/libxkutil/misc_util.h @@ -154,6 +154,7 @@ int virt_set_status(const CMPIBroker *broker, /* get libvirt-cim config */ const char *get_mig_ssh_tmp_key(void); +bool get_force_use_qemu(void); /* * Local Variables: diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index cbb646d..81ec064 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -394,6 +394,13 @@ static bool system_has_kvm(const char *pfx) virConnectPtr conn; char *caps = NULL; bool kvm = false; + bool force_use_qemu = get_force_use_qemu(); + + /* sometimes disable KVM to avoid problem in nested KVM */ + if (force_use_qemu) { + CU_DEBUG("Enter force use qemu mode!"); + return false; + } conn = connect_by_classname(_BROKER, pfx, &s); if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { -- 1.7.1 From cngesaint at outlook.com Thu May 2 07:10:57 2013 From: cngesaint at outlook.com (Xu Wang) Date: Thu, 2 May 2013 15:10:57 +0800 Subject: [Libvirt-cim] [PATCH V2 2/3] VSMS: tip error for invalid disk resource In-Reply-To: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> Message-ID: <1367478658-17026-3-git-send-email-cngesaint@outlook.com> Original code will report xml text missing when a disk is not accessable, make user confuse. This patch will report the real error to tip user check its system health state on the server. Signed-off-by: Xu Wang --- src/Virt_VirtualSystemManagementService.c | 70 +++++++++++++++++++++-------- 1 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 81ec064..1652cf2 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -964,11 +964,13 @@ static const char *net_rasd_to_vdev(CMPIInstance *inst, } static const char *disk_rasd_to_vdev(CMPIInstance *inst, - struct virt_device *dev) + struct virt_device *dev, + char **p_error) { const char *val = NULL; uint16_t type; bool read = false; + int rc; CU_DEBUG("Enter disk_rasd_to_vdev"); if (cu_get_str_prop(inst, "VirtualDevice", &val) != CMPI_RC_OK) @@ -984,6 +986,18 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, dev->dev.disk.source = strdup(val); dev->dev.disk.disk_type = disk_type_from_file(val); + if ((!XSTREQ(dev->dev.disk.source, "/dev/null")) && (dev->dev.disk.disk_type == DISK_UNKNOWN)) { + /* on success or fail caller should try free it */ + rc = asprintf(p_error, "Device %s, Address %s, " + "make sure Address can be accessed on host system.", + dev->dev.disk.virtual_dev, dev->dev.disk.source); + if (rc == -1) { + CU_DEBUG("error during recording exception!"); + p_error = NULL; + } + return "Can't get a valid disk type, "; + } + if (cu_get_u16_prop(inst, "EmulatedType", &type) != CMPI_RC_OK) type = VIRT_DISK_TYPE_DISK; @@ -1452,10 +1466,11 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, - const char *ns) + const char *ns, + char **p_error) { if (type == CIM_RES_TYPE_DISK) { - return disk_rasd_to_vdev(inst, dev); + return disk_rasd_to_vdev(inst, dev, p_error); } else if (type == CIM_RES_TYPE_NET) { return net_rasd_to_vdev(inst, dev, ns); } else if (type == CIM_RES_TYPE_MEM) { @@ -1494,7 +1509,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, static const char *rasd_to_vdev(CMPIInstance *inst, struct domain *domain, struct virt_device *dev, - const char *ns) + const char *ns, + char **p_error) { uint16_t type; CMPIObjectPath *op; @@ -1516,7 +1532,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, if (domain->type == DOMAIN_LXC) msg = _container_rasd_to_vdev(inst, dev, type, ns); else - msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns); + msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns, p_error); out: if (msg && op) CU_DEBUG("rasd_to_vdev(%s): %s", CLASSNAME(op), msg); @@ -1560,7 +1576,8 @@ static char *add_device_nodup(struct virt_device *dev, static const char *classify_resources(CMPIArray *resources, const char *ns, - struct domain *domain) + struct domain *domain, + char **p_error) { int i; uint16_t type; @@ -1613,13 +1630,15 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &domain->dev_vcpu[0], - ns); + ns, + p_error); } else if (type == CIM_RES_TYPE_MEM) { domain->dev_mem_ct = 1; msg = rasd_to_vdev(inst, domain, &domain->dev_mem[0], - ns); + ns, + p_error); } else if (type == CIM_RES_TYPE_DISK) { struct virt_device dev; int dcount = count + domain->dev_disk_ct; @@ -1628,7 +1647,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &dev, - ns); + ns, + p_error); if (msg == NULL) msg = add_device_nodup(&dev, domain->dev_disk, @@ -1646,7 +1666,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &dev, - ns); + ns, + p_error); if (msg == NULL) msg = add_device_nodup(&dev, domain->dev_net, @@ -1676,7 +1697,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &dev, - ns); + ns, + p_error); if (msg == NULL) msg = add_device_nodup(&dev, domain->dev_graphics, @@ -1687,7 +1709,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &domain->dev_input[0], - ns); + ns, + p_error); } if (msg != NULL) return msg; @@ -2083,6 +2106,7 @@ static CMPIInstance *create_system(const CMPIContext *context, struct inst_list list; const char *props[] = {NULL}; struct domain *domain = NULL; + char *error_msg = NULL; inst_list_init(&list); @@ -2113,12 +2137,13 @@ static CMPIInstance *create_system(const CMPIContext *context, if (s->rc != CMPI_RC_OK) goto out; - msg = classify_resources(resources, NAMESPACE(ref), domain); + msg = classify_resources(resources, NAMESPACE(ref), domain, &error_msg); if (msg != NULL) { - CU_DEBUG("Failed to classify resources: %s", msg); + CU_DEBUG("Failed to classify resources: %s, %s", + msg, error_msg); cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED, - "ResourceSettings Error: %s", msg); + "ResourceSettings Error: %s, %s", msg, error_msg); goto out; } @@ -2159,6 +2184,7 @@ static CMPIInstance *create_system(const CMPIContext *context, out: + free(error_msg); cleanup_dominfo(&domain); free(xml); inst_list_free(&list); @@ -2638,6 +2664,7 @@ static CMPIStatus resource_add(struct domain *dominfo, struct virt_device *dev; int *count = NULL; const char *msg = NULL; + char *error_msg = NULL; op = CMGetObjectPath(rasd, &s); if ((op == NULL) || (s.rc != CMPI_RC_OK)) @@ -2677,12 +2704,12 @@ static CMPIStatus resource_add(struct domain *dominfo, dev = &list[*count]; dev->type = type; - msg = rasd_to_vdev(rasd, dominfo, dev, ns); + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); if (msg != NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Add resource failed: %s", - msg); + "Add resource failed: %s, %s", + msg, error_msg); goto out; } @@ -2702,6 +2729,8 @@ static CMPIStatus resource_add(struct domain *dominfo, (*count)++; out: + free(error_msg); + return s; } @@ -2718,6 +2747,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, int *count; int i; const char *msg = NULL; + char *error_msg = NULL; CU_DEBUG("Enter resource_mod"); if (devid == NULL) { @@ -2749,7 +2779,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, struct virt_device *dev = &list[i]; if (STREQ(dev->id, devid)) { - msg = rasd_to_vdev(rasd, dominfo, dev, ns); + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); if (msg != NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -2793,6 +2823,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, } out: + free(error_msg); + return s; } -- 1.7.1 From cngesaint at outlook.com Thu May 2 07:10:58 2013 From: cngesaint at outlook.com (Xu Wang) Date: Thu, 2 May 2013 15:10:58 +0800 Subject: [Libvirt-cim] [PATCH V2 3/3] make lldptool command and support output configurable In-Reply-To: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> Message-ID: <1367478658-17026-4-git-send-email-cngesaint@outlook.com> if lldptool command or vsi support output updates, update items in the libvirt-cim.conf file. vsi support output could support maximum 8 items. Signed-off-by: Xu Wang --- libvirt-cim.conf | 16 +++++++++++ libxkutil/misc_util.c | 18 ++++++++++++ libxkutil/misc_util.h | 2 + src/Virt_SwitchService.c | 66 ++++++++++++++++++++++++++++++++++++++------- 4 files changed, 91 insertions(+), 11 deletions(-) diff --git a/libvirt-cim.conf b/libvirt-cim.conf index f378e4c..0e8f399 100644 --- a/libvirt-cim.conf +++ b/libvirt-cim.conf @@ -40,3 +40,19 @@ # Default value: false # # force_use_qemu = false; + +# lldptool_query_options (string) +# Defines the command used in SwitchService to query VEPA support, will be +# used as "lldptool -i [INTERFACE] [OPTIONS]" +# +# lldptool_query_options = "-t -g ncb -V evbcfg"; + +# vsi_support_key_string (string) +# Defines the string used in SwitchService to search in lldptool's output +# When lldptool updates its output, please set this value and update the +# output set, maximum 8 items. use comma to devide items. If there is +# no need to change the output set, please do not leave it void. Because +# this value has higher level than default. +# +# vsi_support_key_string = "{ supported forwarding mode: (0x40) reflective relay," +# " supported capabilities: (0x7) RTE ECP VDP}"; diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 4c0b0a1..6ce8dca 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -244,6 +244,24 @@ const char *get_mig_ssh_tmp_key(void) return prop.value_string; } +const char *get_lldptool_query_options(void) +{ + static LibvirtcimConfigProperty prop = { + "lldptool_query_options", CONFIG_STRING, {0}, 0}; + + libvirt_cim_config_get(&prop); + return prop.value_string; +} + +const char *get_vsi_support_key_string(void) +{ + static LibvirtcimConfigProperty prop = { + "vsi_support_key_string", CONFIG_STRING, {0}, 0};; + + libvirt_cim_config_get(&prop); + return prop.value_string; +} + virConnectPtr connect_by_classname(const CMPIBroker *broker, const char *classname, CMPIStatus *s) diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h index 9e6b419..4eb588d 100644 --- a/libxkutil/misc_util.h +++ b/libxkutil/misc_util.h @@ -155,6 +155,8 @@ int virt_set_status(const CMPIBroker *broker, /* get libvirt-cim config */ const char *get_mig_ssh_tmp_key(void); bool get_force_use_qemu(void); +const char *get_lldptool_query_options(void); +const char *get_vsi_support_key_string(void); /* * Local Variables: diff --git a/src/Virt_SwitchService.c b/src/Virt_SwitchService.c index 8991426..983ebc0 100644 --- a/src/Virt_SwitchService.c +++ b/src/Virt_SwitchService.c @@ -46,12 +46,29 @@ static CMPIStatus check_vsi_support(char *command) CMPIStatus s = {CMPI_RC_OK, NULL}; char buff[MAX_LEN]; FILE *stream = NULL; - const char *searchStr[] = {" supported forwarding mode: " - "(0x40) reflective relay", - " supported capabilities: " - "(0x07) RTE ECP VDP", - NULL}; - int matched = 0; + char *searchStr[8]; /* maximum items of vsi support output */ + int count = 0; + const char *user_settings = get_vsi_support_key_string(); + char *vsi_support_key_string = NULL; + char *delim = "{},"; + int matched = 0; + char *temp = NULL; + + if (!user_settings) { + /* default supported output set, 8 maximum */ + user_settings = "{ supported forwarding mode: " + "(0x40) reflective relay," + " supported capabilities: " + "(0x7) RTE ECP VDP}"; + } + + vsi_support_key_string = strdup(user_settings); + if (vsi_support_key_string == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Strdup vsi_support_key_string failed!"); + goto out; + } // Run lldptool command to find vsi support. stream = popen(command, "r"); @@ -63,6 +80,25 @@ static CMPIStatus check_vsi_support(char *command) goto out; } + /* Slice vsi_support_key_string into items */ + searchStr[count] = strtok_r(vsi_support_key_string, delim, &temp); + if (searchStr[count] == NULL) { + CU_DEBUG("searchStr fetch failed when calling strtok_r!"); + } else { + CU_DEBUG("searchStr[%d]: %s", count, searchStr[count]); + count++; + } + + while ((searchStr[count] = strtok_r(NULL, delim, &temp))) { + if (count >= 7) { + CU_DEBUG("WARN: searchStr is full, left aborted!"); + break; + } else { + CU_DEBUG("searchStr[%d]: %s", count, searchStr[count]); + count++; + } + } + // Read the output of the command. while (fgets(buff, MAX_LEN, stream) != NULL) { int i = 0; @@ -81,16 +117,18 @@ static CMPIStatus check_vsi_support(char *command) } /* All the search strings were found in the output of this command. */ - if (matched == 2) { + if (matched == count) { cu_statusf(_BROKER, &s, CMPI_RC_OK, "VSI supported"); - goto out;; + goto out; } } + cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, "No VSI Support found"); - out: + out: + free(vsi_support_key_string); if (stream != NULL) pclose(stream); return s; @@ -214,6 +252,7 @@ static CMPIStatus get_switchservice(const CMPIObjectPath *reference, int i; char **if_list; char cmd[MAX_LEN]; + const char *lldptool_query_options = NULL; *_inst = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); @@ -257,10 +296,15 @@ static CMPIStatus get_switchservice(const CMPIObjectPath *reference, CU_DEBUG("Found %d interfaces", count); + lldptool_query_options = get_lldptool_query_options(); + if (!lldptool_query_options) { + lldptool_query_options = "-t -g ncb -V evbcfg"; + } for (i=0; i References: <1366812554-6591-1-git-send-email-jferlan@redhat.com> Message-ID: <51825C06.3030606@redhat.com> On 04/28/2013 01:19 AM, WangXu wrote: > I have run cimtest with these 12 patches and they solved most of bugs > before. > However, I found some new FAIL cases. > 1. > -------------------------------------------------------------------- > HostSystem - 01_enum.py: FAIL > ERROR - Exp KVM_HostSystem, got KVM_HostSystem > ERROR - Exp localhost, got RH64wenchao > CIM_ERR_INVALID_CLASS: Linux_ComputerSystem > -------------------------------------------------------------------- > HostSystem - 03_hs_to_settdefcap.py: FAIL > ERROR - Hostname mismatch > -------------------------------------------------------------------- > Hostname mismatch because cimtest match localhost with RH64wenchao... > Could you find out what cause it and fix it? Not sure this has anything to do with my set of changes - seems more like a system configuration issue that since it's happening on your system is probably more easily debugged by you. Start in 01_enum.py and do various print's in order to figure out where issue is. My system config has an 'options.ip' = localhost and the return from "full_hostname" set to a "generated" name. I have nothing in my /etc/hosts nor in my /etc/sysconfig/network-scripts/* files. > > 2. > -------------------------------------------------------------------- > SwitchService - 01_enum.py: XFAIL > Please check if this is the expected result --- > *** VSI NOT supported *** > -------------------------------------------------------------------- > Why XFAIL but not SKIP here? My computer does not support it. Neither does mine, but XFAIL is the original design. > > 3. > -------------------------------------------------------------------- > VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL > ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal > error unable to execute QEMU command 'device_add': Bus 'pci.0' does not > support hotplugging") > ERROR - Error invoking AddRS: add_net_res > ERROR - AddResourceSettings call failed > ERROR - Failed to destroy Virtual Network 'my_network1' > InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) > device: internal error unable to execute QEMU command 'device_add': Bus > 'pci.0' does not support hotplugging > Bug:<00015> Unrelated to my changes. The only change I made to 22*.py was the 'test_mac' value. See more below though... > -------------------------------------------------------------------- > VirtualSystemManagementService - 30_dynamic_disk_mod.py: XFAIL > ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal > error unable to execute QEMU command 'device_add': Bus 'pci.0' does not > support hotplugging") > ERROR - Error invoking AddRS: add_disk_res > ERROR - AddResourceSettings call failed > InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) > device: internal error unable to execute QEMU command 'device_add': Bus > 'pci.0' does not support hotplugging I didn't make any changes here > -------------------------------------------------------------------- > I am sorry I don't clear what caused it. Same here :-) Although it seems as though the test is trying to add a disk to a pci.0 device/bus, but that addition is not supported for a running domain in the configuration provided by cimtest. It does make me wonder if these tests ever passed for KVM... Digging into the tests a bit, the failure for 22*.py comes as a result of a call to cimtest method 'add_net_res()'. There are two tests that call it. The other is VirtualSystemManagementService/06_addresource.py; however, there's a check in the 06*.py test which doesn't attempt the call when the domain is started, e.g.: if options.virt == "KVM": test_cases = ["define"] else: test_cases = ["define", "start"] Since test 22* attempts this call when things are started, it's a different path of support - namely 'hotplug'. After a bit of trial and error, I have a possible fix. I found that I had to change the domain configuration in the test to set "acpi=True". Then I had to change the 'add_net_res' code to query "source/@bridge" and not "source/@network" and compare against attr['virt_net'] and not attr['net_name']. The net_name (e.g. my_network1) is a network pool attribute not a domain network attribute. I'm really not sure this test worked or passed previously. I will dive into test 30*.py at some point in time. I did try the simple "acpi=True" change there, but that just caused other failures. > > 4. > -------------------------------------------------------------------- > VirtualSystemManagementService - 27_definesystem_macvtap_dev.py: FAIL > ERROR - Got CIM error CIM_ERR_FAILED: Unable to start domain: Unable > to get index for interface eth1: No such device with return code 1 > ERROR - Unable to start rstest_nic > InvokeMethod(RequestStateChange): CIM_ERR_FAILED: Unable to start domain: > Unable to get index for interface eth1: No such device > -------------------------------------------------------------------- > VirtualSystemManagementService - 28_definesystem_with_vsi_profile.py: XFAIL > ERROR - Got CIM error CIM_ERR_FAILED: Unable to start domain: Unable > to get index for interface eth1: No such device with return code 1 > ERROR - Unable to start VM *** Is VSI support available on this > host? *** > InvokeMethod(RequestStateChange): CIM_ERR_FAILED: Unable to start domain: > Unable to get index for interface eth1: No such device > -------------------------------------------------------------------- > This FAIL happens because there is no eth1 interface on my computer. The > name > of my network interface is "eth3". So I think it had better list all network > interfaces and pick available one for testing. For multicard machine > there are > some rule to choice one or...configure it manually? Correct - there is no method now to get a/the list of network interfaces and then "choose" a valid one to execute tests. To further muddy the waters the latest Fedora releases uses 'em#' instead of 'eth#' - the commit message from my change has a pointer to the details. For now though the values are hardcoded. It's something I'm sure I noted in one our exchanges already. John > >> From: jferlan at redhat.com >> To: libvirt-cim at redhat.com >> Date: Wed, 24 Apr 2013 10:09:02 -0400 >> Subject: [Libvirt-cim] [PATCH v2 00/12] cimtest updates >> >> This is primarily a repost of the previous series: >> >> https://www.redhat.com/archives/libvirt-cim/2013-March/msg00051.html >> >> and >> >> https://www.redhat.com/archives/libvirt-cim/2013-April/msg00014.html >> >> The primary difference in this patch vs. the previous sets is to fix the >> version string checking for nfs server checking in common_util.py and to >> add patch 12/12 which handles a problem in 'enum_volumes()' in pool.py. >> >> I assume patches 1-4 and 6-9 were reviewed without issue. So focus on 5/12 >> and 10-12/12. >> >> >> John Ferlan (12): >> Need to check "slp=true", not just "slp" since "slp=false" is possible >> Change the MAC from "99:" to "88:" >> Create a temporary directory for disk pool tests >> Use symbols as named in libvirt-cim for easier reference >> Fix nfs-server lookup code >> Fix os_status passing to reporter functions >> Resolve issues found in test. >> On Fedora systems default to using 'em1' instead of 'eth1' >> 19 - resolve issues found in test >> vxml: Add which volume could not be found to error message >> Add and utilize virsh_version_cmp >> pool: Need to handle when there are no volumes in the default pool >> >> .../Profile/04_verify_libvirt_cim_slp_profiles.py | 2 +- >> .../08_CreateDiskResourcePool.py | 30 +++++-- >> .../09_DeleteDiskPool.py | 19 +++-- >> .../10_create_storagevolume.py | 6 +- >> .../11_create_dir_storagevolume_errs.py | 5 +- >> .../12_create_netfs_storagevolume_errs.py | 5 +- >> .../13_delete_storagevolume.py | 5 +- >> .../14_delete_storagevolume_errs.py | 5 +- >> .../15_DiskPoolAutostart.py | 15 +++- >> .../SettingsDefineCapabilities/01_forward.py | 1 - >> .../libvirt-cim/cimtest/VSSD/06_duplicate_uuid.py | 2 +- >> .../06_addresource.py | 2 +- >> .../08_modifyresource.py | 4 +- >> .../13_refconfig_additional_devs.py | 4 +- >> .../15_mod_system_settings.py | 11 ++- >> .../18_define_sys_bridge.py | 2 +- >> .../19_definenetwork_ers.py | 23 +++--- >> .../22_addmulti_brg_interface.py | 2 +- >> .../27_definesystem_macvtap_dev.py | 19 ++++- >> .../28_definesystem_with_vsi_profile.py | 15 ++++ >> suites/libvirt-cim/lib/XenKvmLib/common_util.py | 93 > +++++++++++++++++----- >> suites/libvirt-cim/lib/XenKvmLib/const.py | 6 +- >> suites/libvirt-cim/lib/XenKvmLib/pool.py | 10 +-- >> suites/libvirt-cim/lib/XenKvmLib/rasd.py | 10 ++- >> suites/libvirt-cim/lib/XenKvmLib/test_xml.py | 2 +- >> suites/libvirt-cim/lib/XenKvmLib/vxml.py | 4 +- >> suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 6 ++ >> suites/libvirt-cim/main.py | 15 ++++ >> 28 files changed, 237 insertions(+), 86 deletions(-) >> >> -- >> 1.8.1.4 >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim From cngesaint at outlook.com Fri May 3 09:17:07 2013 From: cngesaint at outlook.com (WangXu) Date: Fri, 3 May 2013 09:17:07 +0000 Subject: [Libvirt-cim] [PATCH v2 00/12] cimtest updates In-Reply-To: <51825C06.3030606@redhat.com> References: <1366812554-6591-1-git-send-email-jferlan@redhat.com>, , <51825C06.3030606@redhat.com> Message-ID: ---------------------------------------- > Date: Thu, 2 May 2013 08:28:54 -0400 > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Subject: Re: [Libvirt-cim] [PATCH v2 00/12] cimtest updates > > On 04/28/2013 01:19 AM, WangXu wrote: > > I have run cimtest with these 12 patches and they solved most of bugs > > before. > > However, I found some new FAIL cases. > > 1. > > -------------------------------------------------------------------- > > HostSystem - 01_enum.py: FAIL > > ERROR - Exp KVM_HostSystem, got KVM_HostSystem > > ERROR - Exp localhost, got RH64wenchao > > CIM_ERR_INVALID_CLASS: Linux_ComputerSystem > > -------------------------------------------------------------------- > > HostSystem - 03_hs_to_settdefcap.py: FAIL > > ERROR - Hostname mismatch > > -------------------------------------------------------------------- > > Hostname mismatch because cimtest match localhost with RH64wenchao... > > Could you find out what cause it and fix it? > > Not sure this has anything to do with my set of changes - seems more > like a system configuration issue that since it's happening on your > system is probably more easily debugged by you. Start in 01_enum.py and > do various print's in order to figure out where issue is. My system > config has an 'options.ip' = localhost and the return from > "full_hostname" set to a "generated" name. I have nothing in my > /etc/hosts nor in my /etc/sysconfig/network-scripts/* files. > Yes,it has nothing to do with your updates. These 12 patches seems work well under testing. I just point out the problems I met:) This issue I found the cause: I must write hostname before "localhost" in hosts. If they were written as "127.0.0.1 localhost HOSTNAME", this testcase would fail. However, I adjusted the item to be "127.0.0.1 HOSTNAME localhost" and the testcase passed. My suggestion is could it become "smarter" to recoginze the difference between 'localhost' and HOSTNAME? > > > > > 2. > > -------------------------------------------------------------------- > > SwitchService - 01_enum.py: XFAIL > > Please check if this is the expected result --- > > *** VSI NOT supported *** > > -------------------------------------------------------------------- > > Why XFAIL but not SKIP here? My computer does not support it. > > Neither does mine, but XFAIL is the original design. In my original opinion, I thought that if some conditions doesn't be saitisfied, (such as absence of dependency, do not support some hardware or software, etc.) it will be marked as SKIP. But it maybe not accurate. The same reason I listed the following issue. I'll ignore this issue from now on:-) > > > > 3. > > -------------------------------------------------------------------- > > VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL > > ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal > > error unable to execute QEMU command 'device_add': Bus 'pci.0' does not > > support hotplugging") > > ERROR - Error invoking AddRS: add_net_res > > ERROR - AddResourceSettings call failed > > ERROR - Failed to destroy Virtual Network 'my_network1' > > InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) > > device: internal error unable to execute QEMU command 'device_add': Bus > > 'pci.0' does not support hotplugging > > Bug:<00015> > > Unrelated to my changes. The only change I made to 22*.py was the > 'test_mac' value. See more below though... > > > -------------------------------------------------------------------- > > VirtualSystemManagementService - 30_dynamic_disk_mod.py: XFAIL > > ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal > > error unable to execute QEMU command 'device_add': Bus 'pci.0' does not > > support hotplugging") > > ERROR - Error invoking AddRS: add_disk_res > > ERROR - AddResourceSettings call failed > > InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) > > device: internal error unable to execute QEMU command 'device_add': Bus > > 'pci.0' does not support hotplugging > > I didn't make any changes here > > > -------------------------------------------------------------------- > > I am sorry I don't clear what caused it. > > Same here :-) Although it seems as though the test is trying to add a > disk to a pci.0 device/bus, but that addition is not supported for a > running domain in the configuration provided by cimtest. It does make > me wonder if these tests ever passed for KVM... > > Digging into the tests a bit, the failure for 22*.py comes as a result > of a call to cimtest method 'add_net_res()'. There are two tests that > call it. The other is VirtualSystemManagementService/06_addresource.py; > however, there's a check in the 06*.py test which doesn't attempt the > call when the domain is started, e.g.: > > if options.virt == "KVM": > test_cases = ["define"] > else: > test_cases = ["define", "start"] > > Since test 22* attempts this call when things are started, it's a > different path of support - namely 'hotplug'. After a bit of trial and > error, I have a possible fix. I found that I had to change the domain > configuration in the test to set "acpi=True". Then I had to change the > 'add_net_res' code to query "source/@bridge" and not "source/@network" > and compare against attr['virt_net'] and not attr['net_name']. The > net_name (e.g. my_network1) is a network pool attribute not a domain > network attribute. I'm really not sure this test worked or passed > previously. > > I will dive into test 30*.py at some point in time. I did try the > simple "acpi=True" change there, but that just caused other failures. > > > > > 4. > > -------------------------------------------------------------------- > > VirtualSystemManagementService - 27_definesystem_macvtap_dev.py: FAIL > > ERROR - Got CIM error CIM_ERR_FAILED: Unable to start domain: Unable > > to get index for interface eth1: No such device with return code 1 > > ERROR - Unable to start rstest_nic > > InvokeMethod(RequestStateChange): CIM_ERR_FAILED: Unable to start domain: > > Unable to get index for interface eth1: No such device > > -------------------------------------------------------------------- > > VirtualSystemManagementService - 28_definesystem_with_vsi_profile.py: XFAIL > > ERROR - Got CIM error CIM_ERR_FAILED: Unable to start domain: Unable > > to get index for interface eth1: No such device with return code 1 > > ERROR - Unable to start VM *** Is VSI support available on this > > host? *** > > InvokeMethod(RequestStateChange): CIM_ERR_FAILED: Unable to start domain: > > Unable to get index for interface eth1: No such device > > -------------------------------------------------------------------- > > This FAIL happens because there is no eth1 interface on my computer. The > > name > > of my network interface is "eth3". So I think it had better list all network > > interfaces and pick available one for testing. For multicard machine > > there are > > some rule to choice one or...configure it manually? > > Correct - there is no method now to get a/the list of network interfaces > and then "choose" a valid one to execute tests. To further muddy the > waters the latest Fedora releases uses 'em#' instead of 'eth#' - the > commit message from my change has a pointer to the details. > > For now though the values are hardcoded. It's something I'm sure I > noted in one our exchanges already. > > John > > > > > >> From: jferlan at redhat.com > >> To: libvirt-cim at redhat.com > >> Date: Wed, 24 Apr 2013 10:09:02 -0400 > >> Subject: [Libvirt-cim] [PATCH v2 00/12] cimtest updates > >> > >> This is primarily a repost of the previous series: > >> > >> https://www.redhat.com/archives/libvirt-cim/2013-March/msg00051.html > >> > >> and > >> > >> https://www.redhat.com/archives/libvirt-cim/2013-April/msg00014.html > >> > >> The primary difference in this patch vs. the previous sets is to fix the > >> version string checking for nfs server checking in common_util.py and to > >> add patch 12/12 which handles a problem in 'enum_volumes()' in pool.py. > >> > >> I assume patches 1-4 and 6-9 were reviewed without issue. So focus on 5/12 > >> and 10-12/12. > >> > >> > >> John Ferlan (12): > >> Need to check "slp=true", not just "slp" since "slp=false" is possible > >> Change the MAC from "99:" to "88:" > >> Create a temporary directory for disk pool tests > >> Use symbols as named in libvirt-cim for easier reference > >> Fix nfs-server lookup code > >> Fix os_status passing to reporter functions > >> Resolve issues found in test. > >> On Fedora systems default to using 'em1' instead of 'eth1' > >> 19 - resolve issues found in test > >> vxml: Add which volume could not be found to error message > >> Add and utilize virsh_version_cmp > >> pool: Need to handle when there are no volumes in the default pool > >> > >> .../Profile/04_verify_libvirt_cim_slp_profiles.py | 2 +- > >> .../08_CreateDiskResourcePool.py | 30 +++++-- > >> .../09_DeleteDiskPool.py | 19 +++-- > >> .../10_create_storagevolume.py | 6 +- > >> .../11_create_dir_storagevolume_errs.py | 5 +- > >> .../12_create_netfs_storagevolume_errs.py | 5 +- > >> .../13_delete_storagevolume.py | 5 +- > >> .../14_delete_storagevolume_errs.py | 5 +- > >> .../15_DiskPoolAutostart.py | 15 +++- > >> .../SettingsDefineCapabilities/01_forward.py | 1 - > >> .../libvirt-cim/cimtest/VSSD/06_duplicate_uuid.py | 2 +- > >> .../06_addresource.py | 2 +- > >> .../08_modifyresource.py | 4 +- > >> .../13_refconfig_additional_devs.py | 4 +- > >> .../15_mod_system_settings.py | 11 ++- > >> .../18_define_sys_bridge.py | 2 +- > >> .../19_definenetwork_ers.py | 23 +++--- > >> .../22_addmulti_brg_interface.py | 2 +- > >> .../27_definesystem_macvtap_dev.py | 19 ++++- > >> .../28_definesystem_with_vsi_profile.py | 15 ++++ > >> suites/libvirt-cim/lib/XenKvmLib/common_util.py | 93 > > +++++++++++++++++----- > >> suites/libvirt-cim/lib/XenKvmLib/const.py | 6 +- > >> suites/libvirt-cim/lib/XenKvmLib/pool.py | 10 +-- > >> suites/libvirt-cim/lib/XenKvmLib/rasd.py | 10 ++- > >> suites/libvirt-cim/lib/XenKvmLib/test_xml.py | 2 +- > >> suites/libvirt-cim/lib/XenKvmLib/vxml.py | 4 +- > >> suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 6 ++ > >> suites/libvirt-cim/main.py | 15 ++++ > >> 28 files changed, 237 insertions(+), 86 deletions(-) > >> > >> -- > >> 1.8.1.4 > >> > >> _______________________________________________ > >> 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 From cngesaint at outlook.com Tue May 7 09:08:21 2013 From: cngesaint at outlook.com (WangXu) Date: Tue, 7 May 2013 09:08:21 +0000 Subject: [Libvirt-cim] [PATCH v2 10/12] vxml: Add which volume could not be found to error message In-Reply-To: <1366812554-6591-11-git-send-email-jferlan@redhat.com> References: <1366812554-6591-1-git-send-email-jferlan@redhat.com>, <1366812554-6591-11-git-send-email-jferlan@redhat.com> Message-ID: Reviewed-by: Xu Wang ---------------------------------------- > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Date: Wed, 24 Apr 2013 10:09:12 -0400 > Subject: [Libvirt-cim] [PATCH v2 10/12] vxml: Add which volume could not be found to error message > > --- > suites/libvirt-cim/lib/XenKvmLib/vxml.py | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py > index 51a4166..82ab501 100644 > --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py > @@ -921,7 +921,7 @@ class KVMXML(VirtXML, VirtCIM): > port_num='-1', keymap="en-us", irstype="mouse", > btype="ps2", vnc_passwd=None): > if not os.path.exists(disk_file_path): > - logger.error('Error: Disk image does not exist') > + logger.error('Error: Disk image %s does not exist', disk_file_path) > sys.exit(1) > VirtXML.__init__(self, 'kvm', test_dom, set_uuid(), mem, vcpus) > VirtCIM.__init__(self, 'KVM', test_dom, uuid, pae, acpi, apic, disk, > @@ -984,7 +984,7 @@ class XenFVXML(VirtXML, VirtCIM): > keymap="en-us", > irstype="mouse", btype="ps2", vnc_passwd=None): > if not os.path.exists(disk_file_path): > - logger.error('Error: Disk image does not exist') > + logger.error('Error: Disk image %s does not exist', disk_file_path) > sys.exit(1) > VirtXML.__init__(self, 'xenfv', test_dom, set_uuid(), mem, vcpus) > VirtCIM.__init__(self, 'XenFV', test_dom, uuid, pae, acpi, apic, disk, > -- > 1.8.1.4 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From cngesaint at outlook.com Tue May 7 09:09:26 2013 From: cngesaint at outlook.com (WangXu) Date: Tue, 7 May 2013 09:09:26 +0000 Subject: [Libvirt-cim] [PATCH v2 11/12] Add and utilize virsh_version_cmp In-Reply-To: <1366812554-6591-12-git-send-email-jferlan@redhat.com> References: <1366812554-6591-1-git-send-email-jferlan@redhat.com>, <1366812554-6591-12-git-send-email-jferlan@redhat.com> Message-ID: Reviewed-by: Xu Wang ---------------------------------------- > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Date: Wed, 24 Apr 2013 10:09:13 -0400 > Subject: [Libvirt-cim] [PATCH v2 11/12] Add and utilize virsh_version_cmp > > The string version comparisons failed when determining if "0.10.2" was > a greater version than "0.4.1" (and other similar checks). Needed to create > a version comparison method that did the right thing. > > Also, not change to 12_create_netfs_storagevolume_errs.py to use "or" logic > rather than "and" logic on comparison. Other tests within the family use > "or" logic. > --- > .../08_CreateDiskResourcePool.py | 4 ++-- > .../10_create_storagevolume.py | 6 ++++-- > .../11_create_dir_storagevolume_errs.py | 5 +++-- > .../12_create_netfs_storagevolume_errs.py | 5 +++-- > .../13_delete_storagevolume.py | 5 +++-- > .../14_delete_storagevolume_errs.py | 5 +++-- > .../ResourcePoolConfigurationService/15_DiskPoolAutostart.py | 4 ++-- > .../cimtest/SettingsDefineCapabilities/01_forward.py | 1 - > .../VirtualSystemManagementService/19_definenetwork_ers.py | 8 ++++---- > suites/libvirt-cim/lib/XenKvmLib/common_util.py | 9 +++++---- > suites/libvirt-cim/lib/XenKvmLib/pool.py | 6 +++--- > suites/libvirt-cim/lib/XenKvmLib/rasd.py | 10 ++++++---- > suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 6 ++++++ > 13 files changed, 44 insertions(+), 30 deletions(-) > > diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py > index 636f59c..b5ec5dc 100644 > --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py > +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py > @@ -50,7 +50,7 @@ > import sys > import os > from CimTest.Globals import logger > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from CimTest.ReturnCodes import FAIL, PASS, SKIP > from XenKvmLib.const import do_main, platform_sup > from XenKvmLib.classes import get_typed_class > @@ -89,7 +89,7 @@ def main(): > dp_types = { } > > libvirt_version = virsh_version(server, virt) > - if libvirt_version < "0.4.1": > + if virsh_version_cmp(libvirt_version, "0.4.1") < 0: > logger.info("Storage pool creation support is available in Libvirt " > "version >= 0.4.1 , hence skipping the test....") > return SKIP > diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py > index 511463b..3b0673f 100644 > --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py > +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/10_create_storagevolume.py > @@ -38,7 +38,8 @@ from XenKvmLib.rasd import libvirt_rasd_storagepool_changes > from XenKvmLib import rpcs_service > from XenKvmLib.assoc import Associators > from XenKvmLib.enumclass import GetInstance, EnumNames > -from XenKvmLib.xm_virt_util import virsh_version, vol_list, vol_delete > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp, \ > + vol_list, vol_delete > from XenKvmLib.classes import get_typed_class, inst_to_mof > from XenKvmLib.common_util import destroy_diskpool > from XenKvmLib.pool import create_pool, undefine_diskpool, DIR_POOL > @@ -186,7 +187,8 @@ def main(): > > libvirt_ver = virsh_version(server, virt) > cim_rev, changeset = get_provider_version(virt, server) > - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_storagepool_changes: > + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ > + cim_rev < libvirt_rasd_storagepool_changes: > logger.info("Storage Volume creation support is available with Libvirt" > "version >= 0.4.1 and Libvirt-CIM rev '%s'", > libvirt_rasd_storagepool_changes) > diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py > index 76e1e8f..318cfa8 100644 > --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py > +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/11_create_dir_storagevolume_errs.py > @@ -36,7 +36,7 @@ from CimTest.Globals import logger > from XenKvmLib import rpcs_service > from pywbem.cim_types import Uint64 > from pywbem import CIM_ERR_FAILED, CIMError > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from CimTest.ReturnCodes import FAIL, PASS, SKIP > from XenKvmLib.classes import get_typed_class, inst_to_mof > from XenKvmLib.rasd import libvirt_rasd_storagepool_changes > @@ -125,7 +125,8 @@ def main(): > > libvirt_ver = virsh_version(server, virt) > cim_rev, changeset = get_provider_version(virt, server) > - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_storagepool_changes: > + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ > + cim_rev < libvirt_rasd_storagepool_changes: > logger.info("Storage Volume creation support is available with Libvirt" > "version >= 0.4.1 and Libvirt-CIM rev '%s'", > libvirt_rasd_storagepool_changes) > diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py > index 004af9f..215727f 100644 > --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py > +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/12_create_netfs_storagevolume_errs.py > @@ -36,7 +36,7 @@ from CimTest.ReturnCodes import FAIL, PASS, SKIP > from XenKvmLib.const import do_main, platform_sup, get_provider_version > from XenKvmLib.rasd import libvirt_rasd_storagepool_changes > from XenKvmLib import rpcs_service > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from XenKvmLib.classes import get_typed_class, inst_to_mof > from XenKvmLib.common_util import nfs_netfs_setup, netfs_cleanup > from XenKvmLib.pool import create_pool, NETFS_POOL, get_diskpool, \ > @@ -123,7 +123,8 @@ def main(): > > libvirt_ver = virsh_version(server, virt) > cim_rev, changeset = get_provider_version(virt, server) > - if libvirt_ver < "0.4.1" and cim_rev < libvirt_rasd_storagepool_changes: > + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ > + cim_rev < libvirt_rasd_storagepool_changes: > logger.info("Storage Volume creation support is available with Libvirt" > "version >= 0.4.1 and Libvirt-CIM rev '%s'", > libvirt_rasd_storagepool_changes) > diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py > index d7a6365..3578532 100644 > --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py > +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/13_delete_storagevolume.py > @@ -29,7 +29,7 @@ > import sys > from CimTest.Globals import logger > from CimTest.ReturnCodes import FAIL, PASS, SKIP > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from XenKvmLib.const import do_main, platform_sup, get_provider_version, \ > default_pool_name, _image_dir > from XenKvmLib import rpcs_service > @@ -50,7 +50,8 @@ def main(): > > libvirt_ver = virsh_version(server, virt) > cim_rev, changeset = get_provider_version(virt, server) > - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_spool_del_changes: > + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ > + cim_rev < libvirt_rasd_spool_del_changes: > logger.info("Storage Volume deletion support is available with Libvirt" > "version >= 0.4.1 and Libvirt-CIM rev '%s'", > libvirt_rasd_spool_del_changes) > diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py > index 9e33215..d7ed5ad 100644 > --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py > +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/14_delete_storagevolume_errs.py > @@ -33,7 +33,7 @@ from VirtLib import utils > from CimTest.Globals import logger > from pywbem import CIM_ERR_FAILED, CIM_ERR_INVALID_PARAMETER, CIMError > from CimTest.ReturnCodes import FAIL, PASS, SKIP > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from XenKvmLib.const import do_main, platform_sup, get_provider_version,\ > default_pool_name, _image_dir > from XenKvmLib import rpcs_service > @@ -119,7 +119,8 @@ def main(): > > libvirt_ver = virsh_version(server, virt) > cim_rev, changeset = get_provider_version(virt, server) > - if libvirt_ver < "0.4.1" or cim_rev < libvirt_rasd_spool_del_changes: > + if virsh_version_cmp(libvirt_ver, "0.4.1") < 0 or \ > + cim_rev < libvirt_rasd_spool_del_changes: > logger.info("Storage Volume deletion support is available with Libvirt" > "version >= 0.4.1 and Libvirt-CIM rev '%s'", > libvirt_rasd_spool_del_changes) > diff --git a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py > index b7e72a8..3cf6321 100644 > --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py > +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/15_DiskPoolAutostart.py > @@ -26,7 +26,7 @@ import sys > import os > from pywbem import cim_types > from CimTest.Globals import logger > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from CimTest.ReturnCodes import FAIL, PASS, SKIP > from XenKvmLib.const import do_main, platform_sup > from XenKvmLib.classes import get_typed_class > @@ -62,7 +62,7 @@ def main(): > dp_types = { } > > libvirt_version = virsh_version(server, virt) > - if libvirt_version < "0.4.1": > + if virsh_version_cmp(libvirt_version, "0.4.1") < 0: > logger.info("Storage pool creation support is available in Libvirt " > "version >= 0.4.1 , hence skipping the test....") > return SKIP > diff --git a/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py b/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py > index 555e3c1..dd19ca0 100644 > --- a/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py > +++ b/suites/libvirt-cim/cimtest/SettingsDefineCapabilities/01_forward.py > @@ -57,7 +57,6 @@ import os > from distutils.file_util import move_file > from XenKvmLib import assoc > from XenKvmLib import enumclass > -from XenKvmLib.xm_virt_util import virsh_version > from CimTest.ReturnCodes import PASS, FAIL, SKIP > from CimTest.Globals import logger, CIM_ERROR_GETINSTANCE, \ > CIM_ERROR_ASSOCIATORS > diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py > index cf461d1..19294db 100644 > --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py > +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/19_definenetwork_ers.py > @@ -33,7 +33,7 @@ from CimTest.Globals import logger > from CimTest.ReturnCodes import FAIL, PASS > from XenKvmLib.const import default_network_name, do_main, get_provider_version > from XenKvmLib.common_util import create_netpool_conf, destroy_netpool > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > > sup_types = ['Xen', 'KVM', 'XenFV'] > default_dom = 'brgtest_domain' > @@ -71,7 +71,7 @@ def main(): > libvirt_version = virsh_version(options.ip, options.virt) > inv_empty_network = "Network not found" > if options.virt == "Xen" or options.virt == "XenFV": > - if libvirt_version <= "0.3.3": > + if virsh_version_cmp(libvirt_version, "0.3.3") <= 0: > inv_empty_network = "no network with matching name" > > inv_br_str = "POST operation failed: (xend.err 'Device 0 (vif) " + \ > @@ -89,10 +89,10 @@ def main(): > > expected_values['invalid']['bridge'] = inv_br_str > else: > - if libvirt_version >= "0.7.0": > + if virsh_version_cmp(libvirt_version, "0.7.0") >= 0: > expected_values['empty']['network'] = inv_empty_network > expected_values['invalid']['network'] = inv_empty_network > - if libvirt_version >= "0.9.8": > + if virsh_version_cmp(libvirt_version, "0.9.8") >= 0: > expected_values['invalid']['bridge'] = "Cannot get interface "\ > "MTU on 'invalid'" > else: > diff --git a/suites/libvirt-cim/lib/XenKvmLib/common_util.py b/suites/libvirt-cim/lib/XenKvmLib/common_util.py > index 9305c5e..f05fdc0 100644 > --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py > @@ -38,7 +38,8 @@ from XenKvmLib.classes import get_typed_class > from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, \ > CIM_ERROR_GETINSTANCE > from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC, SKIP > -from XenKvmLib.xm_virt_util import diskpool_list, virsh_version, net_list,\ > +from XenKvmLib.xm_virt_util import diskpool_list, virsh_version,\ > + virsh_version_cmp, net_list,\ > domain_list, virt2uri, net_destroy > from XenKvmLib.vxml import PoolXML, NetXML > from VirtLib import utils > @@ -308,7 +309,7 @@ def cleanup_restore(server, virt): > # libvirt_version >= 0.4.1 > # Hence Skipping the logic to delete the new conf file > # and just returning PASS > - if libvirt_version >= '0.4.1': > + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: > return status > try: > if os.path.exists(back_disk_file): > @@ -365,7 +366,7 @@ def create_diskpool(server, virt='KVM', dpool=default_pool_name, > > def create_diskpool_conf(server, virt, dpool=default_pool_name): > libvirt_version = virsh_version(server, virt) > - if libvirt_version >= '0.4.1': > + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: > status, dpoolname = create_diskpool(server, virt, dpool) > diskid = "%s/%s" % ("DiskPool", dpoolname) > else: > @@ -376,7 +377,7 @@ def create_diskpool_conf(server, virt, dpool=default_pool_name): > > def destroy_diskpool(server, virt, dpool): > libvirt_version = virsh_version(server, virt) > - if libvirt_version >= '0.4.1': > + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: > if dpool == None: > logger.error("No disk pool specified") > return FAIL > diff --git a/suites/libvirt-cim/lib/XenKvmLib/pool.py b/suites/libvirt-cim/lib/XenKvmLib/pool.py > index a5ca331..1a57aba 100644 > --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py > @@ -35,7 +35,7 @@ from XenKvmLib import rpcs_service > import pywbem > from CimTest.CimExt import CIMClassMOF > from XenKvmLib.vxml import NetXML, PoolXML > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from XenKvmLib.vsms import RASD_TYPE_STOREVOL > from XenKvmLib.common_util import destroy_diskpool > > @@ -183,7 +183,7 @@ def undefine_netpool(server, virt, net_name): > > def undefine_diskpool(server, virt, dp_name): > libvirt_version = virsh_version(server, virt) > - if libvirt_version >= '0.4.1': > + if virsh_version_cmp(libvirt_version, '0.4.1') >= 0: > if dp_name == None: > return FAIL > > @@ -285,7 +285,7 @@ def verify_pool(server, virt, poolname, pool_attr_list, mode_type=0, > ret_mode = net_xml.xml_get_netpool_mode() > libvirt_version = virsh_version(server, virt) > #Forward mode support was added in 0.4.2 > - if libvirt_version >= '0.4.2': > + if virsh_version_cmp(libvirt_version, '0.4.2') >= 0: > if mode_type == 1 and ret_mode != "nat": > logger.error("Error when verifying 'nat' type network") > return FAIL > diff --git a/suites/libvirt-cim/lib/XenKvmLib/rasd.py b/suites/libvirt-cim/lib/XenKvmLib/rasd.py > index d65011e..4d4240a 100644 > --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py > @@ -31,7 +31,7 @@ from XenKvmLib.assoc import Associators > from XenKvmLib.const import default_pool_name, default_network_name, \ > get_provider_version, default_net_type > from XenKvmLib.pool import enum_volumes > -from XenKvmLib.xm_virt_util import virsh_version > +from XenKvmLib.xm_virt_util import virsh_version, virsh_version_cmp > from XenKvmLib.common_util import parse_instance_id > > pasd_cn = 'ProcResourceAllocationSettingData' > @@ -81,7 +81,8 @@ def rasd_init_list(vsxml, virt, t_disk, t_dom, t_mac, t_mem, server): > > libvirt_version = virsh_version(server, virt) > > - if virt == 'LXC' or (virt == 'XenFV' and libvirt_version < "0.6.3"): > + if virt == 'LXC' or (virt == 'XenFV' and \ > + virsh_version_cmp(libvirt_version, "0.6.3") < 0): > point_device = "%s/%s" %(t_dom, "mouse:usb") > elif virt == 'Xen': > point_device = "%s/%s" %(t_dom, "mouse:xen") > @@ -357,7 +358,8 @@ def get_exp_disk_rasd_len(virt, ip, rev, id): > rev < libvirt_rasd_new_changes: > exp_len = exp_base_num + exp_cdrom > > - elif rev >= libvirt_rasd_dpool_changes and libvirt_ver >= '0.4.1': > + elif rev >= libvirt_rasd_dpool_changes and \ > + virsh_version_cmp(libvirt_ver, '0.4.1') >= 0: > volumes = enum_volumes(virt, ip) > if rev >= libvirt_rasd_floppy_changes: > exp_len = ((volumes * exp_base_num) + \ > @@ -383,7 +385,7 @@ def get_exp_disk_rasd_len(virt, ip, rev, id): > exp_len = (volumes * exp_base_num) + exp_cdrom > > > - if virt != 'LXC' and libvirt_ver >= '0.4.1': > + if virt != 'LXC' and virsh_version_cmp(libvirt_ver, '0.4.1') >= 0: > if rev >= libvirt_rasd_storagepool_changes: > exp_len += exp_storagevol_rasd > > diff --git a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py > index f365a54..7749fb7 100644 > --- a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py > @@ -23,6 +23,7 @@ > # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > # > import os > +import re > from VirtLib import utils > import socket > from VirtLib.live import fv_cap > @@ -223,6 +224,11 @@ def network_by_bridge(bridge, server, virt="Xen"): > > return None > > +def virsh_version_cmp(version1, version2): > + def normalize(v): > + return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")] > + return cmp(normalize(version1), normalize(version2)) > + > def virsh_version(server, virt="KVM"): > cmd = "virsh -c %s -v 2>/dev/null" % virt2uri(virt) > ret, out = utils.run_remote(server, cmd) > -- > 1.8.1.4 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From cngesaint at outlook.com Tue May 7 09:09:53 2013 From: cngesaint at outlook.com (WangXu) Date: Tue, 7 May 2013 09:09:53 +0000 Subject: [Libvirt-cim] [PATCH v2 12/12] pool: Need to handle when there are no volumes in the default pool In-Reply-To: <1366812554-6591-13-git-send-email-jferlan@redhat.com> References: <1366812554-6591-1-git-send-email-jferlan@redhat.com>, <1366812554-6591-13-git-send-email-jferlan@redhat.com> Message-ID: Reviewed-by: Xu Wang ---------------------------------------- > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Date: Wed, 24 Apr 2013 10:09:14 -0400 > Subject: [Libvirt-cim] [PATCH v2 12/12] pool: Need to handle when there are no volumes in the default pool > > Failing test: > HostSystem - 03_hs_to_settdefcap.py: FAIL > ERROR - Failed to get associatornames according to KVM_AllocationCapabilities > ERROR - Exception: list index out of range > > Investigation discovered that 'enum_volumes()' was not properly handling > the case where there were no volumes in 'DiskPool/default'. > > Also function cannot return 'None' as caller 'get_exp_disk_rasd_len' assumed > integer return value and attempted a multiplication resulting in an exception. > --- > suites/libvirt-cim/lib/XenKvmLib/pool.py | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/suites/libvirt-cim/lib/XenKvmLib/pool.py b/suites/libvirt-cim/lib/XenKvmLib/pool.py > index 1a57aba..ddbe532 100644 > --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py > +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py > @@ -110,8 +110,8 @@ def enum_volumes(virt, server, pooln=default_pool_name): > cmd = 'virsh -c %s vol-list %s 2>/dev/null | sed -e "1,2 d" -e "$ d"' % \ > (virt2uri(virt), pooln) > ret, out = run_remote(server ,cmd) > - if ret != 0: > - return None > + if ret != 0 or len(out) == 0: > + return volume > lines = out.split("\n") > for line in lines: > vol = line.split()[0] > -- > 1.8.1.4 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From jferlan at redhat.com Wed May 8 18:49:08 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 08 May 2013 14:49:08 -0400 Subject: [Libvirt-cim] [PATCH V2 1/3] make force use qemu configurable In-Reply-To: <1367478658-17026-2-git-send-email-cngesaint@outlook.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> <1367478658-17026-2-git-send-email-cngesaint@outlook.com> Message-ID: <518A9E24.1090106@redhat.com> On 05/02/2013 03:10 AM, Xu Wang wrote: > From: Wenchao Xia > > Since in nested KVM, libvirt-cim doesn't handler it well now, so add this > option to manually disable KVM and fall back to qemu. If there is something > fail caused by nested KVM happend, please consider to set this option to be > true for development and testing. > > Signed-off-by: Xu Wang > --- > libvirt-cim.conf | 10 ++++++++++ > libxkutil/misc_util.c | 8 ++++++++ > libxkutil/misc_util.h | 1 + > src/Virt_VirtualSystemManagementService.c | 7 +++++++ > 4 files changed, 26 insertions(+), 0 deletions(-) > The commit message is still a bit confusing, but I suppose not enough to hold up adding the capability. Hopefully anyone forced to make changes as a result of being able to develop/test further in the nested environment will duly note where and what had to change... > diff --git a/libvirt-cim.conf b/libvirt-cim.conf > index 37d7b0f..f378e4c 100644 > --- a/libvirt-cim.conf > +++ b/libvirt-cim.conf > @@ -30,3 +30,13 @@ > # Default value: NULL, that is not set. > # > # migrate_ssh_temp_key = "/root/vm_migrate_tmp_id_rsa"; > + > +# force_use_qemu (bool) > +# Since in nested KVM, libvirt-cim doesn't handler it well now, so add this > +# option to manually disable KVM and fall back to qemu. If there is something > +# fail caused by nested KVM happend, please consider to set this option to be > +# true for development and testing. Consider the following explanation to replace the above 4 lines : When executing in a nested KVM environment libvirt-cim may fail unexpectedly with a TBS error. Setting "force_use_qemu" option to true disables use of KVM and falls back to using QEMU directly. NOTE: TBS should be replaced with the error or the clue that someone would need in order to determine they should be using/setting this to true. Remarking about development or testing is irrelevant. John > +# Possible values: {true,false} > +# Default value: false > +# > +# force_use_qemu = false; > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > index 00eb4b1..4c0b0a1 100644 > --- a/libxkutil/misc_util.c > +++ b/libxkutil/misc_util.c > @@ -227,6 +227,14 @@ static int is_read_only(void) > return prop.value_bool; > } > > +bool get_force_use_qemu(void) > +{ > + static LibvirtcimConfigProperty prop = { > + "force_use_qemu", CONFIG_BOOL, {0}, 0}; > + libvirt_cim_config_get(&prop); > + return prop.value_bool; > +} > + > const char *get_mig_ssh_tmp_key(void) > { > static LibvirtcimConfigProperty prop = { > diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h > index 0f52290..9e6b419 100644 > --- a/libxkutil/misc_util.h > +++ b/libxkutil/misc_util.h > @@ -154,6 +154,7 @@ int virt_set_status(const CMPIBroker *broker, > > /* get libvirt-cim config */ > const char *get_mig_ssh_tmp_key(void); > +bool get_force_use_qemu(void); > > /* > * Local Variables: > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index cbb646d..81ec064 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -394,6 +394,13 @@ static bool system_has_kvm(const char *pfx) > virConnectPtr conn; > char *caps = NULL; > bool kvm = false; > + bool force_use_qemu = get_force_use_qemu(); > + > + /* sometimes disable KVM to avoid problem in nested KVM */ > + if (force_use_qemu) { > + CU_DEBUG("Enter force use qemu mode!"); > + return false; > + } > > conn = connect_by_classname(_BROKER, pfx, &s); > if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { > From jferlan at redhat.com Wed May 8 18:56:25 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 08 May 2013 14:56:25 -0400 Subject: [Libvirt-cim] [PATCH V2 2/3] VSMS: tip error for invalid disk resource In-Reply-To: <1367478658-17026-3-git-send-email-cngesaint@outlook.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> <1367478658-17026-3-git-send-email-cngesaint@outlook.com> Message-ID: <518A9FD9.5060406@redhat.com> On 05/02/2013 03:10 AM, Xu Wang wrote: > Original code will report xml text missing when a disk is not accessable, Not resolved from last review: s/accessable/accessible > make user confuse. This patch will report the real error to tip user check > its system health state on the server. I also still see no example of what's being fixed. > > Signed-off-by: Xu Wang > --- > src/Virt_VirtualSystemManagementService.c | 70 +++++++++++++++++++++-------- > 1 files changed, 51 insertions(+), 19 deletions(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index 81ec064..1652cf2 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -964,11 +964,13 @@ static const char *net_rasd_to_vdev(CMPIInstance *inst, > }veillard at redhat.com > > static const char *disk_rasd_to_vdev(CMPIInstance *inst, > - struct virt_device *dev) > + struct virt_device *dev, > + char **p_error) > { > const char *val = NULL; > uint16_t type; > bool read = false; > + int rc; > > CU_DEBUG("Enter disk_rasd_to_vdev"); > if (cu_get_str_prop(inst, "VirtualDevice", &val) != CMPI_RC_OK) > @@ -984,6 +986,18 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, > dev->dev.disk.source = strdup(val); > dev->dev.disk.disk_type = disk_type_from_file(val); > > + if ((!XSTREQ(dev->dev.disk.source, "/dev/null")) && (dev->dev.disk.disk_type == DISK_UNKNOWN)) { So again, there's no checking for NULL on strdup() for dev.disk.source which will cause a seg fault here. NACK and did not review remainder John > + /* on success or fail caller should try free it */ > + rc = asprintf(p_error, "Device %s, Address %s, " > + "make sure Address can be accessed on host system.", > + dev->dev.disk.virtual_dev, dev->dev.disk.source); > + if (rc == -1) { > + CU_DEBUG("error during recording exception!"); > + p_error = NULL; > + } > + return "Can't get a valid disk type, "; > + } > + > if (cu_get_u16_prop(inst, "EmulatedType", &type) != CMPI_RC_OK) > type = VIRT_DISK_TYPE_DISK; > > @@ -1452,10 +1466,11 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, > static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > struct virt_device *dev, > uint16_t type, > - const char *ns) > + const char *ns, > + char **p_error) > { > if (type == CIM_RES_TYPE_DISK) { > - return disk_rasd_to_vdev(inst, dev); > + return disk_rasd_to_vdev(inst, dev, p_error); > } else if (type == CIM_RES_TYPE_NET) { > return net_rasd_to_vdev(inst, dev, ns); > } else if (type == CIM_RES_TYPE_MEM) { > @@ -1494,7 +1509,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, > static const char *rasd_to_vdev(CMPIInstance *inst, > struct domain *domain, > struct virt_device *dev, > - const char *ns) > + const char *ns, > + char **p_error) > { > uint16_t type; > CMPIObjectPath *op; > @@ -1516,7 +1532,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, > if (domain->type == DOMAIN_LXC) > msg = _container_rasd_to_vdev(inst, dev, type, ns); > else > - msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns); > + msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns, p_error); > out: > if (msg && op) > CU_DEBUG("rasd_to_vdev(%s): %s", CLASSNAME(op), msg); > @@ -1560,7 +1576,8 @@ static char *add_device_nodup(struct virt_device *dev, > > static const char *classify_resources(CMPIArray *resources, > const char *ns, > - struct domain *domain) > + struct domain *domain, > + char **p_error) > { > int i; > uint16_t type; > @@ -1613,13 +1630,15 @@ static const char *classify_resources(CMPIArray *resources, > msg = rasd_to_vdev(inst, > domain, > &domain->dev_vcpu[0], > - ns); > + ns, > + p_error); > } else if (type == CIM_RES_TYPE_MEM) { > domain->dev_mem_ct = 1; > msg = rasd_to_vdev(inst, > domain, > &domain->dev_mem[0], > - ns); > + ns, > + p_error); > } else if (type == CIM_RES_TYPE_DISK) { > struct virt_device dev; > int dcount = count + domain->dev_disk_ct; > @@ -1628,7 +1647,8 @@ static const char *classify_resources(CMPIArray *resources, > msg = rasd_to_vdev(inst, > domain, > &dev, > - ns); > + ns, > + p_error); > if (msg == NULL) > msg = add_device_nodup(&dev, > domain->dev_disk, > @@ -1646,7 +1666,8 @@ static const char *classify_resources(CMPIArray *resources, > msg = rasd_to_vdev(inst, > domain, > &dev, > - ns); > + ns, > + p_error); > if (msg == NULL) > msg = add_device_nodup(&dev, > domain->dev_net, > @@ -1676,7 +1697,8 @@ static const char *classify_resources(CMPIArray *resources, > msg = rasd_to_vdev(inst, > domain, > &dev, > - ns); > + ns, > + p_error); > if (msg == NULL) > msg = add_device_nodup(&dev, > domain->dev_graphics, > @@ -1687,7 +1709,8 @@ static const char *classify_resources(CMPIArray *resources, > msg = rasd_to_vdev(inst, > domain, > &domain->dev_input[0], > - ns); > + ns, > + p_error); > } > if (msg != NULL) > return msg; > @@ -2083,6 +2106,7 @@ static CMPIInstance *create_system(const CMPIContext *context, > struct inst_list list; > const char *props[] = {NULL}; > struct domain *domain = NULL; > + char *error_msg = NULL; > > inst_list_init(&list); > > @@ -2113,12 +2137,13 @@ static CMPIInstance *create_system(const CMPIContext *context, > if (s->rc != CMPI_RC_OK) > goto out; > > - msg = classify_resources(resources, NAMESPACE(ref), domain); > + msg = classify_resources(resources, NAMESPACE(ref), domain, &error_msg); > if (msg != NULL) { > - CU_DEBUG("Failed to classify resources: %s", msg); > + CU_DEBUG("Failed to classify resources: %s, %s", > + msg, error_msg); > cu_statusf(_BROKER, s, > CMPI_RC_ERR_FAILED, > - "ResourceSettings Error: %s", msg); > + "ResourceSettings Error: %s, %s", msg, error_msg); > goto out; > } > > @@ -2159,6 +2184,7 @@ static CMPIInstance *create_system(const CMPIContext *context, > > > out: > + free(error_msg); > cleanup_dominfo(&domain); > free(xml); > inst_list_free(&list); > @@ -2638,6 +2664,7 @@ static CMPIStatus resource_add(struct domain *dominfo, > struct virt_device *dev; > int *count = NULL; > const char *msg = NULL; > + char *error_msg = NULL; > > op = CMGetObjectPath(rasd, &s); > if ((op == NULL) || (s.rc != CMPI_RC_OK)) > @@ -2677,12 +2704,12 @@ static CMPIStatus resource_add(struct domain *dominfo, > dev = &list[*count]; > > dev->type = type; > - msg = rasd_to_vdev(rasd, dominfo, dev, ns); > + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); > if (msg != NULL) { > cu_statusf(_BROKER, &s, > CMPI_RC_ERR_FAILED, > - "Add resource failed: %s", > - msg); > + "Add resource failed: %s, %s", > + msg, error_msg); > goto out; > } > > @@ -2702,6 +2729,8 @@ static CMPIStatus resource_add(struct domain *dominfo, > (*count)++; > > out: > + free(error_msg); > + > return s; > } > > @@ -2718,6 +2747,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, > int *count; > int i; > const char *msg = NULL; > + char *error_msg = NULL; > > CU_DEBUG("Enter resource_mod"); > if (devid == NULL) { > @@ -2749,7 +2779,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, > struct virt_device *dev = &list[i]; > > if (STREQ(dev->id, devid)) { > - msg = rasd_to_vdev(rasd, dominfo, dev, ns); > + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); > if (msg != NULL) { > cu_statusf(_BROKER, &s, > CMPI_RC_ERR_FAILED, > @@ -2793,6 +2823,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, > } > > out: > + free(error_msg); > + > return s; > } > > From jferlan at redhat.com Thu May 9 13:03:20 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 09 May 2013 09:03:20 -0400 Subject: [Libvirt-cim] [PATCH V2 0/3] libvirt-cim patches In-Reply-To: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com> Message-ID: <518B9E98.1000808@redhat.com> On 05/02/2013 03:10 AM, Xu Wang wrote: > V2 updates: > 1. adjust comments for force use qemu (disable kvm under nested kvm) > 2. fix the problem of cdrom (with blank or null disk) VSMS patch caused > in V1 > 3. fix syntax errors for comments > 4. status return updates > 5. add description about 8 maximum items limits about vsi support output > > > Wenchao Xia (1): > make force use qemu configurable > > Xu Wang (2): > VSMS: tip error for invalid disk resource > make lldptool command and support output configurable > > libvirt-cim.conf | 26 ++++++++++ > libxkutil/misc_util.c | 26 ++++++++++ > libxkutil/misc_util.h | 3 + > src/Virt_SwitchService.c | 66 ++++++++++++++++++++---- > src/Virt_VirtualSystemManagementService.c | 77 ++++++++++++++++++++++------- > 5 files changed, 168 insertions(+), 30 deletions(-) > > Very strange - this is the 2nd time patch 3/3 didn't make it to my email even though it's on the list. In fact my reply nor either of your responses to my reply made it to the mail server. It's as if it has some magic word or setting so that the mail server refuses to download it. In any case, I'm still not convinced there's not a memory leak, but perhaps a Coverity or Valgrind run would answer that. I'll try to set up Coverity run on the sources. Another consideration - perhaps the get_lldptool_query_options() and get_vsi_support_key_string() should return a char * of the strdup()'d prop.value string. You may also want to consider putting the defaults into those functions too to hide them from the caller. For example, instead of: +const char *get_lldptool_query_options(void) +{ + static LibvirtcimConfigProperty prop = { + "lldptool_query_options", CONFIG_STRING, {0}, 0}; + + libvirt_cim_config_get(&prop); + return prop.value_string; +} + go with char *get_lldptool_query_options(void) { static LibvirtcimConfigProperty prop = { "lldptool_query_options", CONFIG_STRING, {0}, 0}; libvirt_cim_config_get(&prop); if (prop.value_string) return strdup(prop.value_string); return strdup("-t -g ncb -V evbcfg"); } The caller checks for NULL return, errors appropriately and can free() the returned string. John From cngesaint at outlook.com Mon May 13 03:14:36 2013 From: cngesaint at outlook.com (WangXu) Date: Mon, 13 May 2013 03:14:36 +0000 Subject: [Libvirt-cim] [PATCH V2 1/3] make force use qemu configurable In-Reply-To: <518A9E24.1090106@redhat.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com>, <1367478658-17026-2-git-send-email-cngesaint@outlook.com>, <518A9E24.1090106@redhat.com> Message-ID: ---------------------------------------- > Date: Wed, 8 May 2013 14:49:08 -0400 > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Subject: Re: [Libvirt-cim] [PATCH V2 1/3] make force use qemu configurable > > On 05/02/2013 03:10 AM, Xu Wang wrote: > > From: Wenchao Xia > > > > Since in nested KVM, libvirt-cim doesn't handler it well now, so add this > > option to manually disable KVM and fall back to qemu. If there is something > > fail caused by nested KVM happend, please consider to set this option to be > > true for development and testing. > > > > Signed-off-by: Xu Wang > > --- > > libvirt-cim.conf | 10 ++++++++++ > > libxkutil/misc_util.c | 8 ++++++++ > > libxkutil/misc_util.h | 1 + > > src/Virt_VirtualSystemManagementService.c | 7 +++++++ > > 4 files changed, 26 insertions(+), 0 deletions(-) > > > > The commit message is still a bit confusing, but I suppose not enough to > hold up adding the capability. Hopefully anyone forced to make changes > as a result of being able to develop/test further in the nested > environment will duly note where and what had to change... There maybe something unsuitable configuration in the xml files led to the error under nested KVM. Such as qemu is OK under the same condition. > > > diff --git a/libvirt-cim.conf b/libvirt-cim.conf > > index 37d7b0f..f378e4c 100644 > > --- a/libvirt-cim.conf > > +++ b/libvirt-cim.conf > > @@ -30,3 +30,13 @@ > > # Default value: NULL, that is not set. > > # > > # migrate_ssh_temp_key = "/root/vm_migrate_tmp_id_rsa"; > > + > > +# force_use_qemu (bool) > > +# Since in nested KVM, libvirt-cim doesn't handler it well now, so add this > > +# option to manually disable KVM and fall back to qemu. If there is something > > +# fail caused by nested KVM happend, please consider to set this option to be > > +# true for development and testing. > > Consider the following explanation to replace the above 4 lines : > > When executing in a nested KVM environment libvirt-cim may fail > unexpectedly with a TBS error. Setting "force_use_qemu" option to true > disables use of KVM and falls back to using QEMU directly. > > NOTE: TBS should be replaced with the error or the clue that someone > would need in order to determine they should be using/setting this to > true. Remarking about development or testing is irrelevant. Thank you very much for the above words. I think they are much better than old comment. So the new version patch will use them. > > John > > > +# Possible values: {true,false} > > +# Default value: false > > +# > > +# force_use_qemu = false; > > diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c > > index 00eb4b1..4c0b0a1 100644 > > --- a/libxkutil/misc_util.c > > +++ b/libxkutil/misc_util.c > > @@ -227,6 +227,14 @@ static int is_read_only(void) > > return prop.value_bool; > > } > > > > +bool get_force_use_qemu(void) > > +{ > > + static LibvirtcimConfigProperty prop = { > > + "force_use_qemu", CONFIG_BOOL, {0}, 0}; > > + libvirt_cim_config_get(&prop); > > + return prop.value_bool; > > +} > > + > > const char *get_mig_ssh_tmp_key(void) > > { > > static LibvirtcimConfigProperty prop = { > > diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h > > index 0f52290..9e6b419 100644 > > --- a/libxkutil/misc_util.h > > +++ b/libxkutil/misc_util.h > > @@ -154,6 +154,7 @@ int virt_set_status(const CMPIBroker *broker, > > > > /* get libvirt-cim config */ > > const char *get_mig_ssh_tmp_key(void); > > +bool get_force_use_qemu(void); > > > > /* > > * Local Variables: > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > > index cbb646d..81ec064 100644 > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -394,6 +394,13 @@ static bool system_has_kvm(const char *pfx) > > virConnectPtr conn; > > char *caps = NULL; > > bool kvm = false; > > + bool force_use_qemu = get_force_use_qemu(); > > + > > + /* sometimes disable KVM to avoid problem in nested KVM */ > > + if (force_use_qemu) { > > + CU_DEBUG("Enter force use qemu mode!"); > > + return false; > > + } > > > > conn = connect_by_classname(_BROKER, pfx, &s); > > if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From cngesaint at outlook.com Mon May 13 06:01:54 2013 From: cngesaint at outlook.com (WangXu) Date: Mon, 13 May 2013 06:01:54 +0000 Subject: [Libvirt-cim] [PATCH V2 2/3] VSMS: tip error for invalid disk resource In-Reply-To: <518A9FD9.5060406@redhat.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com>, <1367478658-17026-3-git-send-email-cngesaint@outlook.com>, <518A9FD9.5060406@redhat.com> Message-ID: ---------------------------------------- > Date: Wed, 8 May 2013 14:56:25 -0400 > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Subject: Re: [Libvirt-cim] [PATCH V2 2/3] VSMS: tip error for invalid disk resource > > On 05/02/2013 03:10 AM, Xu Wang wrote: > > Original code will report xml text missing when a disk is not accessable, > > Not resolved from last review: > > s/accessable/accessible updated in V3 > > > make user confuse. This patch will report the real error to tip user check > > its system health state on the server. > > I also still see no example of what's being fixed. Before fixed, if I request a unavailable disk resource, the output is: $ wbemexec define_vm.xml The output seems to be a xml definition error instead of disk resource unavailable. Because the error is returned in a wrong place(there is no return if disk resource request failed). After fixed, if disk resource is unavailable, the output is: $ wbemexec define_vm.xml So the cause of failure could be printed correctly. > > > > Signed-off-by: Xu Wang > > --- > > src/Virt_VirtualSystemManagementService.c | 70 +++++++++++++++++++++-------- > > 1 files changed, 51 insertions(+), 19 deletions(-) > > > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > > index 81ec064..1652cf2 100644 > > --- a/src/Virt_VirtualSystemManagementService.c > > +++ b/src/Virt_VirtualSystemManagementService.c > > @@ -964,11 +964,13 @@ static const char *net_rasd_to_vdev(CMPIInstance *inst, > > }veillard at redhat.com > > > > static const char *disk_rasd_to_vdev(CMPIInstance *inst, > > - struct virt_device *dev) > > + struct virt_device *dev, > > + char **p_error) > > { > > const char *val = NULL; > > uint16_t type; > > bool read = false; > > + int rc; > > > > CU_DEBUG("Enter disk_rasd_to_vdev"); > > if (cu_get_str_prop(inst, "VirtualDevice", &val) != CMPI_RC_OK) > > @@ -984,6 +986,18 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, > > dev->dev.disk.source = strdup(val); > > dev->dev.disk.disk_type = disk_type_from_file(val); > > > > + if ((!XSTREQ(dev->dev.disk.source, "/dev/null")) && (dev->dev.disk.disk_type == DISK_UNKNOWN)) { > > So again, there's no checking for NULL on strdup() for dev.disk.source > which will cause a seg fault here. updated in V3 > > NACK and did not review remainder > > John > > + /* on success or fail caller should try free it */ > > + rc = asprintf(p_error, "Device %s, Address %s, " > > + "make sure Address can be accessed on host system.", > > + dev->dev.disk.virtual_dev, dev->dev.disk.source); > > + if (rc == -1) { > > + CU_DEBUG("error during recording exception!"); > > + p_error = NULL; > > + } > > + return "Can't get a valid disk type, "; > > + } > > + > > if (cu_get_u16_prop(inst, "EmulatedType", &type) != CMPI_RC_OK) > > type = VIRT_DISK_TYPE_DISK; > > > > @@ -1452,10 +1466,11 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, > > static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, > > struct virt_device *dev, > > uint16_t type, > > - const char *ns) > > + const char *ns, > > + char **p_error) > > { > > if (type == CIM_RES_TYPE_DISK) { > > - return disk_rasd_to_vdev(inst, dev); > > + return disk_rasd_to_vdev(inst, dev, p_error); > > } else if (type == CIM_RES_TYPE_NET) { > > return net_rasd_to_vdev(inst, dev, ns); > > } else if (type == CIM_RES_TYPE_MEM) { > > @@ -1494,7 +1509,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, > > static const char *rasd_to_vdev(CMPIInstance *inst, > > struct domain *domain, > > struct virt_device *dev, > > - const char *ns) > > + const char *ns, > > + char **p_error) > > { > > uint16_t type; > > CMPIObjectPath *op; > > @@ -1516,7 +1532,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, > > if (domain->type == DOMAIN_LXC) > > msg = _container_rasd_to_vdev(inst, dev, type, ns); > > else > > - msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns); > > + msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns, p_error); > > out: > > if (msg && op) > > CU_DEBUG("rasd_to_vdev(%s): %s", CLASSNAME(op), msg); > > @@ -1560,7 +1576,8 @@ static char *add_device_nodup(struct virt_device *dev, > > > > static const char *classify_resources(CMPIArray *resources, > > const char *ns, > > - struct domain *domain) > > + struct domain *domain, > > + char **p_error) > > { > > int i; > > uint16_t type; > > @@ -1613,13 +1630,15 @@ static const char *classify_resources(CMPIArray *resources, > > msg = rasd_to_vdev(inst, > > domain, > > &domain->dev_vcpu[0], > > - ns); > > + ns, > > + p_error); > > } else if (type == CIM_RES_TYPE_MEM) { > > domain->dev_mem_ct = 1; > > msg = rasd_to_vdev(inst, > > domain, > > &domain->dev_mem[0], > > - ns); > > + ns, > > + p_error); > > } else if (type == CIM_RES_TYPE_DISK) { > > struct virt_device dev; > > int dcount = count + domain->dev_disk_ct; > > @@ -1628,7 +1647,8 @@ static const char *classify_resources(CMPIArray *resources, > > msg = rasd_to_vdev(inst, > > domain, > > &dev, > > - ns); > > + ns, > > + p_error); > > if (msg == NULL) > > msg = add_device_nodup(&dev, > > domain->dev_disk, > > @@ -1646,7 +1666,8 @@ static const char *classify_resources(CMPIArray *resources, > > msg = rasd_to_vdev(inst, > > domain, > > &dev, > > - ns); > > + ns, > > + p_error); > > if (msg == NULL) > > msg = add_device_nodup(&dev, > > domain->dev_net, > > @@ -1676,7 +1697,8 @@ static const char *classify_resources(CMPIArray *resources, > > msg = rasd_to_vdev(inst, > > domain, > > &dev, > > - ns); > > + ns, > > + p_error); > > if (msg == NULL) > > msg = add_device_nodup(&dev, > > domain->dev_graphics, > > @@ -1687,7 +1709,8 @@ static const char *classify_resources(CMPIArray *resources, > > msg = rasd_to_vdev(inst, > > domain, > > &domain->dev_input[0], > > - ns); > > + ns, > > + p_error); > > } > > if (msg != NULL) > > return msg; > > @@ -2083,6 +2106,7 @@ static CMPIInstance *create_system(const CMPIContext *context, > > struct inst_list list; > > const char *props[] = {NULL}; > > struct domain *domain = NULL; > > + char *error_msg = NULL; > > > > inst_list_init(&list); > > > > @@ -2113,12 +2137,13 @@ static CMPIInstance *create_system(const CMPIContext *context, > > if (s->rc != CMPI_RC_OK) > > goto out; > > > > - msg = classify_resources(resources, NAMESPACE(ref), domain); > > + msg = classify_resources(resources, NAMESPACE(ref), domain, &error_msg); > > if (msg != NULL) { > > - CU_DEBUG("Failed to classify resources: %s", msg); > > + CU_DEBUG("Failed to classify resources: %s, %s", > > + msg, error_msg); > > cu_statusf(_BROKER, s, > > CMPI_RC_ERR_FAILED, > > - "ResourceSettings Error: %s", msg); > > + "ResourceSettings Error: %s, %s", msg, error_msg); > > goto out; > > } > > > > @@ -2159,6 +2184,7 @@ static CMPIInstance *create_system(const CMPIContext *context, > > > > > > out: > > + free(error_msg); > > cleanup_dominfo(&domain); > > free(xml); > > inst_list_free(&list); > > @@ -2638,6 +2664,7 @@ static CMPIStatus resource_add(struct domain *dominfo, > > struct virt_device *dev; > > int *count = NULL; > > const char *msg = NULL; > > + char *error_msg = NULL; > > > > op = CMGetObjectPath(rasd, &s); > > if ((op == NULL) || (s.rc != CMPI_RC_OK)) > > @@ -2677,12 +2704,12 @@ static CMPIStatus resource_add(struct domain *dominfo, > > dev = &list[*count]; > > > > dev->type = type; > > - msg = rasd_to_vdev(rasd, dominfo, dev, ns); > > + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); > > if (msg != NULL) { > > cu_statusf(_BROKER, &s, > > CMPI_RC_ERR_FAILED, > > - "Add resource failed: %s", > > - msg); > > + "Add resource failed: %s, %s", > > + msg, error_msg); > > goto out; > > } > > > > @@ -2702,6 +2729,8 @@ static CMPIStatus resource_add(struct domain *dominfo, > > (*count)++; > > > > out: > > + free(error_msg); > > + > > return s; > > } > > > > @@ -2718,6 +2747,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, > > int *count; > > int i; > > const char *msg = NULL; > > + char *error_msg = NULL; > > > > CU_DEBUG("Enter resource_mod"); > > if (devid == NULL) { > > @@ -2749,7 +2779,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, > > struct virt_device *dev = &list[i]; > > > > if (STREQ(dev->id, devid)) { > > - msg = rasd_to_vdev(rasd, dominfo, dev, ns); > > + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); > > if (msg != NULL) { > > cu_statusf(_BROKER, &s, > > CMPI_RC_ERR_FAILED, > > @@ -2793,6 +2823,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, > > } > > > > out: > > + free(error_msg); > > + > > return s; > > } > > > > > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From cngesaint at outlook.com Mon May 13 06:47:27 2013 From: cngesaint at outlook.com (WangXu) Date: Mon, 13 May 2013 06:47:27 +0000 Subject: [Libvirt-cim] [PATCH V2 0/3] libvirt-cim patches In-Reply-To: <518B9E98.1000808@redhat.com> References: <1367478658-17026-1-git-send-email-cngesaint@outlook.com>, <518B9E98.1000808@redhat.com> Message-ID: ---------------------------------------- > Date: Thu, 9 May 2013 09:03:20 -0400 > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Subject: Re: [Libvirt-cim] [PATCH V2 0/3] libvirt-cim patches > > On 05/02/2013 03:10 AM, Xu Wang wrote: > > V2 updates: > > 1. adjust comments for force use qemu (disable kvm under nested kvm) > > 2. fix the problem of cdrom (with blank or null disk) VSMS patch caused > > in V1 > > 3. fix syntax errors for comments > > 4. status return updates > > 5. add description about 8 maximum items limits about vsi support output > > > > > > Wenchao Xia (1): > > make force use qemu configurable > > > > Xu Wang (2): > > VSMS: tip error for invalid disk resource > > make lldptool command and support output configurable > > > > libvirt-cim.conf | 26 ++++++++++ > > libxkutil/misc_util.c | 26 ++++++++++ > > libxkutil/misc_util.h | 3 + > > src/Virt_SwitchService.c | 66 ++++++++++++++++++++---- > > src/Virt_VirtualSystemManagementService.c | 77 ++++++++++++++++++++++------- > > 5 files changed, 168 insertions(+), 30 deletions(-) > > > > > > Very strange - this is the 2nd time patch 3/3 didn't make it to my email > even though it's on the list. In fact my reply nor either of your > responses to my reply made it to the mail server. It's as if it has some > magic word or setting so that the mail server refuses to download it. I'll Cc you in every mail:-) > > In any case, I'm still not convinced there's not a memory leak, but > perhaps a Coverity or Valgrind run would answer that. I'll try to set up > Coverity run on the sources. It's a static variable so every caller use the same memory space. It needn't released by me and shouldn't be freed because other caller may use it too. > > Another consideration - perhaps the get_lldptool_query_options() and > get_vsi_support_key_string() should return a char * of the strdup()'d > prop.value string. You may also want to consider putting the defaults > into those functions too to hide them from the caller. > > For example, instead of: > > +const char *get_lldptool_query_options(void) > +{ > + static LibvirtcimConfigProperty prop = { > + "lldptool_query_options", CONFIG_STRING, {0}, 0}; > + > + libvirt_cim_config_get(&prop); > + return prop.value_string; > +} > + > > > go with > > char *get_lldptool_query_options(void) > { > static LibvirtcimConfigProperty prop = { > "lldptool_query_options", CONFIG_STRING, {0}, 0}; > > libvirt_cim_config_get(&prop); > if (prop.value_string) > return strdup(prop.value_string); > > return strdup("-t -g ncb -V evbcfg"); > } > > The caller checks for NULL return, errors appropriately and can free() > the returned string. Yes, it maybe a feasible way to deal with this command. I discussed with Wenchao for our design ideas and at last we decided to use the old code. The reason is that we think get_xxx method just include fetch value of pointed keywords string and return it to the caller. It wouldn't contain any logic processing. We'll keep the coding style. > > John > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From cngesaint at outlook.com Mon May 13 08:23:53 2013 From: cngesaint at outlook.com (cngesaint at outlook.com) Date: Mon, 13 May 2013 16:23:53 +0800 Subject: [Libvirt-cim] [PATCH V3 0/3] libvirt-cim patches Message-ID: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> From: Xu Wang updates: 1. title and comments for disable KVM updates 2. error message format updates (double ',' in VSMS) 3. added strdup null check Wenchao Xia (1): add an config option to disable KVM acceleration Xu Wang (2): VSMS: tip error for invalid disk resource make lldptool command and support output configurable libvirt-cim.conf | 25 +++++++++ libxkutil/misc_util.c | 26 +++++++++ libxkutil/misc_util.h | 3 + src/Virt_SwitchService.c | 66 +++++++++++++++++++---- src/Virt_VirtualSystemManagementService.c | 82 ++++++++++++++++++++++------- 5 files changed, 172 insertions(+), 30 deletions(-) From cngesaint at outlook.com Mon May 13 08:23:54 2013 From: cngesaint at outlook.com (cngesaint at outlook.com) Date: Mon, 13 May 2013 16:23:54 +0800 Subject: [Libvirt-cim] [PATCH V3 1/3] add an config option to disable KVM acceleration In-Reply-To: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> References: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> Message-ID: <1368433436-6356-2-git-send-email-cngesaint@outlook.com> From: Wenchao Xia Since libvirt-cim doesn't handle nested KVM well now, so add this option to manually disable KVM and fall back to qemu. Signed-off-by: Xu Wang --- libvirt-cim.conf | 9 +++++++++ libxkutil/misc_util.c | 8 ++++++++ libxkutil/misc_util.h | 1 + src/Virt_VirtualSystemManagementService.c | 7 +++++++ 4 files changed, 25 insertions(+), 0 deletions(-) diff --git a/libvirt-cim.conf b/libvirt-cim.conf index 37d7b0f..f6464c3 100644 --- a/libvirt-cim.conf +++ b/libvirt-cim.conf @@ -30,3 +30,12 @@ # Default value: NULL, that is not set. # # migrate_ssh_temp_key = "/root/vm_migrate_tmp_id_rsa"; + +# disable_kvm (bool) +# When executing in a nested KVM environment libvirt-cim may fail +# unexpectedly with some error. Setting "disable_kvm" option to true +# disables use of KVM and falls back to using QEMU directly. +# Possible values: {true,false} +# Default value: false +# +# disable_kvm = false; diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 00eb4b1..921604c 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -227,6 +227,14 @@ static int is_read_only(void) return prop.value_bool; } +bool get_disable_kvm(void) +{ + static LibvirtcimConfigProperty prop = { + "disable_kvm", CONFIG_BOOL, {0}, 0}; + libvirt_cim_config_get(&prop); + return prop.value_bool; +} + const char *get_mig_ssh_tmp_key(void) { static LibvirtcimConfigProperty prop = { diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h index 0f52290..8493005 100644 --- a/libxkutil/misc_util.h +++ b/libxkutil/misc_util.h @@ -154,6 +154,7 @@ int virt_set_status(const CMPIBroker *broker, /* get libvirt-cim config */ const char *get_mig_ssh_tmp_key(void); +bool get_disable_kvm(void); /* * Local Variables: diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index cbb646d..1369c6a 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -394,6 +394,13 @@ static bool system_has_kvm(const char *pfx) virConnectPtr conn; char *caps = NULL; bool kvm = false; + bool disable_kvm = get_disable_kvm(); + + /* sometimes disable KVM to avoid problem in nested KVM */ + if (disable_kvm) { + CU_DEBUG("Enter disable kvm mode!"); + return false; + } conn = connect_by_classname(_BROKER, pfx, &s); if ((conn == NULL) || (s.rc != CMPI_RC_OK)) { -- 1.7.1 From cngesaint at outlook.com Mon May 13 08:23:56 2013 From: cngesaint at outlook.com (cngesaint at outlook.com) Date: Mon, 13 May 2013 16:23:56 +0800 Subject: [Libvirt-cim] [PATCH V3 3/3] make lldptool command and support output configurable In-Reply-To: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> References: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> Message-ID: <1368433436-6356-4-git-send-email-cngesaint@outlook.com> From: Xu Wang If lldptool command or vsi support output updates, user can update items in the libvirt-cim.conf file. The config option could support maximum 8 items. Signed-off-by: Xu Wang --- libvirt-cim.conf | 16 +++++++++++ libxkutil/misc_util.c | 18 ++++++++++++ libxkutil/misc_util.h | 2 + src/Virt_SwitchService.c | 66 ++++++++++++++++++++++++++++++++++++++------- 4 files changed, 91 insertions(+), 11 deletions(-) diff --git a/libvirt-cim.conf b/libvirt-cim.conf index f6464c3..d268169 100644 --- a/libvirt-cim.conf +++ b/libvirt-cim.conf @@ -39,3 +39,19 @@ # Default value: false # # disable_kvm = false; + +# lldptool_query_options (string) +# Defines the command used in SwitchService to query VEPA support, will be +# used as "lldptool -i [INTERFACE] [OPTIONS]" +# +# lldptool_query_options = "-t -g ncb -V evbcfg"; + +# vsi_support_key_string (string) +# Defines the string used in SwitchService to search in lldptool's output +# When lldptool updates its output, please set this value and update the +# output set, maximum 8 items. use comma to devide items. If there is +# no need to change the output set, please do not leave it void. Because +# this value has higher level than default. +# +# vsi_support_key_string = "{ supported forwarding mode: (0x40) reflective relay," +# " supported capabilities: (0x7) RTE ECP VDP}"; diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 921604c..d4515e6 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -244,6 +244,24 @@ const char *get_mig_ssh_tmp_key(void) return prop.value_string; } +const char *get_lldptool_query_options(void) +{ + static LibvirtcimConfigProperty prop = { + "lldptool_query_options", CONFIG_STRING, {0}, 0}; + + libvirt_cim_config_get(&prop); + return prop.value_string; +} + +const char *get_vsi_support_key_string(void) +{ + static LibvirtcimConfigProperty prop = { + "vsi_support_key_string", CONFIG_STRING, {0}, 0};; + + libvirt_cim_config_get(&prop); + return prop.value_string; +} + virConnectPtr connect_by_classname(const CMPIBroker *broker, const char *classname, CMPIStatus *s) diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h index 8493005..3279b09 100644 --- a/libxkutil/misc_util.h +++ b/libxkutil/misc_util.h @@ -155,6 +155,8 @@ int virt_set_status(const CMPIBroker *broker, /* get libvirt-cim config */ const char *get_mig_ssh_tmp_key(void); bool get_disable_kvm(void); +const char *get_lldptool_query_options(void); +const char *get_vsi_support_key_string(void); /* * Local Variables: diff --git a/src/Virt_SwitchService.c b/src/Virt_SwitchService.c index 8991426..983ebc0 100644 --- a/src/Virt_SwitchService.c +++ b/src/Virt_SwitchService.c @@ -46,12 +46,29 @@ static CMPIStatus check_vsi_support(char *command) CMPIStatus s = {CMPI_RC_OK, NULL}; char buff[MAX_LEN]; FILE *stream = NULL; - const char *searchStr[] = {" supported forwarding mode: " - "(0x40) reflective relay", - " supported capabilities: " - "(0x07) RTE ECP VDP", - NULL}; - int matched = 0; + char *searchStr[8]; /* maximum items of vsi support output */ + int count = 0; + const char *user_settings = get_vsi_support_key_string(); + char *vsi_support_key_string = NULL; + char *delim = "{},"; + int matched = 0; + char *temp = NULL; + + if (!user_settings) { + /* default supported output set, 8 maximum */ + user_settings = "{ supported forwarding mode: " + "(0x40) reflective relay," + " supported capabilities: " + "(0x7) RTE ECP VDP}"; + } + + vsi_support_key_string = strdup(user_settings); + if (vsi_support_key_string == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Strdup vsi_support_key_string failed!"); + goto out; + } // Run lldptool command to find vsi support. stream = popen(command, "r"); @@ -63,6 +80,25 @@ static CMPIStatus check_vsi_support(char *command) goto out; } + /* Slice vsi_support_key_string into items */ + searchStr[count] = strtok_r(vsi_support_key_string, delim, &temp); + if (searchStr[count] == NULL) { + CU_DEBUG("searchStr fetch failed when calling strtok_r!"); + } else { + CU_DEBUG("searchStr[%d]: %s", count, searchStr[count]); + count++; + } + + while ((searchStr[count] = strtok_r(NULL, delim, &temp))) { + if (count >= 7) { + CU_DEBUG("WARN: searchStr is full, left aborted!"); + break; + } else { + CU_DEBUG("searchStr[%d]: %s", count, searchStr[count]); + count++; + } + } + // Read the output of the command. while (fgets(buff, MAX_LEN, stream) != NULL) { int i = 0; @@ -81,16 +117,18 @@ static CMPIStatus check_vsi_support(char *command) } /* All the search strings were found in the output of this command. */ - if (matched == 2) { + if (matched == count) { cu_statusf(_BROKER, &s, CMPI_RC_OK, "VSI supported"); - goto out;; + goto out; } } + cu_statusf(_BROKER, &s, CMPI_RC_ERR_NOT_FOUND, "No VSI Support found"); - out: + out: + free(vsi_support_key_string); if (stream != NULL) pclose(stream); return s; @@ -214,6 +252,7 @@ static CMPIStatus get_switchservice(const CMPIObjectPath *reference, int i; char **if_list; char cmd[MAX_LEN]; + const char *lldptool_query_options = NULL; *_inst = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); @@ -257,10 +296,15 @@ static CMPIStatus get_switchservice(const CMPIObjectPath *reference, CU_DEBUG("Found %d interfaces", count); + lldptool_query_options = get_lldptool_query_options(); + if (!lldptool_query_options) { + lldptool_query_options = "-t -g ncb -V evbcfg"; + } for (i=0; i References: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> Message-ID: <1368433436-6356-3-git-send-email-cngesaint@outlook.com> From: Xu Wang Original code will report xml text missing when a disk is not accessible, making user confuse. This patch will report the real error to tip user check its system health state on the server. Signed-off-by: Xu Wang --- src/Virt_VirtualSystemManagementService.c | 75 +++++++++++++++++++++------- 1 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 1369c6a..d3a580f 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -964,11 +964,13 @@ static const char *net_rasd_to_vdev(CMPIInstance *inst, } static const char *disk_rasd_to_vdev(CMPIInstance *inst, - struct virt_device *dev) + struct virt_device *dev, + char **p_error) { const char *val = NULL; uint16_t type; bool read = false; + int rc; CU_DEBUG("Enter disk_rasd_to_vdev"); if (cu_get_str_prop(inst, "VirtualDevice", &val) != CMPI_RC_OK) @@ -982,8 +984,25 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, free(dev->dev.disk.source); dev->dev.disk.source = strdup(val); + if (dev->dev.disk.source == NULL) { + return "dev->dev.disk.source is null!"; + } + dev->dev.disk.disk_type = disk_type_from_file(val); + if ((!XSTREQ(dev->dev.disk.source, "/dev/null")) && + (dev->dev.disk.disk_type == DISK_UNKNOWN)) { + /* on success or fail caller should try free it */ + rc = asprintf(p_error, "Device %s, Address %s, " + "make sure Address can be accessed on host system.", + dev->dev.disk.virtual_dev, dev->dev.disk.source); + if (rc == -1) { + CU_DEBUG("error during recording exception!"); + p_error = NULL; + } + return "Can't get a valid disk type"; + } + if (cu_get_u16_prop(inst, "EmulatedType", &type) != CMPI_RC_OK) type = VIRT_DISK_TYPE_DISK; @@ -1452,10 +1471,11 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev, uint16_t type, - const char *ns) + const char *ns, + char **p_error) { if (type == CIM_RES_TYPE_DISK) { - return disk_rasd_to_vdev(inst, dev); + return disk_rasd_to_vdev(inst, dev, p_error); } else if (type == CIM_RES_TYPE_NET) { return net_rasd_to_vdev(inst, dev, ns); } else if (type == CIM_RES_TYPE_MEM) { @@ -1494,7 +1514,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, static const char *rasd_to_vdev(CMPIInstance *inst, struct domain *domain, struct virt_device *dev, - const char *ns) + const char *ns, + char **p_error) { uint16_t type; CMPIObjectPath *op; @@ -1516,7 +1537,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, if (domain->type == DOMAIN_LXC) msg = _container_rasd_to_vdev(inst, dev, type, ns); else - msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns); + msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns, p_error); out: if (msg && op) CU_DEBUG("rasd_to_vdev(%s): %s", CLASSNAME(op), msg); @@ -1560,7 +1581,8 @@ static char *add_device_nodup(struct virt_device *dev, static const char *classify_resources(CMPIArray *resources, const char *ns, - struct domain *domain) + struct domain *domain, + char **p_error) { int i; uint16_t type; @@ -1613,13 +1635,15 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &domain->dev_vcpu[0], - ns); + ns, + p_error); } else if (type == CIM_RES_TYPE_MEM) { domain->dev_mem_ct = 1; msg = rasd_to_vdev(inst, domain, &domain->dev_mem[0], - ns); + ns, + p_error); } else if (type == CIM_RES_TYPE_DISK) { struct virt_device dev; int dcount = count + domain->dev_disk_ct; @@ -1628,7 +1652,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &dev, - ns); + ns, + p_error); if (msg == NULL) msg = add_device_nodup(&dev, domain->dev_disk, @@ -1646,7 +1671,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &dev, - ns); + ns, + p_error); if (msg == NULL) msg = add_device_nodup(&dev, domain->dev_net, @@ -1676,7 +1702,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &dev, - ns); + ns, + p_error); if (msg == NULL) msg = add_device_nodup(&dev, domain->dev_graphics, @@ -1687,7 +1714,8 @@ static const char *classify_resources(CMPIArray *resources, msg = rasd_to_vdev(inst, domain, &domain->dev_input[0], - ns); + ns, + p_error); } if (msg != NULL) return msg; @@ -2083,6 +2111,7 @@ static CMPIInstance *create_system(const CMPIContext *context, struct inst_list list; const char *props[] = {NULL}; struct domain *domain = NULL; + char *error_msg = NULL; inst_list_init(&list); @@ -2113,12 +2142,13 @@ static CMPIInstance *create_system(const CMPIContext *context, if (s->rc != CMPI_RC_OK) goto out; - msg = classify_resources(resources, NAMESPACE(ref), domain); + msg = classify_resources(resources, NAMESPACE(ref), domain, &error_msg); if (msg != NULL) { - CU_DEBUG("Failed to classify resources: %s", msg); + CU_DEBUG("Failed to classify resources: %s, %s", + msg, error_msg); cu_statusf(_BROKER, s, CMPI_RC_ERR_FAILED, - "ResourceSettings Error: %s", msg); + "ResourceSettings Error: %s, %s", msg, error_msg); goto out; } @@ -2159,6 +2189,7 @@ static CMPIInstance *create_system(const CMPIContext *context, out: + free(error_msg); cleanup_dominfo(&domain); free(xml); inst_list_free(&list); @@ -2638,6 +2669,7 @@ static CMPIStatus resource_add(struct domain *dominfo, struct virt_device *dev; int *count = NULL; const char *msg = NULL; + char *error_msg = NULL; op = CMGetObjectPath(rasd, &s); if ((op == NULL) || (s.rc != CMPI_RC_OK)) @@ -2677,12 +2709,12 @@ static CMPIStatus resource_add(struct domain *dominfo, dev = &list[*count]; dev->type = type; - msg = rasd_to_vdev(rasd, dominfo, dev, ns); + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); if (msg != NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Add resource failed: %s", - msg); + "Add resource failed: %s, %s", + msg, error_msg); goto out; } @@ -2702,6 +2734,8 @@ static CMPIStatus resource_add(struct domain *dominfo, (*count)++; out: + free(error_msg); + return s; } @@ -2718,6 +2752,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, int *count; int i; const char *msg = NULL; + char *error_msg = NULL; CU_DEBUG("Enter resource_mod"); if (devid == NULL) { @@ -2749,7 +2784,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, struct virt_device *dev = &list[i]; if (STREQ(dev->id, devid)) { - msg = rasd_to_vdev(rasd, dominfo, dev, ns); + msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); if (msg != NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -2793,6 +2828,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, } out: + free(error_msg); + return s; } -- 1.7.1 From jferlan at redhat.com Tue May 14 16:51:43 2013 From: jferlan at redhat.com (John Ferlan) Date: Tue, 14 May 2013 12:51:43 -0400 Subject: [Libvirt-cim] [PATCH V3 0/3] libvirt-cim patches In-Reply-To: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> References: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> Message-ID: <51926B9F.4020303@redhat.com> On 05/13/2013 04:23 AM, cngesaint at outlook.com wrote: > From: Xu Wang > > updates: > 1. title and comments for disable KVM updates > 2. error message format updates (double ',' in VSMS) > 3. added strdup null check > > Wenchao Xia (1): > add an config option to disable KVM acceleration > > Xu Wang (2): > VSMS: tip error for invalid disk resource > make lldptool command and support output configurable > > libvirt-cim.conf | 25 +++++++++ > libxkutil/misc_util.c | 26 +++++++++ > libxkutil/misc_util.h | 3 + > src/Virt_SwitchService.c | 66 +++++++++++++++++++---- > src/Virt_VirtualSystemManagementService.c | 82 ++++++++++++++++++++++------- > 5 files changed, 172 insertions(+), 30 deletions(-) > > ACK on all 3 patches. I still didn't get 3/3 - there's some filter that doesn't allow it through our mail system. I did do a Coverity run on the sources prior to these patches - I'll be sending out a set of patches for things found. Nothing major, there will be 19 patches. I wasn't able to re-run with these patches due to some internal license server issues, but hopefully those get cleared up soon. John From jferlan at redhat.com Wed May 15 18:42:48 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 15 May 2013 14:42:48 -0400 Subject: [Libvirt-cim] [PATCH v2 00/12] cimtest updates In-Reply-To: <1366812554-6591-1-git-send-email-jferlan@redhat.com> References: <1366812554-6591-1-git-send-email-jferlan@redhat.com> Message-ID: <5193D728.7050409@redhat.com> On 04/24/2013 10:09 AM, John Ferlan wrote: > This is primarily a repost of the previous series: > > https://www.redhat.com/archives/libvirt-cim/2013-March/msg00051.html > > and > > https://www.redhat.com/archives/libvirt-cim/2013-April/msg00014.html > > The primary difference in this patch vs. the previous sets is to fix the > version string checking for nfs server checking in common_util.py and to > add patch 12/12 which handles a problem in 'enum_volumes()' in pool.py. > > I assume patches 1-4 and 6-9 were reviewed without issue. So focus on 5/12 > and 10-12/12. > > > John Ferlan (12): > Need to check "slp=true", not just "slp" since "slp=false" is possible > Change the MAC from "99:" to "88:" > Create a temporary directory for disk pool tests > Use symbols as named in libvirt-cim for easier reference > Fix nfs-server lookup code > Fix os_status passing to reporter functions > Resolve issues found in test. > On Fedora systems default to using 'em1' instead of 'eth1' > 19 - resolve issues found in test > vxml: Add which volume could not be found to error message > Add and utilize virsh_version_cmp > pool: Need to handle when there are no volumes in the default pool > > .../Profile/04_verify_libvirt_cim_slp_profiles.py | 2 +- > .../08_CreateDiskResourcePool.py | 30 +++++-- > .../09_DeleteDiskPool.py | 19 +++-- > .../10_create_storagevolume.py | 6 +- > .../11_create_dir_storagevolume_errs.py | 5 +- > .../12_create_netfs_storagevolume_errs.py | 5 +- > .../13_delete_storagevolume.py | 5 +- > .../14_delete_storagevolume_errs.py | 5 +- > .../15_DiskPoolAutostart.py | 15 +++- > .../SettingsDefineCapabilities/01_forward.py | 1 - > .../libvirt-cim/cimtest/VSSD/06_duplicate_uuid.py | 2 +- > .../06_addresource.py | 2 +- > .../08_modifyresource.py | 4 +- > .../13_refconfig_additional_devs.py | 4 +- > .../15_mod_system_settings.py | 11 ++- > .../18_define_sys_bridge.py | 2 +- > .../19_definenetwork_ers.py | 23 +++--- > .../22_addmulti_brg_interface.py | 2 +- > .../27_definesystem_macvtap_dev.py | 19 ++++- > .../28_definesystem_with_vsi_profile.py | 15 ++++ > suites/libvirt-cim/lib/XenKvmLib/common_util.py | 93 +++++++++++++++++----- > suites/libvirt-cim/lib/XenKvmLib/const.py | 6 +- > suites/libvirt-cim/lib/XenKvmLib/pool.py | 10 +-- > suites/libvirt-cim/lib/XenKvmLib/rasd.py | 10 ++- > suites/libvirt-cim/lib/XenKvmLib/test_xml.py | 2 +- > suites/libvirt-cim/lib/XenKvmLib/vxml.py | 4 +- > suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 6 ++ > suites/libvirt-cim/main.py | 15 ++++ > 28 files changed, 237 insertions(+), 86 deletions(-) > I have pushed the series to cimtest.git I have a fix for the issues mentioned in follow-up exchanges regarding 22_addmulti_brg_interface.py which I will post shortly. John From jferlan at redhat.com Wed May 15 18:55:07 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 15 May 2013 14:55:07 -0400 Subject: [Libvirt-cim] [PATCH] Resolve hotplug failure for VSMS test 22 Message-ID: <1368644108-19447-1-git-send-email-jferlan@redhat.com> Followup to exchange as part of previous cimtest checkin: https://www.redhat.com/archives/libvirt-cim/2013-May/msg00005.html Test was failing as follows: VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging") ERROR - Error invoking AddRS: add_net_res ERROR - AddResourceSettings call failed ERROR - Failed to destroy Virtual Network 'my_network1' InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging Bug:<00015> Through some investigation, I found/figured that Acpi needed to be set for the domain so that hotplug would work properly. After applying this patch, the test succeeds for me. John Ferlan (1): Allow adding bridged network for running domain .../22_addmulti_brg_interface.py | 9 +++++++-- suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 17 +++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) -- 1.8.1.4 From jferlan at redhat.com Wed May 15 18:55:08 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 15 May 2013 14:55:08 -0400 Subject: [Libvirt-cim] [PATCH] Allow adding bridged network for running domain In-Reply-To: <1368644108-19447-1-git-send-email-jferlan@redhat.com> References: <1368644108-19447-1-git-send-email-jferlan@redhat.com> Message-ID: <1368644108-19447-2-git-send-email-jferlan@redhat.com> Test failed with following: VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging") ERROR - Error invoking AddRS: add_net_res ERROR - AddResourceSettings call failed ERROR - Failed to destroy Virtual Network 'my_network1' InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging Bug:<00015> The fix for this was that the domain needed to be created with the "acpi=True" flag. This allowed the test to get a bit further, but it then failed with the following: VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL ERROR - Got 88:aa:bb:cc:ee:ff, exp 88:aa:bb:cc:ee:ff. Got None, exp my_network1. ERROR - Error invoking AddRS: add_net_res ERROR - Error adding rs for net mac ERROR - Failed to destroy Virtual Network 'my_network1' The issue here is that the created network bridge didn't have an xml resource "source network" as 'my_network1', rather that name is assigned to the pool. A network bridge has a resource "source bridge" which can be compared. Since I wasn't sure how a Xen domain would look I separated the valiation comparisons. --- .../22_addmulti_brg_interface.py | 9 +++++++-- suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 17 +++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py index 36d1873..0452bf6 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py @@ -63,8 +63,13 @@ def main(): service = get_vsms_class(options.virt)(options.ip) classname = get_typed_class(options.virt, 'VirtualSystemSettingData') - vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, - net_name=default_brg) + # Seems ACPI needs to be set for KVM in order for hotplug to work right + if options.virt == "KVM": + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg, acpi=True) + else: + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg) try: ret = vsxml.cim_define(options.ip) if not ret: diff --git a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py index 075c09f..cba7ce0 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py @@ -189,9 +189,14 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): % attr['nmac']) if virt == "KVM": + # For KVM, compare the source bridge name = cxml.get_value_xpath( - '/domain/devices/interface/source/@network[. = "%s"]' - % attr['net_name']) + '/domain/devices/interface/source/@bridge[. = "%s"]' + % attr['virt_net']) + if mac != attr['nmac'] or name != attr['virt_net']: + logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s.", + mac, attr['nmac'], name, attr['virt_net']) + raise Exception('Error adding rs for net mac') else: # For Xen, network interfaces are converted to bridge interfaces. @@ -202,10 +207,10 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): if name != None: name = attr['net_name'] - if mac != attr['nmac'] or name != attr['net_name']: - logger.error("Got %s, exp %s. Got %s, exp %s.", mac, - attr['nmac'], name, attr['net_name']) - raise Exception('Error adding rs for net mac') + if mac != attr['nmac'] or name != attr['net_name']: + logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s. br %s", + mac, attr['nmac'], name, attr['net_name'], br) + raise Exception('Error adding rs for net mac') logger.info('good status for net_mac') except Exception, details: -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:35 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:35 -0400 Subject: [Libvirt-cim] [PATCH 00/19] Resolve Coverity warnings Message-ID: <1368716274-31619-1-git-send-email-jferlan@redhat.com> The following set of patches resolve a number of Coverity errors/warnings that have crept into the code. After these changes there will be zero warnings John Ferlan (19): Coverity: Resolve BAD_COMPARE - ActivateFilter() Coverity: Resolve CHECKED_RETURN - _generic_infostore_open() Coverity: Resolve CHECKED_RETURN - filter_by_pool() Coverity: Resolve CHECKED_RETURN - get_dev_from_pool Coverity: Resolve CHECKED_RETURN - get_pools() Coverity: Resolve CHECKED_RETURN - mem_rasd_to_vdev() Coverity: Resolve CHECKED_RETURN - return_enum_rasds() Coverity: Resolve DEADCODE - do_parse() Coverity: Resolve DEADCODE - get_hypervisor_enabled() Coverity: Resolve DEADCODE - octets_from_ip() Coverity: Resolve NO_EFFECT - set_proc_rasd_params() Coverity: Resolve NO_EFFECT - _set_fv_prop() Coverity: Resolve RESOURCE_LEAK - parse_os() Coverity: Resolve REVERSE_INULL - doms_to_xml() Coverity: Resolve REVERSE_INULL - lifecycle_thread_native() Coverity: Resolve UNINIT - vsss_delete_snapshot() Coverity: Resolve UNUSED_VALUE - system_xml() && mem_xml() Coverity: Resolve USE_AFTER_FREE - lifecycle_thread_native() Coverity: Resolve ARRAY_VS_SINGLETON - get_dev_paths() and callers libxkutil/device_parsing.c | 8 +++++++- libxkutil/infostore.c | 5 ++++- libxkutil/misc_util.c | 4 ++-- libxkutil/xmlgen.c | 16 ++++++++++++++++ src/Virt_ComputerSystemIndication.c | 19 +++++++++++++------ src/Virt_ElementAllocatedFromPool.c | 12 +++++++----- src/Virt_FilterEntry.c | 3 --- src/Virt_RASD.c | 20 ++++++++++++++------ src/Virt_ResourceAllocationFromPool.c | 4 +++- src/Virt_ResourcePoolConfigurationService.c | 20 +++++++------------- src/Virt_VSSD.c | 2 +- src/Virt_VirtualSystemManagementService.c | 4 +++- src/Virt_VirtualSystemSnapshotService.c | 2 +- 13 files changed, 78 insertions(+), 41 deletions(-) -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:37 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:37 -0400 Subject: [Libvirt-cim] [PATCH 02/19] Coverity: Resolve CHECKED_RETURN - _generic_infostore_open() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-3-git-send-email-jferlan@redhat.com> (7) Event check_return: Calling function "fstat(isc->fd, &s)" without checking return value. This library function may fail and return an error code. 196 fstat(isc->fd, &s); Resolve by adding if (fstat->isc->fd, &s) < 0) --- libxkutil/infostore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libxkutil/infostore.c b/libxkutil/infostore.c index dd1e38c..a88b586 100644 --- a/libxkutil/infostore.c +++ b/libxkutil/infostore.c @@ -193,7 +193,10 @@ static struct infostore_ctx *_generic_infostore_open(char *filename) goto err; } - fstat(isc->fd, &s); + if (fstat(isc->fd, &s) < 0) { + CU_DEBUG("Failed to fstat infostore"); + goto err; + } if (s.st_size == 0) isc->doc = new_xml(); else -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:38 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:38 -0400 Subject: [Libvirt-cim] [PATCH 03/19] Coverity: Resolve CHECKED_RETURN - filter_by_pool() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-4-git-send-email-jferlan@redhat.com> 115 (17) Event check_return: Calling function "cu_get_str_prop(CMPIInstance const *, char const *, char const **)" without checking return value (as is done elsewhere 72 out of 77 times). (24) Event unchecked_value: No check of the return value of "cu_get_str_prop(inst, "InstanceID", &rasd_id)". 116 cu_get_str_prop(inst, "InstanceID", &rasd_id); Resolved by adding a check against CMPI_RC_OK, if not equal then just continue --- src/Virt_ResourceAllocationFromPool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Virt_ResourceAllocationFromPool.c b/src/Virt_ResourceAllocationFromPool.c index e702387..398eef5 100644 --- a/src/Virt_ResourceAllocationFromPool.c +++ b/src/Virt_ResourceAllocationFromPool.c @@ -113,7 +113,9 @@ static int filter_by_pool(struct inst_list *dest, CMPI_RC_OK) continue; - cu_get_str_prop(inst, "InstanceID", &rasd_id); + if (cu_get_str_prop(inst, "InstanceID", &rasd_id) != + CMPI_RC_OK) + continue; poolid = pool_member_of(_BROKER, CLASSNAME(op), type, rasd_id); if ((poolid != NULL) && STREQ(poolid, _poolid)) -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:36 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:36 -0400 Subject: [Libvirt-cim] [PATCH 01/19] Coverity: Resolve BAD_COMPARE - ActivateFilter() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-2-git-send-email-jferlan@redhat.com> Two examples of: 807 thread->id = _BROKER->xft->newThread(lifecycle_thread_native, 808 thread, 0); 809 (1) Event null_misuse: Comparing pointer "thread->id" against NULL using anything besides == or != is likely to be incorrect. 810 if (thread->id <= 0) { 811 CU_DEBUG("Error, failed to create new thread."); 812 error = true; Resolve this and subsequent use by changing comparison to: if (thread->id == NULL) { --- src/Virt_ComputerSystemIndication.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c index 247143c..e9fa0c2 100644 --- a/src/Virt_ComputerSystemIndication.c +++ b/src/Virt_ComputerSystemIndication.c @@ -807,7 +807,7 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI *mi, thread->id = _BROKER->xft->newThread(lifecycle_thread_native, thread, 0); - if (thread->id <= 0) { + if (thread->id == NULL) { CU_DEBUG("Error, failed to create new thread."); error = true; } @@ -1463,7 +1463,7 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI* mi, thread->args = args; thread->id = _BROKER->xft->newThread(lifecycle_thread, thread, 0); - if (thread->id <= 0) { + if (thread->id == NULL) { CU_DEBUG("Error, failed to create new thread."); error = true; } -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:39 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:39 -0400 Subject: [Libvirt-cim] [PATCH 04/19] Coverity: Resolve CHECKED_RETURN - get_dev_from_pool In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-5-git-send-email-jferlan@redhat.com> (4) Event check_return: Calling function "cu_get_str_prop(CMPIInstance const *, char const *, char const **)" without checking return value (as is done elsewhere 72 out of 77 times). (11) Event unchecked_value: No check of the return value of "cu_get_str_prop(inst, "CreationClassName", &cn)". 118 cu_get_str_prop(inst, "CreationClassName", &cn); 119 cu_get_str_prop(inst, "DeviceID", &dev_id); 120 121 if ((dev_id == NULL) || (cn == NULL)) 122 continue; Resolve by making proper check of function return vs. CMPI_RC_OK and removing the NULL checks since they are redundant. --- src/Virt_ElementAllocatedFromPool.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c index ad9134c..c7813b7 100644 --- a/src/Virt_ElementAllocatedFromPool.c +++ b/src/Virt_ElementAllocatedFromPool.c @@ -115,10 +115,10 @@ static CMPIStatus get_dev_from_pool(const CMPIObjectPath *ref, const char *cn = NULL; const char *dev_id = NULL; - cu_get_str_prop(inst, "CreationClassName", &cn); - cu_get_str_prop(inst, "DeviceID", &dev_id); - - if ((dev_id == NULL) || (cn == NULL)) + if (cu_get_str_prop(inst, "CreationClassName", &cn) != + CMPI_RC_OK) + continue; + if (cu_get_str_prop(inst, "DeviceID", &dev_id) != CMPI_RC_OK) continue; poolid = pool_member_of(_BROKER, cn, type, dev_id); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:41 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:41 -0400 Subject: [Libvirt-cim] [PATCH 06/19] Coverity: Resolve CHECKED_RETURN - mem_rasd_to_vdev() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-7-git-send-email-jferlan@redhat.com> 1089 dev->dev.mem.maxsize = dev->dev.mem.size; (4) Event check_return: Calling function "cu_get_u64_prop(CMPIInstance const *, char const *, uint64_t *)" without checking return value (as is done elsewhere 9 out of 10 times). (14) Event unchecked_value: No check of the return value of "cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize)". 1090 cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); Resolve by adding check and returning a message indicating what's missing --- src/Virt_VirtualSystemManagementService.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index cbb646d..ebf3e4a 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1087,7 +1087,9 @@ static const char *mem_rasd_to_vdev(CMPIInstance *inst, return "Missing `VirtualQuantity' field in Memory RASD"; dev->dev.mem.maxsize = dev->dev.mem.size; - cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); + ret = cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); + if (ret != CMPI_RC_OK) + return "Missing `Limit' field in Memory RASD"; if (cu_get_str_prop(inst, "AllocationUnits", &units) != CMPI_RC_OK) { CU_DEBUG("Memory RASD has no units, assuming bytes"); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:40 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:40 -0400 Subject: [Libvirt-cim] [PATCH 05/19] Coverity: Resolve CHECKED_RETURN - get_pools() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-6-git-send-email-jferlan@redhat.com> (7) Event check_return: Calling function "cu_get_str_prop(CMPIInstance const *, char const *, char const **)" without checking return value (as is done elsewhere 72 out of 77 times). (14) Event unchecked_value: No check of the return value of "cu_get_str_prop(inst, "InstanceID", &id)". 171 cu_get_str_prop(inst, "InstanceID", &id); Resolve by checking return status vs. CMPI_RC_OK and just continuing to next entry --- src/Virt_ElementAllocatedFromPool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Virt_ElementAllocatedFromPool.c b/src/Virt_ElementAllocatedFromPool.c index c7813b7..946580c 100644 --- a/src/Virt_ElementAllocatedFromPool.c +++ b/src/Virt_ElementAllocatedFromPool.c @@ -168,7 +168,9 @@ static CMPIStatus get_pools(const CMPIObjectPath *ref, CMPIInstance *inst = tmp.list[i]; const char *id = NULL; - cu_get_str_prop(inst, "InstanceID", &id); + if (cu_get_str_prop(inst, "InstanceID", &id) != + CMPI_RC_OK) + continue; if (!STREQC(id, poolid)) inst_list_add(list, inst); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:46 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:46 -0400 Subject: [Libvirt-cim] [PATCH 11/19] Coverity: Resolve NO_EFFECT - set_proc_rasd_params() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-12-git-send-email-jferlan@redhat.com> 143 if (domain_online(dom)) 144 count = domain_vcpu_count(dom); 145 else 146 count = dev->dev.vcpu.quantity; 147 (1) Event unsigned_compare: This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "count >= 0UL". 148 if (count >= 0) Resolve by adjusting logic. Problem was that the active count is returned as an int with an error value of -1, while the quantity value is guaranteed to be 1 or more (see parse_vcpu_device() processing). So initialize count to zero, then only set the property if count > 0. Setting count of the active condition requires a local "active_count" and checking that to be > 0 before blindly setting it to count. Imagine 0xfffffffffffffff vcpu's! --- src/Virt_RASD.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index ad1a2e7..a4cba5b 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -124,7 +124,7 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, struct infostore_ctx *info = NULL; uint32_t weight = 0; uint64_t limit; - uint64_t count; + uint64_t count = 0; conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) @@ -140,12 +140,15 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, goto out; } - if (domain_online(dom)) - count = domain_vcpu_count(dom); - else + if (domain_online(dom)) { + int active_count = domain_vcpu_count(dom); + if (active_count > 0) + count = active_count; + } else { count = dev->dev.vcpu.quantity; + } - if (count >= 0) + if (count > 0) CMSetProperty(inst, "VirtualQuantity", (CMPIValue *)&count, -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:42 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:42 -0400 Subject: [Libvirt-cim] [PATCH 07/19] Coverity: Resolve CHECKED_RETURN - return_enum_rasds() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-8-git-send-email-jferlan@redhat.com> 1097 inst_list_init(&list); 1098 (1) Event check_return: Calling function "res_type_from_rasd_classname(char const *, uint16_t *)" without checking return value (as is done elsewhere 11 out of 12 times). (7) Event unchecked_value: No check of the return value of "res_type_from_rasd_classname( (char *)(*ref->ft->getClassName)(ref, NULL)->hdl, &type)". 1099 res_type_from_rasd_classname(CLASSNAME(ref), &type); Resolve by checking return vs. CMPI_RC_OK, setting error, and returning --- src/Virt_RASD.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 6e8a244..ad1a2e7 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -1096,7 +1096,12 @@ static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref, inst_list_init(&list); - res_type_from_rasd_classname(CLASSNAME(ref), &type); + if (res_type_from_rasd_classname(CLASSNAME(ref), &type) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to determine RASD type"); + goto out; + } s = enum_rasds(_BROKER, ref, NULL, type, properties, &list); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:44 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:44 -0400 Subject: [Libvirt-cim] [PATCH 09/19] Coverity: Resolve DEADCODE - get_hypervisor_enabled() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-10-git-send-email-jferlan@redhat.com> (1) Event assignment: Assigning: "h" = "&hypervisor_list[0]". (2) Event notnull: At condition "h != NULL", the value of "h" cannot be NULL. (3) Event dead_error_condition: The condition "h != NULL" must be true. 75 for (h = &hypervisor_list[0]; h != NULL; h++) { 76 if (strncasecmp(hypervisor, h->name, strlen(h->name)) == 0) { 77 return h->enabled; 78 } 79 } 80 (4) Event dead_error_line: Execution cannot reach this statement "return false;". Resolve by making proper endloop comparison of "h->name != NULL" --- libxkutil/misc_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c index 00eb4b1..819cb71 100644 --- a/libxkutil/misc_util.c +++ b/libxkutil/misc_util.c @@ -72,7 +72,7 @@ static bool get_hypervisor_enabled(const char *hypervisor) { hypervisor_status_t *h; - for (h = &hypervisor_list[0]; h != NULL; h++) { + for (h = &hypervisor_list[0]; h->name != NULL; h++) { if (strncasecmp(hypervisor, h->name, strlen(h->name)) == 0) { return h->enabled; } @@ -85,7 +85,7 @@ static void set_hypervisor_disabled(const char *hypervisor) { hypervisor_status_t *h; - for (h = &hypervisor_list[0]; h != NULL; h++) { + for (h = &hypervisor_list[0]; h->name != NULL; h++) { if (strncasecmp(hypervisor, h->name, strlen(h->name)) == 0) { CU_DEBUG("Setting '%s' hypervisor as DISABLED", h->name); h->enabled = false; -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:43 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:43 -0400 Subject: [Libvirt-cim] [PATCH 08/19] Coverity: Resolve DEADCODE - do_parse() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-9-git-send-email-jferlan@redhat.com> 747 if (nsv == NULL) 748 goto out; 749 750 dev_nodes = nsv->nodeTab; (2) Event notnull: At condition "nsv", the value of "nsv" cannot be NULL. (3) Event dead_error_condition: The condition "nsv" must be true. (4) Event dead_error_line: Execution cannot reach this expression "0" inside statement "count = (nsv ? nsv->nodeNr ...". 751 count = nsv ? nsv->nodeNr : 0; Resolve by not checking nsv and moving up a line to right after the nsv == NULL check --- libxkutil/device_parsing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 264d4cc..edd8bc4 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -746,9 +746,9 @@ static int do_parse(xmlNodeSet *nsv, dev_parse_func_t do_real_parse, if (nsv == NULL) goto out; + count = nsv->nodeNr; dev_nodes = nsv->nodeTab; - count = nsv ? nsv->nodeNr : 0; if (count <= 0) goto out; -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:45 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:45 -0400 Subject: [Libvirt-cim] [PATCH 10/19] Coverity: Resolve DEADCODE - octets_from_ip() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-11-git-send-email-jferlan@redhat.com> 95 (3) Event cond_at_least: Condition "size < 4U", taking false branch. Now the value of "size" is at least 4. 96 if ((s == 0) || (s[0] == '\0') || (buffer == NULL) || (size < 4)) ... 106 family = strstr(s, ":") ? AF_INET6 : AF_INET; (1) Event assignment: Assigning: "n" = "(family == 10U) ? 16 : 4". 107 n = family == AF_INET6 ? 16 : 4; 108 (4) Event cond_at_least: Condition "size < n", taking false branch. Now the value of "size" is at least 16. 109 if (size < n) 110 return 0; 111 112 if (inet_pton(family, s, &addr)) { (2) Event intervals: At condition "n <= size", the value of "n" must be in one of the following intervals: {[4,4], [16,16]}. (5) Event at_least: At condition "n <= size", the value of "size" must be at least 4. (6) Event dead_error_condition: The condition "n <= size" must be true. (7) Event dead_error_line: Execution cannot reach this expression "size" inside statement "n = ((n <= size) ? n : size);". 113 n = n <= size ? n : size; Resolve by removing "if (size < n) return 0;" check --- src/Virt_FilterEntry.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c index 3c4a3e6..2932be2 100644 --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -106,9 +106,6 @@ static int octets_from_ip(const char * s, unsigned int *buffer, family = strstr(s, ":") ? AF_INET6 : AF_INET; n = family == AF_INET6 ? 16 : 4; - if (size < n) - return 0; - if (inet_pton(family, s, &addr)) { n = n <= size ? n : size; for (i = 0; i < n; i++) -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:47 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:47 -0400 Subject: [Libvirt-cim] [PATCH 12/19] Coverity: Resolve NO_EFFECT - _set_fv_prop() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-13-git-send-email-jferlan@redhat.com> 55 bl_ct = dominfo->os_info.fv.bootlist_ct; (1) Event unsigned_compare: This less-than-zero comparison of an unsigned value is never true. "bl_ct < 0U". 56 if (bl_ct < 0) 57 return s; Resolve by changing the comparison to == rather than <. Code inspection determines that bootlist_ct could be zero, but more than likely it's some other positive value. It is never negative. --- src/Virt_VSSD.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Virt_VSSD.c b/src/Virt_VSSD.c index 24bf908..7afe2f1 100644 --- a/src/Virt_VSSD.c +++ b/src/Virt_VSSD.c @@ -53,7 +53,7 @@ static CMPIStatus _set_fv_prop(const CMPIBroker *broker, (CMPIValue *)&fv, CMPI_boolean); bl_ct = dominfo->os_info.fv.bootlist_ct; - if (bl_ct < 0) + if (bl_ct == 0) return s; CU_DEBUG("bootlist_ct = %d", bl_ct); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:48 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:48 -0400 Subject: [Libvirt-cim] [PATCH 13/19] Coverity: Resolve RESOURCE_LEAK - parse_os() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-14-git-send-email-jferlan@redhat.com> There's a loop to allocate and fill in a 'blist' array with entries that is then only saved for a specific domain type ("hvm"). If not hvm, then the blist is not freed (54) Event cond_false: Condition "strcasecmp(dominfo->os_info.fv.type, "hvm") == 0", taking false branch 1101 if (STREQC(dominfo->os_info.fv.type, "hvm")) { 1102 dominfo->os_info.fv.bootlist_ct = bl_size; 1103 dominfo->os_info.fv.bootlist = blist; (55) Event if_end: End of if statement 1104 } 1105 (56) Event leaked_storage: Variable "blist" going out of scope leaks the storage it points to. Resolve by adding code to free the memory --- libxkutil/device_parsing.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index edd8bc4..436415a 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -1101,6 +1101,12 @@ static int parse_os(struct domain *dominfo, xmlNode *os) if (STREQC(dominfo->os_info.fv.type, "hvm")) { dominfo->os_info.fv.bootlist_ct = bl_size; dominfo->os_info.fv.bootlist = blist; + } else { + int i; + + for (i = 0; i < bl_size; i++) + free(blist[i]); + free(blist); } return 1; -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:49 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:49 -0400 Subject: [Libvirt-cim] [PATCH 14/19] Coverity: Resolve REVERSE_INULL - doms_to_xml() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-15-git-send-email-jferlan@redhat.com> (1) Event deref_ptr: Directly dereferencing pointer "dom_xml_list". 436 *dom_xml_list = calloc(dom_ptr_count, sizeof(struct dom_xml)); (2) Event check_after_deref: Null-checking "dom_xml_list" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 437 if (!dom_xml_list) { Resolve by changing check to be "if (!*dom_xml_list) {" --- src/Virt_ComputerSystemIndication.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c index e9fa0c2..1ae8193 100644 --- a/src/Virt_ComputerSystemIndication.c +++ b/src/Virt_ComputerSystemIndication.c @@ -434,7 +434,7 @@ static CMPIStatus doms_to_xml(struct dom_xml **dom_xml_list, return s; } *dom_xml_list = calloc(dom_ptr_count, sizeof(struct dom_xml)); - if (!dom_xml_list) { + if (!*dom_xml_list) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Failed calloc %d dom_xml.", dom_ptr_count); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:51 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:51 -0400 Subject: [Libvirt-cim] [PATCH 16/19] Coverity: Resolve UNINIT - vsss_delete_snapshot() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-17-git-send-email-jferlan@redhat.com> (1) Event var_decl: Declaring variable "s" without initializer. 493 CMPIStatus s; ... (6) Event uninit_use: Using uninitialized value "s": field "s"."msg" is uninitialized. 512 return s; Resolve by initializing properly to CMPIStatus s = {CMPI_RC_OK, NULL}; --- src/Virt_VirtualSystemSnapshotService.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Virt_VirtualSystemSnapshotService.c b/src/Virt_VirtualSystemSnapshotService.c index 8c0889d..f4f3f86 100644 --- a/src/Virt_VirtualSystemSnapshotService.c +++ b/src/Virt_VirtualSystemSnapshotService.c @@ -490,7 +490,7 @@ static CMPIStatus create_snapshot(CMPIMethodMI *self, CMPIStatus vsss_delete_snapshot(const char *domname) { - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK, NULL}; char *path = NULL; path = vsss_get_save_path(domname); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:50 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:50 -0400 Subject: [Libvirt-cim] [PATCH 15/19] Coverity: Resolve REVERSE_INULL - lifecycle_thread_native() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-16-git-send-email-jferlan@redhat.com> 602 csi_thread_data_t *thread = (csi_thread_data_t *) params; (1) Event alias: Assigning: "args" = "thread->args". 603 struct ind_args *args = thread->args; (2) Event deref_ptr: Directly dereferencing pointer "args". ... (3) Event check_after_deref: Null-checking "thread->args" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 728 if (thread->args != NULL) { 729 stdi_free_ind_args(&thread->args); 730 } Resolve by changing the initialization to only set 'args', 'context', and 'prefix' if thread->args is not NULL. Each is initialized to NULL so the if prefix == NULL is still valid --- src/Virt_ComputerSystemIndication.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c index 1ae8193..04e4d89 100644 --- a/src/Virt_ComputerSystemIndication.c +++ b/src/Virt_ComputerSystemIndication.c @@ -600,9 +600,9 @@ static CMPI_THREAD_RETURN lifecycle_thread_native(void *params) { CU_DEBUG("Entering libvirtc-cim native CSI thread."); csi_thread_data_t *thread = (csi_thread_data_t *) params; - struct ind_args *args = thread->args; - CMPIContext *context = args->context; - char *prefix = class_prefix_name(args->classname); + struct ind_args *args = NULL; + CMPIContext *context = NULL; + char *prefix = NULL; virConnectPtr conn; CMPIStatus s; int retry_time = FAIL_WAIT_TIME; @@ -614,6 +614,11 @@ static CMPI_THREAD_RETURN lifecycle_thread_native(void *params) virDomainPtr *tmp_list = NULL; int CBAttached = 0; + if (thread->args != NULL) { + args = thread->args; + context = args->context; + prefix = class_prefix_name(args->classname); + } if (prefix == NULL) { goto init_out; } -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:53 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:53 -0400 Subject: [Libvirt-cim] [PATCH 18/19] Coverity: Resolve USE_AFTER_FREE - lifecycle_thread_native() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-19-git-send-email-jferlan@redhat.com> Resolve 2 instances where tmp_list was used after a free, both in the same location in the loop: (22) Event pass_freed_arg: Passing freed pointer "tmp_list" as an argument to function "doms_to_xml(struct dom_xml **, virDomainPtr *, int)". 658 s = doms_to_xml(&cur_xml, tmp_list, cur_count); 659 free_domain_list(tmp_list, cur_count); (10) Event freed_arg: "free(void *)" frees "tmp_list". 660 free(tmp_list); Resolve by setting "tmp_list = NULL;" after each free. --- src/Virt_ComputerSystemIndication.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c index 04e4d89..086d8c4 100644 --- a/src/Virt_ComputerSystemIndication.c +++ b/src/Virt_ComputerSystemIndication.c @@ -638,6 +638,7 @@ static CMPI_THREAD_RETURN lifecycle_thread_native(void *params) s = doms_to_xml(&prev_xml, tmp_list, prev_count); free_domain_list(tmp_list, prev_count); free(tmp_list); + tmp_list = NULL; if (s.rc != CMPI_RC_OK) { CU_DEBUG("doms_to_xml failed. Attempting to continue."); } @@ -657,6 +658,7 @@ static CMPI_THREAD_RETURN lifecycle_thread_native(void *params) s = doms_to_xml(&cur_xml, tmp_list, cur_count); free_domain_list(tmp_list, cur_count); free(tmp_list); + tmp_list = NULL; if (s.rc != CMPI_RC_OK) { CU_DEBUG("doms_to_xml failed. retry in %d seconds", retry_time); -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:52 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:52 -0400 Subject: [Libvirt-cim] [PATCH 17/19] Coverity: Resolve UNUSED_VALUE - system_xml() && mem_xml() In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-18-git-send-email-jferlan@redhat.com> Numerous instances of : (1) Event returned_pointer: Pointer "tmp" returned by "xmlNewChild(root, NULL, (xmlChar *)"currentMemory", (xmlChar *)string)" is never used. 482 tmp = xmlNewChild(root, 483 NULL, ... Resolved by adding "if (tmp == NULL) return XML_ERROR;" --- libxkutil/xmlgen.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index 94fb7d3..6302b60 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -483,6 +483,8 @@ static const char *mem_xml(xmlNodePtr root, struct domain *dominfo) NULL, BAD_CAST "currentMemory", BAD_CAST string); + if (tmp == NULL) + return XML_ERROR; free(string); tmp = NULL; @@ -650,12 +652,16 @@ static char *system_xml(xmlNodePtr root, struct domain *domain) xmlNodePtr tmp; tmp = xmlNewChild(root, NULL, BAD_CAST "name", BAD_CAST domain->name); + if (tmp == NULL) + return XML_ERROR; if (domain->bootloader) { tmp = xmlNewChild(root, NULL, BAD_CAST "bootloader", BAD_CAST domain->bootloader); + if (tmp == NULL) + return XML_ERROR; } if (domain->bootloader_args) { @@ -663,25 +669,35 @@ static char *system_xml(xmlNodePtr root, struct domain *domain) NULL, BAD_CAST "bootloader_args", BAD_CAST domain->bootloader_args); + if (tmp == NULL) + return XML_ERROR; } tmp = xmlNewChild(root, NULL, BAD_CAST "on_poweroff", BAD_CAST vssd_recovery_action_str(domain->on_poweroff)); + if (tmp == NULL) + return XML_ERROR; tmp = xmlNewChild(root, NULL, BAD_CAST "on_crash", BAD_CAST vssd_recovery_action_str(domain->on_crash)); + if (tmp == NULL) + return XML_ERROR; tmp = xmlNewChild(root, NULL, BAD_CAST "uuid", BAD_CAST domain->uuid); + if (tmp == NULL) + return XML_ERROR; if (domain->clock != NULL) { tmp = xmlNewChild(root, NULL, BAD_CAST "clock", NULL); + if (tmp == NULL) + return XML_ERROR; xmlNewProp(tmp, BAD_CAST "offset", BAD_CAST domain->clock); } -- 1.8.1.4 From jferlan at redhat.com Thu May 16 14:57:54 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 16 May 2013 10:57:54 -0400 Subject: [Libvirt-cim] [PATCH 19/19] Coverity: Resolve ARRAY_VS_SINGLETON - get_dev_paths() and callers In-Reply-To: <1368716274-31619-1-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> Message-ID: <1368716274-31619-20-git-send-email-jferlan@redhat.com> Resolve two instances (disk_fs_or_disk_or_logical_pool() and disk_iscsi_pool()) of (1) Event address_of: Taking address with "&pool->pool_info.disk.device_paths" yields a singleton pointer. (2) Event callee_ptr_arith: Passing "&pool->pool_info.disk.device_paths" to function "get_dev_paths(CMPIInstance *, char ***, uint16_t *)" which uses it as an array. This might corrupt or misinterpret adjacent memory locations. 201 msg = get_dev_paths(inst, 202 &pool->pool_info.disk.device_paths, 203 &pool->pool_info.disk.device_paths_ct); Resolve by changing get_dev_paths() to take "pool" as an address and then expanding the variables within the code to the specific location --- src/Virt_ResourcePoolConfigurationService.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Virt_ResourcePoolConfigurationService.c b/src/Virt_ResourcePoolConfigurationService.c index 0c0cc06..4775e01 100644 --- a/src/Virt_ResourcePoolConfigurationService.c +++ b/src/Virt_ResourcePoolConfigurationService.c @@ -154,8 +154,7 @@ static void init_disk_pool(struct virt_pool *pool) } static char *get_dev_paths(CMPIInstance *inst, - char ***path_list, - uint16_t *count) + struct virt_pool *pool) { CMPICount i; CMPICount ct; @@ -170,11 +169,11 @@ static char *get_dev_paths(CMPIInstance *inst, if ((s.rc != CMPI_RC_OK) || (ct <= 0)) return "Unable to get DevicePaths array count"; - *path_list = calloc(ct, sizeof(char *)); - if (*path_list == NULL) + pool->pool_info.disk.device_paths = calloc(ct, sizeof(char *)); + if (pool->pool_info.disk.device_paths == NULL) return "Failed to alloc space for device paths"; - *count = ct; + pool->pool_info.disk.device_paths_ct = ct; for (i = 0; i < ct; i++) { const char *str = NULL; @@ -187,7 +186,7 @@ static char *get_dev_paths(CMPIInstance *inst, if (str == NULL) return "Unable to get value of DevicePaths element"; - *path_list[i] = strdup(str); + pool->pool_info.disk.device_paths[i] = strdup(str); } return NULL; @@ -198,10 +197,7 @@ static const char *disk_fs_or_disk_or_logical_pool(CMPIInstance *inst, { const char *msg = NULL; - msg = get_dev_paths(inst, - &pool->pool_info.disk.device_paths, - &pool->pool_info.disk.device_paths_ct); - + msg = get_dev_paths(inst, pool); /* Specifying a value for DevicePaths isn't mandatory for logical pool types. */ @@ -243,9 +239,7 @@ static const char *disk_iscsi_pool(CMPIInstance *inst, const char *val = NULL; const char *msg = NULL; - msg = get_dev_paths(inst, - &pool->pool_info.disk.device_paths, - &pool->pool_info.disk.device_paths_ct); + msg = get_dev_paths(inst, pool); if (msg != NULL) return msg; -- 1.8.1.4 From cngesaint at outlook.com Fri May 17 06:19:10 2013 From: cngesaint at outlook.com (WangXu) Date: Fri, 17 May 2013 06:19:10 +0000 Subject: [Libvirt-cim] [PATCH 11/19] Coverity: Resolve NO_EFFECT - set_proc_rasd_params() In-Reply-To: <1368716274-31619-12-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com>, <1368716274-31619-12-git-send-email-jferlan@redhat.com> Message-ID: ---------------------------------------- > From: jferlan at redhat.com > To: libvirt-cim at redhat.com > Date: Thu, 16 May 2013 10:57:46 -0400 > Subject: [Libvirt-cim] [PATCH 11/19] Coverity: Resolve NO_EFFECT - set_proc_rasd_params() > > 143 if (domain_online(dom)) > 144 count = domain_vcpu_count(dom); > 145 else > 146 count = dev->dev.vcpu.quantity; > 147 > > (1) Event unsigned_compare: > This greater-than-or-equal-to-zero comparison of an unsigned value > is always true. "count>= 0UL". > > 148 if (count>= 0) > > Resolve by adjusting logic. Problem was that the active count is returned > as an int with an error value of -1, while the quantity value is guaranteed > to be 1 or more (see parse_vcpu_device() processing). So initialize count to > zero, then only set the property if count> 0. Setting count of the active > condition requires a local "active_count" and checking that to be> 0 before > blindly setting it to count. Imagine 0xfffffffffffffff vcpu's! > --- > src/Virt_RASD.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c > index ad1a2e7..a4cba5b 100644 > --- a/src/Virt_RASD.c > +++ b/src/Virt_RASD.c > @@ -124,7 +124,7 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, > struct infostore_ctx *info = NULL; > uint32_t weight = 0; > uint64_t limit; > - uint64_t count; > + uint64_t count = 0; > > conn = connect_by_classname(broker, CLASSNAME(ref), &s); > if (conn == NULL) > @@ -140,12 +140,15 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, > goto out; > } > > - if (domain_online(dom)) > - count = domain_vcpu_count(dom); > - else > + if (domain_online(dom)) { > + int active_count = domain_vcpu_count(dom); > + if (active_count> 0) > + count = active_count; > + } else { > count = dev->dev.vcpu.quantity; > + } if there was some failure happened, domain_vcpu_count would return -1. I think some code should handle this failure instead of just ignore it and skip CMSetProperty, Such as cu_statusf and goto out; My suggestion is the code like this: if (domain_online(dom)) { int active_count = domain_vcpu_count(dom); if (active_count < 0) {? //count never be less than zero and maybe err code -2, -3...would ???????????????????????? //be added someday. cu_status(...); goto out; } else { count = active_count;??? //equal or more than zero should be OK } } else { count = dev->dev.vcpu.quantity; } Xu Wang > > - if (count>= 0) > + if (count> 0) > CMSetProperty(inst, > "VirtualQuantity", > (CMPIValue *)&count, > -- > 1.8.1.4 > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim From jferlan at redhat.com Fri May 17 13:14:10 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 17 May 2013 09:14:10 -0400 Subject: [Libvirt-cim] [PATCH 11/19] Coverity: Resolve NO_EFFECT - set_proc_rasd_params() In-Reply-To: References: <1368716274-31619-1-git-send-email-jferlan@redhat.com>, <1368716274-31619-12-git-send-email-jferlan@redhat.com> Message-ID: <51962D22.50207@redhat.com> On 05/17/2013 02:19 AM, WangXu wrote: > ---------------------------------------- >> From: jferlan at redhat.com >> To: libvirt-cim at redhat.com >> Date: Thu, 16 May 2013 10:57:46 -0400 >> Subject: [Libvirt-cim] [PATCH 11/19] Coverity: Resolve NO_EFFECT - set_proc_rasd_params() >> >> 143 if (domain_online(dom)) >> 144 count = domain_vcpu_count(dom); >> 145 else >> 146 count = dev->dev.vcpu.quantity; >> 147 >> >> (1) Event unsigned_compare: >> This greater-than-or-equal-to-zero comparison of an unsigned value >> is always true. "count>= 0UL". >> >> 148 if (count>= 0) >> >> Resolve by adjusting logic. Problem was that the active count is returned >> as an int with an error value of -1, while the quantity value is guaranteed >> to be 1 or more (see parse_vcpu_device() processing). So initialize count to >> zero, then only set the property if count> 0. Setting count of the active >> condition requires a local "active_count" and checking that to be> 0 before >> blindly setting it to count. Imagine 0xfffffffffffffff vcpu's! >> --- >> src/Virt_RASD.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c >> index ad1a2e7..a4cba5b 100644 >> --- a/src/Virt_RASD.c >> +++ b/src/Virt_RASD.c >> @@ -124,7 +124,7 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, >> struct infostore_ctx *info = NULL; >> uint32_t weight = 0; >> uint64_t limit; >> - uint64_t count; >> + uint64_t count = 0; >> >> conn = connect_by_classname(broker, CLASSNAME(ref), &s); >> if (conn == NULL) >> @@ -140,12 +140,15 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, >> goto out; >> } >> >> - if (domain_online(dom)) >> - count = domain_vcpu_count(dom); >> - else >> + if (domain_online(dom)) { >> + int active_count = domain_vcpu_count(dom); >> + if (active_count> 0) >> + count = active_count; >> + } else { >> count = dev->dev.vcpu.quantity; >> + } > if there was some failure happened, domain_vcpu_count would return -1. I think some > code should handle this failure instead of just ignore it and skip CMSetProperty, Such > as cu_statusf and goto out; > My suggestion is the code like this: > > if (domain_online(dom)) { > int active_count = domain_vcpu_count(dom); > if (active_count < 0) { //count never be less than zero and maybe err code -2, -3...would > //be added someday. > cu_status(...); > goto out; > } else { > count = active_count; //equal or more than zero should be OK > } > } else { > count = dev->dev.vcpu.quantity; > } > > Xu Wang >> >> - if (count>= 0) >> + if (count> 0) >> CMSetProperty(inst, >> "VirtualQuantity", >> (CMPIValue *)&count, >> -- >> 1.8.1.4 >> >> _______________________________________________ >> Libvirt-cim mailing list >> Libvirt-cim at redhat.com >> https://www.redhat.com/mailman/listinfo/libvirt-cim I will squash in the following: diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index a4cba5b..af6a43f 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -142,8 +142,14 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *br if (domain_online(dom)) { int active_count = domain_vcpu_count(dom); - if (active_count > 0) - count = active_count; + if (active_count < 0) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain `%s' vcpu count", + domain); + goto out; + } + count = active_count; } else { count = dev->dev.vcpu.quantity; } NOTE: No need for an else to if (active_count < 0) since we're jumping to out John From jferlan at redhat.com Wed May 22 18:20:13 2013 From: jferlan at redhat.com (John Ferlan) Date: Wed, 22 May 2013 14:20:13 -0400 Subject: [Libvirt-cim] [PATCH 06/19] Coverity: Resolve CHECKED_RETURN - mem_rasd_to_vdev() In-Reply-To: <1368716274-31619-7-git-send-email-jferlan@redhat.com> References: <1368716274-31619-1-git-send-email-jferlan@redhat.com> <1368716274-31619-7-git-send-email-jferlan@redhat.com> Message-ID: <519D0C5D.4090004@redhat.com> On 05/16/2013 10:57 AM, John Ferlan wrote: > 1089 dev->dev.mem.maxsize = dev->dev.mem.size; > > (4) Event check_return: > Calling function "cu_get_u64_prop(CMPIInstance const *, char const *, > uint64_t *)" without checking return value (as is done elsewhere 9 > out of 10 times). > (14) Event unchecked_value: > No check of the return value of "cu_get_u64_prop(inst, "Limit", > &dev->dev.mem.maxsize)". > > 1090 cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); > > Resolve by adding check and returning a message indicating what's missing > --- > src/Virt_VirtualSystemManagementService.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c > index cbb646d..ebf3e4a 100644 > --- a/src/Virt_VirtualSystemManagementService.c > +++ b/src/Virt_VirtualSystemManagementService.c > @@ -1087,7 +1087,9 @@ static const char *mem_rasd_to_vdev(CMPIInstance *inst, > return "Missing `VirtualQuantity' field in Memory RASD"; > > dev->dev.mem.maxsize = dev->dev.mem.size; > - cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); > + ret = cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); > + if (ret != CMPI_RC_OK) > + return "Missing `Limit' field in Memory RASD"; > > if (cu_get_str_prop(inst, "AllocationUnits", &units) != CMPI_RC_OK) { > CU_DEBUG("Memory RASD has no units, assuming bytes"); > An issue was found with the above code since Limit doesn't seem to be a required value, thus the code has been changed to the following: diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemM index cbb646d..f1441dc 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1086,8 +1086,9 @@ static const char *mem_rasd_to_vdev(CMPIInstance *inst, if (ret != CMPI_RC_OK) return "Missing `VirtualQuantity' field in Memory RASD"; - dev->dev.mem.maxsize = dev->dev.mem.size; - cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); + ret = cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); + if (ret != CMPI_RC_OK) + dev->dev.mem.maxsize = dev->dev.mem.size; if (cu_get_str_prop(inst, "AllocationUnits", &units) != CMPI_RC_OK) { CU_DEBUG("Memory RASD has no units, assuming bytes"); The difference being setting mem.maxsize to mem.size only if the call fails and not messaging if it does fail. From cngesaint at outlook.com Thu May 23 02:21:53 2013 From: cngesaint at outlook.com (WangXu) Date: Thu, 23 May 2013 02:21:53 +0000 Subject: [Libvirt-cim] [PATCH V4 2/3] VSMS: tip error for invalid disk resource - update check condition for cdrom In-Reply-To: <1368433436-6356-3-git-send-email-cngesaint@outlook.com> References: <1368433436-6356-1-git-send-email-cngesaint@outlook.com>, <1368433436-6356-3-git-send-email-cngesaint@outlook.com> Message-ID: >From fed10f9212d2ffd9666547b81b9f7e9c21b530dd Mon Sep 17 00:00:00 2001 From: Xu Wang Date: Mon, 15 Apr 2013 14:45:01 +0800 Subject: [PATCH V4] VSMS: tip error for invalid disk resource ?? Original code will report xml text missing when a disk is not accessible, make user confuse. This patch will report the real error to tip user check its system health state on the server. Signed-off-by: Xu Wang Signed-off-by: root --- ?src/Virt_VirtualSystemManagementService.c |?? 77 ++++++++++++++++++++++------- ?1 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 1369c6a..7a8d27b 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -964,11 +964,13 @@ static const char *net_rasd_to_vdev(CMPIInstance *inst, ?} ? ?static const char *disk_rasd_to_vdev(CMPIInstance *inst, -???????????????????????????????????? struct virt_device *dev) +???????????????????????????????????? struct virt_device *dev, +???????????????????????????????????? char **p_error) ?{ ???????? const char *val = NULL; ???????? uint16_t type; ???????? bool read = false; +??????? int rc; ? ???????? CU_DEBUG("Enter disk_rasd_to_vdev"); ???????? if (cu_get_str_prop(inst, "VirtualDevice", &val) != CMPI_RC_OK) @@ -982,11 +984,30 @@ static const char *disk_rasd_to_vdev(CMPIInstance *inst, ? ???????? free(dev->dev.disk.source); ???????? dev->dev.disk.source = strdup(val); +??????? if (dev->dev.disk.source == NULL) { +??????????????? return "dev->dev.disk.source is null!"; +??????? } + ???????? dev->dev.disk.disk_type = disk_type_from_file(val); ? ???????? if (cu_get_u16_prop(inst, "EmulatedType", &type) != CMPI_RC_OK) ???????????????? type = VIRT_DISK_TYPE_DISK; ? +??????? if ((type == VIRT_DISK_TYPE_DISK) || +??????????? (type == VIRT_DISK_TYPE_FS)){ +??????????? if (dev->dev.disk.disk_type == DISK_UNKNOWN) { +??????????????? /* on success or fail caller should try free it */ +??????????????? rc = asprintf(p_error, "Device %s, Address %s, " +????????????????????????????? "make sure Address can be accessed on host system.", +????????????????????????????? dev->dev.disk.virtual_dev, dev->dev.disk.source); +??????????????? if (rc == -1) { +??????????????????????? CU_DEBUG("error during recording exception!"); +??????????????????????? p_error = NULL; +??????????????? } +??????????????? return "Can't get a valid disk type"; +??????????? } +??????? } + ???????? if (type == VIRT_DISK_TYPE_DISK) ???????????????? dev->dev.disk.device = strdup("disk"); ???????? else if (type == VIRT_DISK_TYPE_CDROM) { @@ -1452,10 +1473,11 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, ?static const char *_sysvirt_rasd_to_vdev(CMPIInstance *inst, ????????????????????????????????????????? struct virt_device *dev, ????????????????????????????????????????? uint16_t type, -???????????????????????????????????????? const char *ns) +???????????????????????????????????????? const char *ns, +???????????????????????????????????????? char **p_error) ?{ ???????? if (type == CIM_RES_TYPE_DISK) { -??????????????? return disk_rasd_to_vdev(inst, dev); +??????????????? return disk_rasd_to_vdev(inst, dev, p_error); ???????? } else if (type == CIM_RES_TYPE_NET) { ???????????????? return net_rasd_to_vdev(inst, dev, ns); ???????? } else if (type == CIM_RES_TYPE_MEM) { @@ -1494,7 +1516,8 @@ static const char *_container_rasd_to_vdev(CMPIInstance *inst, ?static const char *rasd_to_vdev(CMPIInstance *inst, ???????????????????????????????? struct domain *domain, ???????????????????????????????? struct virt_device *dev, -??????????????????????????????? const char *ns) +??????????????????????????????? const char *ns, +??????????????????????????????? char **p_error) ?{ ???????? uint16_t type; ???????? CMPIObjectPath *op; @@ -1516,7 +1539,7 @@ static const char *rasd_to_vdev(CMPIInstance *inst, ???????? if (domain->type == DOMAIN_LXC) ???????????????? msg = _container_rasd_to_vdev(inst, dev, type, ns); ???????? else -??????????????? msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns); +??????????????? msg = _sysvirt_rasd_to_vdev(inst, dev, type, ns, p_error); ? out: ???????? if (msg && op) ???????????????? CU_DEBUG("rasd_to_vdev(%s): %s", CLASSNAME(op), msg); @@ -1560,7 +1583,8 @@ static char *add_device_nodup(struct virt_device *dev, ? ?static const char *classify_resources(CMPIArray *resources, ?????????????????????????????????????? const char *ns, -????????????????????????????????????? struct domain *domain) +????????????????????????????????????? struct domain *domain, +????????????????????????????????????? char **p_error) ?{ ???????? int i; ???????? uint16_t type; @@ -1613,13 +1637,15 @@ static const char *classify_resources(CMPIArray *resources, ???????????????????????? msg = rasd_to_vdev(inst, ??????????????????????????????????????????? domain, ??????????????????????????????????????????? &domain->dev_vcpu[0], -?????????????????????????????????????????? ns); +?????????????????????????????????????????? ns, +?????????????????????????????????????????? p_error); ???????????????? } else if (type == CIM_RES_TYPE_MEM) { ???????????????????????? domain->dev_mem_ct = 1; ???????????????????????? msg = rasd_to_vdev(inst, ??????????????????????????????????????????? domain, ??????????????????????????????????????????? &domain->dev_mem[0], -?????????????????????????????????????????? ns); +?????????????????????????????????????????? ns, +?????????????????????????????????????????? p_error); ???????????????? } else if (type == CIM_RES_TYPE_DISK) { ???????????????????????? struct virt_device dev; ???????????????????????? int dcount = count + domain->dev_disk_ct; @@ -1628,7 +1654,8 @@ static const char *classify_resources(CMPIArray *resources, ???????????????????????? msg = rasd_to_vdev(inst, ??????????????????????????????????????????? domain, ??????????????????????????????????????????? &dev, -?????????????????????????????????????????? ns); +?????????????????????????????????????????? ns, +?????????????????????????????????????????? p_error); ???????????????????????? if (msg == NULL) ???????????????????????????????? msg = add_device_nodup(&dev, ??????????????????????????????????????????????????????? domain->dev_disk, @@ -1646,7 +1673,8 @@ static const char *classify_resources(CMPIArray *resources, ???????????????????????? msg = rasd_to_vdev(inst, ??????????????????????????????????????????? domain, ??????????????????????????????????????????? &dev, -?????????????????????????????????????????? ns); +?????????????????????????????????????????? ns, +?????????????????????????????????????????? p_error); ???????????????????????? if (msg == NULL) ???????????????????????????????? msg = add_device_nodup(&dev, ??????????????????????????????????????????????????????? domain->dev_net, @@ -1676,7 +1704,8 @@ static const char *classify_resources(CMPIArray *resources, ???????????????????????? msg = rasd_to_vdev(inst, ??????????????????????????????????????????? domain, ??????????????????????????????????????????? &dev, -?????????????????????????????????????????? ns); +?????????????????????????????????????????? ns, +?????????????????????????????????????????? p_error); ???????????????????????? if (msg == NULL) ???????????????????????????????? msg = add_device_nodup(&dev, ???????????????????????????????????????????????? domain->dev_graphics, @@ -1687,7 +1716,8 @@ static const char *classify_resources(CMPIArray *resources, ???????????????????????? msg = rasd_to_vdev(inst, ??????????????????????????????????????????? domain, ??????????????????????????????????????????? &domain->dev_input[0], -?????????????????????????????????????????? ns); +?????????????????????????????????????????? ns, +?????????????????????????????????????????? p_error); ???????????????? } ???????????????? if (msg != NULL) ???????????????????????? return msg; @@ -2083,6 +2113,7 @@ static CMPIInstance *create_system(const CMPIContext *context, ???????? struct inst_list list; ???????? const char *props[] = {NULL}; ???????? struct domain *domain = NULL; +??????? char *error_msg = NULL; ? ???????? inst_list_init(&list); ? @@ -2113,12 +2144,13 @@ static CMPIInstance *create_system(const CMPIContext *context, ???????? if (s->rc != CMPI_RC_OK) ???????????????? goto out; ? -??????? msg = classify_resources(resources, NAMESPACE(ref), domain); +??????? msg = classify_resources(resources, NAMESPACE(ref), domain, &error_msg); ???????? if (msg != NULL) { -??????????????? CU_DEBUG("Failed to classify resources: %s", msg); +??????????????? CU_DEBUG("Failed to classify resources: %s, %s", +???????????????????????? msg, error_msg); ???????????????? cu_statusf(_BROKER, s, ??????????????????????????? CMPI_RC_ERR_FAILED, -?????????????????????????? "ResourceSettings Error: %s", msg); +?????????????????????????? "ResourceSettings Error: %s, %s", msg, error_msg); ???????????????? goto out; ???????? } ? @@ -2159,6 +2191,7 @@ static CMPIInstance *create_system(const CMPIContext *context, ? ? ? out: +??????? free(error_msg); ???????? cleanup_dominfo(&domain); ???????? free(xml); ???????? inst_list_free(&list); @@ -2638,6 +2671,7 @@ static CMPIStatus resource_add(struct domain *dominfo, ???????? struct virt_device *dev; ???????? int *count = NULL; ???????? const char *msg = NULL; +??????? char *error_msg = NULL; ? ???????? op = CMGetObjectPath(rasd, &s); ???????? if ((op == NULL) || (s.rc != CMPI_RC_OK)) @@ -2677,12 +2711,12 @@ static CMPIStatus resource_add(struct domain *dominfo, ???????? dev = &list[*count]; ? ???????? dev->type = type; -??????? msg = rasd_to_vdev(rasd, dominfo, dev, ns); +??????? msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); ???????? if (msg != NULL) { ???????????????? cu_statusf(_BROKER, &s, ??????????????????????????? CMPI_RC_ERR_FAILED, -?????????????????????????? "Add resource failed: %s", -?????????????????????????? msg); +?????????????????????????? "Add resource failed: %s, %s", +?????????????????????????? msg, error_msg); ???????????????? goto out; ???????? } ? @@ -2702,6 +2736,8 @@ static CMPIStatus resource_add(struct domain *dominfo, ???????? (*count)++; ? ? out: +??????? free(error_msg); + ???????? return s; ?} ? @@ -2718,6 +2754,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, ???????? int *count; ???????? int i; ???????? const char *msg = NULL; +??????? char *error_msg = NULL; ? ???????? CU_DEBUG("Enter resource_mod"); ???????? if (devid == NULL) { @@ -2749,7 +2786,7 @@ static CMPIStatus resource_mod(struct domain *dominfo, ???????????????? struct virt_device *dev = &list[i]; ? ???????????????? if (STREQ(dev->id, devid)) { -??????????????????????? msg = rasd_to_vdev(rasd, dominfo, dev, ns); +??????????????????????? msg = rasd_to_vdev(rasd, dominfo, dev, ns, &error_msg); ???????????????????????? if (msg != NULL) { ???????????????????????????????? cu_statusf(_BROKER, &s, ??????????????????????????????????????????? CMPI_RC_ERR_FAILED, @@ -2793,6 +2830,8 @@ static CMPIStatus resource_mod(struct domain *dominfo, ???????? } ? ? out: +??????? free(error_msg); + ???????? return s; ?} ? -- 1.7.1 From jferlan at redhat.com Thu May 23 23:16:57 2013 From: jferlan at redhat.com (John Ferlan) Date: Thu, 23 May 2013 19:16:57 -0400 Subject: [Libvirt-cim] [PATCHv2] Allow adding bridged network for running domain Message-ID: <1369351017-3090-1-git-send-email-jferlan@redhat.com> Test failed with following: VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL ERROR - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging") ERROR - Error invoking AddRS: add_net_res ERROR - AddResourceSettings call failed ERROR - Failed to destroy Virtual Network 'my_network1' InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging Bug:<00015> The fix for this was that the domain needed to be created with the "acpi=True" flag. This allowed the test to get a bit further, but it then failed with the following: VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL ERROR - Got 88:aa:bb:cc:ee:ff, exp 88:aa:bb:cc:ee:ff. Got None, exp my_network1. ERROR - Error invoking AddRS: add_net_res ERROR - Error adding rs for net mac ERROR - Failed to destroy Virtual Network 'my_network1' The issue here is that the created network bridge doesn't have an xml resource "source network" as 'my_network1', rather that name is assigned to the pool. A network bridge type object has a resource "source bridge" which correlates to the 'virt_net' attribute while network type object correlates to the 'net_name' attribute. Since I wasn't sure how a Xen domain would look I separated the validation comparisons v2 difference is change to "KVM" code condition in 'vsms_util.py' to fetch different 'name' values based on 'ntype' (network type) and then compare against different attributes based on the type. --- .../22_addmulti_brg_interface.py | 9 +++++++-- suites/libvirt-cim/lib/XenKvmLib/vsms_util.py | 23 +++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py index 36d1873..0452bf6 100644 --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py @@ -63,8 +63,13 @@ def main(): service = get_vsms_class(options.virt)(options.ip) classname = get_typed_class(options.virt, 'VirtualSystemSettingData') - vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, - net_name=default_brg) + # Seems ACPI needs to be set for KVM in order for hotplug to work right + if options.virt == "KVM": + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg, acpi=True) + else: + vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype, + net_name=default_brg) try: ret = vsxml.cim_define(options.ip) if not ret: diff --git a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py index 075c09f..3c3d0fc 100644 --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py @@ -189,9 +189,22 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): % attr['nmac']) if virt == "KVM": - name = cxml.get_value_xpath( + # For KVM bridge types, compare the source bridge + if attr['ntype'] == 'bridge': + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@bridge[. = "%s"]' + % attr['virt_net']) + attr_name = attr['virt_net'] + # For KVM network types, compare the network name + else: + name = cxml.get_value_xpath( '/domain/devices/interface/source/@network[. = "%s"]' % attr['net_name']) + attr_name = attr['net_name'] + if mac != attr['nmac'] or name != attr_name: + logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s.", + mac, attr['nmac'], name, attr['virt_net']) + raise Exception('Error adding rs for net mac') else: # For Xen, network interfaces are converted to bridge interfaces. @@ -202,10 +215,10 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): if name != None: name = attr['net_name'] - if mac != attr['nmac'] or name != attr['net_name']: - logger.error("Got %s, exp %s. Got %s, exp %s.", mac, - attr['nmac'], name, attr['net_name']) - raise Exception('Error adding rs for net mac') + if mac != attr['nmac'] or name != attr['net_name']: + logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s. br %s", + mac, attr['nmac'], name, attr['net_name'], br) + raise Exception('Error adding rs for net mac') logger.info('good status for net_mac') except Exception, details: -- 1.8.1.4 From cngesaint at outlook.com Fri May 24 07:34:51 2013 From: cngesaint at outlook.com (cngesaint at outlook.com) Date: Fri, 24 May 2013 15:34:51 +0800 Subject: [Libvirt-cim] [PATCH] Improve support of nested KVM Message-ID: <1369380891-11250-1-git-send-email-cngesaint@outlook.com> From: Xu Wang Under nested KVM environment libvirt-cim could recognize kvm support correctly now. Signed-off-by: Xu Wang --- libxkutil/device_parsing.c | 19 +++++++++++++++++++ libxkutil/device_parsing.h | 2 ++ src/Virt_VirtualSystemManagementService.c | 22 +++++++++++++++++++--- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c index 436415a..58d9094 100644 --- a/libxkutil/device_parsing.c +++ b/libxkutil/device_parsing.c @@ -396,6 +396,25 @@ err: return 0; } +int parse_domain_type(xmlNodePtr node, char **value) +{ + xmlNodePtr child = NULL; + + child = node->children; + while (child != NULL) { + if (XSTREQ(child->name, "domain")) { + *value = get_attr_value(child, "type"); + } + if (parse_domain_type(child, value) != 1) + goto err; + child = child->next; + } + + return 1; +err: + return 0; +} + static int parse_net_device(xmlNode *inode, struct virt_device **vdevs) { struct virt_device *vdev = NULL; diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h index 6f6b0b4..733324f 100644 --- a/libxkutil/device_parsing.h +++ b/libxkutil/device_parsing.h @@ -221,6 +221,8 @@ int attach_device(virDomainPtr dom, struct virt_device *dev); int detach_device(virDomainPtr dom, struct virt_device *dev); int change_device(virDomainPtr dom, struct virt_device *dev); +int parse_domain_type(xmlNodePtr node, char **value); + #define XSTREQ(x, y) (STREQ((char *)x, y)) #define STRPROP(d, p, n) (d->p = get_node_content(n)) diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 7b7261a..5210fdf 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -393,8 +393,13 @@ static bool system_has_kvm(const char *pfx) CMPIStatus s; virConnectPtr conn; char *caps = NULL; - bool kvm = false; bool disable_kvm = get_disable_kvm(); + char *val = NULL; + int ret; + xmlDocPtr doc; + xmlNodePtr node; + int len; + bool kvm = false; /* sometimes disable KVM to avoid problem in nested KVM */ if (disable_kvm) { @@ -408,10 +413,21 @@ static bool system_has_kvm(const char *pfx) } caps = virConnectGetCapabilities(conn); - if (caps != NULL) - kvm = (strstr(caps, "kvm") != NULL); + if (caps != NULL) { + len = strlen(caps) + 1; + doc = xmlParseMemory(caps, len); + node = xmlDocGetRootElement(doc); + ret = parse_domain_type(node, &val); + CU_DEBUG("domain type is %s.", val); + if (ret == CMPI_RC_OK) { + if(STREQC(val, "kvm")) + kvm = true; + } + } free(caps); + free(doc); + free(val); virConnectClose(conn); -- 1.7.1 From jferlan at redhat.com Fri May 24 19:05:36 2013 From: jferlan at redhat.com (John Ferlan) Date: Fri, 24 May 2013 15:05:36 -0400 Subject: [Libvirt-cim] [PATCH V3 0/3] libvirt-cim patches In-Reply-To: <51926B9F.4020303@redhat.com> References: <1368433436-6356-1-git-send-email-cngesaint@outlook.com> <51926B9F.4020303@redhat.com> Message-ID: <519FBA00.3010608@redhat.com> On 05/14/2013 12:51 PM, John Ferlan wrote: > On 05/13/2013 04:23 AM, cngesaint at outlook.com wrote: >> From: Xu Wang >> >> updates: >> 1. title and comments for disable KVM updates >> 2. error message format updates (double ',' in VSMS) >> 3. added strdup null check >> >> Wenchao Xia (1): >> add an config option to disable KVM acceleration >> >> Xu Wang (2): >> VSMS: tip error for invalid disk resource >> make lldptool command and support output configurable >> >> libvirt-cim.conf | 25 +++++++++ >> libxkutil/misc_util.c | 26 +++++++++ >> libxkutil/misc_util.h | 3 + >> src/Virt_SwitchService.c | 66 +++++++++++++++++++---- >> src/Virt_VirtualSystemManagementService.c | 82 ++++++++++++++++++++++------- >> 5 files changed, 172 insertions(+), 30 deletions(-) >> >> > > ACK on all 3 patches. > > > I still didn't get 3/3 - there's some filter that doesn't allow it > through our mail system. > > I did do a Coverity run on the sources prior to these patches - I'll be > sending out a set of patches for things found. Nothing major, there > will be 19 patches. I wasn't able to re-run with these patches due to > some internal license server issues, but hopefully those get cleared up > soon. > > John > > _______________________________________________ > Libvirt-cim mailing list > Libvirt-cim at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-cim > As requested (privately) I have pushed these patches John