[libvirt] [PATCH] automatic create tap device with network type ethernet
by Vasiliy Tolstov
If use not specify script in network type ethernet, assume that user
needs simple tap device created with libvirt.
This patch does not need to run external script to create tap device.
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
src/qemu/qemu_command.c | 88 ++++++++++++++++++++++++++++++++-----------------
src/qemu/qemu_hotplug.c | 10 ++----
src/qemu/qemu_process.c | 4 +++
3 files changed, 64 insertions(+), 38 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cbdef9c..5f9833e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -319,7 +319,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
} else if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
if (VIR_STRDUP(brname, virDomainNetGetActualBridgeName(net)) < 0)
return ret;
- } else {
+ } else if (actualType != VIR_DOMAIN_NET_TYPE_ETHERNET) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Network type %d is not supported"),
virDomainNetGetActualType(net));
@@ -341,30 +341,42 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
}
- if (cfg->privileged) {
- if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
- def->uuid, tunpath, tapfd, *tapfdSize,
- virDomainNetGetActualVirtPortProfile(net),
- virDomainNetGetActualVlan(net),
- tap_create_flags) < 0) {
+ if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
+ if (virNetDevTapCreate(&net->ifname, tunpath, tapfd, *tapfdSize,
+ tap_create_flags) < 0) {
virDomainAuditNetDevice(def, net, tunpath, false);
goto cleanup;
}
- } else {
- if (qemuCreateInBridgePortWithHelper(cfg, brname,
- &net->ifname,
- tapfd, tap_create_flags) < 0) {
- virDomainAuditNetDevice(def, net, tunpath, false);
+ if (virNetDevSetMAC(net->ifname, &net->mac) < 0)
goto cleanup;
+ if (virNetDevSetOnline(net->ifname, !!(tap_create_flags & VIR_NETDEV_TAP_CREATE_IFUP)) < 0)
+ goto cleanup;
+ } else {
+ if (cfg->privileged) {
+ if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
+ def->uuid, tunpath, tapfd, *tapfdSize,
+ virDomainNetGetActualVirtPortProfile(net),
+ virDomainNetGetActualVlan(net),
+ tap_create_flags) < 0) {
+ virDomainAuditNetDevice(def, net, tunpath, false);
+ goto cleanup;
+ }
+ } else {
+ if (qemuCreateInBridgePortWithHelper(cfg, brname,
+ &net->ifname,
+ tapfd, tap_create_flags) < 0) {
+ virDomainAuditNetDevice(def, net, tunpath, false);
+ goto cleanup;
+ }
+ /* qemuCreateInBridgePortWithHelper can only create a single FD */
+ if (*tapfdSize > 1) {
+ VIR_WARN("Ignoring multiqueue network request");
+ *tapfdSize = 1;
+ }
}
- /* qemuCreateInBridgePortWithHelper can only create a single FD */
- if (*tapfdSize > 1) {
- VIR_WARN("Ignoring multiqueue network request");
- *tapfdSize = 1;
- }
- }
- virDomainAuditNetDevice(def, net, tunpath, true);
+ virDomainAuditNetDevice(def, net, tunpath, true);
+ }
if (cfg->macFilter &&
ebtablesAddForwardAllowIn(driver->ebtables,
@@ -4540,18 +4552,32 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
break;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
- virBufferAddLit(&buf, "tap");
+ virBufferAddLit(&buf, "tap");
+ type_sep = ',';
+ if (net->script) {
if (net->ifname) {
- virBufferAsprintf(&buf, "%cifname=%s", type_sep, net->ifname);
- type_sep = ',';
+ virBufferAsprintf(&buf, "%cifname=%s", type_sep, net->ifname);
+ type_sep = ',';
}
- if (net->script) {
- virBufferAsprintf(&buf, "%cscript=%s", type_sep,
- net->script);
- type_sep = ',';
+ virBufferAsprintf(&buf, "%cscript=%s", type_sep, net->script);
+ type_sep = ',';
+ } else {
+ /* for one tapfd 'fd=' shall be used,
+ * for more than one 'fds=' is the right choice */
+ if (tapfdSize == 1) {
+ virBufferAsprintf(&buf, "%cfd=%s", type_sep, tapfd[0]);
+ } else {
+ virBufferAsprintf(&buf, "%cfds=", type_sep);
+ for (i = 0; i < tapfdSize; i++) {
+ if (i)
+ virBufferAddChar(&buf, ':');
+ virBufferAdd(&buf, tapfd[i], -1);
+ }
}
- is_tap = true;
- break;
+ type_sep = ',';
+ }
+ is_tap = true;
+ break;
case VIR_DOMAIN_NET_TYPE_CLIENT:
virBufferAsprintf(&buf, "socket%cconnect=%s:%d",
@@ -7348,7 +7374,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
/* Currently nothing besides TAP devices supports multiqueue. */
if (net->driver.virtio.queues > 0 &&
!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Multiqueue network is not supported for: %s"),
virDomainNetTypeToString(actualType));
@@ -7356,7 +7383,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
}
if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
tapfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = 1;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b00fd8f..bf92e4d 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -908,7 +908,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
}
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
- actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
+ actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
+ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
tapfdSize = vhostfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
@@ -939,13 +940,6 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
iface_connected = true;
if (qemuOpenVhostNet(vm->def, net, priv->qemuCaps, vhostfd, &vhostfdSize) < 0)
goto cleanup;
- } else if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) {
- vhostfdSize = 1;
- if (VIR_ALLOC(vhostfd) < 0)
- goto cleanup;
- *vhostfd = -1;
- if (qemuOpenVhostNet(vm->def, net, priv->qemuCaps, vhostfd, &vhostfdSize) < 0)
- goto cleanup;
}
/* Set Bandwidth */
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c3ee40b..8bc4d81 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5085,6 +5085,10 @@ void qemuProcessStop(virQEMUDriverPtr driver,
cfg->stateDir));
VIR_FREE(net->ifname);
break;
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ ignore_value(virNetDevTapDelete(net->ifname, net->backend.tap));
+ VIR_FREE(net->ifname);
+ break;
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_NETWORK:
#ifdef VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP
--
2.1.3
10 years, 1 month
[libvirt] [PATCH] Resolve build breaker
by John Ferlan
Commit 'c264eeaa' didn't do the prerequisite 'make syntax-check' before
pushing. There was a <tab> in the whitespace for the comment. Replaced
with spaces and aligned.
pushed as build breaker since Jenkins complained loudly
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/security/virt-aa-helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index f273e09..869bf18 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -571,7 +571,7 @@ valid_path(const char *path, const bool readonly)
};
/* override the above with these */
const char * const override[] = {
- "/sys/devices/pci", /* for hostdev pci devices */
+ "/sys/devices/pci", /* for hostdev pci devices */
"/etc/libvirt-sandbox/services/" /* for virt-sandbox service config */
};
--
1.9.3
10 years, 1 month
[libvirt] [libvirt-glib PATCHv2] Add gvir_domain_open_graphics_fd()
by Zeeshan Ali (Khattak)
Add binding for virDomainOpenGraphicsFD. If virDomainOpenGraphicsFD is
not available, it means we are dealing with older libvirt so we create
the socket pair ourselves if that is the case.
---
configure.ac | 4 ++
libvirt-gobject/libvirt-gobject-domain.c | 72 ++++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 4 ++
libvirt-gobject/libvirt-gobject.sym | 5 +++
4 files changed, 85 insertions(+)
diff --git a/configure.ac b/configure.ac
index 8cc3fca..bcb5cda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,10 @@ m4_if(m4_version_compare([2.61a.100],
LIBVIRT_GLIB_COMPILE_WARNINGS
PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
+# virDomainOpenGraphicsFD was introduced in libvirt 1.2.8
+AC_CHECK_LIB([virt],
+ [virDomainOpenGraphicsFD],
+ [AC_DEFINE([HAVE_VIR_DOMAIN_OPEN_GRAPHICS_FD], 1, [Have virDomainOpenGraphicsFD?])])
enable_tests=no
PKG_CHECK_MODULES(GLIB2, glib-2.0 >= $GLIB2_TEST_REQUIRED,
[enable_tests=yes],
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 8df30d7..d41dadd 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -25,6 +25,7 @@
#include <libvirt/virterror.h>
#include <string.h>
+#include <sys/socket.h>
#include "libvirt-glib/libvirt-glib.h"
#include "libvirt-gobject/libvirt-gobject.h"
@@ -1222,6 +1223,77 @@ cleanup:
}
/**
+ * gvir_domain_open_graphics_fd:
+ * @dom: the domain
+ * @idx: the graphics index
+ * @flags: extra flags, currently unused
+ *
+ * This will create a socket pair connected to the graphics backend of @dom. One
+ * end of the socket will be returned on success, and the other end is handed to
+ * the hypervisor. If @dom has multiple graphics backends configured, then @idx
+ * will determine which one is opened, starting from @idx 0.
+ *
+ * Returns: An fd on success, -1 on failure.
+ *
+ * Since: 0.2.0
+ */
+int gvir_domain_open_graphics_fd(GVirDomain *dom,
+ guint idx,
+ unsigned int flags,
+ GError **err)
+{
+ GVirDomainPrivate *priv;
+ int ret = -1;
+#ifndef HAVE_VIR_DOMAIN_OPEN_GRAPHICS_FD
+ int pair[2];
+#endif
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), -1);
+ g_return_val_if_fail(err == NULL || *err == NULL, -1);
+
+ priv = dom->priv;
+
+#ifdef HAVE_VIR_DOMAIN_OPEN_GRAPHICS_FD
+ ret = virDomainOpenGraphicsFD(priv->handle, idx, flags);
+ if (ret <= 0) {
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Unable to open graphics");
+ goto end;
+ }
+#else
+
+ if (socketpair(PF_UNIX, SOCK_STREAM, 0, pair) < 0) {
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Failed to create socket pair");
+ goto end;
+ }
+
+ if (virDomainOpenGraphics(priv->handle, idx, pair[0], flags) < 0) {
+ virErrorPtr vir_err;
+
+ vir_err = virGetLastError();
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ vir_err && vir_err->message ?
+ vir_err->message :
+ "Unable to open graphics");
+ close(pair[0]);
+ close(pair[1]);
+
+ goto end;
+ }
+ close(pair[0]);
+ ret = pair[1];
+
+#endif
+
+end:
+ return ret;
+}
+
+/**
* gvir_domain_suspend:
* @dom: the domain to suspend
* @err: Place-holder for possible errors
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 47ed784..4fe381e 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -332,6 +332,10 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
int fd,
unsigned int flags,
GError **err);
+int gvir_domain_open_graphics_fd(GVirDomain *dom,
+ guint idx,
+ unsigned int flags,
+ GError **err);
gboolean gvir_domain_suspend (GVirDomain *dom,
GError **err);
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index d18769b..927cad9 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -260,4 +260,9 @@ LIBVIRT_GOBJECT_0.1.9 {
gvir_stream_io_condition_get_type;
} LIBVIRT_GOBJECT_0.1.5;
+LIBVIRT_GOBJECT_0.2.0 {
+ global:
+ gvir_domain_open_graphics_fd;
+} LIBVIRT_GOBJECT_0.1.9;
+
# .... define new API here using predicted next version number ....
--
2.1.0
10 years, 1 month
[libvirt] [PATCH 0/2] use bool type for bool values
by Eric Blake
I stumbled into this one on work I'm doing with qemu blockinfo.
The DBus interaction code was tricky enough to need to be its own
patch; but I like the end result that clients reading a 'b' entry
from virDBus code can now pass a sane 'bool*' instead of a weird
'int*' variable.
Eric Blake (2):
virdbus: don't force users to pass int for bool values
maint: forbid 'int foo = true'
cfg.mk | 6 ++++++
src/conf/snapshot_conf.c | 2 +-
src/qemu/qemu_driver.c | 4 ++--
src/test/test_driver.c | 2 +-
src/util/vircgroup.c | 2 +-
src/util/virdbus.c | 25 ++++++++++++++-----------
src/util/virpci.c | 2 +-
src/util/virpolkit.c | 6 +++---
src/util/virutil.c | 2 +-
tests/virdbustest.c | 4 ++--
tools/virsh-domain-monitor.c | 2 +-
tools/virsh-domain.c | 12 ++++++------
12 files changed, 39 insertions(+), 30 deletions(-)
--
1.9.3
10 years, 1 month
[libvirt] [libvirt-python PATCH v2] override: Implement bindings for virDomainGetFSInfo as domain.fsInfo
by Tomoki Sekiyama
Implement the function which returns a list of tuples, that contains members
of virDomainFSInfo struct.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama(a)hds.com>
---
generator.py | 5 +++
libvirt-override-api.xml | 6 ++++
libvirt-override.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++
sanitytest.py | 5 +++
4 files changed, 85 insertions(+), 1 deletion(-)
diff --git a/generator.py b/generator.py
index c66c6d4..20df54f 100755
--- a/generator.py
+++ b/generator.py
@@ -476,6 +476,7 @@ skip_impl = (
'virNetworkGetDHCPLeases',
'virDomainBlockCopy',
'virNodeAllocPages',
+ 'virDomainGetFSInfo',
)
lxc_skip_impl = (
@@ -586,6 +587,7 @@ skip_function = (
'virNetworkDHCPLeaseFree', # only useful in C, python code uses list
'virDomainStatsRecordListFree', # only useful in C, python uses dict
+ 'virDomainFSInfoFree', # only useful in C, python code uses list
)
lxc_skip_function = (
@@ -1107,6 +1109,9 @@ def nameFixup(name, classe, type, file):
elif name[0:20] == "virDomainGetCPUStats":
func = name[9:]
func = func[0:1].lower() + func[1:]
+ elif name[0:18] == "virDomainGetFSInfo":
+ func = name[12:]
+ func = func[0:2].lower() + func[2:]
elif name[0:12] == "virDomainGet":
func = name[12:]
func = func[0:1].lower() + func[1:]
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 4fe3c4d..439cb40 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -658,5 +658,11 @@
<arg name='flags' type='unsigned int' info='an OR'ed set of virNodeAllocPagesFlags'/>
<return type='int' info='the number of nodes successfully adjusted or -1 in case of an error'/>
</function>
+ <function name="virDomainGetFSInfo" file='python'>
+ <info>Get a list of mapping information for each mounted file systems within the specified guest and the disks.</info>
+ <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
+ <arg name='flags' type='unsigned int' info='unused, pass 0'/>
+ <return type='char *' info="list of mounted filesystems information"/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 8895289..a91bf0d 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8266,6 +8266,73 @@ libvirt_virNodeAllocPages(PyObject *self ATTRIBUTE_UNUSED,
}
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+#if LIBVIR_CHECK_VERSION(1, 2, 11)
+
+static PyObject *
+libvirt_virDomainGetFSInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ unsigned int flags;
+ virDomainFSInfoPtr *fsinfo = NULL;
+ char **dev;
+ int c_retval, i;
+ PyObject *py_retval;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainFSInfo",
+ &pyobj_domain, &flags))
+ return NULL;
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainGetFSInfo(domain, &fsinfo, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_retval < 0)
+ goto cleanup;
+
+ /* convert to a Python list */
+ if ((py_retval = PyList_New(c_retval)) == NULL)
+ goto cleanup;
+
+ for (i = 0; i < c_retval; i++) {
+ virDomainFSInfoPtr fs = fsinfo[i];
+ PyObject *info, *alias;
+
+ if (fs == NULL)
+ goto cleanup;
+ info = PyTuple_New(4);
+ if (info == NULL)
+ goto cleanup;
+ PyList_SetItem(py_retval, i, info);
+ alias = PyList_New(0);
+ if (alias == NULL)
+ goto cleanup;
+
+ PyTuple_SetItem(info, 0, libvirt_constcharPtrWrap(fs->mountpoint));
+ PyTuple_SetItem(info, 1, libvirt_constcharPtrWrap(fs->name));
+ PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(fs->type));
+ PyTuple_SetItem(info, 3, alias);
+
+ for (dev = fs->devAlias; dev && *dev; dev++)
+ if (PyList_Append(alias, libvirt_constcharPtrWrap(*dev)) < 0)
+ goto cleanup;
+ }
+
+ for (i = 0; i < c_retval; i++)
+ virDomainFSInfoFree(fsinfo[i]);
+ VIR_FREE(fsinfo);
+ return py_retval;
+
+ cleanup:
+ for (i = 0; i < c_retval; i++)
+ virDomainFSInfoFree(fsinfo[i]);
+ VIR_FREE(fsinfo);
+ Py_XDECREF(py_retval);
+ return VIR_PY_NONE;
+}
+
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
+
/************************************************************************
* *
* The registration stuff *
@@ -8459,6 +8526,9 @@ static PyMethodDef libvirtMethods[] = {
#if LIBVIR_CHECK_VERSION(1, 2, 9)
{(char *) "virNodeAllocPages", libvirt_virNodeAllocPages, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
+#if LIBVIR_CHECK_VERSION(1, 2, 11)
+ {(char *) "virDomainGetFSInfo", libvirt_virDomainGetFSInfo, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
{NULL, NULL, 0, NULL}
};
diff --git a/sanitytest.py b/sanitytest.py
index b161696..f5337fc 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -137,6 +137,9 @@ for cname in wantfunctions:
if name[0:28] == "virDomainStatsRecordListFree":
continue
+ if name[0:19] == "virDomainFSInfoFree":
+ continue
+
if name[0:21] == "virDomainListGetStats":
name = "virConnectDomainListGetStats"
@@ -269,7 +272,7 @@ for name in sorted(basicklassmap):
func = func[0:1].lower() + func[1:]
if func[0:8] == "nWFilter":
func = "nwfilter" + func[8:]
- if func[0:8] == "fSFreeze" or func[0:6] == "fSThaw":
+ if func[0:8] == "fSFreeze" or func[0:6] == "fSThaw" or func[0:6] == "fSInfo":
func = "fs" + func[2:]
if klass == "virNetwork":
10 years, 1 month
[libvirt] [PATCH] storage_driver: fix a comment typo
by Chen Hanxiao
s/rereshed/refreshed
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/storage/storage_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 4655cde..23b63f5 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1998,7 +1998,7 @@ virStorageVolPoolRefreshThread(void *opaque)
* to perform a pool refresh.
*
* @st Pointer to stream being closed.
- * @opaque Buffer to hold the pool name to be rereshed
+ * @opaque Buffer to hold the pool name to be refreshed
*/
static void
virStorageVolFDStreamCloseCb(virStreamPtr st ATTRIBUTE_UNUSED,
--
1.9.3
10 years, 1 month
[libvirt] [PATCH] util: Avoid calling closedir(NULL)
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/util/virutil.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 9c40317..3037293 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1780,7 +1780,7 @@ virFindSCSIHostByPCI(const char *sysfs_prefix,
virReportSystemError(errno,
_("Failed to opendir path '%s'"),
prefix);
- goto cleanup;
+ return NULL;
}
while (virDirRead(dir, &entry, prefix) > 0) {
--
2.1.3
10 years, 1 month
[libvirt] [python PATCHv2] event: Add bindings for agent lifecycle event
by Peter Krempa
Also add the example.
---
Version 2:
- version 2 actually works ...
examples/event-test.py | 11 ++++++++
libvirt-override-virConnect.py | 10 +++++++
libvirt-override.c | 60 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+)
mode change 100644 => 100755 examples/event-test.py
diff --git a/examples/event-test.py b/examples/event-test.py
old mode 100644
new mode 100755
index be7a7d4..6cc33ce
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -464,6 +464,14 @@ def blockJobStatusToString(status):
blockJobStatus = ( "Completed", "Failed", "Canceled", "Ready", )
return blockJobStatus[status]
+def agentLifecycleStateToString(state):
+ agentStates = ( "unknown", "connected", "disconnected", )
+ return agentStates[state]
+
+def agentLifecycleReasonToString(reason):
+ agentReasons = ( "unknown", "domain started", "channel event", )
+ return agentReasons[reason]
+
def myDomainEventCallback1 (conn, dom, event, detail, opaque):
print("myDomainEventCallback1 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
domEventToString(event),
@@ -517,6 +525,8 @@ def myDomainEventBlockJob2Callback(conn, dom, disk, type, status, opaque):
print("myDomainEventBlockJob2Callback: Domain %s(%s) %s on disk %s %s" % (dom.name(), dom.ID(), blockJobTypeToString(type), disk, blockJobStatusToString(status)))
def myDomainEventTunableCallback(conn, dom, params, opaque):
print("myDomainEventTunableCallback: Domain %s(%s) %s" % (dom.name(), dom.ID(), params))
+def myDomainEventAgentLifecycleCallback(conn, dom, state, reason, opaque):
+ print("myDomainEventAgentLifecycleCallback: Domain %s(%s) %s %s" % (dom.name(), dom.ID(), agentLifecycleStateToString(state), agentLifecycleReasonToString(reason)))
##########################################################################
# Network events
@@ -627,6 +637,7 @@ def main():
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, myDomainEventDeviceRemovedCallback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2, myDomainEventBlockJob2Callback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_TUNABLE, myDomainEventTunableCallback, None)
+ vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE, myDomainEventAgentLifecycleCallback, None)
vc.networkEventRegisterAny(None, libvirt.VIR_NETWORK_EVENT_ID_LIFECYCLE, myNetworkEventLifecycleCallback, None)
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index ffb6d6b..88c864c 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -197,6 +197,16 @@
cb(self, virDomain(self, _obj=dom), params, opaque)
return 0
+ def _dispatchDomainEventAgentLifecycleCallback(self, dom, state, reason, cbData):
+ """Dispatches event to python user domain agent lifecycle event callback
+ """
+
+ cb = cbData["cb"]
+ opaque = cbData["opaque"]
+
+ cb(self, virDomain(self, _obj=dom), state, reason, opaque)
+ return 0
+
def domainEventDeregisterAny(self, callbackID):
"""Removes a Domain Event Callback. De-registering for a
domain callback will disable delivery of this event type """
diff --git a/libvirt-override.c b/libvirt-override.c
index 8895289..e00d908 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -6566,6 +6566,61 @@ libvirt_virConnectDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED
}
#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
+#if LIBVIR_CHECK_VERSION(1, 2, 11)
+static int
+libvirt_virConnectDomainEventAgentLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom,
+ int state,
+ int reason,
+ void *opaque)
+{
+ PyObject *pyobj_cbData = (PyObject*)opaque;
+ PyObject *pyobj_dom;
+ PyObject *pyobj_ret = NULL;
+ PyObject *pyobj_conn;
+ PyObject *dictKey;
+ int ret = -1;
+
+ LIBVIRT_ENSURE_THREAD_STATE;
+
+ if (!(dictKey = libvirt_constcharPtrWrap("conn")))
+ goto cleanup;
+ pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
+ Py_DECREF(dictKey);
+
+ /* Create a python instance of this virDomainPtr */
+ virDomainRef(dom);
+ if (!(pyobj_dom = libvirt_virDomainPtrWrap(dom))) {
+ virDomainFree(dom);
+ goto cleanup;
+ }
+ Py_INCREF(pyobj_cbData);
+
+ /* Call the Callback Dispatcher */
+ pyobj_ret = PyObject_CallMethod(pyobj_conn,
+ (char*)"_dispatchDomainEventAgentLifecycleCallback",
+ (char*)"OiiO",
+ pyobj_dom, state, reason, pyobj_cbData);
+
+ Py_DECREF(pyobj_cbData);
+ Py_DECREF(pyobj_dom);
+
+ cleanup:
+ if (!pyobj_ret) {
+ DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
+ PyErr_Print();
+ } else {
+ Py_DECREF(pyobj_ret);
+ ret = 0;
+ }
+
+ LIBVIRT_RELEASE_THREAD_STATE;
+ return ret;
+
+}
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
+
+
static PyObject *
libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject *self,
PyObject *args)
@@ -6658,6 +6713,11 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject *self,
cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTunableCallback);
break;
#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
+#if LIBVIR_CHECK_VERSION(1, 2, 11)
+ case VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE:
+ cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventAgentLifecycleCallback);
+ break;
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
case VIR_DOMAIN_EVENT_ID_LAST:
break;
}
--
2.1.0
10 years, 1 month
[libvirt] [PATCH 0/8] Add XML validation to the APIs
by Daniel P. Berrange
This proof of concept patch extends the virDomainDefineXML
and virDomainCreateXML APIs so that they can validate
the user supplied XML document against the RNG schemas.
The virsh command will enable validation by default, it
must be turned off with --skip-validation if desired.
This series is not complete
- The network, interface, storage pool, etc APIs are
not wired up to support validation.
- Only the QEMU virt driver is wired up to validate
- The virsh edit command is not wired up to validate
It is enough to demonstrate it working with 'virsh define'
and the QEMU driver though.
The biggest problem I see is the really awful error
messages we get back from libxml2 when validation
fails :-( They are essentially useless :-(
Daniel P. Berrange (8):
Add new virDomainDefineXMLFlags public API
Add stub virDomainDefineXMLFlags impls
Add virXMLValidateAgainstSchema helper method
Fix use of flags when parsing/formatting snapshot domain XML
Don't pass VIR_DOMAIN_XML_SECURE to virDomainDefParseString in phyp
Fix flags passed to virDomainDefParseString by XenAPI driver
Given virDomainDef parser & formatter their own flags
Add support for schema validation when passing in XML
include/libvirt/libvirt-domain.h | 9 ++
include/libvirt/virterror.h | 1 +
src/bhyve/bhyve_driver.c | 21 ++-
src/conf/domain_conf.c | 315 +++++++++++++++++++-------------------
src/conf/domain_conf.h | 71 ++++++---
src/conf/snapshot_conf.c | 8 +-
src/driver-hypervisor.h | 5 +
src/esx/esx_driver.c | 23 ++-
src/hyperv/hyperv_driver.c | 3 +-
src/internal.h | 4 +
src/libvirt-domain.c | 48 ++++++
src/libvirt_private.syms | 2 +
src/libvirt_public.syms | 5 +
src/libxl/libxl_domain.c | 2 +-
src/libxl/libxl_driver.c | 35 +++--
src/libxl/libxl_migration.c | 6 +-
src/lxc/lxc_driver.c | 25 ++-
src/openvz/openvz_driver.c | 23 ++-
src/parallels/parallels_driver.c | 11 +-
src/phyp/phyp_driver.c | 7 +-
src/qemu/qemu_domain.c | 10 +-
src/qemu/qemu_driver.c | 48 ++++--
src/qemu/qemu_migration.c | 8 +-
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 19 ++-
src/remote_protocol-structs | 8 +
src/test/test_driver.c | 31 ++--
src/uml/uml_driver.c | 22 ++-
src/util/virerror.c | 6 +
src/util/virxml.c | 74 +++++++++
src/util/virxml.h | 5 +
src/vbox/vbox_common.c | 25 ++-
src/vmware/vmware_driver.c | 19 ++-
src/xen/xen_driver.c | 21 ++-
src/xen/xend_internal.c | 6 +-
src/xen/xm_internal.c | 4 +-
src/xenapi/xenapi_driver.c | 15 +-
tests/domainsnapshotxml2xmltest.c | 2 +-
tests/lxcxml2xmltest.c | 4 +-
tests/openvzutilstest.c | 2 +-
tests/qemuhotplugtest.c | 6 +-
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxml2xmltest.c | 9 +-
tests/qemuxmlnstest.c | 2 +-
tests/vmx2xmltest.c | 2 +-
tests/xmconfigtest.c | 4 +-
tests/xml2sexprtest.c | 2 +-
tests/xml2vmxtest.c | 2 +-
tools/virsh-domain.c | 19 ++-
49 files changed, 684 insertions(+), 318 deletions(-)
--
2.1.0
10 years, 1 month