[libvirt] [PATCH] storage: implement rudimentary glusterfs pool refresh
by Eric Blake
Actually put gfapi to use, by allowing the creation of a gluster
pool. Right now, all volumes are treated as raw; further patches
will allow peering into files to allow for qcow2 files and backing
chains, and reporting proper volume allocation.
I've reported a couple of glusterfs bugs; if we were to require a
minimum of (not-yet-released) glusterfs 3.5, we could use the new
glfs_readdir [1] and not worry about the bogus return value of
glfs_fini [2], but for now I'm testing with Fedora 19's glusterfs
3.4.1.
[1] http://lists.gnu.org/archive/html/gluster-devel/2013-10/msg00085.html
[2] http://lists.gnu.org/archive/html/gluster-devel/2013-10/msg00086.html
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshPool): Initial implementation.
(virStorageBackendGlusterOpen, virStorageBackendGlusterClose): New
helper functions.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Depends on these pre-req patches:
https://www.redhat.com/archives/libvir-list/2013-October/msg01266.html
https://www.redhat.com/archives/libvir-list/2013-October/msg00913.html
My next task - figuring out the use of glfs_open() to read metadata
from a file and determine backing chains.
src/storage/storage_backend_gluster.c | 138 ++++++++++++++++++++++++++++++++--
1 file changed, 133 insertions(+), 5 deletions(-)
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 2863c73..b0b6ce6 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -23,20 +23,148 @@
#include <glusterfs/api/glfs.h>
-#include "virerror.h"
#include "storage_backend_gluster.h"
#include "storage_conf.h"
+#include "viralloc.h"
+#include "virerror.h"
+#include "virlog.h"
+#include "virstoragefile.h"
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
+struct _virStorageBackendGlusterState {
+ glfs_t *vol;
+};
+
+typedef struct _virStorageBackendGlusterState virStorageBackendGlusterState;
+typedef virStorageBackendGlusterState *virStorageBackendGlusterStatePtr;
+
+static void
+virStorageBackendGlusterClose(virStorageBackendGlusterStatePtr state)
+{
+ if (!state || !state->vol)
+ return;
+ /* Yuck - glusterfs-api-3.4.1 appears to always return -1 for
+ * glfs_fini, with errno containing random data, so there's no way
+ * to tell if it succeeded. 3.4.2 is supposed to fix this.*/
+ if (glfs_fini(state->vol) < 0)
+ VIR_DEBUG("shutdown of gluster failed with errno %d", errno);
+}
+
+static virStorageBackendGlusterStatePtr
+virStorageBackendGlusterOpen(virStoragePoolObjPtr pool)
+{
+ virStorageBackendGlusterStatePtr ret = NULL;
+
+ if (VIR_ALLOC(ret) < 0)
+ return NULL;
+
+ if (!(ret->vol = glfs_new(pool->def->source.name))) {
+ virReportOOMError();
+ goto error;
+ }
+
+ /* FIXME: allow alternate transport in the pool xml */
+ if (glfs_set_volfile_server(ret->vol, "tcp",
+ pool->def->source.hosts[0].name,
+ pool->def->source.hosts[0].port) < 0 ||
+ glfs_init(ret->vol) < 0) {
+ virReportSystemError(errno, _("failed to connect to gluster %s/%s"),
+ pool->def->source.hosts[0].name,
+ pool->def->name);
+ goto error;
+ }
+
+ return ret;
+
+error:
+ virStorageBackendGlusterClose(ret);
+ return NULL;
+}
static int
virStorageBackendGlusterRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
- virStoragePoolObjPtr pool ATTRIBUTE_UNUSED)
+ virStoragePoolObjPtr pool)
{
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
- _("gluster pool type not fully supported yet"));
- return -1;
+ int ret = -1;
+ virStorageBackendGlusterStatePtr state = NULL;
+ struct {
+ struct dirent ent;
+ /* See comment below about readdir_r needing padding */
+ char padding[MAX(1, 256 - (int) (sizeof(struct dirent)
+ - offsetof(struct dirent, d_name)))];
+ } de;
+ struct dirent *ent;
+ glfs_fd_t *dir = NULL;
+ virStorageVolDefPtr vol = NULL;
+ struct statvfs sb;
+
+ if (!(state = virStorageBackendGlusterOpen(pool)))
+ goto cleanup;
+
+ /* Why oh why did glfs 3.4 decide to expose only readdir_r rather
+ * than readdir? POSIX admits that readdir_r is inherently a
+ * flawed design, because systems are not required to define
+ * NAME_MAX: http://austingroupbugs.net/view.php?id=696
+ * http://womble.decadent.org.uk/readdir_r-advisory.html
+ *
+ * Fortunately, gluster uses _only_ XFS file systems, and XFS has
+ * a known NAME_MAX of 255; so we are guaranteed that if we
+ * provide 256 bytes of tail padding, then we have enough space to
+ * avoid buffer overflow no matter whether the OS used d_name[],
+ * d_name[1], or d_name[256] in its 'struct dirent'.
+ * http://lists.gnu.org/archive/html/gluster-devel/2013-10/msg00083.html
+ */
+
+ if (!(dir = glfs_opendir(state->vol, "."))) {
+ virReportSystemError(errno, _("cannot open path '%s'"),
+ pool->def->name);
+ goto cleanup;
+ }
+ while (!(errno = glfs_readdir_r(dir, &de.ent, &ent)) && ent) {
+ if (STREQ(ent->d_name, ".") || STREQ(ent->d_name, ".."))
+ continue;
+ if (VIR_ALLOC(vol) < 0 ||
+ VIR_STRDUP(vol->name, ent->d_name) < 0)
+ goto cleanup;
+ /* FIXME - must open files to determine if they are non-raw */
+ vol->type = VIR_STORAGE_VOL_NETWORK;
+ vol->target.format = VIR_STORAGE_FILE_RAW;
+ if (virAsprintf(&vol->key, "%s/%s",
+ pool->def->name, vol->name) < 0)
+ goto cleanup;
+ if (VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count,
+ vol) < 0)
+ goto cleanup;
+ }
+ if (errno) {
+ virReportSystemError(errno, _("failed to read directory '%s'"),
+ pool->def->name);
+ goto cleanup;
+ }
+
+ if (glfs_statvfs(state->vol, ".", &sb) < 0) {
+ virReportSystemError(errno, _("cannot statvfs path '%s'"),
+ pool->def->name);
+ goto cleanup;
+ }
+
+ pool->def->capacity = ((unsigned long long)sb.f_frsize *
+ (unsigned long long)sb.f_blocks);
+ pool->def->available = ((unsigned long long)sb.f_bfree *
+ (unsigned long long)sb.f_frsize);
+ pool->def->allocation = pool->def->capacity - pool->def->available;
+
+ ret = 0;
+cleanup:
+ if (dir)
+ glfs_closedir(dir);
+ virStorageVolDefFree(vol);
+ virStorageBackendGlusterClose(state);
+ if (ret < 0)
+ virStoragePoolObjClearVols(pool);
+ return ret;
}
virStorageBackend virStorageBackendGluster = {
--
1.8.3.1
10 years, 11 months
[libvirt] the case for volatile nwfilters
by Dan Kenigsberg
I'd like oVirt to make a more extensive usage of libvirt's nwfilters in
order to implement security groups, i.e. which protocol/port/host should
be open on an interface.
Since oVirt is cetrally-managed by ovirt-engine, filter definitions
should be edited there and kept in its database. However, libivrt's
domain xml requires to have a locally-defined filter as well:
<devices>
<interface type='bridge'>
<filterref filter='filter-name'/>
</interface>
</devices>
We can leave with it by defining an ad-hoc filter before staring a VM,
deleting it after the VM stops, and collecting garbage (due to system
crashes) occasionally.
It would be nicer if we could instead have just-in-time filter
definition such as
<devices>
<interface type='bridge'>
<filter name='nameless'>
<rule/>
<rule/>
<rule/>
</filter>
</interface>
</devices>
avoiding nwfilter persistence. Would something like this be beneficial
to other libvirt users? Would it be easy to implement within libvirt?
Regards,
Dan.
10 years, 11 months
[libvirt] [PATCH] nodedev_hal: fix segfault when virDBusGetSystemBus fails
by Ryota Ozaki
Thie patch fixes the segfault:
error : nodeStateInitialize:658 : DBus not available,
disabling HAL driver: internal error: Unable to get DBus
system bus connection: Failed to connect to socket
/var/run/dbus/system_bus_socket: No such file or directory
error : nodeStateInitialize:719 : ?:
Caught Segmentation violation dumping internal log buffer:
This segfault occurs at the below VIR_ERROR:
failure:
if (dbus_error_is_set(&err)) {
VIR_ERROR(_("%s: %s"), err.name, err.message);
When virDBusGetSystemBus fails, the code jumps to the above failure
path. However, the err variable is not correctly initialized
before calling virDBusGetSystemBus. As a result, dbus_error_is_set
may pass over the uninitialized err variable whose name or
message may point to somewhere unknown memory region, which
causes a segfault on VIR_ERROR.
The new code initializes the err variable before calling
virDBusGetSystemBus.
Signed-off-by: Ryota Ozaki <ozaki.ryota(a)gmail.com>
---
src/node_device/node_device_hal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index d94767c..a019a07 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -652,6 +652,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
}
nodeDeviceLock(driverState);
+ dbus_error_init(&err);
if (!(sysbus = virDBusGetSystemBus())) {
virErrorPtr verr = virGetLastError();
VIR_ERROR(_("DBus not available, disabling HAL driver: %s"),
@@ -660,7 +661,6 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
goto failure;
}
- dbus_error_init(&err);
hal_ctx = libhal_ctx_new();
if (hal_ctx == NULL) {
VIR_ERROR(_("libhal_ctx_new returned NULL"));
--
1.8.4
10 years, 11 months
[libvirt] [PATCH] maint: update to latest gnulib
by Eric Blake
Since we haven't quite frozen yet, it's time to pick up some
fixes. I know at least cygwin benefits from this update.
* .gnulib: Update to latest, in part for cygwin compilation.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the gnulib rule.
* .gnulib 4a5ee89...8f74258 (33):
> Revert "error: make the module depend on vfprintf-posix"
> maint.mk: fix "release" target to build _version
> maint.mk: get current gnulib revision correctly.
> install-reloc: Support multi-binary installation.
> selinux-h: really build without selinux when library is missing
> regex: also remove dependency on HAVE_WCSCOLL
> xfreopen: fix typo: s/frepoen/freopen/
> regex: don't depend on wcscoll
> error: add the printf attribute to a static function
> error: make the module depend on vfprintf-posix
> fpending, obstack, strerror-override: use pure+const function attrs
> extern-inline: make safe for -Wundef usage
> mkfifo-tests, etc.: allow HP-UX 11.11 bug
> acl: allow cross-compilation to Gentoo
> mgetgroups: remove dependency on realloc-gnu
> regex-tests: port to HP-UX 11.11
> verify: document some 'assume' pitfalls
> strtoumax: fix another typo in previous commit
> strtoumax: fix typo in previous commit.
> strtoumax: port to Solaris 8
> autoupdate
> strtoimax, strtoumax: port to HP-UX 11.11
> strtoimax: port to HP-UX 11.11
> New module 'count-trailing-zeros'.
> count-leading-zeros: port to MSC; support types wider than 64 bits
> count-one-bits: port to MSC; support types wider than 64 bits
> mountlist: fix resource leak with MOUNTED_INTERIX_STATVFS
> tests: improve diagnostic when an assertion fails
> verify: new macro 'assume'
> autoupdate
> dup2, dup3: work around another cygwin crasher
> getdtablesize: work around cygwin issue
> pmccabe2html: escaping of special characters
.gnulib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gnulib b/.gnulib
index 4a5ee89..8f74258 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 4a5ee89c8a8be7350a8fd8ca1bacb196a190e492
+Subproject commit 8f7425866463f994538584d1dd7211603b8b0550
--
1.8.3.1
10 years, 11 months
[libvirt] [PATCH] Fix race condition reconnecting to vms & loading configs
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The following sequence
1. Define a persistent QMEU guest
2. Start the QEMU guest
3. Stop libvirtd
4. Kill the QEMU process
5. Start libvirtd
6. List persistent guets
At the last step, the previously running persistent guest
will be missing. This is because of a race condition in the
QEMU driver startup code. It does
1. Load all VM state files
2. Spawn thread to reconnect to each VM
3. Load all VM config files
Only at the end of step 3, does the 'virDomainObjPtr' get
marked as "persistent". There is therefore a window where
the thread reconnecting to the VM will remove the persistent
VM from the list.
The easy fix is to simply switch the order of steps 2 & 3.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_driver.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c613967..9c3daad 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -816,8 +816,6 @@ qemuStateInitialize(bool privileged,
conn = virConnectOpen(cfg->uri);
- qemuProcessReconnectAll(conn, qemu_driver);
-
/* Then inactive persistent configs */
if (virDomainObjListLoadAllConfigs(qemu_driver->domains,
cfg->configDir,
@@ -828,6 +826,7 @@ qemuStateInitialize(bool privileged,
NULL, NULL) < 0)
goto error;
+ qemuProcessReconnectAll(conn, qemu_driver);
virDomainObjListForEach(qemu_driver->domains,
qemuDomainSnapshotLoad,
--
1.8.3.1
10 years, 11 months
[libvirt] [libvirt-glib][PATCH V3] Add filterref and filterref parameter support.
by Ian Main
This patch adds support for setting filterref's on interfaces. Also
supported are parameters to the filterref's.
V2:
- alphabetical orderized (don't look it up!) Makefile.am
- s/set_filter/set_name/ s/get_filter/get_name/
- remove trailing whitespace.
- fix missing line.
- add return_val_if_fail check.
- moved qcow fix in demo to a new patch.
- fixed new_from_xml().
V3:
- added g_debug in add_filterref_parameter();
- more fixing new_from_xml().
- orderized (I like this word now) libvirt-gconfig.h includes.
Signed-off-by: Ian Main <imain(a)redhat.com>
---
examples/config-demo.py | 7 +
libvirt-gconfig/Makefile.am | 4 +
...-gconfig-domain-interface-filterref-parameter.c | 101 +++++++++++++
...-gconfig-domain-interface-filterref-parameter.h | 75 ++++++++++
.../libvirt-gconfig-domain-interface-filterref.c | 159 +++++++++++++++++++++
.../libvirt-gconfig-domain-interface-filterref.h | 76 ++++++++++
libvirt-gconfig/libvirt-gconfig-domain-interface.c | 41 ++++++
libvirt-gconfig/libvirt-gconfig-domain-interface.h | 5 +
libvirt-gconfig/libvirt-gconfig.h | 2 +
libvirt-gconfig/libvirt-gconfig.sym | 18 +++
10 files changed, 488 insertions(+)
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.h
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.h
diff --git a/examples/config-demo.py b/examples/config-demo.py
index 09b9e89..367d99a 100644
--- a/examples/config-demo.py
+++ b/examples/config-demo.py
@@ -35,6 +35,13 @@ domain.add_device(disk)
interface = LibvirtGConfig.DomainInterfaceNetwork.new()
interface.set_source("default")
+filterref = LibvirtGConfig.DomainInterfaceFilterref.new()
+filterref.set_name("clean-traffic")
+parameter = LibvirtGConfig.DomainInterfaceFilterrefParameter.new()
+parameter.set_name("IP")
+parameter.set_value("205.23.12.40")
+filterref.add_parameter(parameter)
+interface.set_filterref(filterref)
domain.add_device(interface)
interface = LibvirtGConfig.DomainInterfaceUser.new()
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 35dc978..0793da1 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -47,6 +47,8 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-domain-input.h \
libvirt-gconfig-domain-interface.h \
libvirt-gconfig-domain-interface-bridge.h \
+ libvirt-gconfig-domain-interface-filterref.h \
+ libvirt-gconfig-domain-interface-filterref-parameter.h \
libvirt-gconfig-domain-interface-network.h \
libvirt-gconfig-domain-interface-user.h \
libvirt-gconfig-domain-memballoon.h \
@@ -129,6 +131,8 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-domain-input.c \
libvirt-gconfig-domain-interface.c \
libvirt-gconfig-domain-interface-bridge.c \
+ libvirt-gconfig-domain-interface-filterref.c \
+ libvirt-gconfig-domain-interface-filterref-parameter.c \
libvirt-gconfig-domain-interface-network.c \
libvirt-gconfig-domain-interface-user.c \
libvirt-gconfig-domain-memballoon.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c
new file mode 100644
index 0000000..e697e86
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c
@@ -0,0 +1,101 @@
+/*
+ * libvirt-gconfig-domain-interface-filterref-parameter.c:
+ * libvirt filterref parameters
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Ian Main <imain(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER, GVirConfigDomainInterfaceFilterrefParameterPrivate))
+
+struct _GVirConfigDomainInterfaceFilterrefParameterPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainInterfaceFilterrefParameter, gvir_config_domain_interface_filterref_parameter, GVIR_CONFIG_TYPE_OBJECT);
+
+static void gvir_config_domain_interface_filterref_parameter_class_init(GVirConfigDomainInterfaceFilterrefParameterClass *klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigDomainInterfaceFilterrefParameterPrivate));
+}
+
+static void gvir_config_domain_interface_filterref_parameter_init(GVirConfigDomainInterfaceFilterrefParameter *parameter)
+{
+ g_debug("Init GVirConfigDomainInterfaceFilterrefParameter=%p", parameter);
+
+ parameter->priv = GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER_GET_PRIVATE(parameter);
+}
+
+GVirConfigDomainInterfaceFilterrefParameter *gvir_config_domain_interface_filterref_parameter_new(void)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER,
+ "parameter", NULL);
+ return GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER(object);
+}
+
+GVirConfigDomainInterfaceFilterrefParameter *
+gvir_config_domain_interface_filterref_parameter_new_from_xml(const gchar *xml, GError **error)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER,
+ "parameter",
+ NULL,
+ xml,
+ error);
+
+ return GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER(object);
+}
+
+void gvir_config_domain_interface_filterref_parameter_set_name(GVirConfigDomainInterfaceFilterrefParameter *parameter, const gchar *name)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF_PARAMETER(parameter));
+ gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(parameter),
+ "name", name, NULL);
+}
+
+void gvir_config_domain_interface_filterref_parameter_set_value(GVirConfigDomainInterfaceFilterrefParameter *parameter, const gchar *value)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF_PARAMETER(parameter));
+ gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(parameter),
+ "value", value, NULL);
+}
+
+const gchar *gvir_config_domain_interface_filterref_parameter_get_name(GVirConfigDomainInterfaceFilterrefParameter *parameter)
+{
+ return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(parameter),
+ NULL,
+ "name");
+}
+const gchar *gvir_config_domain_interface_filterref_parameter_get_value(GVirConfigDomainInterfaceFilterrefParameter *parameter)
+{
+ return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(parameter),
+ NULL,
+ "value");
+}
+
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.h b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.h
new file mode 100644
index 0000000..a768c84
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.h
@@ -0,0 +1,75 @@
+/*
+ * libvirt-gconfig-domain-interface-filterref-parameter.h:
+ * libvirt filterref parameters
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Ian Main <imain(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD)
+#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER (gvir_config_domain_interface_filterref_parameter_get_type ())
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER, GVirConfigDomainInterfaceFilterrefParameter))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER, GVirConfigDomainInterfaceFilterrefParameterClass))
+#define GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF_PARAMETER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER))
+#define GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF_PARAMETER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER, GVirConfigDomainInterfaceFilterrefParameterClass))
+
+typedef struct _GVirConfigDomainInterfaceFilterrefParameter GVirConfigDomainInterfaceFilterrefParameter;
+typedef struct _GVirConfigDomainInterfaceFilterrefParameterPrivate GVirConfigDomainInterfaceFilterrefParameterPrivate;
+typedef struct _GVirConfigDomainInterfaceFilterrefParameterClass GVirConfigDomainInterfaceFilterrefParameterClass;
+
+struct _GVirConfigDomainInterfaceFilterrefParameter
+{
+ GVirConfigObject parent;
+
+ GVirConfigDomainInterfaceFilterrefParameterPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainInterfaceFilterrefParameterClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_domain_interface_filterref_parameter_get_type(void);
+
+GVirConfigDomainInterfaceFilterrefParameter *gvir_config_domain_interface_filterref_parameter_new(void);
+
+GVirConfigDomainInterfaceFilterrefParameter *
+gvir_config_domain_interface_filterref_parameter_new_from_xml(const gchar *xml, GError **error);
+
+void gvir_config_domain_interface_filterref_parameter_set_name(GVirConfigDomainInterfaceFilterrefParameter *parameter, const gchar *name);
+void gvir_config_domain_interface_filterref_parameter_set_value(GVirConfigDomainInterfaceFilterrefParameter *parameter, const gchar *value);
+const gchar *gvir_config_domain_interface_filterref_parameter_get_name(GVirConfigDomainInterfaceFilterrefParameter *parameter);
+const gchar *gvir_config_domain_interface_filterref_parameter_get_value(GVirConfigDomainInterfaceFilterrefParameter *parameter);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_FILTERREF_PARAMETER_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.c
new file mode 100644
index 0000000..c192249
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.c
@@ -0,0 +1,159 @@
+/*
+ * libvirt-gconfig-domain-interface-network-filterref.c:
+ * libvirt filter reference config.
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Ian Main <imain(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF, GVirConfigDomainInterfaceFilterrefPrivate))
+
+struct _GVirConfigDomainInterfaceFilterrefPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainInterfaceFilterref, gvir_config_domain_interface_filterref, GVIR_CONFIG_TYPE_OBJECT);
+
+static void gvir_config_domain_interface_filterref_class_init(GVirConfigDomainInterfaceFilterrefClass *klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigDomainInterfaceFilterrefPrivate));
+}
+
+static void gvir_config_domain_interface_filterref_init(GVirConfigDomainInterfaceFilterref *filterref)
+{
+ g_debug("Init GVirConfigDomainInterfaceFilterref=%p", filterref);
+
+ filterref->priv = GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_GET_PRIVATE(filterref);
+}
+
+
+GVirConfigDomainInterfaceFilterref *gvir_config_domain_interface_filterref_new(void)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF,
+ "filterref", NULL);
+ return GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF(object);
+}
+
+GVirConfigDomainInterfaceFilterref *gvir_config_domain_interface_filterref_new_from_xml(const gchar *xml,
+ GError **error)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF,
+ "filterref", NULL, xml, error);
+ if (gvir_config_object_get_attribute(object, NULL, "filter") == NULL) {
+ g_object_unref(G_OBJECT(object));
+ return NULL;
+ }
+ return GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF(object);
+}
+
+void gvir_config_domain_interface_filterref_set_name(GVirConfigDomainInterfaceFilterref *filterref,
+ const char *filter)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(filterref));
+
+ gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(filterref),
+ "filter", filter, NULL);
+}
+
+const char *gvir_config_domain_interface_filterref_get_name(GVirConfigDomainInterfaceFilterref *filterref)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(filterref), NULL);
+ return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(filterref),
+ NULL,
+ "filter");
+}
+
+void gvir_config_domain_interface_filterref_add_parameter(GVirConfigDomainInterfaceFilterref *filterref,
+ GVirConfigDomainInterfaceFilterrefParameter *parameter)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(filterref));
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF_PARAMETER(parameter));
+
+ gvir_config_object_attach_add(GVIR_CONFIG_OBJECT(filterref),
+ GVIR_CONFIG_OBJECT(parameter));
+}
+
+struct GetParameterData {
+ GVirConfigXmlDoc *doc;
+ GList *parameters;
+};
+
+
+static gboolean add_filterref_parameter(xmlNodePtr node, gpointer opaque)
+{
+ struct GetParameterData* data = (struct GetParameterData*)opaque;
+ GVirConfigObject *parameter;
+
+ if (g_strcmp0((const gchar *)node->name, "parameter") != 0) {
+ g_debug("unexpected node %s", node->name);
+ return TRUE;
+ }
+
+ parameter = gvir_config_object_new_from_tree(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF_PARAMETER,
+ data->doc, NULL, node);
+ if (parameter != NULL)
+ data->parameters = g_list_append(data->parameters, parameter);
+ else
+ g_debug("Failed to parse %s node", node->name);
+
+ return TRUE;
+}
+
+/**
+ * gvir_config_domain_interface_filterref_get_parameters:
+ * @filterref: a #GVirConfigDomainInterfaceFilterref
+ *
+ * Gets the list of parameters attached to @filterref. The returned list should be
+ * freed with g_list_free(), after its elements have been unreffed with
+ * g_object_unref().
+ *
+ * Returns: (element-type LibvirtGConfig.DomainInterfaceFilterrefParameter) (transfer full):
+ * a newly allocated #GList of #GVirConfigDomainInterfaceFilterrefParameter.
+ */
+GList *gvir_config_domain_interface_filterref_get_parameters(GVirConfigDomainInterfaceFilterref *filterref)
+{
+ struct GetParameterData data;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(filterref), NULL);
+
+ g_object_get(G_OBJECT(filterref), "doc", &data.doc, NULL);
+ data.parameters = NULL;
+
+ gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(filterref),
+ NULL,
+ add_filterref_parameter,
+ &data);
+
+ if (data.doc != NULL) {
+ g_object_unref(G_OBJECT(data.doc));
+ }
+
+ return data.parameters;
+}
+
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.h b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.h
new file mode 100644
index 0000000..4a2bfd4
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.h
@@ -0,0 +1,76 @@
+/*
+ * libvirt-gconfig-domain-interface-network-filterref.h: libvirt filter reference config
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Ian Main <imain(a)redhat.com>
+ */
+
+#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD)
+#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_FILTERREF_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_FILTERREF_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF (gvir_config_domain_interface_filterref_get_type ())
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF, GVirConfigDomainInterfaceFilterref))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF, GVirConfigDomainInterfaceFilterrefClass))
+#define GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF))
+#define GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF, GVirConfigDomainInterfaceFilterrefClass))
+
+typedef struct _GVirConfigDomainInterfaceFilterref GVirConfigDomainInterfaceFilterref;
+typedef struct _GVirConfigDomainInterfaceFilterrefPrivate GVirConfigDomainInterfaceFilterrefPrivate;
+typedef struct _GVirConfigDomainInterfaceFilterrefClass GVirConfigDomainInterfaceFilterrefClass;
+
+struct _GVirConfigDomainInterfaceFilterref
+{
+ GVirConfigObject parent;
+
+ GVirConfigDomainInterfaceFilterrefPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainInterfaceFilterrefClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_domain_interface_filterref_get_type(void);
+
+GVirConfigDomainInterfaceFilterref *gvir_config_domain_interface_filterref_new(void);
+
+GVirConfigDomainInterfaceFilterref *
+gvir_config_domain_interface_filterref_new_from_xml(const gchar *xml, GError **error);
+
+void gvir_config_domain_interface_filterref_set_name(GVirConfigDomainInterfaceFilterref *filterref,
+ const char *filter);
+const char *gvir_config_domain_interface_filterref_get_name(GVirConfigDomainInterfaceFilterref *filterref);
+
+void gvir_config_domain_interface_filterref_add_parameter(GVirConfigDomainInterfaceFilterref *filterref,
+ GVirConfigDomainInterfaceFilterrefParameter *parameter);
+GList *gvir_config_domain_interface_filterref_get_parameters(GVirConfigDomainInterfaceFilterref *filterref);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_FILTERREF_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.c b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
index 86a0c34..ce1b3f0 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
@@ -131,6 +131,47 @@ const char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *in
"model", "type");
}
+/**
+ * gvir_config_domain_interface_set_filterref:
+ * @interface: a #GVirConfigDomainInterface
+ * @filterref: (allow-none): the filterref to set
+ */
+void gvir_config_domain_interface_set_filterref(GVirConfigDomainInterface *interface,
+ GVirConfigDomainInterfaceFilterref *filterref)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface));
+ g_return_if_fail(filterref == NULL || GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(filterref));
+
+ gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(interface),
+ "filterref",
+ GVIR_CONFIG_OBJECT(filterref));
+}
+
+/**
+ * gvir_config_domain_interface_get_filterref:
+ * @interface: a #GVirConfigDomainInterface
+ *
+ * Gets the filterref associated with the @interface
+ *
+ * Returns: (transfer full): A #GVirConfigDomainInterfaceFilterref. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
+ */
+
+GVirConfigDomainInterfaceFilterref *gvir_config_domain_interface_get_filterref(GVirConfigDomainInterface *interface)
+{
+ GVirConfigObject *object;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface), NULL);
+
+ object = gvir_config_object_get_child_with_type
+ (GVIR_CONFIG_OBJECT(interface),
+ "filterref",
+ GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF);
+
+ return GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF(object);
+}
+
+
G_GNUC_INTERNAL GVirConfigDomainDevice *
gvir_config_domain_interface_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.h b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
index 65c5d0b..2b0c22f 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
@@ -27,6 +27,8 @@
#ifndef __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_H__
#define __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_H__
+#include <libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.h>
+
G_BEGIN_DECLS
#define GVIR_CONFIG_TYPE_DOMAIN_INTERFACE (gvir_config_domain_interface_get_type ())
@@ -76,6 +78,9 @@ const char *gvir_config_domain_interface_get_ifname(GVirConfigDomainInterface *i
GVirConfigDomainInterfaceLinkState gvir_config_domain_interface_get_link_state(GVirConfigDomainInterface *interface);
const char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface);
const char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *interface);
+void gvir_config_domain_interface_set_filterref(GVirConfigDomainInterface *interface,
+ GVirConfigDomainInterfaceFilterref *filterref);
+GVirConfigDomainInterfaceFilterref *gvir_config_domain_interface_get_filterref(GVirConfigDomainInterface *interface);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 03e8ce7..af80241 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -64,6 +64,8 @@
#include <libvirt-gconfig/libvirt-gconfig-domain-input.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-interface.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-interface-network.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-interface-user.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-memballoon.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 72eafc1..a5f8b05 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -608,6 +608,24 @@ global:
gvir_config_domain_graphics_rdp_set_replace_user;
gvir_config_object_new_from_xml;
+
+ gvir_config_domain_interface_set_filterref;
+ gvir_config_domain_interface_get_filterref;
+
+ gvir_config_domain_interface_filterref_get_type;
+ gvir_config_domain_interface_filterref_new;
+ gvir_config_domain_interface_filterref_new_from_xml;
+ gvir_config_domain_interface_filterref_set_name;
+ gvir_config_domain_interface_filterref_get_name;
+ gvir_config_domain_interface_filterref_add_parameter;
+ gvir_config_domain_interface_filterref_get_parameters;
+ gvir_config_domain_interface_filterref_parameter_get_type;
+ gvir_config_domain_interface_filterref_parameter_new;
+ gvir_config_domain_interface_filterref_parameter_new_from_xml;
+ gvir_config_domain_interface_filterref_parameter_set_name;
+ gvir_config_domain_interface_filterref_parameter_set_value;
+ gvir_config_domain_interface_filterref_parameter_get_name;
+ gvir_config_domain_interface_filterref_parameter_get_value;
} LIBVIRT_GCONFIG_0.1.7;
# .... define new API here using predicted next version number ....
--
1.8.1.4
10 years, 11 months
[libvirt] [PATCH] Improve debugging of job enter/exit code
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
In debugging a recent oVirt/libvirt race condition, I was very
frustrated by lack of logging in the job enter/exit code. This
patch adds some key data which would have been useful in by
debugging attempts.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_domain.c | 45 +++++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b8aec2d..81d0ba9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1014,6 +1014,12 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
bool nested = job == QEMU_JOB_ASYNC_NESTED;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ VIR_DEBUG("Starting %s: %s (async=%s vm=%p name=%s)",
+ job == QEMU_JOB_ASYNC ? "async job" : "job",
+ qemuDomainJobTypeToString(job),
+ qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
+ obj, obj->def->name);
+
priv->jobs_queued++;
if (virTimeMillisNow(&now) < 0) {
@@ -1032,11 +1038,13 @@ retry:
}
while (!nested && !qemuDomainNestedJobAllowed(priv, job)) {
+ VIR_DEBUG("Waiting for async job (vm=%p name=%s)", obj, obj->def->name);
if (virCondWaitUntil(&priv->job.asyncCond, &obj->parent.lock, then) < 0)
goto error;
}
while (priv->job.active) {
+ VIR_DEBUG("Waiting for job (vm=%p name=%s)", obj, obj->def->name);
if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0)
goto error;
}
@@ -1049,14 +1057,16 @@ retry:
qemuDomainObjResetJob(priv);
if (job != QEMU_JOB_ASYNC) {
- VIR_DEBUG("Starting job: %s (async=%s)",
+ VIR_DEBUG("Started job: %s (async=%s vm=%p name=%s)",
qemuDomainJobTypeToString(job),
- qemuDomainAsyncJobTypeToString(priv->job.asyncJob));
+ qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
+ obj, obj->def->name);
priv->job.active = job;
priv->job.owner = virThreadSelfID();
} else {
- VIR_DEBUG("Starting async job: %s",
- qemuDomainAsyncJobTypeToString(asyncJob));
+ VIR_DEBUG("Started async job: %s (vm=%p name=%s)",
+ qemuDomainAsyncJobTypeToString(asyncJob),
+ obj, obj->def->name);
qemuDomainObjResetAsyncJob(priv);
priv->job.asyncJob = asyncJob;
priv->job.asyncOwner = virThreadSelfID();
@@ -1161,9 +1171,10 @@ bool qemuDomainObjEndJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
priv->jobs_queued--;
- VIR_DEBUG("Stopping job: %s (async=%s)",
+ VIR_DEBUG("Stopping job: %s (async=%s vm=%p name=%s)",
qemuDomainJobTypeToString(job),
- qemuDomainAsyncJobTypeToString(priv->job.asyncJob));
+ qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
+ obj, obj->def->name);
qemuDomainObjResetJob(priv);
if (qemuDomainTrackJob(job))
@@ -1180,8 +1191,9 @@ qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
priv->jobs_queued--;
- VIR_DEBUG("Stopping async job: %s",
- qemuDomainAsyncJobTypeToString(priv->job.asyncJob));
+ VIR_DEBUG("Stopping async job: %s (vm=%p name=%s)",
+ qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
+ obj, obj->def->name);
qemuDomainObjResetAsyncJob(priv);
qemuDomainObjSaveJob(driver, obj);
@@ -1195,8 +1207,9 @@ qemuDomainObjAbortAsyncJob(virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
- VIR_DEBUG("Requesting abort of async job: %s",
- qemuDomainAsyncJobTypeToString(priv->job.asyncJob));
+ VIR_DEBUG("Requesting abort of async job: %s (vm=%p name=%s)",
+ qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
+ obj, obj->def->name);
priv->job.asyncAbort = true;
}
@@ -1232,6 +1245,8 @@ qemuDomainObjEnterMonitorInternal(virQEMUDriverPtr driver,
" monitor without asking for a nested job is dangerous");
}
+ VIR_DEBUG("Entering monitor (mon=%p vm=%p name=%s)",
+ priv->mon, obj, obj->def->name);
virObjectLock(priv->mon);
virObjectRef(priv->mon);
ignore_value(virTimeMillisNow(&priv->monStart));
@@ -1253,6 +1268,8 @@ qemuDomainObjExitMonitorInternal(virQEMUDriverPtr driver,
virObjectUnlock(priv->mon);
virObjectLock(obj);
+ VIR_DEBUG("Exited monitor (mon=%p vm=%p name=%s)",
+ priv->mon, obj, obj->def->name);
priv->monStart = 0;
if (!hasRefs)
@@ -1321,6 +1338,8 @@ qemuDomainObjEnterAgent(virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
+ VIR_DEBUG("Entering agent (agent=%p vm=%p name=%s)",
+ priv->agent, obj, obj->def->name);
virObjectLock(priv->agent);
virObjectRef(priv->agent);
ignore_value(virTimeMillisNow(&priv->agentStart));
@@ -1344,6 +1363,8 @@ qemuDomainObjExitAgent(virDomainObjPtr obj)
virObjectUnlock(priv->agent);
virObjectLock(obj);
+ VIR_DEBUG("Exited agent (agent=%p vm=%p name=%s)",
+ priv->agent, obj, obj->def->name);
priv->agentStart = 0;
if (!hasRefs)
@@ -1352,6 +1373,8 @@ qemuDomainObjExitAgent(virDomainObjPtr obj)
void qemuDomainObjEnterRemote(virDomainObjPtr obj)
{
+ VIR_DEBUG("Entering remote (vm=%p name=%s)",
+ obj, obj->def->name);
virObjectRef(obj);
virObjectUnlock(obj);
}
@@ -1359,6 +1382,8 @@ void qemuDomainObjEnterRemote(virDomainObjPtr obj)
void qemuDomainObjExitRemote(virDomainObjPtr obj)
{
virObjectLock(obj);
+ VIR_DEBUG("Exited remote (vm=%p name=%s)",
+ obj, obj->def->name);
virObjectUnref(obj);
}
--
1.8.3.1
10 years, 11 months
[libvirt] [PATCH] Improve debugging of QEMU start/stop
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Include reference of the VM object pointer and name in debug
logs for QEMU start/stop functions. Also make sure we log the
PID that we started, since it isn't available elsewhere in the
logs.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index bdffdf8..dd7566b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3499,6 +3499,9 @@ int qemuProcessStart(virConnectPtr conn,
virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
+ VIR_DEBUG("vm=%p name=%s id=%d pid=%d",
+ vm, vm->def->name, vm->def->id, vm->pid);
+
/* Okay, these are just internal flags,
* but doesn't hurt to check */
virCheckFlags(VIR_QEMU_PROCESS_START_COLD |
@@ -3845,23 +3848,11 @@ int qemuProcessStart(virConnectPtr conn,
_("Domain %s didn't show up"), vm->def->name);
ret = -1;
}
-#if 0
- } else if (ret == -2) {
- /*
- * XXX this is bogus. It isn't safe to set vm->pid = child
- * because the child no longer exists.
- */
-
- /* The virCommand process that launches the daemon failed. Pending on
- * when it failed (we can't determine for sure), there may be
- * extra info in the domain log (if the hook failed for example).
- *
- * Pretend like things succeeded, and let 'WaitForMonitor' report
- * the log contents for us.
- */
- vm->pid = child;
- ret = 0;
-#endif
+ VIR_DEBUG("QEMU vm=%p name=%s running with pid=%llu",
+ vm, vm->def->name, (unsigned long long)vm->pid);
+ } else {
+ VIR_DEBUG("QEMU vm=%p name=%s failed to spawn",
+ vm, vm->def->name);
}
VIR_DEBUG("Writing early domain status to disk");
@@ -4085,8 +4076,8 @@ qemuProcessKill(virDomainObjPtr vm, unsigned int flags)
{
int ret;
- VIR_DEBUG("vm=%s pid=%d flags=%x",
- vm->def->name, vm->pid, flags);
+ VIR_DEBUG("vm=%p name=%s pid=%d flags=%x",
+ vm, vm->def->name, vm->pid, flags);
if (!(flags & VIR_QEMU_PROCESS_KILL_NOCHECK)) {
if (!virDomainObjIsActive(vm)) {
@@ -4126,8 +4117,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
char ebuf[1024];
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
- VIR_DEBUG("Shutting down VM '%s' pid=%d flags=%x",
- vm->def->name, vm->pid, flags);
+ VIR_DEBUG("Shutting down vm=%p name=%s id=%d pid=%d flags=%x",
+ vm, vm->def->name, vm->def->id, vm->pid, flags);
if (!virDomainObjIsActive(vm)) {
VIR_DEBUG("VM '%s' not active", vm->def->name);
--
1.8.3.1
10 years, 11 months
[libvirt] [PATCH] storage: use correct type for array count
by Eric Blake
Using size_t counts will let us use VIR_APPEND_ELEMENT and friends.
* src/conf/storage_conf.h (_virStoragePoolObjList)
(_virStorageVolDefList): Track list sizes with size_t.
* src/storage/storage_backend_rbd.c
(virStorageBackendRBDRefreshPool): Fix type fallout.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/conf/storage_conf.h | 4 ++--
src/storage/storage_backend_rbd.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 251e897..d13cb99 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -112,7 +112,7 @@ struct _virStorageVolDef {
typedef struct _virStorageVolDefList virStorageVolDefList;
typedef virStorageVolDefList *virStorageVolDefListPtr;
struct _virStorageVolDefList {
- unsigned int count;
+ size_t count;
virStorageVolDefPtr *objs;
};
@@ -341,7 +341,7 @@ struct _virStoragePoolObj {
typedef struct _virStoragePoolObjList virStoragePoolObjList;
typedef virStoragePoolObjList *virStoragePoolObjListPtr;
struct _virStoragePoolObjList {
- unsigned int count;
+ size_t count;
virStoragePoolObjPtr *objs;
};
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 4e18bf9..b7a41c2 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -381,7 +381,7 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn,
pool->volumes.objs[pool->volumes.count++] = vol;
}
- VIR_DEBUG("Found %d images in RBD pool %s",
+ VIR_DEBUG("Found %zu images in RBD pool %s",
pool->volumes.count, pool->def->source.name);
ret = 0;
--
1.8.3.1
10 years, 11 months