[libvirt] [test-API][PATCH] Add 2 emulatorpin cases cover config and live flags
by Wayne Sun
- use pinEmulator to pin domain emulator to host cpu
- 2 cases cover config and live flags
- cpulist with '^', '-' and ',' is supported to give multiple
host cpus
Related bug 916493:
pinEmulator and emulatorPinInfo should be simple with required params
https://bugzilla.redhat.com/show_bug.cgi?id=916493
is fixed, so the test can run successfully now.
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
repos/setVcpus/emulatorpin_config.py | 97 +++++++++++++++++++++++++++++++++++
repos/setVcpus/emulatorpin_live.py | 98 ++++++++++++++++++++++++++++++++++++
2 files changed, 195 insertions(+)
create mode 100644 repos/setVcpus/emulatorpin_config.py
create mode 100644 repos/setVcpus/emulatorpin_live.py
diff --git a/repos/setVcpus/emulatorpin_config.py b/repos/setVcpus/emulatorpin_config.py
new file mode 100644
index 0000000..9b94f98
--- /dev/null
+++ b/repos/setVcpus/emulatorpin_config.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+# Test domain emulator pin with flag VIR_DOMAIN_AFFECT_CONFIG, check
+# domain config xml with emulatorpin configuration.
+
+import re
+from xml.dom import minidom
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'cpulist',)
+optional_params = {}
+
+def emulatorpin_check(domobj, cpumap):
+ """check domain config xml with emulatorpin element
+ """
+ guestxml = domobj.XMLDesc(2)
+ logger.debug("domain %s xml :\n%s" %(domobj.name(), guestxml))
+
+ doc = minidom.parseString(guestxml)
+ emulatorpin = doc.getElementsByTagName('emulatorpin')
+ if not emulatorpin:
+ logger.error("no emulatorpin element in domain xml")
+ return 1
+
+ if not emulatorpin[0].hasAttribute('cpuset'):
+ logger.error("no cpuset attribute with emulatorpin in domain xml")
+ return 1
+ else:
+ emulator_attr = emulatorpin[0].getAttributeNode('cpuset')
+ cpulist = emulator_attr.nodeValue
+ cpumap_tmp = utils.param_to_tuple(cpulist, maxcpu)
+
+ if cpumap_tmp == cpumap:
+ logger.info("cpuset is as expected in domain xml")
+ return 0
+ else:
+ logger.error("cpuset is not as expected in domain xml")
+ return 1
+
+def emulatorpin_config(params):
+ """pin domain emulator to host cpu with config flag
+ """
+ global logger
+ logger = params['logger']
+ params.pop('logger')
+ guestname = params['guestname']
+ cpulist = params['cpulist']
+
+ logger.info("the name of virtual machine is %s" % guestname)
+ logger.info("the given cpulist is %s" % cpulist)
+
+ global maxcpu
+ maxcpu = utils.get_host_cpus()
+ logger.info("%s physical cpu on host" % maxcpu)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ cpumap = utils.param_to_tuple(cpulist, maxcpu)
+
+ if not cpumap:
+ logger.error("cpulist: Invalid format")
+ return 1
+
+ logger.debug("cpumap for emulator pin is:")
+ logger.debug(cpumap)
+
+ logger.info("pin domain emulator to host cpulist %s with flag: %s" %
+ (cpulist, libvirt.VIR_DOMAIN_AFFECT_CONFIG))
+ domobj.pinEmulator(cpumap, libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+
+ logger.info("check emulator pin info")
+ ret = domobj.emulatorPinInfo(libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+ logger.debug("emulator pin info is:")
+ logger.debug(ret)
+ if ret == cpumap:
+ logger.info("emulator pin info is expected")
+ else:
+ logger.error("emulator pin info is not expected")
+ return 1
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ logger.info("check domain emulatorpin configuration in xml")
+ ret = emulatorpin_check(domobj, cpumap)
+ if ret:
+ logger.error("domain emulator pin check failed")
+ return 1
+ else:
+ logger.info("domain emulator pin check succeed")
+ return 0
diff --git a/repos/setVcpus/emulatorpin_live.py b/repos/setVcpus/emulatorpin_live.py
new file mode 100644
index 0000000..08b7073
--- /dev/null
+++ b/repos/setVcpus/emulatorpin_live.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# Test domain emulator pin with flag VIR_DOMAIN_AFFECT_LIVE, check
+# emulator process status under domain task list on host.
+
+import re
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'cpulist',)
+optional_params = {}
+
+def emulatorpin_check(guestname, cpumap):
+ """check emulator process status of the running virtual machine
+ grep Cpus_allowed_list /proc/PID/status
+ """
+ tmp_str = ''
+ cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname
+ status, pid = utils.exec_cmd(cmd, shell=True)
+ if status:
+ logger.error("failed to get the pid of domain %s" % guestname)
+ return 1
+
+ cmd = "grep Cpus_allowed_list /proc/%s/status" % pid[0]
+ status, output = utils.exec_cmd(cmd, shell=True)
+ if status:
+ logger.error("failed to run command: %s" % cmd)
+ return 1
+
+ logger.debug("command '%s' output is:\n%s" % (cmd, output[0]))
+
+ cpulist = output[0].split('\t')[1]
+ ret = utils.param_to_tuple(cpulist, maxcpu)
+
+ if ret == cpumap:
+ logger.info("emulator process cpus allowed list is expected")
+ return 0
+ else:
+ logger.error("emulator process cpus allowed list is not expected")
+ return 1
+
+def emulatorpin_live(params):
+ """pin domain emulator to host cpu with live flag
+ """
+ global logger
+ logger = params['logger']
+ params.pop('logger')
+ guestname = params['guestname']
+ cpulist = params['cpulist']
+
+ logger.info("the name of virtual machine is %s" % guestname)
+ logger.info("the given cpulist is %s" % cpulist)
+
+ global maxcpu
+ maxcpu = utils.get_host_cpus()
+ logger.info("%s physical cpu on host" % maxcpu)
+
+ conn = sharedmod.libvirtobj['conn']
+
+ try:
+ domobj = conn.lookupByName(guestname)
+ cpumap = utils.param_to_tuple(cpulist, maxcpu)
+ if not cpumap:
+ logger.error("cpulist: Invalid format")
+ return 1
+
+ logger.debug("cpumap for emulator pin is:")
+ logger.debug(cpumap)
+
+ logger.info("pin domain emulator to host cpu %s with flag: %s" %
+ (cpulist, libvirt.VIR_DOMAIN_AFFECT_LIVE))
+ domobj.pinEmulator(cpumap, libvirt.VIR_DOMAIN_AFFECT_LIVE)
+
+ logger.info("check emulator info")
+ ret = domobj.emulatorPinInfo()
+ logger.debug("emulator info is:")
+ logger.debug(ret)
+ if ret == cpumap:
+ logger.info("emulator info is expected")
+ else:
+ logger.error("emulator info is not expected")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ logger.info("check emulator pin status on host")
+ ret = emulatorpin_check(guestname, cpumap)
+ if ret:
+ logger.error("domain emulator pin failed")
+ return 1
+ else:
+ logger.info("domain emulator pin succeed")
+ return 0
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH] qemuOpenVhostNet: Decrease vhostfdSize on open failure
by Michal Privoznik
Currently, if there's an error opening /dev/vhost-net (e.g. because
it doesn't exist) but it's not required we proceed with vhostfd array
filled with -1 and vhostfdSize unchanged. Later, when constructing
the qemu command line only non-negative items within vhostfd array
are taken into account. This means, vhostfdSize may be greater than
the actual count of non-negative items in vhostfd array. This results
in improper command line arguments being generated, e.g.:
-netdev tap,fd=21,id=hostnet0,vhost=on,vhostfd=(null)
---
src/qemu/qemu_command.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 434f5a7..d969f88 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -486,6 +486,8 @@ qemuOpenVhostNet(virDomainDefPtr def,
"but is unavailable"));
goto error;
}
+ i--;
+ (*vhostfdSize)--;
}
}
virDomainAuditNetDevice(def, net, "/dev/vhost-net", *vhostfdSize);
@@ -6560,12 +6562,10 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
}
for (i = 0; i < vhostfdSize; i++) {
- if (vhostfd[i] >= 0) {
- virCommandTransferFD(cmd, vhostfd[i]);
- if (virAsprintf(&vhostfdName[i], "%d", vhostfd[i]) < 0) {
- virReportOOMError();
- goto cleanup;
- }
+ virCommandTransferFD(cmd, vhostfd[i]);
+ if (virAsprintf(&vhostfdName[i], "%d", vhostfd[i]) < 0) {
+ virReportOOMError();
+ goto cleanup;
}
}
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH 0/2] Fix the display of *virsh vcpuinfo* command.
by yangdongsheng
Hi,
I found some confusion in display of commad *virsh vcpuinfo domname* .
There is no diffrence between a cpu offline and a cpu online but not be set
for the affinity of vcpu, both are '-'. But users will find the difference of them
in using them for a same action (such as vcpupin) and be confused.
Example:
[root@yds-pc ~]# echo "0" >/sys/devices/system/cpu/cpu2/online
[root@yds-pc ~]# cat /proc/cpuinfo |grep processor
processor : 0
processor : 1
processor : 3
[root@yds-pc ~]# virsh vcpupin virt-tests-vm1 0 0,3
[root@yds-pc ~]# virsh vcpuinfo virt-tests-vm1
VCPU: 0
CPU: 0
State: running
CPU time: 14.8s
CPU Affinity: y--y
*There is no diff between cpu1 and cpu2 (both '-')*
BUT:
[root@yds-pc ~]# virsh vcpupin virt-tests-vm1 0 1
[root@yds-pc ~]# echo $?
0
[root@yds-pc ~]# virsh vcpupin virt-tests-vm1 0 2
error: Requested operation is not valid: failed to set cpuset.cpus in cgroup for vcpu 0
[root@yds-pc ~]# echo $?
1
So, I think we should show the cpu in different state with different symbol.
In this patchset, I introduce a symbol 'x' (maybe there is a better one :)) to display
the cpu is offline on host.
Just like:
[root@yds-pc ~]# virsh vcpuinfo virt-tests-vm1
VCPU: 0
CPU: 0
State: running
CPU time: 14.8s
CPU Affinity: y-xy
yangdongsheng (2):
tool/virsh-domain.c: Add a vshNodeGetCPUMap function to get cpumap of
host.
tool/virsh-domain.c: Fix the display of Affinity in function
cmdVcpuinfo.
tools/virsh-domain.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 75 insertions(+), 3 deletions(-)
--
1.7.10.1
11 years, 6 months
[libvirt] virCommandWait internal error Child process unexpected exit status 1
by jj
I am use libvirt master branch to test LXC , the lastest commit of the master branch is 03d813bbcd7b4a18360105500672b84d985dd889,
by Marek Marczykowski <marmarek(a)invisiblethingslab.com>
on Thu May 23 02:01:30 2013 +0200,
root@wheezy:/tmp# cat test.xml
<domain type='lxc'>
<name>vmtest</name>
<memory>500000</memory>
<os>
<type>exe</type>
<cmdline>console=ttyS0</cmdline>
<init>/sbin/init</init>
</os>
<vcpu>1</vcpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<filesystem type="mount">
<source dir="/tmp/x"/>
<target dir="/"/>
</filesystem>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<interface type='network'>
<source network='default'/>
</interface>
<console type='pty' />
</devices>
</domain>
root@wheezy:/tmp# virsh -c lxc:/// define test.xml
Domain vmtest defined from test.xml
root@wheezy:/tmp# virsh -c lxc:/// start vmtest
error: Failed to start domain vmtest
error: internal error Child process (PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LIBVIRT_DEBUG=3 LIBVIRT_LOG_OUTPUTS=3:stderr /usr/libexec/libvirt_lxc --name vmtest --console 19 --security=none --handshake 22 --background --veth veth7) unexpected exit status 1
below's a libvirtd log
2013-05-25 14:46:58.727+0000: 7865: error : virCommandWait:2354 : internal error Child process (PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LIBVIRT_DEBUG=3 LIBVIRT_LOG_OUTPUTS=3:stderr /usr/libexec/libvirt_lxc --name vmtest --console 19 --security=none --handshake 22 --background --veth veth7) unexpected exit status 1
11 years, 6 months
Re: [libvirt] [Qemu-devel] [PATCH] qapi-schema.json: Reformat TargetType enum to one-per-line
by Anthony Liguori
Peter Maydell <peter.maydell(a)linaro.org> writes:
> On 22 May 2013 14:15, Anthony Liguori <aliguori(a)us.ibm.com> wrote:
>> Paolo Bonzini <pbonzini(a)redhat.com> writes:
>>> You
>>> don't need to know what targets were supported in the version that you
>>> compiled from. Only one target is supported in this executable
>>> anyway.
>>
>> It seems useful to me. One day we may support multiple targets per
>> executable.
>
> Why would you care about which architectures the executable supports?
> What you actually want to know is which machine models are supported;
> whether board foo happens to be ARM or PPC isn't really very interesting
> IMHO.
That's a very good point. It was the libvirt folks that requested
this. Perhaps they can shed some light on the logic?
Regards,
Anthony Liguori
>
> -- PMM
11 years, 6 months
[libvirt] [PATCH] qemu: save domain state to XML after reboot
by root
Currently qemuDomainReboot() does reboot in two phases:
qemuMonitorSystemPowerdown() and qemuProcessFakeReboot().
qemuMonitorSystemPowerdown() shutdowns the domain and saves domain
state/reason as VIR_DOMAIN_SHUTDOWN_UNKNOWN.
qemuProcessFakeReboot() sets domain state/reason to
VIR_DOMAIN_RESUMED_UNPAUSED but does not save domain state changes.
Subsequent restart of libvirtd leads to restoring domain state/reason to
saved that is VIR_DOMAIN_SHUTDOWN_UNKNOWN and to automatic shutdown of
the domain. This commit adds virDomainSaveStatus() into
qemuProcessFakeReboot() to avoid unexpected shutdowns.
---
src/qemu/qemu_process.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index e5b4679..cbe35ac 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -547,6 +547,7 @@ qemuProcessFakeReboot(void *opaque)
virDomainObjPtr vm = opaque;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainEventPtr event = NULL;
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = -1;
VIR_DEBUG("vm=%p", vm);
virObjectLock(vm);
@@ -585,6 +586,11 @@ qemuProcessFakeReboot(void *opaque)
VIR_DOMAIN_EVENT_RESUMED,
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
+ if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
+ VIR_WARN("Unable to save status on vm %s after state change",
+ vm->def->name);
+ }
+
ret = 0;
endjob:
@@ -601,6 +607,7 @@ cleanup:
}
if (event)
qemuDomainEventQueue(driver, event);
+ virObjectUnref(cfg);
}
--
1.8.2.1
11 years, 6 months
[libvirt] virStream double unref in virChrdevOpen()
by Sergey Fionov
Hello,
There is double unref virChrdevOpen() (src/conf/virchrdev.c) when error occured.
if (virStreamRef(st) < 0) {
virMutexUnlock(&devs->lock);
return -1;
}
...
if (virHashAddEntry(devs->hash, path, st) < 0)
goto error;
...
if (virFDStreamOpenFile(st, path, 0, 0, O_RDWR) < 0) /* error
occured here */
goto error;
...
error:
virStreamFree(st);
virHashRemoveEntry(devs->hash, path);
stream is virStreamRef'ed 1 time but if it is successfully placed into
hash then it will be unreferenced 2 times - in virStreamFree() and
virHashRemoveEntry()'s dataFree callback.
That leads to dispose stream object and segmentation fault due to use
after free.
Steps to reproduce:
# hide the /dev/pts to throw an error in virFDStreamOpenFile()
$ mount -t tmpfs empty-devpts /dev/pts
$ virsh console a111
Connected to domain a111
Escape character is ^]
error: End of file while reading data: Input/output error
error: One or more references were leaked after disconnect from the hypervisor
error: Failed to reconnect to the hypervisor
(libvirtd segfaults)
$ umount empty-devpts
wbr,
Sergey.
11 years, 6 months
[libvirt] [PATCH] esx: Fix dynamic VI object type detection
by Matthias Bolte
VI objects support inheritance with subtype polymorphism. For example the
FileInfo object type is extended by FloppyImageFileInfo, FolderFileInfo
etc. Then SearchDatastore_Task returns an array of FileInfo objects and
depending on the represented file the FileInfo is actually a FolderFileInfo
or FloppyImageFileInfo etc. The actual type information is stored as XML
attribute that allows clients such as libvirt to distinguish between the
actual types. esxVI_GetActualObjectType is used to extract the actual type.
I assumed that this mechanism would be used for all VI object types that
have subtypes. But this is not the case. It seems only to be used for types
that are actually used as generic base type such as FileInfo. But it is not
used for types that got extended later such as ElementDescription that was
extended by ExtendedElementDescription (added in vSphere API 4.0) or that
are not meant to be used with subtype polymorphism.
This breaks the deserialization of types that contain ElementDescription
properties such as PerfCounterInfo or ChoiceOption, because the code
expects an ElementDescription object to have an XML attribute named type
that is not present, since ExtendedElementDescription was added to the
esx_vi_generator.input in commit 60f0f55ee4686fecbffc5fb32f90863427d02a14.
This in turn break virtual machine question handling and auto answering.
Fix this by using the base type if no XML type attribute is present.
---
src/esx/esx_vi_types.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 1a26556..c55396c 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -720,10 +720,9 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type baseType,
BAD_CAST "http://www.w3.org/2001/XMLSchema-instance");
if (type == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("%s is missing 'type' property"),
- esxVI_Type_ToString(baseType));
- return -1;
+ // no actual type specified, use base type instead
+ *actualType = baseType;
+ return 0;
}
*actualType = esxVI_Type_FromString(type);
--
1.7.9.5
11 years, 6 months
[libvirt] [PATCH] spec: Build vbox packages only for x86 architectures
by Viktor Mihajlovski
Commit 6ab6bc19f03513fd87d29ecfd405bb7f4a7de114 has introduced separate
daemon/driver packages for vbox. These should only be built for x86
architectures which is done hereby.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
libvirt.spec.in | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index e1c5f49..7abe9fe 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -130,6 +130,11 @@
%define with_libxl 0
%endif
+# vbox is available only on i386 x86_64
+%ifnarch %{ix86} x86_64
+ %define with_vbox 0
+%endif
+
# Numactl is not available on s390[x] and ARM
%ifarch s390 s390x %{arm}
%define with_numactl 0
--
1.7.9.5
11 years, 6 months
[libvirt] [PATCH] syntax-check: ignore all quoted strings in bracket-spacing
by Ján Tomko
Ignore strings with an escaped double quote too.
This removes the need for special handling of quotes in the
semicolon check.
---
build-aux/bracket-spacing.pl | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl
index fbe6666..a99edeb 100755
--- a/build-aux/bracket-spacing.pl
+++ b/build-aux/bracket-spacing.pl
@@ -31,8 +31,8 @@ foreach my $file (@ARGV) {
while (defined (my $line = <FILE>)) {
my $data = $line;
- # Kill any quoted strongs
- $data =~ s,".*?","XXX",g;
+ # Kill any quoted strings
+ $data =~ s,"([^\\\"]|\\.)+","XXX",g;
# Kill any C++ style comments
$data =~ s,//.*$,//,;
@@ -120,14 +120,9 @@ foreach my $file (@ARGV) {
# errno == EINTR)
# ;
#
- # 3) ";" is inside double-quote, I.e, as part of const string. E.g.
- # printf("%s", "a ; b\n");
while ($data =~ /[^;\s]\s+;/) {
- # Inside the double-quote
- if ($data !~ /"[^"]*\s;/) {
- print "$file:$.: $line";
- $ret = 1;
- }
+ print "$file:$.: $line";
+ $ret = 1;
last;
}
}
--
1.8.1.5
11 years, 6 months