[libvirt] [PATCH 0/3] Fix unmounting of dirs in LXC code
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Dan Walsh identified that if you ask LXC to mount both
/etc/aliases and /etc/aliases.db in the container you
only end up with one of them mounted. This was due to
a bogus subpath check.
It is a one line fix which turned into a much bigger
series so that I could add a test case for this code.
Daniel P. Berrange (3):
Remove 'abs_srcdir' variable from test files
Pull lxcContainerGetSubtree out into shared virfile module
Fix bug in identifying sub-mounts
.gitignore | 1 +
src/libvirt_private.syms | 4 ++
src/lxc/lxc_container.c | 63 ++-------------------
src/util/virfile.c | 114 +++++++++++++++++++++++++++++++++++++
src/util/virfile.h | 9 +++
src/util/virstring.c | 29 ++++++++++
src/util/virstring.h | 3 +
tests/Makefile.am | 7 +++
tests/testutils.c | 12 ----
tests/testutils.h | 1 -
tests/virfiledata/mounts1.txt | 31 ++++++++++
tests/virfiledata/mounts2.txt | 33 +++++++++++
tests/virfiletest.c | 128 ++++++++++++++++++++++++++++++++++++++++++
tests/virpcimock.c | 5 --
14 files changed, 363 insertions(+), 77 deletions(-)
create mode 100644 tests/virfiledata/mounts1.txt
create mode 100644 tests/virfiledata/mounts2.txt
create mode 100644 tests/virfiletest.c
--
1.8.3.1
10 years, 12 months
[libvirt] [PATCH] qemu: add support for -device pvpanic
by Hu Tao
qemu removes the builtin pvpanic device for all qemu versions since 1.7,
in order to support <on_crash>, '-device pvpanic' has to be added to
qemu command line.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
src/qemu/qemu_capabilities.c | 8 ++++++++
src/qemu/qemu_capabilities.h | 2 ++
src/qemu/qemu_command.c | 4 ++++
3 files changed, 14 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 548b988..7783997 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -243,6 +243,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-mmio",
"ich9-intel-hda",
"kvm-pit-lost-tick-policy",
+
+ "pvpanic", /* 160 */
);
struct _virQEMUCaps {
@@ -1198,6 +1200,9 @@ virQEMUCapsComputeCmdFlags(const char *help,
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_SHARE_POLICY);
}
+ if (version >= 1005000)
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_PVPANIC);
+
return 0;
}
@@ -2561,6 +2566,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (qemuCaps->version >= 1006000)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ if (qemuCaps->version >= 1005000)
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_PVPANIC);
+
if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
goto cleanup;
if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0)
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 02d47c6..06d2fac 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -199,6 +199,8 @@ enum virQEMUCapsFlags {
QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */
QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */
+ QEMU_CAPS_PVPANIC = 160, /* -device pvpanic */
+
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 763417f..b1307a3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9588,6 +9588,10 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PVPANIC)) {
+ virCommandAddArgList(cmd, "-device", "pvpanic", NULL);
+ }
+
if (mlock) {
unsigned long long memKB;
--
1.8.3.1
10 years, 12 months
[libvirt] [PATCH] libvirt-perl: Fix the wrong binding of virNodeDeviceLookupSCSIHostByWWN
by Osier Yang
The second parameter for virNodeDeviceLookupSCSIHostByWWN is "wwnn"
instead of "wwpn", and the API supports "flags".
---
AUTHORS | 1 +
lib/Sys/Virt/NodeDevice.pm | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index d53f191..c2af49a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,5 +12,6 @@ Patches contributed by:
Stepan Kasal <skasal-at-redhat-dot-com>
Ludwig Nussel <ludwig-dot-nussel-at-suse-dot-de>
Zhe Peng <zpeng-at-redhat-dot-com>
+ Osier Yang <jyang-at-redhat-dot-com>
-- End
diff --git a/lib/Sys/Virt/NodeDevice.pm b/lib/Sys/Virt/NodeDevice.pm
index 984910d..29ceac7 100644
--- a/lib/Sys/Virt/NodeDevice.pm
+++ b/lib/Sys/Virt/NodeDevice.pm
@@ -51,10 +51,11 @@ sub _new {
my $self;
if (exists $params{name}) {
$self = Sys::Virt::NodeDevice::_lookup_by_name($con, $params{name});
- } elsif (exists $params{wwpn}) {
+ } elsif (exists $params{wwnn}) {
$self = Sys::Virt::NodeDevice::_lookup_scsihost_by_wwn($con,
+ $params{wwnn},
$params{wwpn},
- $params{wwnn});
+ $params{flags});
} elsif (exists $params{xml}) {
$self = Sys::Virt::NodeDevice::_create_xml($con, $params{xml});
} else {
--
1.8.1.4
10 years, 12 months
[libvirt] [test-API][PATCH V2] Add blockjob related test functions and cases
by Jincheng Miao
* repos/domain/blkstatsflags.py
* repos/domain/block_iotune.py
* repos/domain/block_peek.py
* repos/domain/block_resize.py
* repos/domain/domain_blkio.py
* cases/basic_blockjob.conf
V1->V2:
Removed diskpath params for block_resize, this hard code disk device is
not convenient for users.
---
cases/basic_blockjob.conf | 83 +++++++++++++++++++++
repos/domain/blkstatsflags.py | 63 ++++++++++++++++
repos/domain/block_iotune.py | 118 ++++++++++++++++++++++++++++++
repos/domain/block_peek.py | 69 ++++++++++++++++++
repos/domain/block_resize.py | 94 ++++++++++++++++++++++++
repos/domain/domain_blkio.py | 163 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 590 insertions(+)
create mode 100644 cases/basic_blockjob.conf
create mode 100644 repos/domain/blkstatsflags.py
create mode 100644 repos/domain/block_iotune.py
create mode 100644 repos/domain/block_peek.py
create mode 100644 repos/domain/block_resize.py
create mode 100644 repos/domain/domain_blkio.py
diff --git a/cases/basic_blockjob.conf b/cases/basic_blockjob.conf
new file mode 100644
index 0000000..21332dc
--- /dev/null
+++ b/cases/basic_blockjob.conf
@@ -0,0 +1,83 @@
+domain:install_linux_cdrom
+ guestname
+ $defaultname
+ guestos
+ $defaultos
+ guestarch
+ $defaultarch
+ vcpu
+ $defaultvcpu
+ memory
+ $defaultmem
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+ macaddr
+ 54:52:00:45:c3:8a
+
+domain:install_linux_check
+ guestname
+ $defaultname
+ virt_type
+ $defaulthv
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+
+domain:block_iotune
+ guestname
+ $defaultname
+ bytes_sec
+ 100000
+ iops_sec
+ 0
+
+domain:block_iotune
+ guestname
+ $defaultname
+ bytes_sec
+ 0
+ iops_sec
+ 1000
+
+domain:block_peek
+ guestname
+ $defaultname
+
+domain:block_peek
+ guestname
+ $defaultname
+
+domain:block_resize
+ guestname
+ $defaultname
+ disksize
+ 1G
+
+domain:blkstats
+ guestname
+ $defaultname
+
+domain:blkstatsflags
+ guestname
+ $defaultname
+ flags
+ 0
+
+domain:domain_blkinfo
+ guestname
+ $defaultname
+
+domain:domain_blkio
+ guestname
+ $defaultname
+ weight
+ 500
+
+domain:undefine
+ guestname
+ $defaultname
+
+options cleanup=enable
diff --git a/repos/domain/blkstatsflags.py b/repos/domain/blkstatsflags.py
new file mode 100644
index 0000000..4c84a18
--- /dev/null
+++ b/repos/domain/blkstatsflags.py
@@ -0,0 +1,63 @@
+#!/usr/bin/evn python
+# To test domain block device statistics with flags
+
+import time
+import libxml2
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'flags')
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def check_blkstats():
+ """Check block device statistic result"""
+ pass
+
+def blkstatsflags(params):
+ """Domain block device statistic"""
+ logger = params['logger']
+ guestname = params['guestname']
+ flags = int(params['flags'])
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ devs = cont.xpathEval("/domain/devices/disk/target/@dev")
+
+ for dev in devs:
+ path = dev.content
+ blkstats = domobj.blockStatsFlags(path, flags)
+ # check_blkstats()
+ logger.debug(blkstats)
+ for entry in blkstats.keys():
+ logger.info("%s %s %s" %(path, entry, blkstats[entry]))
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/block_iotune.py b/repos/domain/block_iotune.py
new file mode 100644
index 0000000..26e4823
--- /dev/null
+++ b/repos/domain/block_iotune.py
@@ -0,0 +1,118 @@
+#!/usr/bin/evn python
+# To test domain block device iotune
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'bytes_sec', 'iops_sec')
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def prepare_block_iotune(param, wbs, rbs, tbs, wis, ris, tis, logger):
+ """prepare the block iotune parameter
+ """
+ logger.info("write_bytes_sec : %s" % wbs)
+ param['write_bytes_sec'] = wbs
+ logger.info("read_bytes_sec : %s" % rbs)
+ param['read_bytes_sec'] = rbs
+ logger.info("total_bytes_sec : %s" % tbs)
+ param['total_bytes_sec'] = tbs
+ logger.info("write_iops_sec : %s" % wis)
+ param['write_iops_sec'] = wis
+ logger.info("read_iops_sec : %s" % ris)
+ param['read_iops_sec'] = ris
+ logger.info("total_iops_sec : %s\n" % tis)
+ param['total_iops_sec'] = tis
+ return 0
+
+def check_iotune(expected_param, result_param):
+ """check block iotune configuration
+ """
+ for k in expected_param.keys():
+ if expected_param[k] != result_param[k]:
+ return 1
+ return 0
+
+def block_iotune(params):
+ """Domain block device iotune"""
+ logger = params['logger']
+ guestname = params['guestname']
+ bytes_sec = int(params['bytes_sec'])
+ iops_sec = int(params['iops_sec'])
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/target/@dev")
+ vdev = vdevs[0].content
+
+ iotune_para = {'write_bytes_sec': 0L,
+ 'total_iops_sec': 0L,
+ 'read_iops_sec': 0L,
+ 'read_bytes_sec': 0L,
+ 'write_iops_sec': 0L,
+ 'total_bytes_sec': 0L
+ }
+
+ logger.info("prepare block iotune:")
+ prepare_block_iotune(iotune_para, bytes_sec, bytes_sec, 0,
+ iops_sec, iops_sec, 0, logger)
+
+ logger.info("start to set block iotune:")
+ domobj.setBlockIoTune(vdev, iotune_para, flag)
+
+ res = domobj.blockIoTune(vdev, flag)
+ ret = check_iotune(iotune_para, res)
+ if not ret:
+ logger.info("set pass")
+ else:
+ logger.error("fails to set")
+ return 1
+
+ logger.info("prepare block iotune:")
+ prepare_block_iotune(iotune_para, 0, 0, bytes_sec,
+ 0, 0, iops_sec, logger)
+
+ logger.info("start to set block iotune:")
+ domobj.setBlockIoTune(vdev, iotune_para, flag)
+
+ res = domobj.blockIoTune(vdev, flag)
+ ret = check_iotune(iotune_para, res)
+ if not ret:
+ logger.info("set pass")
+ else:
+ logger.error("fails to set")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/block_peek.py b/repos/domain/block_peek.py
new file mode 100644
index 0000000..b88668a
--- /dev/null
+++ b/repos/domain/block_peek.py
@@ -0,0 +1,69 @@
+#!/usr/bin/evn python
+# To test domain block device peek
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname',)
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def block_peek(params):
+ """domain block peek test function
+ """
+ logger = params['logger']
+ guestname = params['guestname']
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/target/@dev")
+ vdev = vdevs[0].content
+
+ logger.info("start to test block_peek.")
+ logger.info("get the MBR's last byte of domain %s %s is:"
+ % (guestname, vdev))
+
+ last_byte = domobj.blockPeek(vdev, 511, 1, flag)
+ logger.info(last_byte)
+
+ # compare with '\xaa'
+ if last_byte == '\xaa':
+ logger.info("Pass: the last byte is \\xaa")
+ else:
+ logger.error("Failed: the last byte is not \\xaa")
+ logger.error("please make sure the guest is bootable")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/block_resize.py b/repos/domain/block_resize.py
new file mode 100644
index 0000000..6070c22
--- /dev/null
+++ b/repos/domain/block_resize.py
@@ -0,0 +1,94 @@
+#!/usr/bin/evn python
+# To test domain block device resize
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'disksize',)
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def block_resize(params):
+ """domain block resize test function
+ """
+ logger = params['logger']
+ guestname = params['guestname']
+ disksize = params['disksize']
+ flag = 0
+
+ out = utils.get_capacity_suffix_size(disksize)
+ if len(out) == 0:
+ logger.error("disksize parse error: \'%s\'" % disksize)
+ logger.error("disksize should be a number with capacity suffix")
+ return 1
+
+ if out['suffix'] == 'K':
+ flag = 0
+ disksize = long(out['capacity'])
+ elif out['suffix'] == 'B':
+ flag = 1
+ disksize = long(out['capacity_byte'])
+ elif out['suffix'] == 'M':
+ flag = 0
+ disksize = long(out['capacity']) * 1024
+ elif out['suffix'] == 'G':
+ flag = 0
+ disksize = long(out['capacity']) * 1024 * 1024
+ else:
+ logger.error("disksize parse error: with a unsupported suffix \'%s\'"
+ % out['suffix'])
+ logger.error("the available disksize suffix of block_resize is: ")
+ logger.error("B, K, M, G, T")
+ return 1
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/source/@file")
+ diskpath = vdevs[0].content
+ logger.info("the disk is %s" % diskpath)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ logger.info("resize domain disk to %s" % disksize)
+ domobj.blockResize(diskpath, disksize, flag)
+
+ # Currently, the units of disksize which get from blockInfo is byte.
+ block_info = domobj.blockInfo(diskpath, 0)
+
+ if block_info[0] == disksize * (1 + 1023 * (1 - flag)):
+ logger.info("domain disk resize success")
+ else:
+ logger.error("error: domain disk change into %s" % block_info[0])
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/domain_blkio.py b/repos/domain/domain_blkio.py
new file mode 100644
index 0000000..f1c637d
--- /dev/null
+++ b/repos/domain/domain_blkio.py
@@ -0,0 +1,163 @@
+#!/usr/bin/evn python
+# To test domain blkio parameters
+
+import os
+import time
+import libxml2
+import libvirt
+import commands
+from libvirt import libvirtError
+
+from src import sharedmod
+
+CGROUP_PATH = "/cgroup"
+BLKIO_PATH1 = "%s/blkio/libvirt/qemu/%s"
+BLKIO_PATH2 = "/sys/fs%s/blkio/machine/%s.libvirt-qemu"
+GET_PARTITION = "df -P %s | tail -1 | awk {'print $1'}"
+
+required_params = ('guestname', 'weight',)
+optional_params = {}
+
+def get_output(command, logger):
+ """execute shell command
+ """
+ status, ret = commands.getstatusoutput(command)
+ if status:
+ logger.error("executing "+ "\"" + command + "\"" + " failed")
+ logger.error(ret)
+ return status, ret
+
+def get_device(domobj, logger):
+ """get the disk device which domain image stored in
+ """
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ devs = cont.xpathEval("/domain/devices/disk/source/@file")
+ image_file = devs[0].content
+
+ status, output = get_output(GET_PARTITION % image_file, logger)
+ if not status:
+ return output[:-1]
+ else:
+ logger.error("get device error: ")
+ logger.error(GET_PARTITION % image_file)
+ return ""
+
+def check_blkio_paras(domain_blkio_path, domainname, blkio_paras, logger):
+ """check blkio parameters according to cgroup filesystem
+ """
+ logger.info("checking blkio parameters from cgroup")
+ if 'weight' in blkio_paras:
+ expected_weight = blkio_paras['weight']
+ status, output = get_output("cat %s/blkio.weight"
+ % domain_blkio_path, logger)
+ if not status:
+ logger.info("%s/blkio.weight is \"%s\""
+ % (domain_blkio_path, output))
+ else:
+ return 1
+
+ if int(output) == expected_weight:
+ logger.info("the weight matches with cgroup blkio.weight")
+ return 0
+ else:
+ logger.error("the weight mismatches with cgroup blkio.weight")
+ return 1
+
+ if 'device_weight' in blkio_paras:
+ expected_device_weight = blkio_paras['device_weight']
+ status, output = get_output("cat %s/blkio.weight_device"
+ % domain_blkio_path, logger)
+ if not status:
+ logger.info("%s/blkio.weight_device is \"%s\""
+ % (domain_blkio_path, output))
+ else:
+ return 1
+
+ if output.split(' ')[1] == expected_device_weight.split(',')[1]:
+ logger.info("the device_weight matches with cgroup \
+ blkio.weight_device")
+ return 0
+ else:
+ logger.error("the device_weight mismatches with cgroup \
+ blkio.weight_device")
+ return 1
+
+ return 0
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def domain_blkio(params):
+ """domain blkio parameters test function"""
+ logger = params['logger']
+ guestname = params['guestname']
+ expected_weight = params['weight']
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ if os.path.exists(CGROUP_PATH):
+ blkio_path = BLKIO_PATH1 % (CGROUP_PATH, guestname)
+ else:
+ blkio_path = BLKIO_PATH2 % (CGROUP_PATH, guestname)
+
+ try:
+ blkio_paras = domobj.blkioParameters(flag)
+
+ logger.info("the blkio weight of %s is: %d"
+ % (guestname, blkio_paras['weight']))
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ logger.info("start to set param weight to %s" % expected_weight)
+ blkio_paras = {'weight':int(expected_weight)}
+ status = domobj.setBlkioParameters(blkio_paras, flag)
+ if status != 0:
+ return 1
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ device = get_device(domobj, logger)
+ device_weight = "%s,%s" % (device, expected_weight)
+ logger.info("start to set param device_weight to %s"
+ % device_weight)
+ blkio_paras = {'device_weight':device_weight}
+ status = domobj.setBlkioParameters(blkio_paras, flag)
+ if status != 0:
+ return 1
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
--
1.8.3.1
10 years, 12 months
[libvirt] Entering freeze for 1.2.0, rc1 available
by Daniel Veillard
So as planned we are entering freeze for libvirt-1.2.0,
I just tagged the git trees - plural as we now use libvirt-python
separate git for this binding - and pushed tarballs and rpms to
the usual place at:
ftp://libvirt.org/libvirt/
it did allows a correct update at the rpm level for me and
virt-manager does work correctly at least with my minimal testing.
We now need further reviews, obviously on the portability front
especially as the python bindings are a separate tarball. It would be
cool to get more testing on specific aspects of the release too, like
the gluster pool and VBox 4.3 support.
Give it a try,
thanks !
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
10 years, 12 months
[libvirt] [PATCH] tests: Make pci config files writable
by Michal Privoznik
As of 21685c955 the 'distcheck' is broken. The problem is, by default it
copies all the necessary files and make them read only. However, pci
device detach test doesn't work that way. The PCI device configs are
stored within our tests/ directory and need to be writable (detaching
and resetting means writing into the config file). Hence, we must make
those files writable again.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/Makefile.am | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e46d5f7..29dbf76 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -921,3 +921,8 @@ endif ! WITH_CIL
CLEANFILES = *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda *.cmi *.cmx \
object-locking-files.txt
+
+# Some tests tend to write into files. Notably, the virpcitest, which detach
+# and reset a pci device (achieved byt writing into a pci config file).
+check-local:
+ chmod -R u+w $(srcdir)/virpcitestdata/
--
1.8.4.4
10 years, 12 months
[libvirt] [PATCH] network: properly update iptables rules during net-update
by Laine Stump
This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1035336
The basic problem is that during a network update, the required
iptables rules sometimes change, and this was being handled by simply
removing and re-adding the rules. However, the removal of the old
rules was done based on the *new* state of the network, which would
mean that some of the rules would not match those currently in the
system, so the old rules wouldn't be removed.
This patch removes the old rules prior to updating the network
definitionm then adds the new rules as soon as the definition is
updated. Note that this could lead to a stray packet or two during the
interim, but that was already a problem before (the period of limbo is
now just slightly longer).
While moving the location for the rules, I added a few more sections that should result in the iptables rules being redone:
DHCP_RANGE and DHCP_HOST - these are needed because adding/removing a dhcp
host entry could lead to the dhcp service being started/stopped, which
would require that the mangle rule that fixes up dhcp response
checksums sould need to be added/removed, and this wasn't being done.
---
src/network/bridge_driver.c | 47 +++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 83dc931..d7f12e1 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2642,6 +2642,7 @@ networkUpdate(virNetworkPtr net,
size_t i;
virNetworkIpDefPtr ipdef;
bool oldDhcpActive = false;
+ bool needFirewallRefresh = false;
virCheckFlags(VIR_NETWORK_UPDATE_AFFECT_LIVE |
@@ -2683,8 +2684,39 @@ networkUpdate(virNetworkPtr net,
flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
}
+ if (isActive && (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE)) {
+ /* Take care of anything that must be done before updating the
+ * live NetworkDef.
+ */
+ if (network->def->forward.type == VIR_NETWORK_FORWARD_NONE ||
+ network->def->forward.type == VIR_NETWORK_FORWARD_NAT ||
+ network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
+ switch (section) {
+ case VIR_NETWORK_SECTION_FORWARD:
+ case VIR_NETWORK_SECTION_FORWARD_INTERFACE:
+ case VIR_NETWORK_SECTION_IP:
+ case VIR_NETWORK_SECTION_IP_DHCP_RANGE:
+ case VIR_NETWORK_SECTION_IP_DHCP_HOST:
+ /* these could affect the firewall rules, so remove the
+ * old rules (and remember to load new ones after the
+ * update).
+ */
+ networkRemoveFirewallRules(network);
+ needFirewallRefresh = true;
+ default:
+ break;
+ }
+ }
+ }
+
/* update the network config in memory/on disk */
- if (virNetworkObjUpdate(network, command, section, parentIndex, xml, flags) < 0)
+ if (virNetworkObjUpdate(network, command, section, parentIndex, xml, flags) < 0) {
+ if (needFirewallRefresh)
+ ignore_value(networkAddFirewallRules(network));
+ goto cleanup;
+ }
+
+ if (needFirewallRefresh && networkAddFirewallRules(network) < 0)
goto cleanup;
if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
@@ -2754,19 +2786,6 @@ networkUpdate(virNetworkPtr net,
goto cleanup;
}
- if ((section == VIR_NETWORK_SECTION_IP ||
- section == VIR_NETWORK_SECTION_FORWARD ||
- section == VIR_NETWORK_SECTION_FORWARD_INTERFACE) &&
- (network->def->forward.type == VIR_NETWORK_FORWARD_NONE ||
- network->def->forward.type == VIR_NETWORK_FORWARD_NAT ||
- network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE)) {
- /* these could affect the iptables rules */
- networkRemoveFirewallRules(network);
- if (networkAddFirewallRules(network) < 0)
- goto cleanup;
-
- }
-
/* save current network state to disk */
if ((ret = virNetworkSaveStatus(driverState->stateDir,
network)) < 0) {
--
1.8.4.2
10 years, 12 months
[libvirt] [PATCH] tests: fix virpcitest with read-only srcdir
by Eric Blake
'make distcheck' has been broken since commit 21685c9; basically,
it emulates the case of a read-only $(srcdir) (such as building
from a tarball exploded onto a CD-ROM), but we were creating our
fake pci device as a symlink into $(srcdir) and failing when that
requires opening the config file for writing:
3) testVirPCIDeviceReset ... libvirt: error : Failed to open config space file '/sys/bus/pci/devices/0000:00:01.0/config': Permission denied
Fix it by copying rather than symlinking.
* tests/virpcimock.c (make_file): Add parameter to allow binary
creation; adjust all callers.
(pci_device_new_from_stub): Copy rather than symlink.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule, as an alternative
to the earlier attempt that I nak'ed:
https://www.redhat.com/archives/libvir-list/2013-November/msg00999.html
tests/virpcimock.c | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 48d5f16..a5cef46 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -154,10 +154,13 @@ static int pci_driver_handle_remove_id(const char *path);
static void
make_file(const char *path,
const char *name,
- const char *value)
+ const char *value,
+ ssize_t len)
{
int fd = -1;
char *filepath = NULL;
+ if (value && len == -1)
+ len = strlen(value);
if (virAsprintfQuiet(&filepath, "%s/%s", path, name) < 0)
ABORT_OOM();
@@ -165,7 +168,7 @@ make_file(const char *path,
if ((fd = realopen(filepath, O_CREAT|O_WRONLY, 0666)) < 0)
ABORT("Unable to open: %s", filepath);
- if (value && safewrite(fd, value, strlen(value)) != strlen(value))
+ if (value && safewrite(fd, value, len) != len)
ABORT("Unable to write: %s", filepath);
VIR_FORCE_CLOSE(fd);
@@ -302,7 +305,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
{
struct pciDevice *dev;
char *devpath;
- char *configSrc, *configDst;
+ char *configSrc;
char tmp[32];
struct stat sb;
@@ -321,25 +324,32 @@ pci_device_new_from_stub(const struct pciDevice *data)
* symlink it. Otherwise create a dummy config file. */
if ((realstat && realstat(configSrc, &sb) == 0) ||
(real__xstat && real__xstat(_STAT_VER, configSrc, &sb) == 0)) {
- /* On success make symlink to @configSrc */
- if (virAsprintfQuiet(&configDst, "%s/config", devpath) < 0)
- ABORT_OOM();
-
- if (symlink(configSrc, configDst) < 0)
- ABORT("Unable to create symlink: %s", configDst);
+ /* On success, copy @configSrc into the destination (a copy,
+ * rather than a symlink, is required since we write into the
+ * file, and parallel VPATH builds must not stomp on the
+ * original; besides, 'make distcheck' requires the original
+ * to be read-only */
+ char *buf;
+ ssize_t len;
+
+ if ((len = virFileReadAll(configSrc, 4096, &buf)) < 0)
+ ABORT("Unable to read config file '%s'", configSrc);
+
+ make_file(devpath, "config", buf, len);
+ VIR_FREE(buf);
} else {
/* If there's no config data in the virpcitestdata dir, create a dummy
* config file */
- make_file(devpath, "config", "some dummy config");
+ make_file(devpath, "config", "some dummy config", -1);
}
if (snprintf(tmp, sizeof(tmp), "0x%.4x", dev->vendor) < 0)
ABORT("@tmp overflow");
- make_file(devpath, "vendor", tmp);
+ make_file(devpath, "vendor", tmp, -1);
if (snprintf(tmp, sizeof(tmp), "0x%.4x", dev->device) < 0)
ABORT("@tmp overflow");
- make_file(devpath, "device", tmp);
+ make_file(devpath, "device", tmp, -1);
if (pci_device_autobind(dev) < 0)
ABORT("Unable to bind: %s", data->id);
@@ -348,6 +358,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
ABORT_OOM();
VIR_FREE(devpath);
+ VIR_FREE(configSrc);
}
static struct pciDevice *
@@ -425,10 +436,10 @@ pci_driver_new(const char *name, ...)
va_end(args);
- make_file(driverpath, "bind", NULL);
- make_file(driverpath, "unbind", NULL);
- make_file(driverpath, "new_id", NULL);
- make_file(driverpath, "remove_id", NULL);
+ make_file(driverpath, "bind", NULL, -1);
+ make_file(driverpath, "unbind", NULL, -1);
+ make_file(driverpath, "new_id", NULL, -1);
+ make_file(driverpath, "remove_id", NULL, -1);
if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPciDrivers, driver) < 0)
ABORT_OOM();
--
1.8.3.1
10 years, 12 months
[libvirt] [PATCH] tests: guarantee abs_srcdir in all C tests
by Eric Blake
While trying to debug a failure of virpcitest during 'make distcheck',
I noticed that with a VPATH build, 'cd tests; ./virpcitest' fails for
an entirely different reason. To reproduce the distcheck failure, I
had to run 'cd tests; abs_srcdir=/path/to/src ./virpcitest'. But we
document in HACKING that all of our tests are supposed to be runnable
without requiring extra environment variables.
The solution: hardcode the location of srcdir into the just-built
binaries, rather than requiring make to prepopulate environment
variables. With this, './virpcitest' passes even in a VPATH build
(provided that $(srcdir) is writable; a followup patch will fix the
conditions required by 'make distcheck').
* tests/Makefile.am (AM_CFLAGS): Define abs_srcdir in all compiled
tests.
* tests/testutils.h (abs_srcdir): Quit declaring.
* tests/testutils.c (virtTestMain): Rely on define rather than
environment variable.
* tests/virpcimock.c (pci_device_new_from_stub): Rely on define.
* tests/cputest.c (mymain): Adjust abs_top_srcdir default.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxmlnstest.c (mymain): Likewise.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
tests/Makefile.am | 1 +
tests/cputest.c | 2 +-
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxmlnstest.c | 2 +-
tests/testutils.c | 11 +----------
tests/testutils.h | 6 +++++-
tests/virpcimock.c | 12 ++++--------
7 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e46d5f7..520fd2a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -29,6 +29,7 @@ INCLUDES = \
AM_CFLAGS = \
-Dabs_builddir="\"`pwd`\"" \
+ -Dabs_srcdir="\"`cd '$(srcdir)'; pwd`\"" \
$(LIBXML_CFLAGS) \
$(GNUTLS_CFLAGS) \
$(SASL_CFLAGS) \
diff --git a/tests/cputest.c b/tests/cputest.c
index b80fac7..20bc544 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -503,7 +503,7 @@ mymain(void)
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir)
- abs_top_srcdir = "..";
+ abs_top_srcdir = abs_srcdir "/..";
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
cpuMapOverride(map) < 0) {
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a290062..dad5973 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -297,7 +297,7 @@ mymain(void)
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir)
- abs_top_srcdir = "..";
+ abs_top_srcdir = abs_srcdir "/..";
driver.config = virQEMUDriverConfigNew(false);
VIR_FREE(driver.config->spiceListen);
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 2cc15d1..2093e1e 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -203,7 +203,7 @@ mymain(void)
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir)
- abs_top_srcdir = "..";
+ abs_top_srcdir = abs_srcdir "/..";
driver.config = virQEMUDriverConfigNew(false);
if ((driver.caps = testQemuCapsInit()) == NULL)
diff --git a/tests/testutils.c b/tests/testutils.c
index 5d634b4..32fe374 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -69,7 +69,6 @@ static size_t testStart = 0;
static size_t testEnd = 0;
char *progname;
-char *abs_srcdir;
void virtTestResult(const char *name, int ret, const char *msg, ...)
{
@@ -535,15 +534,9 @@ int virtTestMain(int argc,
int (*func)(void))
{
int ret;
- bool abs_srcdir_cleanup = false;
char *testRange = NULL;
- abs_srcdir = getenv("abs_srcdir");
- if (!abs_srcdir) {
- abs_srcdir = getcwd(NULL, 0);
- abs_srcdir_cleanup = true;
- }
- if (!abs_srcdir)
+ if (!virFileExists(abs_srcdir))
return EXIT_AM_HARDFAIL;
progname = last_component(argv[0]);
@@ -599,8 +592,6 @@ int virtTestMain(int argc,
ret = (func)();
- if (abs_srcdir_cleanup)
- VIR_FREE(abs_srcdir);
virResetLastError();
if (!virTestGetVerbose() && ret != EXIT_AM_SKIP) {
if (testCounter == 0 || testCounter % 40)
diff --git a/tests/testutils.h b/tests/testutils.h
index 478b53c..674d3df 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -38,7 +38,11 @@
# endif
extern char *progname;
-extern char *abs_srcdir;
+
+/* Makefile.am provides these two definitions */
+# if !defined(abs_srcdir) || !defined(abs_builddir)
+# error Fix Makefile.am
+# endif
void virtTestResult(const char *name, int ret, const char *msg, ...)
ATTRIBUTE_FMT_PRINTF(3,4);
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 19062c3..48d5f16 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -305,14 +305,10 @@ pci_device_new_from_stub(const struct pciDevice *data)
char *configSrc, *configDst;
char tmp[32];
struct stat sb;
- char *abs_srcdir;
-
- abs_srcdir = getenv("abs_srcdir");
- if (!abs_srcdir)
- abs_srcdir = getcwd(NULL, 0);
if (VIR_ALLOC_QUIET(dev) < 0 ||
- virAsprintfQuiet(&configSrc, "%s/virpcitestdata/%s.config", abs_srcdir, data->id) < 0 ||
+ virAsprintfQuiet(&configSrc, "%s/virpcitestdata/%s.config",
+ abs_srcdir, data->id) < 0 ||
virAsprintfQuiet(&devpath, "%s/devices/%s", fakesysfsdir, data->id) < 0)
ABORT_OOM();
@@ -480,7 +476,7 @@ pci_driver_bind(struct pciDriver *driver,
char *devpath = NULL, *driverpath = NULL;
if (dev->driver) {
- /* Device already binded */
+ /* Device already bound */
errno = ENODEV;
return ret;
}
@@ -527,7 +523,7 @@ pci_driver_unbind(struct pciDriver *driver,
char *devpath = NULL, *driverpath = NULL;
if (dev->driver != driver) {
- /* Device not binded to the @driver */
+ /* Device not bound to the @driver */
errno = ENODEV;
return ret;
}
--
1.8.3.1
10 years, 12 months
[libvirt] [PATCH] Remove invalid parsing of pty path from XML for PTY type chardevs
by Nehal J Wani
While running valgrind on the qemuhotplugtest, one of the many memory leaks
detected are:
==3915== 12 bytes in 1 blocks are definitely lost in loss record 36 of 129
==3915== at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==3915== by 0x34268AF275: xmlStrndup (in /usr/lib64/libxml2.so.2.9.1)
==3915== by 0x4CCC3BB: virDomainChrSourceDefParseXML (domain_conf.c:6957)
==3915== by 0x4CD6A29: virDomainChrDefParseXML (domain_conf.c:7243)
==3915== by 0x4CEC0C9: virDomainDeviceDefParse (domain_conf.c:9616)
==3915== by 0x41D14F: testQemuHotplug (qemuhotplugtest.c:247)
==3915== by 0x41E421: virtTestRun (testutils.c:139)
==3915== by 0x41C6E3: mymain (qemuhotplugtest.c:428)
==3915== by 0x41EAB2: virtTestMain (testutils.c:600)
==3915== by 0x341F421A04: (below main) (libc-start.c:225)
==3915==
The main reason behind this error is that for the PTY type chardevs, it is
not valid to specify or parse a pty path from the XML. This is an output-only
attribute, not under user control. Hence, the parsing code inside
qemuMonitorJSONAttachCharDev() was wrong.
Refer the discussion: https://www.redhat.com/archives/libvir-list/2013-November/msg01255.html
tests/qemumonitorjsontest.c
* Remove unwanted parsing code inside qemuMonitorJSONAttachCharDev
src/qemu/qemu_monitor_json.c:
* Remove erraneous testcase
---
src/qemu/qemu_monitor_json.c | 20 --------------------
tests/qemumonitorjsontest.c | 16 ----------------
2 files changed, 36 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index ec3b958..1bfeef0 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5368,26 +5368,6 @@ qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon,
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
- if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
- virJSONValuePtr data;
- const char *path;
-
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("chardev-add reply was missing return data"));
- goto cleanup;
- }
-
- if (!(path = virJSONValueObjectGetString(data, "pty"))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("chardev-add reply was missing pty path"));
- goto cleanup;
- }
-
- if (VIR_STRDUP(chr->data.file.path, path) < 0)
- goto cleanup;
- }
-
ret = 0;
cleanup:
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 2152e4a..a3c38b6 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -708,22 +708,6 @@ testQemuMonitorJSONAttachChardev(const void *data)
chr = (virDomainChrSourceDef) { .type =VIR_DOMAIN_CHR_TYPE_VC };
CHECK("chr_vc", "{\"return\": {}}");
-#define PTY_PATH "/dev/ttyS0"
- chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_PTY };
- CHECK("chr_pty", "{\"return\": {\"pty\" : \"" PTY_PATH "\"}}");
- if (STRNEQ_NULLABLE(PTY_PATH, chr.data.file.path)) {
- VIR_FREE(chr.data.file.path);
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "expected PTY path: %s got: %s",
- PTY_PATH, NULLSTR(chr.data.file.path));
- ret = -1;
- }
- VIR_FREE(chr.data.file.path);
-
- chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_PTY };
- CHECK_FAIL("chr_pty_fail", "{\"return\": {}}");
-#undef PTY_PATH
-
chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_FILE };
CHECK("chr_file", "{\"return\": {}}");
--
1.8.1.4
10 years, 12 months