[libvirt] [PATCH 0/4] Resolve UNINIT errors found by Coverity
by John Ferlan
This set of patches resolves "Error: UNINIT (CWE-457)" errors found by Coverity
John Ferlan (4):
parallels: Resolve issues with uninitialized 'ret' value
openvz: Need to initialize 'ret' for kb_per_pages error path
lxc: Initialize dst due to potential cleanup usage before setting
interface: Need to initialize 'add_to_list'
src/interface/interface_backend_udev.c | 2 +-
src/lxc/lxc_driver.c | 2 +-
src/openvz/openvz_conf.c | 2 +-
src/parallels/parallels_storage.c | 19 ++++++++++++++-----
4 files changed, 17 insertions(+), 8 deletions(-)
--
1.7.11.7
11 years, 10 months
[libvirt] [PATCH 0/9 v2] Miscs of nodedev
by Osier Yang
This is the second part of [1]. Some of them are preparations
for persistent vHBA support in storage pool, some are fixes,
some are improvements.
v1 - v2:
* One more patch: 9/9
Osier Yang (9):
nodedev: Remove the unused enum
nodedev: Introduce two new flags for listAll API
util: Add one helper virReadFCHost to read the value of fc_host entry
nodedev: Use access instead of stat
nodedev: Refactor the helpers
nodedev: Dump max vports and vports in use for HBA's XML
nodedev: Fix the improper logic when enumerating SRIOV VF
nodedev: Abstract nodeDeviceVportCreateDelete as util function
cleanup libvirt_private.syms
docs/formatnode.html.in | 10 +-
docs/schemas/nodedev.rng | 6 +
include/libvirt/libvirt.h.in | 20 +-
src/conf/node_device_conf.c | 41 +-
src/conf/node_device_conf.h | 16 +-
src/libvirt.c | 2 +
src/libvirt_private.syms | 1160 +++++++++++++++--------------
src/node_device/node_device_driver.c | 110 +---
src/node_device/node_device_driver.h | 19 +-
src/node_device/node_device_hal.c | 15 +-
src/node_device/node_device_linux_sysfs.c | 245 ++----
src/node_device/node_device_udev.c | 14 +-
src/util/virpci.c | 36 +-
src/util/virutil.c | 224 ++++++
src/util/virutil.h | 19 +
tools/virsh-nodedev.c | 6 +
tools/virsh.pod | 7 +-
17 files changed, 1034 insertions(+), 916 deletions(-)
Regards,
Osier
11 years, 10 months
Re: [libvirt] [RFC qom-cpu v2 1/2] target-i386: Convert CPU definitions into X86CPU subclasses
by Eduardo Habkost
On Tue, Jan 15, 2013 at 09:41:04AM +0100, Igor Mammedov wrote:
> On Mon, 10 Dec 2012 23:59:31 +0100
> Andreas Färber <afaerber(a)suse.de> wrote:
>
> > TODO: sort classes for -cpu ?, generalize X86CPUListState, more testing
> >
> > Signed-off-by: Andreas Färber <afaerber(a)suse.de>
> > Cc: Eduardo Habkost <ehabkost(a)redhat.com>
> > Cc: Igor Mammedov <imammedo(a)redhat.com>
[...]
> The patch is just renaming of the current builtin_x86_defs
> into a bunch of functions and polluting X86CPUClass
> with fields from the former x86_def_t.
> object_new() still creates a dummy cpu instance whose defaults
> are still manually copied from X86CPUClass instead of x86_def_t.
>
That's a good thing, isn't it? It means the patch is easier to review.
:-)
No patch alone will do everything we want, because we want to do a lot.
We need to do it one step at a time.
(BTW, why are you looking at this RFC instead of the more recent one,
that I have sent on Jan 4? [that's very similar to this one])
> What's the point in having dummy sub-classes?
> How it can help in your CPU re-factoring?
It will help us to unify the CPU creation/realization code that's
duplicated over all the architectures.
It will give libvirt an easy mechanism to list the available CPU models
that won't require parsing help output (using "qom-list-types" QMP
command).
>
>
> On the other hand converting features to static properties first and
> then converting X86CPU to sub-classes, yields already initialized to
> defaults sub-class completely removing notion of x86_def_t and
> not polluting X86CPUClass with redundant fields.
I wouldn't disagree with this approach in principle, but I believe our
main problem today is lack of reviewer bandwidth. I learned the hard way
that trying to clean up everything before implementing something will
make sure the code takes forever to be reviewed.
> For example see following patches on
> https://github.com/imammedo/qemu/commits/x86-cpu-classes.Jan142013
>
> e9fd18f qdev: extend DEFINE_GENERIC_PROP() to support default values
> c65eca9 qdev: make qdev_prop_find_bit return non const so prop default value could be modified
> 0311952 allow to expolit default value static props for model, family, stepping & vendor props
> 8b3080e target-i386: add helpers to change default values of static properties before object is created
> ed506d3 target-i386: prepare for subclasses to have its own instance of static properties definitions
> a48e252 target-i386: declare subclass for qemu64 cpu model
> 9c556c2 target-i386: move cpu_x86_init() & cpu_x86_register() into it and switch to subclasses. PS: implemended only for qemu64
> f5dbfe6 CPU_CLASS_NAME(qemu64) hack
> 00e15b8 target-i386: properties list are per subclass: do not set them in superclass to avoid defaults set by subclass be over-written
>
> --
> Regards,
> Igor
--
Eduardo
11 years, 10 months
[libvirt] [PATCH 0/9] Add ability to connect to LXC namespaces
by Daniel P. Berrange
This series introduces an LXC specific library libvirt-lxc.so
which adds ability for a process to connect to the namespaces
used by an LXC container from outside. It uses FD passing
magic to allow the caller to connect, even if it is not root.
11 years, 10 months
[libvirt] [test-API][PATCH] Add logical volume download and upload cases
by Wayne Sun
This is for logical volume download and upload testing.
* using download and upload API under class virStream.
they are functions act as same with download/upload APIs
under class virStorageVol, just different entrance.
* using logical volume specified xml to create volume.
no need to provide volume format.
* check method is the same with dir vol download/upload
cases.
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
cases/storage_logical_vol_upload_download.conf | 179 ++++++++++++++++++++++++
repos/storage/logical_vol_download.py | 125 +++++++++++++++++
repos/storage/logical_vol_upload.py | 152 ++++++++++++++++++++
3 files changed, 456 insertions(+), 0 deletions(-)
create mode 100644 cases/storage_logical_vol_upload_download.conf
create mode 100644 repos/storage/logical_vol_download.py
create mode 100644 repos/storage/logical_vol_upload.py
diff --git a/cases/storage_logical_vol_upload_download.conf b/cases/storage_logical_vol_upload_download.conf
new file mode 100644
index 0000000..51b640e
--- /dev/null
+++ b/cases/storage_logical_vol_upload_download.conf
@@ -0,0 +1,179 @@
+storage:define_logical_pool
+ poolname
+ $defaultpoolname
+ sourcename
+ $defaultpoolname
+ sourcepath
+ $defaultpartition
+
+storage:build_logical_pool
+ poolname
+ $defaultpoolname
+
+storage:activate_pool
+ poolname
+ $defaultpoolname
+
+storage:logical_vol_download
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 0
+ length
+ 0
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:logical_vol_download
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 0
+ length
+ 1048576
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:logical_vol_download
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 1048576
+ length
+ 0
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:logical_vol_download
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 1048576
+ length
+ 1048576
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:logical_vol_upload
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 0
+ length
+ 0
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:logical_vol_upload
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 0
+ length
+ 1048576
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:logical_vol_upload
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 1048576
+ length
+ 0
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:logical_vol_upload
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 50
+ offset
+ 1048576
+ length
+ 1048576
+clean
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:destroy_pool
+ poolname
+ $defaultpoolname
+
+storage:delete_logical_pool
+ poolname
+ $defaultpoolname
+
+storage:undefine_pool
+ poolname
+ $defaultpoolname
diff --git a/repos/storage/logical_vol_download.py b/repos/storage/logical_vol_download.py
new file mode 100644
index 0000000..9797f36
--- /dev/null
+++ b/repos/storage/logical_vol_download.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+# logical storage volume download testing
+
+import os
+import string
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('poolname', 'volname', 'capacity', 'offset', 'length',)
+optional_params = {'xml' : 'xmls/logical_volume.xml',
+ }
+
+def get_pool_path(poolobj):
+ """ get pool xml description
+ """
+ poolxml = poolobj.XMLDesc(0)
+
+ logger.debug("the xml description of pool is %s" % poolxml)
+
+ doc = minidom.parseString(poolxml)
+ path_element = doc.getElementsByTagName('path')[0]
+ textnode = path_element.childNodes[0]
+ path_value = textnode.data
+
+ return path_value
+
+def write_file(path, capacity):
+ """write test data to file
+ """
+ logger.info("write %sM data into file %s" % (capacity, path))
+ f = open(path, 'w')
+ datastr = ''.join(string.lowercase + string.uppercase
+ + string.digits + '.' + '\n')
+ repeat = capacity / 64
+ data = ''.join(repeat * datastr)
+ f.write(data)
+ f.close()
+
+def handler(stream, data, file_):
+ return file_.write(data)
+
+def logical_vol_download(params):
+ """test volume download and check"""
+ global logger
+ logger = params['logger']
+ poolname = params['poolname']
+ volname = params['volname']
+ offset = int(params['offset'])
+ length = int(params['length'])
+ capacity = int(params['capacity'])
+ xmlstr = params['xml']
+
+ logger.info("the poolname is %s, volname is %s" %
+ (poolname, volname))
+ logger.info("download offset is: %s" % offset)
+ logger.info("the data length to download is: %s" % length)
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+ poolobj = conn.storagePoolLookupByName(poolname)
+ path_value = get_pool_path(poolobj)
+ volume_path = path_value + "/" + volname
+ logger.debug("volume target path: %s" % volume_path)
+
+ xmlstr = xmlstr.replace('TARGETPATH', volume_path)
+ logger.debug("volume xml:\n%s" % xmlstr)
+
+ logger.info("create %s logical storage volume" % volname)
+ vol = poolobj.createXML(xmlstr, 0)
+ logger.debug("current created storage volume: %s" %
+ poolobj.listVolumes())
+
+ write_file(volume_path, capacity)
+ origdigest = utils.digest(volume_path, offset, length)
+ logger.debug("the md5 hex digest of data read from %s is: %s" %
+ (volume_path, origdigest))
+
+ st = conn.newStream(0)
+
+ test_path = path_value + "/" + "vol_test"
+
+ f = open(test_path, 'w')
+ logger.info("start download")
+ st.download(vol, offset, length, 0)
+ logger.info("downloaded all data")
+ st.recvAll(handler, f)
+ logger.info("finished stream")
+ st.finish()
+ f.close()
+
+ newdigest = utils.digest(test_path, 0, 0)
+ logger.debug("the md5 hex digest of data read from %s is: %s" %
+ (test_path, newdigest))
+
+ if origdigest == newdigest:
+ logger.info("file digests match, download succeed")
+ else:
+ logger.error("file digests not match, download failed")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
+
+def logical_vol_download_clean(params):
+ """clean testing environment"""
+ poolname = params['poolname']
+ volname = params['volname']
+
+ conn = sharedmod.libvirtobj['conn']
+ poolobj = conn.storagePoolLookupByName(poolname)
+ path_value = get_pool_path(poolobj)
+ test_path = path_value + "/" + "vol_test"
+
+ if os.path.exists(test_path):
+ os.unlink(test_path)
+
+ return 0
diff --git a/repos/storage/logical_vol_upload.py b/repos/storage/logical_vol_upload.py
new file mode 100644
index 0000000..fc03ee6
--- /dev/null
+++ b/repos/storage/logical_vol_upload.py
@@ -0,0 +1,152 @@
+#!/usr/bin/env python
+# logical storage volume upload testing, offset and length can
+# only be chosen in 0 and 1048576.
+
+import os
+import string
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('poolname', 'volname', 'capacity', 'offset', 'length',)
+optional_params = {'xml' : 'xmls/logical_volume.xml',
+ }
+
+def get_pool_path(poolobj):
+ """ get pool xml description
+ """
+ poolxml = poolobj.XMLDesc(0)
+
+ logger.debug("the xml description of pool is %s" % poolxml)
+
+ doc = minidom.parseString(poolxml)
+ path_element = doc.getElementsByTagName('path')[0]
+ textnode = path_element.childNodes[0]
+ path_value = textnode.data
+
+ return path_value
+
+def write_file(path):
+ """write 1M test data to file
+ """
+ logger.info("write 1M data into file %s" % path)
+ f = open(path, 'w')
+ datastr = ''.join(string.lowercase + string.uppercase
+ + string.digits + '.' + '\n')
+ data = ''.join(16384 * datastr)
+ f.write(data)
+ f.close()
+
+def handler(stream, data, file_):
+ return file_.read(data)
+
+def logical_vol_upload(params):
+ """test volume download and check"""
+ global logger
+ logger = params['logger']
+ poolname = params['poolname']
+ volname = params['volname']
+ offset = int(params['offset'])
+ length = int(params['length'])
+ capacity = int(params['capacity'])
+ xmlstr = params['xml']
+
+ logger.info("the poolname is %s, volname is %s" %
+ (poolname, volname))
+ logger.info("download offset is: %s" % offset)
+ logger.info("the data length to download is: %s" % length)
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+ poolobj = conn.storagePoolLookupByName(poolname)
+ path_value = get_pool_path(poolobj)
+ volume_path = path_value + "/" + volname
+ logger.debug("volume target path: %s" % volume_path)
+
+ xmlstr = xmlstr.replace('TARGETPATH', volume_path)
+ logger.debug("volume xml:\n%s" % xmlstr)
+
+ logger.info("create %s logical storage volume" % volname)
+ vol = poolobj.createXML(xmlstr, 0)
+ logger.debug("current created storage volume: %s" %
+ poolobj.listVolumes())
+
+ test_path = path_value + "/" + "vol_test"
+ write_file(test_path)
+ olddigest = utils.digest(test_path, 0, 0)
+ logger.debug("the old file digest is: %s" % olddigest)
+
+ if offset:
+ origdigestpre = utils.digest(volume_path, 0, offset)
+ else:
+ origdigestpre = ''
+ logger.debug("the original pre region digest is: %s" % origdigestpre)
+
+ origdigestpost = utils.digest(volume_path, offset + 1024 * 1024, 0)
+ logger.debug("the original post region digest is: %s" % origdigestpost)
+
+ st = conn.newStream(0)
+
+ f = open(test_path, 'r')
+ logger.info("start upload")
+ st.upload(vol, offset, length, 0)
+ logger.info("sent all data")
+ st.sendAll(handler, f)
+ logger.info("finished stream")
+ st.finish()
+ f.close()
+
+ newdigest = utils.digest(volume_path, offset, 1024 * 1024)
+ logger.debug("the new file digest is: %s" % olddigest)
+
+ if offset:
+ newdigestpre = utils.digest(volume_path, 0, offset)
+ else:
+ newdigestpre = ''
+ logger.debug("the new pre region digest is: %s" % origdigestpre)
+
+ newdigestpost = utils.digest(volume_path, offset + 1024 * 1024, 0)
+ logger.debug("the new post region digest is: %s" % origdigestpost)
+
+ if newdigestpre == origdigestpre:
+ logger.info("file pre region digests match")
+ else:
+ logger.error("file pre region digests not match")
+ return 1
+
+ if olddigest == newdigest:
+ logger.info("file digests match")
+ else:
+ logger.error("file digests not match")
+ return 1
+
+ if newdigestpost == origdigestpost:
+ logger.info("file post region digests match")
+ else:
+ logger.error("file post region digests not match")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
+
+def logical_vol_upload_clean(params):
+ """clean testing environment"""
+ poolname = params['poolname']
+ volname = params['volname']
+
+ conn = sharedmod.libvirtobj['conn']
+ poolobj = conn.storagePoolLookupByName(poolname)
+ path_value = get_pool_path(poolobj)
+ test_path = path_value + "/" + "vol_test"
+
+ if os.path.exists(test_path):
+ os.unlink(test_path)
+
+ return 0
--
1.7.1
11 years, 10 months
[libvirt] [test-API][PATCH] Add volume resize case with delta flag
by Wayne Sun
Only storage backend for RBD (RADOS Block Device), FS and directory
have the resizeVol function, so only testing dir volume here.
Flags 'allocate' and 'shrik' are with bug:
https://bugzilla.redhat.com/show_bug.cgi?id=804516
they are not supported yet, so leave the case for later.
* using volume resize API with flag VIR_STORAGE_VOL_RESIZE_DELTA
* using volume info API to get volume info and check
* add dir volume resize conf
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
cases/storage_dir_vol_resize_delta.conf | 47 +++++++++++++++++++
repos/storage/vol_resize_delta.py | 75 +++++++++++++++++++++++++++++++
2 files changed, 122 insertions(+), 0 deletions(-)
create mode 100644 cases/storage_dir_vol_resize_delta.conf
create mode 100644 repos/storage/vol_resize_delta.py
diff --git a/cases/storage_dir_vol_resize_delta.conf b/cases/storage_dir_vol_resize_delta.conf
new file mode 100644
index 0000000..58e15bf
--- /dev/null
+++ b/cases/storage_dir_vol_resize_delta.conf
@@ -0,0 +1,47 @@
+storage:create_dir_pool
+ poolname
+ $defaultpoolname
+
+storage:create_dir_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ volformat
+ $defaultvolumetype
+ capacity
+ $defaultvolumesize
+
+storage:vol_resize_delta
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 1M
+
+storage:vol_resize_delta
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 2G
+
+storage:vol_resize_delta
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ capacity
+ 4096K
+
+storage:delete_dir_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
+storage:destroy_pool
+ poolname
+ $defaultpoolname
diff --git a/repos/storage/vol_resize_delta.py b/repos/storage/vol_resize_delta.py
new file mode 100644
index 0000000..a87941e
--- /dev/null
+++ b/repos/storage/vol_resize_delta.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+# volume resize testing with delta flags, libvirt storage
+# driver only support dir now
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('poolname', 'volname', 'capacity',)
+optional_params = {}
+
+def vol_resize_delta(params):
+ """test volume resize with delta flags"""
+
+ global logger
+ logger = params['logger']
+ poolname = params['poolname']
+ volname = params['volname']
+ capacity = params['capacity']
+
+ logger.info("the poolname is %s, volname is %s" %
+ (poolname, volname))
+
+ logger.info("the capacity given is %s" % capacity)
+ out = utils.get_capacity_suffix_size(capacity)
+ capacity_val = out['capacity_byte']
+ logger.debug("the capacity to byte is %s" % capacity_val)
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+ poolobj = conn.storagePoolLookupByName(poolname)
+ vol = poolobj.storageVolLookupByName(volname)
+
+ logger.info("get volume info before resize")
+ out = vol.info()
+ pre_capacity = out[1]
+ pre_allocation = out[2]
+ logger.info("volume capacity is %s bytes, allocation is %s bytes" %
+ (pre_capacity, pre_allocation))
+
+ flag = libvirt.VIR_STORAGE_VOL_RESIZE_DELTA
+ logger.info("resize %s with capacity %s in pool %s using flag: %s"
+ % (volname, capacity, poolname, flag))
+
+ vol.resize(capacity_val, flag)
+
+ logger.info("get volume info after resize")
+ out = vol.info()
+ post_capacity = out[1]
+ post_allocation = out[2]
+ logger.info("volume capacity is %s bytes, allocation is %s bytes" %
+ (post_capacity, post_allocation))
+
+ logger.info("check resize effect")
+ if post_capacity - pre_capacity == capacity_val:
+ logger.info("increased size is expected")
+ else:
+ logger.error("increase size not equal to set, resize failed")
+ return 1
+
+ if pre_allocation == post_allocation:
+ logger.info("allocation is expected")
+ else:
+ logger.error("allocation changed, resize failed")
+ return 1
+
+ logger.info("resize succeed")
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
--
1.7.1
11 years, 10 months
[libvirt] [test-API][PATCH] Add find storage pool sources cases
by Wayne Sun
Add cases for testing findStoragePoolSources API
* add 3 cases for storage type 'netfs', 'iscsi' and 'logical'
* add 2 xmls for 'netfs' and 'iscsi'
find 'logical' storage pool sources did not require xml start with
source tag and xml could be empty
* add test conf for find storage pool sources
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
cases/find_storage_pool_sources.conf | 31 +++++++++++
repos/storage/find_iscsi_pool_sources.py | 72 ++++++++++++++++++++++++
repos/storage/find_logical_pool_sources.py | 82 ++++++++++++++++++++++++++++
repos/storage/find_netfs_pool_sources.py | 71 ++++++++++++++++++++++++
repos/storage/xmls/iscsi_pool_source.xml | 3 +
repos/storage/xmls/netfs_pool_source.xml | 4 ++
6 files changed, 263 insertions(+), 0 deletions(-)
create mode 100644 cases/find_storage_pool_sources.conf
create mode 100644 repos/storage/find_iscsi_pool_sources.py
create mode 100644 repos/storage/find_logical_pool_sources.py
create mode 100644 repos/storage/find_netfs_pool_sources.py
create mode 100644 repos/storage/xmls/iscsi_pool_source.xml
create mode 100644 repos/storage/xmls/netfs_pool_source.xml
diff --git a/cases/find_storage_pool_sources.conf b/cases/find_storage_pool_sources.conf
new file mode 100644
index 0000000..d2e86db
--- /dev/null
+++ b/cases/find_storage_pool_sources.conf
@@ -0,0 +1,31 @@
+storage:find_iscsi_pool_sources
+ sourcehost
+ $iscsi_server
+
+storage:find_netfs_pool_sources
+ sourcehost
+ $nfs_server
+
+storage:define_logical_pool
+ poolname
+ $defaultpoolname
+ sourcename
+ $defaultpoolname
+ sourcepath
+ $defaultpartition
+
+storage:build_logical_pool
+ poolname
+ $defaultpoolname
+
+storage:find_logical_pool_sources
+ sourcepath
+ $defaultpartition
+
+storage:delete_logical_pool
+ poolname
+ $defaultpoolname
+
+storage:undefine_pool
+ poolname
+ $defaultpoolname
diff --git a/repos/storage/find_iscsi_pool_sources.py b/repos/storage/find_iscsi_pool_sources.py
new file mode 100644
index 0000000..4b758d2
--- /dev/null
+++ b/repos/storage/find_iscsi_pool_sources.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+# Test finding storage pool source of 'iscsi' type
+
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('sourcehost',)
+optional_params = {'xml' : 'xmls/iscsi_pool_source.xml',
+ }
+
+def check_pool_sources(host, xmlstr):
+ """check the iscsi sources with command:
+ iscsiadm --mode discovery --type sendtargets --portal
+ """
+ source_val = []
+
+ doc = minidom.parseString(xmlstr)
+ for diskTag in doc.getElementsByTagName("source"):
+ device_element = diskTag.getElementsByTagName("device")[0]
+ attr = device_element.getAttributeNode('path')
+ path_val = attr.nodeValue
+
+ source_val.append(path_val)
+
+ logger.debug("pool source info list is: %s" % source_val)
+
+ cmd = "iscsiadm --mode discovery --type sendtargets --portal %s:3260,1 |\
+ awk -F' ' '{print $2}'" % host
+ ret, path_list = utils.exec_cmd(cmd, shell=True)
+
+ logger.debug("iscsiadm command output list is: %s" % path_list)
+
+ if source_val == path_list:
+ logger.info("source list matched with iscsiadm command output")
+ return 0
+ else:
+ logger.error("source list did not match with iscsiadm command output")
+ return 1
+
+def find_iscsi_pool_sources(params):
+ """Find iscsi type storage pool sources from xml"""
+ global logger
+ logger = params['logger']
+ sourcehost = params['sourcehost']
+ xmlstr = params['xml']
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+
+ logger.debug("storage source spec xml:\n%s" % xmlstr)
+
+ logger.info("find pool sources of iscsi type")
+ source_xml = conn.findStoragePoolSources('iscsi', xmlstr, 0)
+ logger.info("pool sources xml description is:\n %s" % source_xml)
+
+ ret = check_pool_sources(sourcehost, source_xml)
+ if ret:
+ logger.error("pool sources check failed")
+ return 1
+ else:
+ logger.info("pool sources check succeed")
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/storage/find_logical_pool_sources.py b/repos/storage/find_logical_pool_sources.py
new file mode 100644
index 0000000..255d879
--- /dev/null
+++ b/repos/storage/find_logical_pool_sources.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# Test finding storage pool source of 'logical' type
+
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('sourcepath',)
+optional_params = {'xml' : 'xmls/logical_pool.xml',
+ }
+
+def check_pool_sources(xmlstr):
+ """check the logical sources with command:
+ pvs --noheadings -o pv_name,vg_name
+ """
+ source_val = {}
+ source_cmp = {}
+
+ doc = minidom.parseString(xmlstr)
+ for diskTag in doc.getElementsByTagName("source"):
+ device_element = diskTag.getElementsByTagName("device")[0]
+ attr = device_element.getAttributeNode('path')
+ path_val = attr.nodeValue
+
+ name_element = diskTag.getElementsByTagName("name")[0]
+ textnode = name_element.childNodes[0]
+ name_val = textnode.data
+
+ source_val.update({path_val: name_val, })
+
+ logger.debug("pool source info dict is: %s" % source_val)
+
+ cmd = "pvs --noheadings -o pv_name,vg_name | awk -F' ' '{print $1}'"
+ ret, path_list = utils.exec_cmd(cmd, shell=True)
+
+ cmd = "pvs --noheadings -o pv_name,vg_name | awk -F' ' '{print $2}'"
+ ret, name_list = utils.exec_cmd(cmd, shell=True)
+
+ for i in range(len(path_list)):
+ source_cmp.update({path_list[i]: name_list[i]})
+
+ logger.debug("pvs command output dict is: %s" % source_cmp)
+
+ if source_val == source_cmp:
+ logger.info("source dict match with pvs command output")
+ return 0
+ else:
+ logger.error("source dict did not match with pvs command output")
+ return 1
+
+def find_logical_pool_sources(params):
+ """Find logical type storage pool sources from xml"""
+ global logger
+ logger = params['logger']
+ sourcepath = params['sourcepath']
+ xmlstr = params['xml']
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+
+ logger.debug("storage source spec xml:\n%s" % xmlstr)
+
+ logger.info("find pool sources of logical type")
+ source_xml = conn.findStoragePoolSources('logical', xmlstr, 0)
+ logger.info("pool sources xml description is:\n %s" % source_xml)
+
+ ret = check_pool_sources(source_xml)
+ if ret:
+ logger.error("pool sources check failed")
+ return 1
+ else:
+ logger.info("pool sources check succeed")
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/storage/find_netfs_pool_sources.py b/repos/storage/find_netfs_pool_sources.py
new file mode 100644
index 0000000..bc71233
--- /dev/null
+++ b/repos/storage/find_netfs_pool_sources.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# Test finding storage pool source of 'netfs' type
+
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('sourcehost',)
+optional_params = {'xml' : 'xmls/netfs_pool_source.xml',
+ }
+
+def check_pool_sources(host, xmlstr):
+ """check the netfs sources with command:
+ showmount --no-headers -e HOSTNAME
+ """
+ source_val = []
+
+ doc = minidom.parseString(xmlstr)
+ for diskTag in doc.getElementsByTagName("source"):
+ device_element = diskTag.getElementsByTagName("dir")[0]
+ attr = device_element.getAttributeNode('path')
+ path_val = attr.nodeValue
+
+ source_val.append(path_val)
+
+ logger.debug("pool source info list is: %s" % source_val)
+
+ cmd = "showmount --no-headers -e %s | awk -F' ' '{print $1}'" % host
+ ret, path_list = utils.exec_cmd(cmd, shell=True)
+
+ logger.debug("showmount command output list is: %s" % path_list)
+
+ if source_val == path_list:
+ logger.info("source list matched with showmount command output")
+ return 0
+ else:
+ logger.error("source list did not match with showmount command output")
+ return 1
+
+def find_netfs_pool_sources(params):
+ """Find netfs type storage pool sources from xml"""
+ global logger
+ logger = params['logger']
+ sourcehost = params['sourcehost']
+ xmlstr = params['xml']
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+
+ logger.debug("storage source spec xml:\n%s" % xmlstr)
+
+ logger.info("find pool sources of netfs type")
+ source_xml = conn.findStoragePoolSources('netfs', xmlstr, 0)
+ logger.info("pool sources xml description is:\n %s" % source_xml)
+
+ ret = check_pool_sources(sourcehost, source_xml)
+ if ret:
+ logger.error("pool sources check failed")
+ return 1
+ else:
+ logger.info("pool sources check succeed")
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
diff --git a/repos/storage/xmls/iscsi_pool_source.xml b/repos/storage/xmls/iscsi_pool_source.xml
new file mode 100644
index 0000000..93216c5
--- /dev/null
+++ b/repos/storage/xmls/iscsi_pool_source.xml
@@ -0,0 +1,3 @@
+<source>
+ <host name="SOURCEHOST"/>
+</source>
diff --git a/repos/storage/xmls/netfs_pool_source.xml b/repos/storage/xmls/netfs_pool_source.xml
new file mode 100644
index 0000000..6a2aeea
--- /dev/null
+++ b/repos/storage/xmls/netfs_pool_source.xml
@@ -0,0 +1,4 @@
+<source>
+ <host name="SOURCEHOST"/>
+ <format type="nfs"/>
+</source>
--
1.7.1
11 years, 10 months
[libvirt] [test-API][PATCH] Add the volume clone case
by Wayne Sun
This is for volume clone testing by using createXMLFrom API
* add the vol_clone case under storage
it is general for all pool types
* add cases into confs:
cases/storage_dir.conf
cases/storage_logical.conf
cases/storage_netfs.conf
* add variable 'defaultvolclonename' in global.cfg
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
cases/storage_dir.conf | 14 +++++++
cases/storage_logical.conf | 14 +++++++
cases/storage_netfs.conf | 14 +++++++
global.cfg | 2 +
repos/storage/vol_clone.py | 81 ++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 125 insertions(+), 0 deletions(-)
create mode 100644 repos/storage/vol_clone.py
diff --git a/cases/storage_dir.conf b/cases/storage_dir.conf
index dcac700..38b349d 100644
--- a/cases/storage_dir.conf
+++ b/cases/storage_dir.conf
@@ -20,6 +20,20 @@ storage:create_dir_volume
capacity
$defaultvolumesize
+storage:vol_clone
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ clonevolname
+ $defaultvolclonename
+
+storage:delete_dir_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolclonename
+
storage:delete_dir_volume
poolname
$defaultpoolname
diff --git a/cases/storage_logical.conf b/cases/storage_logical.conf
index 3334abd..d374dfa 100644
--- a/cases/storage_logical.conf
+++ b/cases/storage_logical.conf
@@ -22,6 +22,20 @@ storage:create_logical_volume
capacity
$defaultvolumesize
+storage:vol_clone
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ clonevolname
+ $defaultvolclonename
+
+storage:delete_logical_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolclonename
+
storage:delete_logical_volume
poolname
$defaultpoolname
diff --git a/cases/storage_netfs.conf b/cases/storage_netfs.conf
index e764813..f486ff4 100644
--- a/cases/storage_netfs.conf
+++ b/cases/storage_netfs.conf
@@ -24,6 +24,20 @@ storage:create_netfs_volume
capacity
$defaultvolumesize
+storage:vol_clone
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+ clonevolname
+ $defaultvolclonename
+
+storage:delete_netfs_volume
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolclonename
+
storage:delete_netfs_volume
poolname
$defaultpoolname
diff --git a/global.cfg b/global.cfg
index 9e28614..182acbd 100644
--- a/global.cfg
+++ b/global.cfg
@@ -156,6 +156,8 @@ defaultpoolname = test_api_pool
defaultpoolpath = /var/lib/libvirt/images/dir_pool
# default volume name for creating new volume
defaultvolumename = test_api_volume
+# default clone volume name for clone a volume
+defaultvolclonename = test_clone_volume
# default volume type for creating a new volume
defaultvolumetype = raw
# default volume capacity for creating a new volume
diff --git a/repos/storage/vol_clone.py b/repos/storage/vol_clone.py
new file mode 100644
index 0000000..abf5644
--- /dev/null
+++ b/repos/storage/vol_clone.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# volume clone testing
+
+import os
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('poolname', 'volname', 'clonevolname',)
+optional_params = {}
+
+def prepare_clone_xml(xmlstr, volname):
+ """prepare clone xmldesc by replace name element
+ with clone souce volume xml
+ """
+ doc = minidom.parseString(xmlstr)
+ oldname = doc.getElementsByTagName("name")[0]
+
+ newname = doc.createElement('name')
+ newnameval = doc.createTextNode(volname)
+ newname.appendChild(newnameval)
+
+ volume = doc.getElementsByTagName('volume')[0]
+
+ volume.replaceChild(newname, oldname)
+ newxmlstr = doc.toxml()
+
+ return newxmlstr
+
+def vol_clone(params):
+ """volume clone testing"""
+
+ global logger
+ logger = params['logger']
+ poolname = params['poolname']
+ volname = params['volname']
+ clonevolname = params['clonevolname']
+
+ logger.info("the poolname is %s, volname is %s" % (poolname, volname))
+ logger.info("the clone volume name is %s" % clonevolname)
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+ poolobj = conn.storagePoolLookupByName(poolname)
+ old_vol = poolobj.storageVolLookupByName(volname)
+
+ xmlstr = old_vol.XMLDesc(0)
+ newxmlstr = prepare_clone_xml(xmlstr, clonevolname)
+ logger.debug("volume xml:\n%s" % newxmlstr)
+
+ logger.info("clone volume %s from source volume %s" %
+ (clonevolname, volname))
+
+ old_volnum = poolobj.numOfVolumes()
+
+ new_vol = poolobj.createXMLFrom(newxmlstr, old_vol, 0)
+ poolobj.refresh(0)
+
+ new_volnum = poolobj.numOfVolumes()
+
+ logger.debug("new cloned volume path is: %s" % new_vol.path())
+ if os.access(new_vol.path(), os.R_OK):
+ logger.info("cloned volume path exist")
+ else:
+ logger.error("cloned volume path not exist")
+ return 1
+
+ if new_volnum > old_volnum:
+ logger.info("clone succeed")
+ else:
+ logger.error("clone failed")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ return 0
--
1.7.1
11 years, 10 months
[libvirt] [PATCH] docs: remove extra "
by Eric Blake
* tools/virsh.pod: Fix typo.
---
Pushing under the trivial rule.
tools/virsh.pod | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 3687a4d..c9ebc8f 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2095,7 +2095,7 @@ destroy and re-start the network.
I<command> is one of "add-first", "add-last", "add" (a synonym for
add-last), "delete", or "modify".
-I<section> is one of ""bridge", "domain", "ip", "ip-dhcp-host",
+I<section> is one of "bridge", "domain", "ip", "ip-dhcp-host",
"ip-dhcp-range", "forward", "forward-interface", "forward-pf",
"portgroup", "dns-host", "dns-txt", or "dns-srv", each section being
named by a concatenation of the xml element hierarchy leading to the
--
1.8.0.2
11 years, 10 months
[libvirt] [PATCH v2] Build breaker securityselinuxhelper.c
by John Ferlan
v2: syntax-check - need space on # include
Commit 907a39e7 missed adding the WITH_ATTR around #include <attr/xattr.h>
resulting in a build failure:
CC libsecurityselinuxhelper_la-securityselinuxhelper.lo
securityselinuxhelper.c:27:24: fatal error: attr/xattr.h: No such file or directory
compilation terminated.
make[2]: *** [libsecurityselinuxhelper_la-securityselinuxhelper.lo] Error 1
make[2]: Leaving directory `/home/jferlan/libvirt.work/tests'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/jferlan/libvirt.work'
make: *** [all] Error 2
---
tests/securityselinuxhelper.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c
index daad7dd..a9656a8 100644
--- a/tests/securityselinuxhelper.c
+++ b/tests/securityselinuxhelper.c
@@ -24,7 +24,9 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <attr/xattr.h>
+#if WITH_ATTR
+# include <attr/xattr.h>
+#endif
/*
--
1.7.11.7
11 years, 10 months