[libvirt] [python PATCHv2] Implement new virNetworkGetDHCPLeases API
by Peter Krempa
From: Nehal J Wani <nehaljw.kkd1(a)gmail.com>
This API returns a list of DHCP leases for all network interfaces
connected to the given virtual network or limited output just for one
interface if mac is specified.
Example Output:
[{'iface': 'virbr3', 'ipaddr': '192.168.150.181', 'hostname': 'ubuntu14',
'expirytime': 1403737495L, 'prefix': 24, 'clientid': None,
'mac': '52:54:00:e8:73:eb', 'iaid': None, 'type': 0},
{'iface': 'virbr3', 'ipaddr': '2001:db8:ca2:2:1::bd', 'hostname': 'fedora20-test',
'expirytime': 1403738587L, 'prefix': 64, 'clientid': '00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd',
'mac': '52:54:00:5b:40:98', 'iaid': '5980312', 'type': 1}]
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
examples/README | 1 +
examples/dhcpleases.py | 53 +++++++++++++++++++++++++++++
generator.py | 4 +++
libvirt-override-api.xml | 7 ++++
libvirt-override.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
sanitytest.py | 6 ++++
6 files changed, 159 insertions(+)
create mode 100755 examples/dhcpleases.py
diff --git a/examples/README b/examples/README
index f4db76c..5b5d405 100644
--- a/examples/README
+++ b/examples/README
@@ -10,6 +10,7 @@ domsave.py - save all running domU's into a directory
domrestore.py - restore domU's from their saved files in a directory
esxlist.py - list active domains of an VMware ESX host and print some info.
also demonstrates how to use the libvirt.openAuth() method
+dhcpleases.py - list dhcp leases for a given virtual network
The XML files in this directory are examples of the XML format that libvirt
expects, and will have to be adapted for your setup. They are only needed
diff --git a/examples/dhcpleases.py b/examples/dhcpleases.py
new file mode 100755
index 0000000..c172dc2
--- /dev/null
+++ b/examples/dhcpleases.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# netdhcpleases - print leases info for given virtual network
+
+import libvirt
+import sys
+import time
+
+def usage():
+ print "Usage: %s [URI] NETWORK" % sys.argv[0]
+ print " Print leases info for a given virtual network"
+
+uri = None
+network = None
+args = len(sys.argv)
+
+if args == 2:
+ network = sys.argv[1]
+elif args == 3:
+ uri = sys.argv[1]
+ network = sys.argv[2]
+else:
+ usage()
+ sys.exit(2)
+
+conn = libvirt.open(uri)
+if conn == None:
+ print "Unable to open connection to libvirt"
+ sys.exit(1)
+
+try:
+ net = conn.networkLookupByName(network)
+except libvirt.libvirtError:
+ print "Network %s not found" % network
+ sys.exit(0)
+
+leases = net.DHCPLeases();
+if (leases == None):
+ print "Failed to get leases for %s" % net.name()
+ sys.exit(0)
+
+def toIPAddrType(addrType):
+ if addrType == libvirt.VIR_IP_ADDR_TYPE_IPV4:
+ return "ipv4"
+ elif addrType == libvirt.VIR_IP_ADDR_TYPE_IPV6:
+ return "ipv6"
+
+print " {0:20} {1:18} {2:9} {3:25} {4:15} {5}".format("Expiry Time", "MAC address", "Protocol", "IP address", "Hostname", "Client ID or DUID")
+print "-"*115
+
+for lease in leases:
+ print " {0:20}".format(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(lease['expirytime']))),
+ print "{0:18} {1:9}".format(lease['mac'], toIPAddrType(lease['type'])),
+ print "{0:<25} {1:15} {2}".format("{}/{}".format(lease['ipaddr'], lease['prefix']), lease['hostname'], lease['clientid'])
diff --git a/generator.py b/generator.py
index 03027c6..a12c52b 100755
--- a/generator.py
+++ b/generator.py
@@ -463,6 +463,7 @@ skip_impl = (
'virDomainMigrateToURI3',
'virConnectGetCPUModelNames',
'virNodeGetFreePages',
+ 'virNetworkGetDHCPLeases',
)
lxc_skip_impl = (
@@ -568,6 +569,8 @@ skip_function = (
"virTypedParamsGetString",
"virTypedParamsGetUInt",
"virTypedParamsGetULLong",
+
+ 'virNetworkDHCPLeaseFree', # only useful in C, python code uses list
)
lxc_skip_function = (
@@ -1115,6 +1118,7 @@ def nameFixup(name, classe, type, file):
elif name[0:13] == "virNetworkGet":
func = name[13:]
func = func[0:1].lower() + func[1:]
+ func = func.replace("dHCP", "DHCP")
elif name[0:10] == "virNetwork":
func = name[10:]
func = func[0:1].lower() + func[1:]
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index bbf0ab1..09bbbf8 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -633,5 +633,12 @@
<arg name='flags' type='int' info='unused, pass 0'/>
<return type='char *' info='the list available memory in the cells'/>
</function>
+ <function name="virNetworkGetDHCPLeases" file='python'>
+ <info>Returns a list of dhcp leases for interfaces connected to the given virtual network</info>
+ <arg name='network' type='virNetworkPtr' info='a network object'/>
+ <arg name='mac' type='const char *' info='optional mac address'/>
+ <arg name='flags' type='unsigned int' info='unused, pass 0'/>
+ <return type='char *' info="list of leases"/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 40aefcc..ed5e9e4 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7866,6 +7866,93 @@ libvirt_virNodeGetFreePages(PyObject *self ATTRIBUTE_UNUSED,
VIR_FREE(counts);
return py_retval;
}
+
+
+static PyObject *
+libvirt_virNetworkGetDHCPLeases(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *py_retval = NULL;
+ PyObject *py_lease = NULL;
+ virNetworkPtr network;
+ PyObject *pyobj_network;
+ unsigned int flags;
+ virNetworkDHCPLeasePtr *leases = NULL;
+ int leases_count;
+ char *mac = NULL;
+ size_t i;
+
+ if (!PyArg_ParseTuple(args, (char *) "Ozi:virNetworkDHCPLeasePtr",
+ &pyobj_network, &mac, &flags))
+ return NULL;
+
+ network = (virNetworkPtr) PyvirNetwork_Get(pyobj_network);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ leases_count = virNetworkGetDHCPLeases(network, mac, &leases, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (leases_count < 0) {
+ py_retval = VIR_PY_NONE;
+ goto cleanup;
+ }
+
+ if (!(py_retval = PyList_New(leases_count)))
+ goto no_memory;
+
+ for (i = 0; i < leases_count; i++) {
+ virNetworkDHCPLeasePtr lease = leases[i];
+
+ if ((py_lease = PyDict_New()) == NULL)
+ goto no_memory;
+
+#define VIR_SET_LEASE_ITEM(NAME, VALUE_OBJ_FUNC) \
+ do { \
+ PyObject *tmp_val; \
+ \
+ if (!(tmp_val = VALUE_OBJ_FUNC)) \
+ goto no_memory; \
+ \
+ if (PyDict_SetItemString(py_lease, NAME, tmp_val) < 0) { \
+ Py_DECREF(tmp_val); \
+ goto no_memory; \
+ } \
+ } while (0)
+
+ VIR_SET_LEASE_ITEM("iface", libvirt_charPtrWrap(lease->iface));
+ VIR_SET_LEASE_ITEM("expirytime", libvirt_longlongWrap(lease->expirytime));
+ VIR_SET_LEASE_ITEM("type", libvirt_intWrap(lease->type));
+ VIR_SET_LEASE_ITEM("mac", libvirt_charPtrWrap(lease->mac));
+ VIR_SET_LEASE_ITEM("ipaddr", libvirt_charPtrWrap(lease->ipaddr));
+ VIR_SET_LEASE_ITEM("prefix", libvirt_uintWrap(lease->prefix));
+ VIR_SET_LEASE_ITEM("hostname", libvirt_charPtrWrap(lease->hostname));
+ VIR_SET_LEASE_ITEM("clientid", libvirt_charPtrWrap(lease->clientid));
+ VIR_SET_LEASE_ITEM("iaid", libvirt_charPtrWrap(lease->iaid));
+
+#undef VIR_SET_LEASE_ITEM
+
+ if (PyList_SetItem(py_retval, i, py_lease) < 0)
+ goto no_memory;
+
+ py_lease = NULL;
+ }
+
+ cleanup:
+ Py_XDECREF(py_lease);
+ if (leases) {
+ for (i = 0; i < leases_count; i++)
+ virNetworkDHCPLeaseFree(leases[i]);
+ }
+ VIR_FREE(leases);
+
+ return py_retval;
+
+ no_memory:
+ Py_XDECREF(py_retval);
+ py_retval = PyErr_NoMemory();
+ goto cleanup;
+}
+
#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
/************************************************************************
@@ -8051,6 +8138,7 @@ static PyMethodDef libvirtMethods[] = {
#endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
#if LIBVIR_CHECK_VERSION(1, 2, 6)
{(char *) "virNodeGetFreePages", libvirt_virNodeGetFreePages, METH_VARARGS, NULL},
+ {(char *) "virNetworkGetDHCPLeases", libvirt_virNetworkGetDHCPLeases, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
{NULL, NULL, 0, NULL}
};
diff --git a/sanitytest.py b/sanitytest.py
index 6067a3f..4f4a648 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -78,6 +78,9 @@ for cname in wantfunctions:
if name[0:14] == "virTypedParams":
continue
+ if name[0:23] == "virNetworkDHCPLeaseFree":
+ continue
+
# These aren't functions, they're callback signatures
if name in ["virConnectAuthCallbackPtr", "virConnectCloseFunc",
"virStreamSinkFunc", "virStreamSourceFunc", "virStreamEventCallback",
@@ -210,6 +213,9 @@ for name in sorted(basicklassmap):
if func[0:8] == "fSFreeze" or func[0:6] == "fSThaw":
func = "fs" + func[2:]
+ if klass == "virNetwork":
+ func = func.replace("dHCP", "DHCP")
+
# ...except when they don't. More stupid naming
# decisions we can't fix
if func == "iD":
--
1.9.3
10 years, 9 months
[libvirt] Change of server
by Daniel Veillard
I went ahead and switched earlier today, the new IP for libvirt.org
is 91.121.203.120 , seems to me that all services are functionning
as before, I also migrated the various cron. The DNS TTL should
expire within 2 hours and everybody should see the new box then.
it has twice the memory and twice the CPU power (still not a speed
daemon by any measure but should be a bit better). Main point is that
the hardware is newer and hence less likely to fail, but don't repeat
it Murphy could hear about it !
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, 9 months
[libvirt] [PATCH] block/sheepdog: rename management program from collie to dog
by Hitoshi Mitake
The management program of latest sheepdog is named as "dog", "collie"
is obsolete. This patch updates the name in the configure script and
the sheepdog driver.
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi(a)lab.ntt.co.jp>
---
configure.ac | 10 +++++-----
src/storage/storage_backend_sheepdog.c | 12 ++++++------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index 710cb71..186d9e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1926,14 +1926,14 @@ AC_SUBST([LIBRBD_LIBS])
if test "$with_storage_sheepdog" = "yes" ||
test "$with_storage_sheepdog" = "check"; then
- AC_PATH_PROG([COLLIE], [collie], [], [$PATH:/sbin:/usr/sbin])
+ AC_PATH_PROG([DOG], [dog], [], [$PATH:/sbin:/usr/sbin])
if test "$with_storage_sheepdog" = "yes"; then
- if test -z "$COLLIE"; then
- AC_MSG_ERROR([We need collie for Sheepdog storage driver])
+ if test -z "$DOG"; then
+ AC_MSG_ERROR([We need dog for Sheepdog storage driver])
fi
else
- if test -z "$COLLIE"; then
+ if test -z "$DOG"; then
with_storage_sheepdog=no
fi
@@ -1945,7 +1945,7 @@ if test "$with_storage_sheepdog" = "yes" ||
if test "$with_storage_sheepdog" = "yes"; then
AC_DEFINE_UNQUOTED([WITH_STORAGE_SHEEPDOG], 1,
[whether Sheepdog backend for storage driver is enabled])
- AC_DEFINE_UNQUOTED([COLLIE],["$COLLIE"],[Location of collie program])
+ AC_DEFINE_UNQUOTED([DOG],["$DOG"],[Location of dog program])
fi
fi
AM_CONDITIONAL([WITH_STORAGE_SHEEPDOG],
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 9419859..864ecd6 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -150,7 +150,7 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
char **cells = NULL;
size_t i;
- virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "list", "-r", NULL);
+ virCommandPtr cmd = virCommandNewArgList(DOG, "vdi", "list", "-r", NULL);
virStorageBackendSheepdogAddHostArg(cmd, pool);
virCommandSetOutputBuffer(cmd, &output);
if (virCommandRun(cmd, NULL) < 0)
@@ -195,7 +195,7 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
char *output = NULL;
virCommandPtr cmd;
- cmd = virCommandNewArgList(COLLIE, "node", "info", "-r", NULL);
+ cmd = virCommandNewArgList(DOG, "node", "info", "-r", NULL);
virStorageBackendSheepdogAddHostArg(cmd, pool);
virCommandSetOutputBuffer(cmd, &output);
if (virCommandRun(cmd, NULL) < 0)
@@ -221,7 +221,7 @@ virStorageBackendSheepdogDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virCheckFlags(0, -1);
- virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "delete", vol->name, NULL);
+ virCommandPtr cmd = virCommandNewArgList(DOG, "vdi", "delete", vol->name, NULL);
virStorageBackendSheepdogAddHostArg(cmd, pool);
int ret = virCommandRun(cmd, NULL);
@@ -266,7 +266,7 @@ virStorageBackendSheepdogBuildVol(virConnectPtr conn,
virCheckFlags(0, -1);
- virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "create", vol->name, NULL);
+ virCommandPtr cmd = virCommandNewArgList(DOG, "vdi", "create", vol->name, NULL);
virCommandAddArgFormat(cmd, "%llu", vol->target.capacity);
virStorageBackendSheepdogAddHostArg(cmd, pool);
if (virCommandRun(cmd, NULL) < 0)
@@ -351,7 +351,7 @@ virStorageBackendSheepdogRefreshVol(virConnectPtr conn ATTRIBUTE_UNUSED,
int ret;
char *output = NULL;
- virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "list", vol->name, "-r", NULL);
+ virCommandPtr cmd = virCommandNewArgList(DOG, "vdi", "list", vol->name, "-r", NULL);
virStorageBackendSheepdogAddHostArg(cmd, pool);
virCommandSetOutputBuffer(cmd, &output);
ret = virCommandRun(cmd, NULL);
@@ -387,7 +387,7 @@ virStorageBackendSheepdogResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virCheckFlags(0, -1);
- virCommandPtr cmd = virCommandNewArgList(COLLIE, "vdi", "resize", vol->name, NULL);
+ virCommandPtr cmd = virCommandNewArgList(DOG, "vdi", "resize", vol->name, NULL);
virCommandAddArgFormat(cmd, "%llu", capacity);
virStorageBackendSheepdogAddHostArg(cmd, pool);
int ret = virCommandRun(cmd, NULL);
--
1.7.1
10 years, 9 months
[libvirt] [PATCH] Add test for type none model dac seclabel
by Ján Tomko
---
.../qemuxml2argv-seclabel-dac-none.args | 4 ++++
.../qemuxml2argv-seclabel-dac-none.xml | 28 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmltest.c | 1 +
4 files changed, 34 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.args b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.args
new file mode 100644
index 0000000..d891234
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -name QEMUGuest1 -S -M pc -m 214 -smp 1 -nographic \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-usb -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.xml
new file mode 100644
index 0000000..493f38b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dac-none.xml
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ </devices>
+ <seclabel type='none' model='dac'/>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 24d104e..349eb1e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1214,6 +1214,7 @@ mymain(void)
DO_TEST("seclabel-static-relabel", QEMU_CAPS_NAME);
DO_TEST("seclabel-static-labelskip", QEMU_CAPS_NAME);
DO_TEST("seclabel-none", QEMU_CAPS_NAME);
+ DO_TEST("seclabel-dac-none", QEMU_CAPS_NAME);
DO_TEST("pseries-basic",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 200d50f..43cd022 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -304,6 +304,7 @@ mymain(void)
DO_TEST("seclabel-static");
DO_TEST_FULL("seclabel-static-labelskip", false, WHEN_ACTIVE);
DO_TEST("seclabel-none");
+ DO_TEST("seclabel-dac-none");
DO_TEST("numad-static-vcpu-no-numatune");
DO_TEST("disk-scsi-lun-passthrough-sgio");
--
1.8.3.2
10 years, 9 months
[libvirt] [PATCH] test: add user_xattr check for securityselinuxlabeltest
by Jincheng Miao
libvirt unit test used setxattr with "user.libvirt.selinux" name to
emulate setfilecon of selinux. But for some old kernel filesystem
(like 2.6.32-431.el6.x86_64), if the filesystem is not mounted with
user_xattr flag, the setxattr with "user.libvirt.selinux" will fail.
So adding testUserXattrEnabled() in securityselinuxlabeltest.c,
if user_xattr is not enabled, skip this case.
The user_xattr is departed in newer kernel, therefore this commit is
only for the compatablity for old kernel.
Signed-off-by: Jincheng Miao <jmiao(a)redhat.com>
---
tests/securityselinuxlabeltest.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index 88ec35a..3f155e3 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -28,6 +28,7 @@
#include <selinux/selinux.h>
#include <selinux/context.h>
+#include <attr/xattr.h>
#include "internal.h"
#include "testutils.h"
@@ -56,6 +57,35 @@ struct testSELinuxFile {
char *context;
};
+static int
+testUserXattrEnabled(void)
+{
+ int ret = -1;
+ ssize_t len;
+ const char *con_value = "system_u:object_r:svirt_image_t:s0:c41,c264";
+ char *path = NULL;
+ if (virAsprintf(&path, "%s/securityselinuxlabeldata/testxattr",
+ abs_srcdir) < 0)
+ goto cleanup;
+
+ if (virFileTouch(path, 0600) < 0)
+ goto cleanup;
+
+ len = setxattr(path, "user.libvirt.selinux", con_value,
+ strlen(con_value), 0);
+ if (len < 0) {
+ if (errno == EOPNOTSUPP)
+ ret = 0;
+ goto cleanup;
+ }
+
+ ret = 1;
+
+ cleanup:
+ unlink(path);
+ VIR_FREE(path);
+ return ret;
+}
static int
testSELinuxMungePath(char **path)
@@ -322,6 +352,9 @@ mymain(void)
{
int ret = 0;
+ if (!testUserXattrEnabled())
+ return EXIT_AM_SKIP;
+
if (!(mgr = virSecurityManagerNew("selinux", "QEMU", false, true, false))) {
virErrorPtr err = virGetLastError();
fprintf(stderr, "Unable to initialize security driver: %s\n",
--
1.7.1
10 years, 9 months
[libvirt] [PATCH V2] libxl: detect support for save and restore
by Jim Fehlig
libxl does not support save, restore, or migrate on all architectures,
notably ARM. Detect whether libxl supports these operations using
LIBXL_HAVE_NO_SUSPEND_RESUME. If not supported, drop advertisement of
<migration_features>.
Found by Ian Campbell while improving Xen's OSSTEST infrastructure
http://lists.xen.org/archives/html/xen-devel/2014-06/msg02171.html
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
Another option for
https://www.redhat.com/archives/libvir-list/2014-June/msg01276.html
With this one, we even avoid the distasteful double negative :).
Compile-tested on x86 only at this point. The ARM build is still
slowly grinding away...
src/libxl/libxl_conf.c | 4 ++++
src/libxl/libxl_driver.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4b6b5c0..8eeaf82 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1340,7 +1340,11 @@ libxlMakeCapabilities(libxl_ctx *ctx)
{
virCapsPtr caps;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ if ((caps = virCapabilitiesNew(virArchFromHost(), 0, 0)) == NULL)
+#else
if ((caps = virCapabilitiesNew(virArchFromHost(), 1, 1)) == NULL)
+#endif
return NULL;
if (libxlCapsInitHost(ctx, caps) < 0)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 1ea99e2..646c9b9 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1379,6 +1379,11 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
int ret = -1;
bool remove_dom = false;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ virReportUnsupportedError();
+ return -1;
+#endif
+
virCheckFlags(0, -1);
if (dxml) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
@@ -1440,6 +1445,11 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
int fd = -1;
int ret = -1;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ virReportUnsupportedError();
+ return -1;
+#endif
+
virCheckFlags(VIR_DOMAIN_SAVE_PAUSED, -1);
if (dxml) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
@@ -4351,6 +4361,11 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain,
const char *xmlin = NULL;
virDomainObjPtr vm = NULL;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ virReportUnsupportedError();
+ return NULL;
+#endif
+
virCheckFlags(LIBXL_MIGRATION_FLAGS, NULL);
if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0)
return NULL;
@@ -4395,6 +4410,11 @@ libxlDomainMigratePrepare3Params(virConnectPtr dconn,
const char *dname = NULL;
const char *uri_in = NULL;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ virReportUnsupportedError();
+ return -1;
+#endif
+
virCheckFlags(LIBXL_MIGRATION_FLAGS, -1);
if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0)
goto error;
@@ -4445,6 +4465,11 @@ libxlDomainMigratePerform3Params(virDomainPtr dom,
const char *uri = NULL;
int ret = -1;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ virReportUnsupportedError();
+ return -1;
+#endif
+
virCheckFlags(LIBXL_MIGRATION_FLAGS, -1);
if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0)
goto cleanup;
@@ -4497,6 +4522,11 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn,
virDomainObjPtr vm = NULL;
const char *dname = NULL;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ virReportUnsupportedError();
+ return NULL;
+#endif
+
virCheckFlags(LIBXL_MIGRATION_FLAGS, NULL);
if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0)
return NULL;
@@ -4545,6 +4575,11 @@ libxlDomainMigrateConfirm3Params(virDomainPtr domain,
libxlDriverPrivatePtr driver = domain->conn->privateData;
virDomainObjPtr vm = NULL;
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+ virReportUnsupportedError();
+ return -1;
+#endif
+
virCheckFlags(LIBXL_MIGRATION_FLAGS, -1);
if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0)
return -1;
--
1.8.4.5
10 years, 9 months
[libvirt] [for 1.2.6] Redundancy of virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC
by Peter Krempa
Hi,
when reviewing the patch to add python bindings for the said APIs it
occurred to me that the two APIs are so close in their prototypes and
way of functioning that we could actually merge them into one.
Both of those return a list of lease structures and the only difference
is the presence of the @mac argument.
We could unify those two APIs into one with the following signature:
int
virNetworkGetDHCPLeases(virNetworkPtr network,
const char *mac,
virNetworkDHCPLeasePtr **leases,
unsigned int flags)
And tweak the semantics of @mac where when the user passes NULL we'd
return the complete unfiltered list.
This would simplify our API and also the python bindings.
If we decide this is a good idea (in time for the release) I'll post
patches to flesh out the redundant parts.
Peter
10 years, 9 months
[libvirt] [PATCH] qemu: fix guestfwd chardev option back how it was
by Martin Kletzander
Since commit d86c876a66e320b55220d00113027c9ad6199cff we are using
guestfwd=tcp:IP:PORT,chardev=ID for guestfwd specification, however,
that has not changed in qemu, so guestfwd does not work since.
Apart from that, guestfwd is not working with older qemu that doesn't
have QEMU_CAPS_DEVICE.
Both regressions exist since late 2009 and nobody found that (until
now), so I'm only fixing the first one.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1112066
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_command.c | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 93d303e..5074aa1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9186,7 +9186,7 @@ qemuBuildChannelChrDeviceStr(char **deviceStr,
port = virSocketAddrGetPort(chr->target.addr);
if (virAsprintf(deviceStr,
- "user,guestfwd=tcp:%s:%i,chardev=char%s,id=user-%s",
+ "user,guestfwd=tcp:%s:%i-chardev:char%s,id=user-%s",
addr, port, chr->info.alias, chr->info.alias) < 0) {
virReportOOMError();
goto cleanup;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args
index 7a15369..eb13430 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.args
@@ -4,5 +4,5 @@ pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev socket,\
id=charmonitor,path=/tmp/test-monitor,server,nowait -mon chardev=charmonitor,\
id=monitor,mode=readline -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -chardev \
pipe,id=charchannel0,path=/tmp/guestfwd -netdev user,\
-guestfwd=tcp:10.0.2.1:4600,chardev=charchannel0,id=user-channel0 -device \
+guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 -device \
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
--
2.0.0
10 years, 9 months
[libvirt] [PATCH] docs: publish correct enum values
by Eric Blake
We publish libvirt-api.xml for others to use, and in fact, the
libvirt-python bindings use it to generate enum values. However,
we had an off-by-one bug that any enum that relied on C's rules
for implicit initialization of the first enum member to 0 got
listed in the xml as having a value of 1 (and all later members
of the enum were equally botched).
Affected are:
- virDomainCoreDumpFormat (such as VIR_DOMAIN_CORE_DUMP_FORMAT_RAW),
since libvirt TBD
- virDomainEventGraphicsAddressType (such as
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4), since libvirt TBD
- virIPAddrType (such as VIR_IP_ADDR_TYPE_IPV4), since libvirt TBD
The fix is simple - since we add one to the previous value when
encountering an enum without an initializer, the previous value
must start at -1 so that the first enum member is assigned 0.
Thanks to Nehal J Wani for reporting the problem on IRC, and
for helping me zero in on the culprit function.
* docs/apibuild.py (CParser.parseEnumBlock): Fix implicit enum
values.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
I'm going to touch up the commit message before pushing, once I
do enough research on which versions of libvirt were impacted;
but I just got interrupted, so I'm posting this now to get the
review started.
docs/apibuild.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/apibuild.py b/docs/apibuild.py
index 5250c5a..30e224d 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -1312,7 +1312,7 @@ class CParser:
name = None
self.comment = None
comment = ""
- value = "0"
+ value = "-1"
while token is not None:
if token[0] == "sep" and token[1] == "{":
token = self.token()
--
1.9.3
10 years, 9 months
[libvirt] [PATCH] Fix typo s/SASL_CONF_DIR/SASL_CONF_PATH/ in QEMU VNC code
by Daniel P. Berrange
The QEMU VNC client arg code has a long standing typo
of SASL_CONF_DIR when it should be SASL_CONFIG_PATH for
the env variable name.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_command.c | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.args | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 93d303e..d53315a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6541,7 +6541,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
virBufferAddLit(&opt, ",sasl");
if (cfg->vncSASLdir)
- virCommandAddEnvPair(cmd, "SASL_CONF_DIR", cfg->vncSASLdir);
+ virCommandAddEnvPair(cmd, "SASL_CONF_PATH", cfg->vncSASLdir);
/* TODO: Support ACLs later */
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args
index 67ef88f..239fde1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args
@@ -1,5 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
-SASL_CONF_DIR=/root/.sasl2 QEMU_AUDIO_DRV=none \
+SASL_CONF_PATH=/root/.sasl2 QEMU_AUDIO_DRV=none \
/usr/bin/qemu -S -M pc -m 214 \
-smp 1 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -hda \
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -vnc \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.args
index d71a998..c681b1b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.args
@@ -1,5 +1,5 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
-SASL_CONF_DIR=/root/.sasl2 QEMU_AUDIO_DRV=none \
+SASL_CONF_PATH=/root/.sasl2 QEMU_AUDIO_DRV=none \
/usr/bin/qemu -S -M pc -m 214 \
-smp 1 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -hda \
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -vnc \
--
1.9.3
10 years, 9 months