[PATCH V3 0/3] libvirt-cim patches

From: Xu Wang <cngesaint@outlook.com> 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: Wenchao Xia <xiawenc@linux.vnet.ibm.com> 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 <cngesaint@outlook.com> --- 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: Xu Wang <cngesaint@outlook.com> 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 <cngesaint@outlook.com> --- 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 fed10f9212d2ffd9666547b81b9f7e9c21b530dd Mon Sep 17 00:00:00 2001 From: Xu Wang <cngesaint@outlook.com> 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 <cngesaint@outlook.com> Signed-off-by: root <root@RH64wenchao.(none)> --- 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: Xu Wang <cngesaint@outlook.com> 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 <cngesaint@outlook.com> --- 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<count; i++) { - sprintf(cmd, "lldptool -i %s -t -V evbcfg", if_list[i]); - CU_DEBUG("running command %s ...", cmd); + sprintf(cmd, "lldptool -i %s %s", + if_list[i], lldptool_query_options); + CU_DEBUG("running command [%s]", cmd); s = check_vsi_support(cmd); if (s.rc == CMPI_RC_OK) { vsi = true; -- 1.7.1

On 05/13/2013 04:23 AM, cngesaint@outlook.com wrote:
From: Xu Wang <cngesaint@outlook.com>
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

On 05/14/2013 12:51 PM, John Ferlan wrote:
On 05/13/2013 04:23 AM, cngesaint@outlook.com wrote:
From: Xu Wang <cngesaint@outlook.com>
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@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
As requested (privately) I have pushed these patches John
participants (3)
-
cngesaint@outlook.com
-
John Ferlan
-
WangXu