[PATCH 00/19] Resolve Coverity warnings
by John Ferlan
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
11 years, 5 months
[PATCH] Improve support of nested KVM
by cngesaint@outlook.com
From: Xu Wang <cngesaint(a)outlook.com>
Under nested KVM environment libvirt-cim could recognize kvm support
correctly now.
Signed-off-by: Xu Wang <cngesaint(a)outlook.com>
---
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
11 years, 5 months
[PATCH V3 0/3] libvirt-cim patches
by cngesaint@outlook.com
From: Xu Wang <cngesaint(a)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(-)
11 years, 6 months
[PATCHv2] Allow adding bridged network for running domain
by John Ferlan
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
11 years, 6 months
[PATCH] Resolve hotplug failure for VSMS test 22
by John Ferlan
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
11 years, 6 months
[PATCH v2 00/12] cimtest updates
by John Ferlan
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
11 years, 6 months
[PATCH V2 0/3] libvirt-cim patches
by Xu Wang
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(-)
11 years, 6 months