[libvirt] [PATCH v2 0/9] admin API: Introduce server listing API
by Erik Skultety
v2:
- tab replacing patch now also includes files Martin added in his keepalive
series (trivial, ready to be pushed)
- admin_server now marked as renamed instead of deleted and formated with -M
- introduction of virAdmServe structure split to a separate patch
- resolved server naming issues from review (added fallback data)
- refactored lock_daemon a little not to store duplicate reference to a
server, since we now have daemon structure
- tweaked virnetdaemontest and included new data for it
virt-admin still missing in this series, because first we need to handle proper
connecting to daemons, i.e. discuss the URI format and then we can add
individual commands, so I postponed it in this series and will look at the
connect routine first.
Erik Skultety (9):
test: Replace tabs with spaces in virnetdaemondata json files
test:
s/{in,out}put-data-admin-nomdns/{in,out}put-data-admin-nomdns-nonames
locking: Remove redundant 'srv' element from virLockDaemon
rpc: Introduce new elements 'id' and 'name' to virnetserver structure
virnetdaemon: Add post exec restart support for multiple servers
admin: Move admin_server.{h,c} to admin.{h,c}
admin: Introduce virAdmServer structure
admin: Introduce adminDaemonConnectListServers API
admin: Usage example of the new server listing API (not to be pushed)
.gitignore | 1 +
Makefile.am | 2 +-
configure.ac | 1 +
daemon/Makefile.am | 6 +-
daemon/admin.c | 174 +++++++++++++++
daemon/admin.h | 36 ++++
daemon/admin_server.c | 103 +++------
daemon/admin_server.h | 23 +-
daemon/libvirtd.c | 10 +-
examples/admin/Makefile.am | 25 +++
examples/admin/listservers.c | 65 ++++++
include/libvirt/libvirt-admin.h | 12 ++
po/POTFILES.in | 2 +-
src/admin/admin_protocol.x | 27 ++-
src/admin_protocol-structs | 16 ++
src/datatypes.c | 35 +++
src/datatypes.h | 36 ++++
src/libvirt-admin.c | 171 +++++++++++++++
src/libvirt_admin_private.syms | 5 +
src/libvirt_admin_public.syms | 4 +
src/libvirt_remote.syms | 3 +-
src/locking/lock_daemon.c | 42 ++--
src/lxc/lxc_controller.c | 2 +-
src/rpc/virnetdaemon.c | 111 +++++++---
src/rpc/virnetdaemon.h | 30 ++-
src/rpc/virnetserver.c | 46 +++-
src/rpc/virnetserver.h | 5 +
.../input-data-admin-nomdns-names.json | 128 +++++++++++
.../input-data-admin-nomdns-nonames.json | 126 +++++++++++
.../virnetdaemondata/input-data-admin-nomdns.json | 126 -----------
.../input-data-no-keepalive-required.json | 240 ++++++++++-----------
.../output-data-admin-nomdns-names.json | 128 +++++++++++
....json => output-data-admin-nomdns-nonames.json} | 2 +
.../virnetdaemondata/output-data-anon-clients.json | 1 +
.../output-data-initial-nomdns.json | 1 +
tests/virnetdaemondata/output-data-initial.json | 1 +
.../output-data-no-keepalive-required.json | 240 ++++++++++-----------
tests/virnetdaemontest.c | 52 ++---
38 files changed, 1492 insertions(+), 546 deletions(-)
create mode 100644 daemon/admin.c
create mode 100644 daemon/admin.h
create mode 100644 examples/admin/Makefile.am
create mode 100644 examples/admin/listservers.c
create mode 100644 tests/virnetdaemondata/input-data-admin-nomdns-names.json
create mode 100644 tests/virnetdaemondata/input-data-admin-nomdns-nonames.json
delete mode 100644 tests/virnetdaemondata/input-data-admin-nomdns.json
create mode 100644 tests/virnetdaemondata/output-data-admin-nomdns-names.json
rename tests/virnetdaemondata/{output-data-admin-nomdns.json => output-data-admin-nomdns-nonames.json} (98%)
--
2.4.3
9 years, 2 months
[libvirt] [PATCH] qemu: Need to check for machine.os when using ADDRESS_TYPE_CCW
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1258361
When attaching a disk or rng when providing an address type ccw, we need
to ensure the machine.os is valid for the target guest. Checks are made
when the address type is not provided, but if provided the os.machine
check is bypassed.
For an inactive guest, an addition followed by a start would cause the
startup to fail after qemu_command builds the command line and attempts
to start the guest. For an active guest, libvirtd would crash.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
NOTE:
For 'rng' in qemu_command - rather than change each of the if..else if..
conditions to have the {}, I just made the check up front.
Also while I could separate these into disk and rng - since it's the same
fix for the same problem it just seem "proper" to include both in same patch
src/qemu/qemu_command.c | 15 +++++++++++++++
src/qemu/qemu_hotplug.c | 21 ++++++++++++++++++---
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index abc57d7..ecdec2c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4296,6 +4296,13 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
case VIR_DOMAIN_DISK_BUS_VIRTIO:
if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+ if (!STREQLEN(def->os.machine, "s390-ccw", 8)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("cannot use CCW address type for disk target "
+ "'%s' using machine type '%s'"),
+ disk->dst, def->os.machine);
+ goto error;
+ }
virBufferAddLit(&opt, "virtio-blk-ccw");
if (disk->iothread)
virBufferAsprintf(&opt, ",iothread=iothread%u", disk->iothread);
@@ -6874,6 +6881,14 @@ qemuBuildRNGDevStr(virDomainDefPtr def,
goto error;
}
+ if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
+ !STREQLEN(def->os.machine, "s390-ccw", 8)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("cannot use CCW address type for rng device "
+ "using machine type '%s'"),
+ def->os.machine);
+ goto error;
+ }
if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)
virBufferAsprintf(&buf, "virtio-rng-ccw,rng=obj%s,id=%s",
dev->info.alias, dev->info.alias);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index e71a204..154539c 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -319,6 +319,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
int ret = -1;
const char* type = virDomainDiskBusTypeToString(disk->bus);
qemuDomainObjPrivatePtr priv = vm->privateData;
+ bool is_s390_ccw = STREQLEN(vm->def->os.machine, "s390-ccw", 8);
char *devstr = NULL;
char *drivestr = NULL;
bool releaseaddr = false;
@@ -326,8 +327,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
const char *src = virDomainDiskGetSource(disk);
if (!disk->info.type) {
- if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
- virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
+ if (is_s390_ccw && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390;
@@ -346,6 +346,13 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+ if (!is_s390_ccw) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("cannot use CCW address type for disk target "
+ "'%s' using machine type '%s'"),
+ disk->dst, vm->def->os.machine);
+ return -1;
+ }
if (virDomainCCWAddressAssign(&disk->info, priv->ccwaddrs,
!disk->info.addr.ccw.assigned) < 0)
goto error;
@@ -1642,6 +1649,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
virDomainRNGDefPtr rng)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
+ bool is_s390_ccw = STRPREFIX(vm->def->os.machine, "s390-ccw");
char *devstr = NULL;
char *charAlias = NULL;
char *objAlias = NULL;
@@ -1657,7 +1665,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
return -1;
if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
- if (STRPREFIX(vm->def->os.machine, "s390-ccw") &&
+ if (is_s390_ccw &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
@@ -1670,6 +1678,13 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &rng->info) < 0)
return -1;
} else if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+ if (!is_s390_ccw) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("cannot use CCW address type for rng device "
+ "using machine type '%s'"),
+ vm->def->os.machine);
+ return -1;
+ }
if (virDomainCCWAddressAssign(&rng->info, priv->ccwaddrs,
!rng->info.addr.ccw.assigned) < 0)
return -1;
--
2.1.0
9 years, 2 months
[libvirt] [PATCH v3 0/5] vz: add migration support
by nshirokovskiy@virtuozzo.com
NOTE that minimal command to migrate vz domain is like next:
virsh -c vz:///system migrate --direct 200 shiny0 --migrateuri vz+ssh://shiny0/system
--live --persistent --compressed
==Difference from v1:
1. Patch is quite different. First patchset implements migration thru managed
migration scheme. This one goes thru p2p scheme. I belive this is a better
approach. Vz migration is done via vz sdk and first patchset uses 5 phased
migration only to get a token from destination on prepare phase which is kind a
misuse. This patch just adds vz specific function to driver interface
to archive the same goal.
2. Offline migration is supported as there is no more dependency on current
flow of managed migration scheme.
==Difference from v2:
1. Implement thru direct migration instead of p2p. p2p is just managed
5-staged migration when managing is done on daemon side. Vz migration stages
are all hidden in vz sdk and thus it would be more consistent to use direct
scheme.
2. Use existing driver function for prepare migration phase to pass session
uuid from destination to source instead of new one. As vz migration is direct
one we will not use prepare phase function in a straight forward manner
anyway.
src/libvirt-domain.c | 3 +-
src/vz/vz_driver.c | 315 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/vz/vz_sdk.c | 86 ++++++++++++---
src/vz/vz_sdk.h | 6 +
src/vz/vz_utils.h | 4 +-
5 files changed, 398 insertions(+), 16 deletions(-)
9 years, 2 months
[libvirt] [PATCH] virVMXParseDisk: Recognize scsi-passthru
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1172544
So, imagine you have this config:
scsi0:1.present = "TRUE"
scsi0:1.deviceType = "scsi-passthru"
scsi0:1.fileName = "/vmfs/devices/cdrom/mpx.vmhba32:C0:T0:L0"
scsi0:1.allowGuestConnectionControl = "FALSE"
So far, libvirt does not recognize this pattern and fails. What
if we produce the following XML to it?
<disk type='block' device='disk'>
<source dev='/vmfs/devices/cdrom/mpx.vmhba32:C0:T0:L0'/>
<target dev='sdb' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/vmx/vmx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 36e2891..6d83d81 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2187,6 +2187,17 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
* function to parse a CDROM device may handle it.
*/
goto ignore;
+ } else if (STREQ_NULLABLE(deviceType, "scsi-passthru")) {
+ char *tmp;
+
+ virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
+ if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
+ goto cleanup;
+ if (virDomainDiskSetSource(*def, tmp) < 0) {
+ VIR_FREE(tmp);
+ goto cleanup;
+ }
+ VIR_FREE(tmp);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid or not yet handled value '%s' "
--
2.4.6
9 years, 2 months
[libvirt] [PATCH] qemu: Default to virtio network devices on ppc64
by Andrea Bolognani
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1254044
---
src/qemu/qemu_domain.c | 3 ++-
.../qemuxml2argvdata/qemuxml2argv-pseries-net-default.args | 6 ++++++
.../qemuxml2argvdata/qemuxml2argv-pseries-net-default.xml | 14 ++++++++++++++
tests/qemuxml2argvtest.c | 1 +
4 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.xml
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0a9ed6b..4c5b3ec 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1195,7 +1195,8 @@ qemuDomainDefPostParse(virDomainDefPtr def,
static const char *
qemuDomainDefaultNetModel(const virDomainDef *def)
{
- if (ARCH_IS_S390(def->os.arch))
+ if (ARCH_IS_S390(def->os.arch) ||
+ ARCH_IS_PPC64(def->os.arch))
return "virtio";
if (def->os.arch == VIR_ARCH_ARMV7L ||
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.args
new file mode 100644
index 0000000..50adffa
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 -S -M pseries -m 512 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:55:2b:d9,bus=pci,addr=0x1 \
+-net user,vlan=0,name=hostnet0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.xml
new file mode 100644
index 0000000..7bf8139
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-net-default.xml
@@ -0,0 +1,14 @@
+<domain type='qemu'>
+ <name>pseries-net-default</name>
+ <memory unit='KiB'>524288</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <interface type='user'>
+ <mac address='52:54:00:55:2b:d9'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c2482e6..f20a94b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1397,6 +1397,7 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PIIX3_USB_UHCI,
QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
+ DO_TEST("pseries-net-default", QEMU_CAPS_DEVICE);
DO_TEST("pseries-vio-user-assigned", QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST_ERROR("pseries-vio-address-clash", QEMU_CAPS_DRIVE,
--
2.4.3
9 years, 2 months
[libvirt] [PATCH 0/3] Couple of src/Makefile.am fixes
by Michal Privoznik
I've noticed that 'make distcheck' is failing. While investigating that issue
I've came up with some other checks too.
Preferably, I'd like to get these into the current release (the fix 2/3 at
least).
Michal Privoznik (3):
src: Check libvirt_admin.syms for exported symbols
src: Cleanup libvirt_admin.syms
src: Check for symbols ordering in ADMIN_SYM_FILES
src/Makefile.am | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
--
2.4.6
9 years, 2 months
[libvirt] [PATCH] migration: remove direct migration dependency on version1 of driver
by Nikolay Shirokovskiy
From: Nikolay Shirokovskiy <Nikolay Shirokovskiy nshirokovskiy(a)virtuozzo.com>
Direct migration should work if *perform3 is present but *perform
is not. This is situation when driver migration is implemented
after new version of driver function is introduced. We should not
be forced to support old version too as its parameter space is
subspace of newer one.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/libvirt-domain.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 6ab50ba..c89775b 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -3427,7 +3427,8 @@ virDomainMigrateDirect(virDomainPtr domain,
NULLSTR(xmlin), flags, NULLSTR(dname), NULLSTR(dconnuri),
NULLSTR(miguri), bandwidth);
- if (!domain->conn->driver->domainMigratePerform) {
+ if (!domain->conn->driver->domainMigratePerform &&
+ !domain->conn->driver->domainMigratePerform3) {
virReportUnsupportedError();
return -1;
}
--
1.7.1
9 years, 2 months
[libvirt] Entering freeze for libvirt-1.2.19
by Daniel Veillard
So I have tagged rc1 in git and pushed signed tarball and rpms to
the usual place:
ftp://libvirt.org/libvirt/
The release works just fine in my limited testing, but others should
try it out to check portability and more advanced functionalities.
I will likely push rc2 at the end of the week-end and the final release
on Tuesday or Wednesday, assuming no big issue is raised in the meantime.
thanks for giving it a try.
I also note that we have some CI test failing, not for core libvirt
but perl bindings, virt-manager, ... it would be good to investigate before
we push the release:
https://ci.centos.org/view/libvirt-project/
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/
9 years, 2 months
[libvirt] [libvirt-test-api][PATCH] Add new test case for allocPages API
by Luyao Huang
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
cases/test_connection.conf | 4 ++
repos/virconn/connection_allocPages.py | 88 ++++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+)
create mode 100644 repos/virconn/connection_allocPages.py
diff --git a/cases/test_connection.conf b/cases/test_connection.conf
index 336b1ad..600ec32 100644
--- a/cases/test_connection.conf
+++ b/cases/test_connection.conf
@@ -77,3 +77,7 @@ virconn:connection_getMemoryParameters
virconn:connection_getMemoryStats
conn
qemu:///system
+
+virconn:connection_allocPages
+ conn
+ qemu:///system
diff --git a/repos/virconn/connection_allocPages.py b/repos/virconn/connection_allocPages.py
new file mode 100644
index 0000000..9ddd474
--- /dev/null
+++ b/repos/virconn/connection_allocPages.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+
+import libvirt
+from libvirt import libvirtError
+import lxml
+import lxml.etree
+
+required_params = ()
+optional_params = {'conn': ''}
+
+HOST_HUGEPAGE = '/sys/devices/system/node/node%d/hugepages/hugepages-%dkB/nr_hugepages'
+
+def get_host_pagesize(conn):
+ ret = []
+ tree = lxml.etree.fromstring(conn.getCapabilities())
+
+ set = tree.xpath("/capabilities/host/cpu/pages")
+ for n in set:
+ ret.append(int(n.attrib['size']))
+
+ return ret
+
+def get_host_pagecount(pagesize):
+ try:
+ return int(open(HOST_HUGEPAGE % (0, pagesize)).read())
+ except IOError:
+ return -1
+
+def connection_allocPages(params):
+ """
+ test API for allocPages in class virConnect
+ """
+ logger = params['logger']
+ fail=0
+
+ try:
+ conn=libvirt.open(params['conn'])
+ logger.info("get connection to libvirtd")
+ list1 = get_host_pagesize(conn)
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ for i in list1:
+ logger.info("test hugepage size %d" % i)
+
+ if get_host_pagecount(i) == -1:
+ logger.info("Skip system page size %d" % i)
+ continue
+
+ """ test flag VIR_NODE_ALLOC_PAGES_SET """
+ try:
+ cur_count = get_host_pagecount(i)
+ conn.allocPages({i : cur_count + 1}, 0, 1, libvirt.VIR_NODE_ALLOC_PAGES_SET)
+ if get_host_pagecount(i) != cur_count + 1:
+ logger.info("libvirt set a wrong page count to %dKiB hugepage" % i)
+ fail = 1
+ except libvirtError, e:
+ if "Allocated only" in e.message:
+ tmp_count = int(e.message.replace(" ", "")[-1:])
+
+ if tmp_count != get_host_pagecount(i):
+ logger.info("libvirt output %dKiB hugepage count is not right" % i)
+ fail = 1
+ else:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ """ test flag VIR_NODE_ALLOC_PAGES_ADD """
+ try:
+ cur_count = get_host_pagecount(i)
+ conn.allocPages({i : 1}, 0, 1, libvirt.VIR_NODE_ALLOC_PAGES_ADD)
+ if get_host_pagecount(i) != cur_count + 1:
+ logger.info("libvirt set a wrong page count to %dKiB hugepage" % i)
+ fail = 1
+ except libvirtError, e:
+ if "Allocated only" in e.message:
+ tmp_count = int(e.message.replace(" ", "")[-1:])
+
+ if tmp_count != get_host_pagecount(i):
+ logger.info("libvirt output %dKiB hugepage count is not right" % i)
+ fail = 1
+ else:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return fail
--
1.8.3.1
9 years, 2 months
[libvirt] [libvirt-test-api][PATCH 1/3] Introduce new test case for add/del IOthread
by Luyao Huang
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
cases/linux_domain.conf | 6 +++
repos/domain/add_del_iothread.py | 82 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+)
create mode 100644 repos/domain/add_del_iothread.py
diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index fd32aad..8a7efe9 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -281,6 +281,12 @@ domain:set_memory_period
conn
qemu:///system
+domain:add_del_iothread
+ guestname
+ $defaultname
+ conn
+ qemu:///system
+
domain:destroy
guestname
$defaultname
diff --git a/repos/domain/add_del_iothread.py b/repos/domain/add_del_iothread.py
new file mode 100644
index 0000000..2d874f9
--- /dev/null
+++ b/repos/domain/add_del_iothread.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+import libvirt
+from libvirt import libvirtError
+import lxml
+import lxml.etree
+
+required_params = ('guestname',)
+optional_params = {'conn': 'qemu:///system'}
+
+def find_iothreadid_fromxml(vm, running, iothreadid):
+ if (running == 1):
+ tree = lxml.etree.fromstring(vm.XMLDesc(0))
+ else:
+ tree = lxml.etree.fromstring(vm.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE))
+
+ set = tree.xpath("//iothreadids/iothread")
+ for n in set:
+ ids = n.attrib['id']
+ if int(ids) == iothreadid:
+ return True
+
+ return False
+
+def add_del_iothread(params):
+ """
+ test API for addIOThread and delIOThread in class virDomain
+ """
+
+ logger = params['logger']
+ fail=0
+
+ try:
+ conn = libvirt.open(params['conn'])
+
+ logger.info("get connection to libvirtd")
+ guest = params['guestname']
+ vm = conn.lookupByName(guest)
+ logger.info("test guest name: %s" % guest)
+
+ """ test effect guest running XML """
+ if vm.isActive() == 1:
+ logger.info("guest is running test with running guest")
+
+ for i in range(300, 1000):
+ if not find_iothreadid_fromxml(vm, 1, i):
+ logger.info("add iothread %d to running guest" % i)
+ vm.addIOThread(i, libvirt.VIR_DOMAIN_AFFECT_LIVE)
+ if find_iothreadid_fromxml(vm, 1, i):
+ vm.delIOThread(i, libvirt.VIR_DOMAIN_AFFECT_LIVE)
+ if find_iothreadid_fromxml(vm, 1, i):
+ logger.info("FAIL: still can find iothread id in XML")
+ fail=1
+
+ break
+ else:
+ logger.info("FAIL: cannot find iothread id in XML")
+ fail=1
+ break
+
+ """ test effect guest config"""
+ logger.info("test with guest inactive XML")
+ for i in range(300, 1000):
+ if not find_iothreadid_fromxml(vm, 0, i):
+ logger.info("add iothread %d to guest config" % i)
+ vm.addIOThread(i, libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+ if find_iothreadid_fromxml(vm, 0, i):
+ vm.delIOThread(i, libvirt.VIR_DOMAIN_AFFECT_CONFIG)
+ if find_iothreadid_fromxml(vm, 0, i):
+ logger.info("FAIL: still can find iothread id in XML")
+ fail=1
+
+ break
+ else:
+ logger.info("FAIL: cannot find iothread id in XML")
+ fail=1
+ break
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ fail=1
+ return fail
--
1.8.3.1
9 years, 2 months