[libvirt] [PATCH] lock_daemon: Simplify error handling
by Peter Krempa
No need to check the run_dir variable twice for NULL.
---
src/locking/lock_daemon.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index f0eba48..97e5d74 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -1311,19 +1311,16 @@ int main(int argc, char **argv) {
/* Ensure the rundir exists (on tmpfs on some systems) */
if (privileged) {
- run_dir = strdup(LOCALSTATEDIR "/run/libvirt");
+ if (!(run_dir = strdup(LOCALSTATEDIR "/run/libvirt"))) {
+ virReportOOMError();
+ goto cleanup;
+ }
} else {
- run_dir = virGetUserRuntimeDirectory();
-
- if (!run_dir) {
+ if (!(run_dir = virGetUserRuntimeDirectory())) {
VIR_ERROR(_("Can't determine user directory"));
goto cleanup;
}
}
- if (!run_dir) {
- virReportOOMError();
- goto cleanup;
- }
if (privileged)
old_umask = umask(022);
--
1.8.1.1
11 years, 10 months
[libvirt] [PATCH 0/2 v2] Colorize HTML documentation
by Claudio Bley
The only difference to v1 is that I fixed the CSS pseudo elements
adding some vital whitespaces.
(I tried to be extra smart and removed some whitespace without further
testing, just to discover that it did not work anymore *after*
sending the patcheset).
Claudio Bley (2):
docs: Assign classes to documentation elements
docs: Add some style and color to the HTML documentation
docs/generic.css | 4 ++
docs/libvirt.css | 56 +++++++++++++++-
docs/newapi.xsl | 187 +++++++++++++++++++++++++++++++-----------------------
3 files changed, 166 insertions(+), 81 deletions(-)
--
1.7.9.5
11 years, 10 months
[libvirt] [PATCH 00/12] virsh: Partially convert to c99 struct initialization
by Michal Privoznik
For now, we have to suffice with vshCmdOptDef. Others coming soon.
Changes are pretty mechanical, so if you find a mistake there,
blame my vim macro :)
Michal Privoznik (12):
virsh.c: Switch to C99 initialization of vshCmdOptDef
virsh-domain.c: Switch to C99 initialization of vshCmdOptDef
virsh-domain-monitor.c: Switch to C99 initialization of vshCmdOptDef
virsh-host.c: Switch to C99 initialization of vshCmdOptDef
virsh-interface.c: Switch to C99 initialization of vshCmdOptDef
virsh-network.c: Switch to C99 initialization of vshCmdOptDef
virsh-nodedev.c: Switch to C99 initialization of vshCmdOptDef
virsh-nwfilter.c: Switch to C99 initialization of vshCmdOptDef
virsh-pool.c: Switch to C99 initialization of vshCmdOptDef
virsh-secret.c: Switch to C99 initialization of vshCmdOptDef
virsh-snapshot.c: Switch to C99 initialization of vshCmdOptDef
virsh-volume.c: Switch to C99 initialization of vshCmdOptDef
tools/virsh-domain-monitor.c | 279 +++--
tools/virsh-domain.c | 2299 +++++++++++++++++++++++++++++++++---------
tools/virsh-host.c | 102 +-
tools/virsh-interface.c | 138 ++-
tools/virsh-network.c | 193 +++-
tools/virsh-nodedev.c | 64 +-
tools/virsh-nwfilter.c | 34 +-
tools/virsh-pool.c | 286 ++++--
tools/virsh-secret.c | 72 +-
tools/virsh-snapshot.c | 452 +++++++--
tools/virsh-volume.c | 368 +++++--
tools/virsh.c | 62 +-
12 files changed, 3406 insertions(+), 943 deletions(-)
--
1.8.0.2
11 years, 10 months
[libvirt] [PATCH] libvirt.c: fix typo in comment
by Claudio Bley
Signed-off-by: Claudio Bley <cbley(a)av-test.de>
---
Pushing under the trivial rule.
src/libvirt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 7db677f..d5d561c 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17181,7 +17181,7 @@ error:
* encrypted, or running over a channel which is not exposed
* to eavesdropping (eg a UNIX domain socket, or pipe)
*
- * Returns 1 if secure, 0 if secure, -1 on error
+ * Returns 1 if secure, 0 if not secure, -1 on error
*/
int virConnectIsSecure(virConnectPtr conn)
{
--
1.7.9.5
11 years, 10 months
[libvirt] [PATCH] Move comment after enum members
by Claudio Bley
The api builder always associates comments to the last member it read,
not to the current member even if there was a comment for the previous
member and a comma was already seen.
This has the effect that the comment for the previous member gets
overwritten and the current member has no comment at all.
Signed-off-by: Claudio Bley <cbley(a)av-test.de>
---
include/libvirt/libvirt.h.in | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 09c89c5..9110fcf 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -127,12 +127,12 @@ typedef enum {
power management */
#ifdef VIR_ENUM_SENTINELS
- /*
- * NB: this enum value will increase over time as new events are
- * added to the libvirt API. It reflects the last state supported
- * by this version of the libvirt API.
- */
VIR_DOMAIN_LAST
+ /*
+ * NB: this enum value will increase over time as new events are
+ * added to the libvirt API. It reflects the last state supported
+ * by this version of the libvirt API.
+ */
#endif
} virDomainState;
@@ -2742,12 +2742,12 @@ typedef enum {
VIR_STORAGE_VOL_WIPE_ALG_RANDOM = 8, /* 1-pass random */
#ifdef VIR_ENUM_SENTINELS
+ VIR_STORAGE_VOL_WIPE_ALG_LAST
/*
* NB: this enum value will increase over time as new algorithms are
* added to the libvirt API. It reflects the last algorithm supported
* by this version of the libvirt API.
*/
- VIR_STORAGE_VOL_WIPE_ALG_LAST
#endif
} virStorageVolWipeAlgorithm;
@@ -2974,12 +2974,12 @@ typedef enum {
VIR_KEYCODE_SET_RFB = 9,
#ifdef VIR_ENUM_SENTINELS
+ VIR_KEYCODE_SET_LAST
/*
* NB: this enum value will increase over time as new events are
* added to the libvirt API. It reflects the last keycode set supported
* by this version of the libvirt API.
*/
- VIR_KEYCODE_SET_LAST
#endif
} virKeycodeSet;
@@ -3533,12 +3533,12 @@ typedef enum {
VIR_SECRET_USAGE_TYPE_CEPH = 2,
#ifdef VIR_ENUM_SENTINELS
+ VIR_SECRET_USAGE_TYPE_LAST
/*
* NB: this enum value will increase over time as new events are
* added to the libvirt API. It reflects the last secret owner ID
* supported by this version of the libvirt API.
*/
- VIR_SECRET_USAGE_TYPE_LAST
#endif
} virSecretUsageType;
@@ -4443,12 +4443,12 @@ typedef enum {
VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK = 14, /* virConnectDomainEventPMSuspendDiskCallback */
#ifdef VIR_ENUM_SENTINELS
+ VIR_DOMAIN_EVENT_ID_LAST
/*
* NB: this enum value will increase over time as new events are
* added to the libvirt API. It reflects the last event ID supported
* by this version of the libvirt API.
*/
- VIR_DOMAIN_EVENT_ID_LAST
#endif
} virDomainEventID;
--
1.7.9.5
11 years, 10 months
[libvirt] iptables --physdev-out warnings
by Reinier Schoof
Hi,
we've experienced some issues with starting lots of KVM based VM's with
libvirt. Since I couldn't find any clues on the libvirt mailing list,
I'm posting the way I fixed the issues.
When starting a VM, /var/log/messages was spammed with the following
message:
xt_physdev: using --physdev-out in the OUTPUT, FORWARD and POSTROUTING
chains for non-bridged traffic is not supported anymore.
With each extra VM I start, the messages get amplified exponentially.
This results in longer starting times every new VM, relative the the
previously started VM. When I ran a test with starting 100 equal VM's,
the first VM started in about 2 seconds, the 100th VM took 48 seconds to
start. I'm running a vanilla 3.7.1 kernel, but I have the same issue on
VM hosts with kernel 3.2.28 or 3.2.0, running libvirt 0.9.12 and 0.9.8
respectively.
Looking into the warning, it seemed that iptables need an extra
argument, --physdev-is-bridged, in commands like:
iptables -A libvirt-out -m physdev --physdev-is-bridged --physdev-out
vnet99 -g FP-vnet99
I patched the libvirt source (version 1.0.0) to test whether this works
or not:
--- src/nwfilter/nwfilter_ebiptables_driver.c.orig 2013-01-16
10:51:43.000000000 +0100
+++ src/nwfilter/nwfilter_ebiptables_driver.c 2013-01-16
10:52:07.000000000 +0100
@@ -166,7 +166,7 @@
snprintf(buf, sizeof(buf), "%c%c-%s", prefix[0], prefix[1], ifname)
#define PHYSDEV_IN "--physdev-in"
-#define PHYSDEV_OUT "--physdev-out"
+#define PHYSDEV_OUT "--physdev-is-bridged --physdev-out"
static const char *m_state_out_str = "-m state --state NEW,ESTABLISHED";
static const char *m_state_in_str = "-m state --state ESTABLISHED";
The warnings in /var/log/messages are gone and running the test again
proved the 100th VM started in 3.8 seconds. It suprises me I'm the first
to mention this problem on the libvirt mailing list and I wondering if
I'm doing something wrong. Until then, this fix helps me a lot!
Reinier Schoof
--
TransIP BV | https://www.transip.nl/
11 years, 10 months
[libvirt] [test-API][PATCH] Add storage cases of pool list, pool lookup and volume lookup
by Wayne Sun
Add 3 simple storage realted API cases
* pool_list_active is only for testing with flags:
libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE
* pool_lookup is for testing lookup pool object by name, UUID,
UUIDString and volume object
* vol_lookup is for testing lookup volume object by name, key
and path
* add cases into storage_dir.conf
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
cases/storage_dir.conf | 14 +++++++
repos/storage/pool_list_active.py | 50 +++++++++++++++++++++++++
repos/storage/pool_lookup.py | 74 +++++++++++++++++++++++++++++++++++++
repos/storage/vol_lookup.py | 62 +++++++++++++++++++++++++++++++
4 files changed, 200 insertions(+), 0 deletions(-)
create mode 100644 repos/storage/pool_list_active.py
create mode 100644 repos/storage/pool_lookup.py
create mode 100644 repos/storage/vol_lookup.py
diff --git a/cases/storage_dir.conf b/cases/storage_dir.conf
index 38b349d..2bdb7d6 100644
--- a/cases/storage_dir.conf
+++ b/cases/storage_dir.conf
@@ -2,14 +2,22 @@ storage:define_dir_pool
poolname
$defaultpoolname
+storage:pool_lookup
+ poolname
+ $defaultpoolname
+
storage:build_dir_pool
poolname
$defaultpoolname
+storage:pool_list_active
+
storage:activate_pool
poolname
$defaultpoolname
+storage:pool_list_active
+
storage:create_dir_volume
poolname
$defaultpoolname
@@ -20,6 +28,12 @@ storage:create_dir_volume
capacity
$defaultvolumesize
+storage:vol_lookup
+ poolname
+ $defaultpoolname
+ volname
+ $defaultvolumename
+
storage:vol_clone
poolname
$defaultpoolname
diff --git a/repos/storage/pool_list_active.py b/repos/storage/pool_list_active.py
new file mode 100644
index 0000000..3e390c8
--- /dev/null
+++ b/repos/storage/pool_list_active.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# list active storage pool testing with flag:
+# libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ()
+optional_params = {
+ }
+
+def pool_list_active(params):
+ """list active storage pool testing"""
+
+ global logger
+ logger = params['logger']
+ namelist = []
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+ pool_num = conn.numOfStoragePools()
+ logger.info("number of active storage pools is %s" % pool_num)
+
+ flag = libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE
+ poolobj_list = conn.listAllStoragePools(flag)
+ if not len(poolobj_list) == pool_num:
+ logger.error("active pool object number mismatched")
+ return 1
+
+ for i in poolobj_list:
+ pool_name = i.name()
+ namelist.append(pool_name)
+
+ logger.info("active pool name list is %s" % namelist)
+
+ active_namelist = conn.listStoragePools()
+ if namelist == active_namelist:
+ logger.info("active pool name list matched")
+ else:
+ logger.error("active pool name list mismatched")
+ return 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ logger.info("list active storage pool succeed")
+ return 0
diff --git a/repos/storage/pool_lookup.py b/repos/storage/pool_lookup.py
new file mode 100644
index 0000000..89d7252
--- /dev/null
+++ b/repos/storage/pool_lookup.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# storage pool lookup testing
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('poolname',)
+optional_params = {
+ 'volname': None
+ }
+
+def pool_lookup(params):
+ """storage pool lookup testing"""
+
+ global logger
+ logger = params['logger']
+ poolname = params['poolname']
+ volname = params.get('volname')
+ retval = 0
+
+ logger.info("the poolname is %s" % poolname)
+ if volname:
+ logger.info("the given volume name is %s" % volname)
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+ logger.info("lookup the pool object by name: %s" % poolname)
+ poolobj = conn.storagePoolLookupByName(poolname)
+ if poolobj.name() == poolname:
+ logger.info("pool object lookup by name succeed")
+ else:
+ logger.error("pool object lookup by name failed")
+ retval += 1
+
+ uuid = poolobj.UUID()
+ logger.info("lookup the pool object by UUID: %s" % uuid)
+ poolobj_uuid = conn.storagePoolLookupByUUID(uuid)
+ if poolobj_uuid.name() == poolname:
+ logger.info("pool object lookup by UUID succeed")
+ else:
+ logger.error("pool object lookup by UUID failed")
+ retval += 1
+
+ uuidstr = poolobj.UUIDString()
+ logger.info("lookup the pool object by UUID string: %s" % uuidstr)
+ poolobj_uuidstr = conn.storagePoolLookupByUUIDString(uuidstr)
+ if poolobj_uuidstr.name() == poolname:
+ logger.info("pool object lookup by UUID string succeed")
+ else:
+ logger.error("pool object lookup by UUID string failed")
+ retval += 1
+
+ if volname:
+ logger.info("lookup volume object by volume name: %s" % volname)
+ volobj = poolobj.storageVolLookupByName(volname)
+ logger.info("lookup the pool object by volume object")
+ poolobj_vol = volobj.storagePoolLookupByVolume()
+
+ if poolobj_vol.name() == poolname:
+ logger.info("pool object lookup by UUID string succeed")
+ else:
+ logger.error("pool object lookup by UUID string failed")
+ retval += 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ if retval:
+ return 1
+
+ return 0
diff --git a/repos/storage/vol_lookup.py b/repos/storage/vol_lookup.py
new file mode 100644
index 0000000..30238e1
--- /dev/null
+++ b/repos/storage/vol_lookup.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# storage pool volume lookup testing
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('poolname', 'volname',)
+optional_params = {
+ }
+
+def vol_lookup(params):
+ """storage pool volume lookup testing"""
+
+ global logger
+ logger = params['logger']
+ poolname = params['poolname']
+ volname = params['volname']
+ retval = 0
+
+ logger.info("the poolname is %s" % poolname)
+ logger.info("the given volume name is %s" % volname)
+
+ conn = sharedmod.libvirtobj['conn']
+ try:
+ poolobj = conn.storagePoolLookupByName(poolname)
+
+ logger.info("lookup the volume object by name: %s" % volname)
+ volobj = poolobj.storageVolLookupByName(volname)
+ if volobj.name() == volname:
+ logger.info("volume object lookup by name succeed")
+ else:
+ logger.error("volume object lookup by name failed")
+ retval += 1
+
+ volkey = volobj.key()
+ logger.info("lookup the volume object by key: %s" % volkey)
+ volobj_key = conn.storageVolLookupByKey(volkey)
+ if volobj_key.name() == volname:
+ logger.info("volume object lookup by key succeed")
+ else:
+ logger.error("volume object lookup by key failed")
+ retval += 1
+
+ volpath = volobj.path()
+ logger.info("lookup the volume object by path: %s" % volpath)
+ volobj_path = conn.storageVolLookupByPath(volpath)
+ if volobj_path.name() == volname:
+ logger.info("volume object lookup by path succeed")
+ else:
+ logger.error("volume object lookup by path failed")
+ retval += 1
+
+ except libvirtError, e:
+ logger.error("libvirt call failed: " + str(e))
+ return 1
+
+ if retval:
+ return 1
+
+ return 0
--
1.7.1
11 years, 10 months
[libvirt] [PATCH v2 0/5]use VIR_ENUM_DECL for domain NIC model and add usb-net
by Guannan Ren
v1 to v2
*removed i8* NIC models support for QEMU/KVM
*updated docs
This patchset uses VIR_ENUM_DECL and VIR_ENUM_IMPL macros for NIC models
and changes the related codes to use them.
All of NIC models supported by various hypervisors comprise the enum,
so the problem is that we need to do further checking in hypervisor-specific
implementation. Fortunately, VMX and Vbox did this checking very well already.
In 4/5, a similar job is performed for QEMU/KVM.
And, adds usb-net support.
The vendorId and productID of is 0525:a4a2. The corresponding item in
usb-ids is as follows:
0525 Netchip Technology, Inc.
a4a2 Linux-USB Ethernet/RNDIS Gadget
In my opinion, using usb-net directly is good enough, so I keep it.
Any idea is welcome.
Libvirt XML sample:
<devices>
<interface type='user'>
<mac address='52:54:00:32:6a:91'/>
<model type='usb-net'/>
<alias name='net1'/>
<address type='usb' bus='0' port='1'/>
</interface>
</devices>
qemu commandline:
qemu ${other_vm_args}
-netdev user,id=hostnet1 \
-device usb-net,netdev=hostnet1,id=net1,\
mac=52:54:00:32:6a:91,bus=usb.0,port=1
Guannan Ren(2)
[PATCH v2 1/5] conf: fix mismatch on two domain VIR_ENUM_IMPL macro
[PATCH v2 2/5] add domain NIC model enum macro
[PATCH v2 3/5] net: use virDomainNICModelType{From|To}String functions
[PATCH v2 4/5] qemu: add NIC model checking for qemu hypervisor
[PATCH v2 5/5] qemu: add usb-net support
docs/formatdomain.html.in | 29 +++++++++++------------------
src/conf/domain_conf.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
src/conf/domain_conf.h | 32 +++++++++++++++++++++++++++++++-
src/libvirt_private.syms | 2 ++
src/libxl/libxl_conf.c | 5 +++--
src/parallels/parallels_driver.c | 2 +-
src/qemu/qemu_command.c | 41 +++++++++++++++++++++++++++--------------
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_hotplug.c | 10 ++++++----
src/qemu/qemu_process.c | 14 +++++++-------
src/vbox/vbox_tmpl.c | 57 +++++++++++++++++++++++++++------------------------------
src/vmx/vmx.c | 31 ++++++++++++++++---------------
src/xenxs/xen_sxpr.c | 23 ++++++++++++-----------
src/xenxs/xen_xm.c | 21 +++++++++++----------
14 files changed, 215 insertions(+), 142 deletions(-)
11 years, 10 months
[libvirt] [PATCH 0/5] use VIR_ENUM_DECL for domain NIC model and add usb-net
by Guannan Ren
This patchset uses VIR_ENUM_DECL and VIR_ENUM_IMPL macros for NIC models
and changes the related codes to use them.
All of NIC models supported by various hypervisors comprise the enum,
so the problem is that we need to do further checking in hypervisor-specific
implementation. Fortunately, VMX and Vbox did this checking very well already.
In 4/5, a similar job is performed for QEMU/KVM.
And, adds usb-net support.
The vendorId and productID of is 0525:a4a2. The corresponding item in
usb-ids is as follows:
0525 Netchip Technology, Inc.
a4a2 Linux-USB Ethernet/RNDIS Gadget
In my opinion, using usb-net directly is good enough, so I keep it.
Any idea is welcome.
Libvirt XML sample:
<devices>
<interface type='user'>
<mac address='52:54:00:32:6a:91'/>
<model type='usb-net'/>
<alias name='net1'/>
<address type='usb' bus='0' port='1'/>
</interface>
</devices>
qemu commandline:
qemu ${other_vm_args}
-netdev user,id=hostnet1 \
-device usb-net,netdev=hostnet1,id=net1,\
mac=52:54:00:32:6a:91,bus=usb.0,port=1
Guannan Ren(5)
[PATCH 1/5] conf: fix mismatch on two domain VIR_ENUM_IMPL macro
[PATCH 2/5] conf: add domain NIC model enum macro
[PATCH 3/5] net: use virDomainNICModelType{From|To}String functions
[PATCH 4/5] qemu: add NIC model checking for qemu hypervisor
[PATCH 5/5] qemu: add usb-net support
docs/formatdomain.html.in | 8 +++++++-
src/conf/domain_conf.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
src/conf/domain_conf.h | 45 ++++++++++++++++++++++++++++++++++++++++++++-
src/libvirt_private.syms | 2 ++
src/libxl/libxl_conf.c | 5 +++--
src/parallels/parallels_driver.c | 2 +-
src/qemu/qemu_command.c | 41 +++++++++++++++++++++++++++--------------
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_hotplug.c | 10 ++++++----
src/qemu/qemu_process.c | 14 +++++++-------
src/vbox/vbox_tmpl.c | 57 +++++++++++++++++++++++++++------------------------------
src/vmx/vmx.c | 31 ++++++++++++++++---------------
src/xenxs/xen_sxpr.c | 23 ++++++++++++-----------
src/xenxs/xen_xm.c | 21 +++++++++++----------
14 files changed, 237 insertions(+), 125 deletions(-)
11 years, 10 months