[libvirt] [PATCH] Return right error code for baselineCPU
by Don Dugger
This Python interface code is returning a -1 on errors for the
`baselineCPU' API. Since this API is supposed to return a pointer
the error return value should really be VIR_PY_NONE.
NB: I've checked all the other APIs in this file and this is the
only pointer API that is returning -1.
Signed-off-by: Don Dugger <donald.d.dugger(a)intel.com>
---
python/libvirt-override.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index c60747d..b471605 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -4471,13 +4471,13 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
ncpus = PyList_Size(list);
if (VIR_ALLOC_N_QUIET(xmlcpus, ncpus) < 0)
- return VIR_PY_INT_FAIL;
+ return VIR_PY_NONE;
for (i = 0; i < ncpus; i++) {
xmlcpus[i] = PyString_AsString(PyList_GetItem(list, i));
if (xmlcpus[i] == NULL) {
VIR_FREE(xmlcpus);
- return VIR_PY_INT_FAIL;
+ return VIR_PY_NONE;
}
}
}
@@ -4489,13 +4489,13 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
VIR_FREE(xmlcpus);
if (base_cpu == NULL)
- return VIR_PY_INT_FAIL;
+ return VIR_PY_NONE;
pybase_cpu = PyString_FromString(base_cpu);
VIR_FREE(base_cpu);
if (pybase_cpu == NULL)
- return VIR_PY_INT_FAIL;
+ return VIR_PY_NONE;
return pybase_cpu;
}
--
1.7.10.4
--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
n0ano(a)n0ano.com
Ph: 303/443-3786
10 years, 11 months
[libvirt] [PATCH 00/34] network events feature v2
by Cédric Bosdonnat
This patch serie is replacing the previous one I sent. The improvements that
were made in between are:
* splitting the 2 huge commits into smaller reviewable ones.
* Get rid of the huge union in virDomainEvent and use virObjects instead.
* No domain events-related code in object_event.c. I left the network events
related code there as it would be pretty small in a separate set of files.
* Rebased on the python split repository
I saw something weird in the domain events code when working on this:
VIR_DOMAIN_EVENT_LAST is defined if VIR_ENUM_SENTINELS is defined, but is
generally used independently of it. I did the same for the VIR_NETWORK_EVENT_LAST
thought I'm not sure that's the correct thing to do.
These changes are all about bringing events for network object like the
ones existing for domains. This feature is needed for virt-manager to
refresh its UI when networks are started/destroyed/defined/undefined.
The network events are implemented in the test, bridge network and remote
drivers ATM.
Cédric Bosdonnat (34):
Added domain start/stop/define/undefine event unit tests
Rename virDomainEventCallback to virObjectEventCallback
Renamed virDomainMeta to virObjectMeta
Renamed virDomainEventQueue to virObjectEventQueue
Renamed virDomainEventState to virObjectEventState
Renamed virDomainEventCallbackList* to virObjectEventCallbackList*
Created virObjectEventStateRegisterID
virObject-ified virDomainEvent
Create virDomainEventLifecycle to start removing the huge union
Renamed virDomainEventNew* to virDomainEventLifecycleNew*
Renamed virDomainEventNewInternal to virDomainEventNew
Create virDomainEventRTCChange to get rid of the huge union
Created virDomainEventWatchdog to get rid of the huge union
Created virDomainEventIOError
Created virDomainEventGraphics
Created virDomainEventBlockJob
Create virDomainEventDiskChange
Created virDomainEventTrayChange
Created virDomainEventBalloonChange
Created virDomainEventDeviceRemoved and removed the huge union
Changed the remaining domain event creation methods results to void*
Removed virDomainEventPtr in favor of virObjectEventPtr
Add object event namespaces for the event IDs
Renamed virDomainEventTimer to virObjectEventTimer
Split the virObjectEvent and virDomainEvent* to separate them after
Extracted common parts of domain_event.[ch] to object_event.[ch]
Added virNetworkEventLifecycle object
Added API for network events similar to the one from Domain events
test driver: renamed testDomainEventQueue into testObjectEventQueue
test driver: implemented network events
Add network events unit tests
daemon/remote.c: renamed remoteDispatchDomainEventSend
Add network events to the remote driver
Added network events to the bridged network driver
.gitignore | 1 +
cfg.mk | 6 +-
daemon/libvirtd.h | 1 +
daemon/remote.c | 175 ++-
include/libvirt/libvirt.h.in | 86 ++
src/Makefile.am | 6 +
src/conf/domain_event.c | 1954 ++++++++++++++--------------------
src/conf/domain_event.h | 219 ++--
src/conf/object_event.c | 903 ++++++++++++++++
src/conf/object_event.h | 113 ++
src/conf/object_event_private.h | 113 ++
src/driver.h | 14 +
src/libvirt.c | 133 +++
src/libvirt_private.syms | 25 +-
src/libvirt_public.syms | 7 +
src/libxl/libxl_conf.h | 2 +-
src/libxl/libxl_driver.c | 46 +-
src/lxc/lxc_conf.h | 2 +-
src/lxc/lxc_driver.c | 54 +-
src/lxc/lxc_process.c | 20 +-
src/network/bridge_driver.c | 89 ++
src/network/bridge_driver_platform.h | 3 +
src/parallels/parallels_utils.h | 2 +-
src/qemu/qemu_conf.h | 2 +-
src/qemu/qemu_domain.c | 6 +-
src/qemu/qemu_domain.h | 2 +-
src/qemu/qemu_driver.c | 116 +-
src/qemu/qemu_hotplug.c | 10 +-
src/qemu/qemu_migration.c | 38 +-
src/qemu/qemu_process.c | 70 +-
src/remote/remote_driver.c | 178 +++-
src/remote/remote_protocol.x | 46 +-
src/test/test_driver.c | 197 ++--
src/uml/uml_conf.h | 2 +-
src/uml/uml_driver.c | 44 +-
src/vbox/vbox_tmpl.c | 22 +-
src/xen/xen_driver.c | 10 +-
src/xen/xen_driver.h | 4 +-
src/xen/xen_inotify.c | 10 +-
src/xen/xs_internal.c | 20 +-
tests/Makefile.am | 7 +
tests/objecteventtest.c | 407 +++++++
tests/qemuhotplugtest.c | 2 +-
43 files changed, 3525 insertions(+), 1642 deletions(-)
create mode 100644 src/conf/object_event.c
create mode 100644 src/conf/object_event.h
create mode 100644 src/conf/object_event_private.h
create mode 100644 tests/objecteventtest.c
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCH]lxc: remove redundant mount operation
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
If we do not specify a readonly mount, we don't need to
re-mount it again.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 255c711..351217a 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1126,13 +1126,6 @@ static int lxcContainerMountFSBind(virDomainFSDefPtr fs,
_("Failed to make directory %s readonly"),
fs->dst);
}
- } else {
- VIR_DEBUG("Binding %s readwrite", fs->dst);
- if (mount(src, fs->dst, NULL, MS_BIND|MS_REMOUNT, NULL) < 0) {
- virReportSystemError(errno,
- _("Failed to make directory %s readwrite"),
- fs->dst);
- }
}
ret = 0;
--
1.8.2.1
10 years, 11 months
[libvirt] [PATCH 0/3] add percentage limit support for RAM filesystems in LXC container
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
Chen Hanxiao (3):
add percentage limit parse and define support for RAM filesystems
enable percentage limit of RAM filesystem in lxc container
docs: add docs for percentage limitation
docs/formatdomain.html.in | 4 +++-
src/conf/domain_conf.c | 21 +++++++++++++++++----
src/conf/domain_conf.h | 1 +
src/lxc/lxc_container.c | 14 +++++++++++---
4 files changed, 32 insertions(+), 8 deletions(-)
--
1.8.2.1
10 years, 11 months
[libvirt] [PATCH] docs: fix double articles bug
by Wangyufei (A)
Delete the extra article 'the'.
Signed-off-by: Wang Yufei <james.wangyufei(a)huawei.com>
---
src/libvirt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index eff44eb..0eb4c64 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -16525,7 +16525,7 @@ error:
* Otherwise, creates a new secret with an automatically chosen UUID, and
* initializes its attributes from xml.
*
- * Returns a the secret on success, NULL on failure.
+ * Returns a secret on success, NULL on failure.
*/
virSecretPtr
virSecretDefineXML(virConnectPtr conn, const char *xml, unsigned int flags)
--
1.7.3.1.msysgit.0
Best Regards,
-WangYufei
10 years, 11 months
[libvirt] [libvirt-sandbox PATCH V2] Add filter support.
by Ian Main
This patch adds two new classes, filterref and filterref-parameter.
Network interfaces can now have an associated filter reference with any
number of filterref parameters. Also added filter= option to
virt-sandbox tool.
V2:
- Changed set_filter to set_name and get_filter to get_name.
---
libvirt-sandbox/Makefile.am | 4 +
.../libvirt-sandbox-builder-container.c | 37 +++-
libvirt-sandbox/libvirt-sandbox-builder-machine.c | 36 ++++
...rt-sandbox-config-network-filterref-parameter.c | 205 ++++++++++++++++++++
...rt-sandbox-config-network-filterref-parameter.h | 75 ++++++++
.../libvirt-sandbox-config-network-filterref.c | 209 +++++++++++++++++++++
.../libvirt-sandbox-config-network-filterref.h | 75 ++++++++
libvirt-sandbox/libvirt-sandbox-config-network.c | 33 ++++
libvirt-sandbox/libvirt-sandbox-config-network.h | 4 +
libvirt-sandbox/libvirt-sandbox-config.c | 39 ++++
libvirt-sandbox/libvirt-sandbox.h | 3 +
libvirt-sandbox/libvirt-sandbox.sym | 14 ++
12 files changed, 733 insertions(+), 1 deletion(-)
create mode 100644 libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c
create mode 100644 libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h
create mode 100644 libvirt-sandbox/libvirt-sandbox-config-network-filterref.c
create mode 100644 libvirt-sandbox/libvirt-sandbox-config-network-filterref.h
diff --git a/libvirt-sandbox/Makefile.am b/libvirt-sandbox/Makefile.am
index 0882490..4de8766 100644
--- a/libvirt-sandbox/Makefile.am
+++ b/libvirt-sandbox/Makefile.am
@@ -57,6 +57,8 @@ SANDBOX_HEADER_FILES = \
libvirt-sandbox-config.h \
libvirt-sandbox-config-network.h \
libvirt-sandbox-config-network-address.h \
+ libvirt-sandbox-config-network-filterref.h \
+ libvirt-sandbox-config-network-filterref-parameter.h \
libvirt-sandbox-config-network-route.h \
libvirt-sandbox-config-mount.h \
libvirt-sandbox-config-mount-file.h \
@@ -85,6 +87,8 @@ SANDBOX_SOURCE_FILES = \
libvirt-sandbox-config.c \
libvirt-sandbox-config-network.c \
libvirt-sandbox-config-network-address.c \
+ libvirt-sandbox-config-network-filterref.c \
+ libvirt-sandbox-config-network-filterref-parameter.c \
libvirt-sandbox-config-network-route.c \
libvirt-sandbox-config-mount.c \
libvirt-sandbox-config-mount-file.c \
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c b/libvirt-sandbox/libvirt-sandbox-builder-container.c
index 43ee5ef..db70403 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-container.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c
@@ -319,11 +319,12 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
g_list_foreach(mounts, (GFunc)g_object_unref, NULL);
g_list_free(mounts);
-
tmp = networks = gvir_sandbox_config_get_networks(config);
while (tmp) {
const gchar *source, *mac;
GVirSandboxConfigNetwork *network = GVIR_SANDBOX_CONFIG_NETWORK(tmp->data);
+ GVirSandboxConfigNetworkFilterref *filterref;
+ GVirConfigDomainInterfaceFilterref *glib_fref;
iface = gvir_config_domain_interface_network_new();
source = gvir_sandbox_config_network_get_source(network);
@@ -339,6 +340,40 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
gvir_config_domain_add_device(domain,
GVIR_CONFIG_DOMAIN_DEVICE(iface));
+
+ filterref = gvir_sandbox_config_network_get_filterref(network);
+ if (filterref) {
+ GList *param_iter, *parameters;
+ const gchar *fref_name = gvir_sandbox_config_network_filterref_get_name(filterref);
+ glib_fref = gvir_config_domain_interface_filterref_new();
+ gvir_config_domain_interface_filterref_set_name(glib_fref, fref_name);
+ param_iter = parameters = gvir_sandbox_config_network_filterref_get_parameters(filterref);
+ while (param_iter) {
+ const gchar *name;
+ const gchar *value;
+ GVirSandboxConfigNetworkFilterrefParameter *param = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER(param_iter->data);
+ GVirConfigDomainInterfaceFilterrefParameter *glib_param;
+
+ name = gvir_sandbox_config_network_filterref_parameter_get_name(param);
+ value = gvir_sandbox_config_network_filterref_parameter_get_value(param);
+
+ glib_param = gvir_config_domain_interface_filterref_parameter_new();
+ gvir_config_domain_interface_filterref_parameter_set_name(glib_param, name);
+ gvir_config_domain_interface_filterref_parameter_set_value(glib_param, value);
+
+ gvir_config_domain_interface_filterref_add_parameter(glib_fref, glib_param);
+ g_object_unref(glib_param);
+
+ param_iter = param_iter->next;
+ }
+
+ g_list_foreach(parameters, (GFunc)g_object_unref, NULL);
+ g_list_free(parameters);
+
+ gvir_config_domain_interface_set_filterref(GVIR_CONFIG_DOMAIN_INTERFACE(iface), glib_fref);
+ g_object_unref(glib_fref);
+ }
+
g_object_unref(iface);
tmp = tmp->next;
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
index a8c5d8c..0cfedc7 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
@@ -577,6 +577,8 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
while (tmp) {
const gchar *source, *mac;
GVirSandboxConfigNetwork *network = GVIR_SANDBOX_CONFIG_NETWORK(tmp->data);
+ GVirSandboxConfigNetworkFilterref *filterref;
+ GVirConfigDomainInterfaceFilterref *glib_fref;
source = gvir_sandbox_config_network_get_source(network);
if (source) {
@@ -596,6 +598,40 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
gvir_config_domain_add_device(domain,
GVIR_CONFIG_DOMAIN_DEVICE(iface));
+
+ filterref = gvir_sandbox_config_network_get_filterref(network);
+ if (filterref) {
+ GList *param_iter, *parameters;
+ const gchar *fref_name = gvir_sandbox_config_network_filterref_get_name(filterref);
+ glib_fref = gvir_config_domain_interface_filterref_new();
+ gvir_config_domain_interface_filterref_set_name(glib_fref, fref_name);
+ param_iter = parameters = gvir_sandbox_config_network_filterref_get_parameters(filterref);
+ while (param_iter) {
+ const gchar *name;
+ const gchar *value;
+ GVirSandboxConfigNetworkFilterrefParameter *param = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER(param_iter->data);
+ GVirConfigDomainInterfaceFilterrefParameter *glib_param;
+
+ name = gvir_sandbox_config_network_filterref_parameter_get_name(param);
+ value = gvir_sandbox_config_network_filterref_parameter_get_value(param);
+
+ glib_param = gvir_config_domain_interface_filterref_parameter_new();
+ gvir_config_domain_interface_filterref_parameter_set_name(glib_param, name);
+ gvir_config_domain_interface_filterref_parameter_set_value(glib_param, value);
+
+ gvir_config_domain_interface_filterref_add_parameter(glib_fref, glib_param);
+ g_object_unref(glib_param);
+
+ param_iter = param_iter->next;
+ }
+
+ g_list_foreach(parameters, (GFunc)g_object_unref, NULL);
+ g_list_free(parameters);
+
+ gvir_config_domain_interface_set_filterref(iface, glib_fref);
+ g_object_unref(glib_fref);
+ }
+
g_object_unref(iface);
tmp = tmp->next;
diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c
new file mode 100644
index 0000000..c1ed941
--- /dev/null
+++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c
@@ -0,0 +1,205 @@
+/*
+ * libvirt-sandbox-config-network-filterref-parameter.c: libvirt sandbox configuration
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Ian Main <imain(a)redhat.com>
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include "libvirt-sandbox/libvirt-sandbox.h"
+
+/**
+ * SECTION: libvirt-sandbox-config-network-filterref-parameter
+ * @short_description: Set parameters for a filter reference.
+ * @include: libvirt-sandbox/libvirt-sandbox.h
+ *
+ * Provides an object to store filter parameter name and value.
+ *
+ * The GVirSandboxConfigNetworkFilterrefParameter object stores a
+ * name and value required to set a single parameter of a filter reference.
+ */
+
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER, GVirSandboxConfigNetworkFilterrefParameterPrivate))
+
+struct _GVirSandboxConfigNetworkFilterrefParameterPrivate
+{
+ gchar *name;
+ gchar *value;
+};
+
+G_DEFINE_TYPE(GVirSandboxConfigNetworkFilterrefParameter, gvir_sandbox_config_network_filterref_parameter, G_TYPE_OBJECT);
+
+
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_VALUE,
+};
+
+enum {
+ LAST_SIGNAL
+};
+
+//static gint signals[LAST_SIGNAL];
+
+
+static void gvir_sandbox_config_network_filterref_parameter_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GVirSandboxConfigNetworkFilterrefParameter *config = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER(object);
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv = config->priv;
+
+ switch (prop_id) {
+ case PROP_NAME:
+ g_value_set_string(value, priv->name);
+ break;
+
+ case PROP_VALUE:
+ g_value_set_string(value, priv->value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+
+static void gvir_sandbox_config_network_filterref_parameter_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GVirSandboxConfigNetworkFilterrefParameter *config = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER(object);
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv = config->priv;
+
+ switch (prop_id) {
+ case PROP_NAME:
+ g_free(priv->name);
+ priv->name = g_value_dup_string(value);
+ break;
+
+ case PROP_VALUE:
+ g_free(priv->value);
+ priv->value = g_value_dup_string(value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+
+static void gvir_sandbox_config_network_filterref_parameter_finalize(GObject *object)
+{
+ GVirSandboxConfigNetworkFilterrefParameter *config = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER(object);
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv = config->priv;
+
+ g_free(priv->name);
+ g_free(priv->value);
+
+ G_OBJECT_CLASS(gvir_sandbox_config_network_filterref_parameter_parent_class)->finalize(object);
+}
+
+
+static void gvir_sandbox_config_network_filterref_parameter_class_init(GVirSandboxConfigNetworkFilterrefParameterClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ object_class->finalize = gvir_sandbox_config_network_filterref_parameter_finalize;
+ object_class->get_property = gvir_sandbox_config_network_filterref_parameter_get_property;
+ object_class->set_property = gvir_sandbox_config_network_filterref_parameter_set_property;
+
+ g_object_class_install_property(object_class,
+ PROP_NAME,
+ g_param_spec_string("name",
+ "Name",
+ "Name of parameter",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property(object_class,
+ PROP_VALUE,
+ g_param_spec_string("value",
+ "Value",
+ "Value of parameter",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+
+ g_type_class_add_private(klass, sizeof(GVirSandboxConfigNetworkFilterrefParameterPrivate));
+}
+
+
+static void gvir_sandbox_config_network_filterref_parameter_init(GVirSandboxConfigNetworkFilterrefParameter *param)
+{
+ param->priv = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER_GET_PRIVATE(param);
+}
+
+
+/**
+ * gvir_sandbox_config_network_filterref_parameter_new:
+ *
+ * Create a new network config with DHCP enabled
+ *
+ * Returns: (transfer full): a new sandbox network object
+ */
+GVirSandboxConfigNetworkFilterrefParameter *gvir_sandbox_config_network_filterref_parameter_new(void)
+{
+ return GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER(g_object_new(GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER,
+ NULL));
+}
+
+void gvir_sandbox_config_network_filterref_parameter_set_name(GVirSandboxConfigNetworkFilterrefParameter *param,
+ const gchar *name)
+{
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv = param->priv;
+ g_free(priv->name);
+ priv->name = g_strdup(name);
+}
+
+const gchar *gvir_sandbox_config_network_filterref_parameter_get_name(GVirSandboxConfigNetworkFilterrefParameter *param)
+{
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv = param->priv;
+ return priv->name;
+}
+
+void gvir_sandbox_config_network_filterref_parameter_set_value(GVirSandboxConfigNetworkFilterrefParameter *param,
+ const gchar *value)
+{
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv = param->priv;
+ g_free(priv->value);
+ priv->value = g_strdup(value);
+}
+
+const gchar *gvir_sandbox_config_network_filterref_parameter_get_value(GVirSandboxConfigNetworkFilterrefParameter *param)
+{
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv = param->priv;
+ return priv->value;
+}
diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h
new file mode 100644
index 0000000..f40895f
--- /dev/null
+++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h
@@ -0,0 +1,75 @@
+/*
+ * libvirt-sandbox-config-network-filterref-parameter.h: libvirt sandbox configuration
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Ian Main <imain(a)redhat.com>
+ */
+
+#if !defined(__LIBVIRT_SANDBOX_H__) && !defined(LIBVIRT_SANDBOX_BUILD)
+#error "Only <libvirt-sandbox/libvirt-sandbox.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER_H__
+#define __LIBVIRT_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER (gvir_sandbox_config_network_filterref_parameter_get_type ())
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER, GVirSandboxConfigNetworkFilterrefParameter))
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER, GVirSandboxConfigNetworkFilterrefParameterClass))
+#define GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF_PARAMETER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER))
+#define GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF_PARAMETER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER))
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER, GVirSandboxConfigNetworkFilterrefParameterClass))
+
+#define GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_PARAMETER_HANDLE (gvir_sandbox_config_network_filterref_parameter_handle_get_type ())
+
+typedef struct _GVirSandboxConfigNetworkFilterrefParameter GVirSandboxConfigNetworkFilterrefParameter;
+typedef struct _GVirSandboxConfigNetworkFilterrefParameterPrivate GVirSandboxConfigNetworkFilterrefParameterPrivate;
+typedef struct _GVirSandboxConfigNetworkFilterrefParameterClass GVirSandboxConfigNetworkFilterrefParameterClass;
+
+struct _GVirSandboxConfigNetworkFilterrefParameter
+{
+ GObject parent;
+
+ GVirSandboxConfigNetworkFilterrefParameterPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirSandboxConfigNetworkFilterrefParameterClass
+{
+ GObjectClass parent_class;
+
+ gpointer padding[LIBVIRT_SANDBOX_CLASS_PADDING];
+};
+
+GType gvir_sandbox_config_network_filterref_parameter_get_type(void);
+
+GVirSandboxConfigNetworkFilterrefParameter *gvir_sandbox_config_network_filterref_parameter_new(void);
+
+void gvir_sandbox_config_network_filterref_parameter_set_name(GVirSandboxConfigNetworkFilterrefParameter *param,
+ const gchar *name);
+const gchar *gvir_sandbox_config_network_filterref_parameter_get_name(GVirSandboxConfigNetworkFilterrefParameter *param);
+
+void gvir_sandbox_config_network_filterref_parameter_set_value(GVirSandboxConfigNetworkFilterrefParameter *param,
+ const gchar *value);
+const gchar *gvir_sandbox_config_network_filterref_parameter_get_value(GVirSandboxConfigNetworkFilterrefParameter *param);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_SANDBOX_CONFIG_NETWORK_FILTERREF_PARAMETER_H__ */
diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref.c b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.c
new file mode 100644
index 0000000..71cec31
--- /dev/null
+++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.c
@@ -0,0 +1,209 @@
+/*
+ * libvirt-sandbox-config-mount.c: libvirt sandbox configuration
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Ian Main <imain(a)redhat.com>
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include "libvirt-sandbox/libvirt-sandbox.h"
+
+/**
+ * SECTION: libvirt-sandbox-config-network-filterref
+ * @short_description: Add a network filter to a network interface.
+ * @include: libvirt-sandbox/libvirt-sandbox.h
+ * @see_aloso: #GVirSandboxConfig
+ *
+ * Provides an object to store the name of the filter reference.
+ *
+ * The GVirSandboxConfigNetworkFilterref object stores the name of the filter
+ * references associated with a network interface.
+ */
+
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF, GVirSandboxConfigNetworkFilterrefPrivate))
+
+struct _GVirSandboxConfigNetworkFilterrefPrivate
+{
+ gchar *filter;
+ GList *parameters;
+};
+
+G_DEFINE_TYPE(GVirSandboxConfigNetworkFilterref, gvir_sandbox_config_network_filterref, G_TYPE_OBJECT);
+
+
+enum {
+ PROP_0,
+ PROP_FILTER
+};
+
+enum {
+ LAST_SIGNAL
+};
+
+//static gint signals[LAST_SIGNAL];
+
+static void gvir_sandbox_config_network_filterref_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GVirSandboxConfigNetworkFilterref *config = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF(object);
+ GVirSandboxConfigNetworkFilterrefPrivate *priv = config->priv;
+
+ switch (prop_id) {
+ case PROP_FILTER:
+ g_value_set_string(value, priv->filter);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+
+static void gvir_sandbox_config_network_filterref_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GVirSandboxConfigNetworkFilterref *config = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF(object);
+ GVirSandboxConfigNetworkFilterrefPrivate *priv = config->priv;
+
+ switch (prop_id) {
+ case PROP_FILTER:
+ g_free(priv->filter);
+ priv->filter = g_value_dup_string(value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+
+
+static void gvir_sandbox_config_network_filterref_finalize(GObject *object)
+{
+ GVirSandboxConfigNetworkFilterref *config = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF(object);
+ GVirSandboxConfigNetworkFilterrefPrivate *priv = config->priv;
+
+ g_free(priv->filter);
+ g_list_foreach(priv->parameters, (GFunc)g_object_unref, NULL);
+
+ G_OBJECT_CLASS(gvir_sandbox_config_network_filterref_parent_class)->finalize(object);
+}
+
+
+static void gvir_sandbox_config_network_filterref_class_init(GVirSandboxConfigNetworkFilterrefClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ object_class->finalize = gvir_sandbox_config_network_filterref_finalize;
+ object_class->get_property = gvir_sandbox_config_network_filterref_get_property;
+ object_class->set_property = gvir_sandbox_config_network_filterref_set_property;
+
+ g_object_class_install_property(object_class,
+ PROP_FILTER,
+ g_param_spec_string("filter",
+ "Filter name",
+ "The filter reference name",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+
+ g_type_class_add_private(klass, sizeof(GVirSandboxConfigNetworkFilterrefPrivate));
+}
+
+/**
+ * gvir_sandbox_config_network_filterref_new:
+ *
+ * Create a new network filterref config.
+ *
+ * Returns: (transfer full): a new sandbox network_filterref object
+ */
+GVirSandboxConfigNetworkFilterref *gvir_sandbox_config_network_filterref_new(void)
+{
+ return GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF(g_object_new(GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF,
+ NULL));
+}
+
+
+static void gvir_sandbox_config_network_filterref_init(GVirSandboxConfigNetworkFilterref *config)
+{
+ config->priv = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_GET_PRIVATE(config);
+}
+
+
+/**
+ * gvir_sandbox_config_network_filterref_get_name:
+ * @config: (transfer none): the network filter reference name
+ *
+ * Retrieves the network filter reference name.
+ *
+ * Returns: (transfer none): the network filter reference name.
+ */
+const gchar *gvir_sandbox_config_network_filterref_get_name(GVirSandboxConfigNetworkFilterref *config)
+{
+ GVirSandboxConfigNetworkFilterrefPrivate *priv = config->priv;
+ return priv->filter;
+}
+
+void gvir_sandbox_config_network_filterref_set_name(GVirSandboxConfigNetworkFilterref *config,
+ const gchar *name)
+{
+ GVirSandboxConfigNetworkFilterrefPrivate *priv = config->priv;
+ g_free(priv->filter);
+ priv->filter = g_strdup(name);
+}
+
+/**
+ * gvir_sandbox_config_network_filterref_add_parameter:
+ * @filter: (transfer none): the network filter reference.
+ * @param: (transfer none): the filter parameter
+ *
+ * Add a parameter to a network filter reference.
+ */
+void gvir_sandbox_config_network_filterref_add_parameter(GVirSandboxConfigNetworkFilterref *filter,
+ GVirSandboxConfigNetworkFilterrefParameter *param)
+{
+ GVirSandboxConfigNetworkFilterrefPrivate *priv = filter->priv;
+ priv->parameters = g_list_append(priv->parameters, g_object_ref(param));
+}
+
+
+/**
+ * gvir_sandbox_config_network_filterref_get_parameters:
+ * @filter: (transfer none): the filter reference configuration
+ *
+ * Retrieve the list of parameters associated with a network filter reference
+ *
+ * Returns: (transfer full)(element-type GVirSandboxConfigNetworkFilterrefParameter): the parameter list
+ */
+GList *gvir_sandbox_config_network_filterref_get_parameters(GVirSandboxConfigNetworkFilterref *filter)
+{
+ GVirSandboxConfigNetworkFilterrefPrivate *priv = filter->priv;
+ g_list_foreach(priv->parameters, (GFunc)g_object_ref, NULL);
+ return g_list_copy(priv->parameters);
+}
diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref.h b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.h
new file mode 100644
index 0000000..4925530
--- /dev/null
+++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.h
@@ -0,0 +1,75 @@
+/*
+ * libvirt-sandbox-config-mount.h: libvirt sandbox configuration
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Ian Main <imain(a)redhat.com>
+ */
+
+#if !defined(__LIBVIRT_SANDBOX_H__) && !defined(LIBVIRT_SANDBOX_BUILD)
+#error "Only <libvirt-sandbox/libvirt-sandbox.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_SANDBOX_CONFIG_NETWORK_FILTERREF_H__
+#define __LIBVIRT_SANDBOX_CONFIG_NETWORK_FILTERREF_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF (gvir_sandbox_config_network_filterref_get_type ())
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF, GVirSandboxConfigNetworkFilterref))
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF, GVirSandboxConfigNetworkFilterrefClass))
+#define GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF))
+#define GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF))
+#define GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF, GVirSandboxConfigNetworkFilterrefClass))
+
+#define GVIR_SANDBOX_TYPE_CONFIG_NETWORK_FILTERREF_HANDLE (gvir_sandbox_config_network_filterref_handle_get_type ())
+
+typedef struct _GVirSandboxConfigNetworkFilterref GVirSandboxConfigNetworkFilterref;
+typedef struct _GVirSandboxConfigNetworkFilterrefPrivate GVirSandboxConfigNetworkFilterrefPrivate;
+typedef struct _GVirSandboxConfigNetworkFilterrefClass GVirSandboxConfigNetworkFilterrefClass;
+
+struct _GVirSandboxConfigNetworkFilterref
+{
+ GObject parent;
+
+ GVirSandboxConfigNetworkFilterrefPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirSandboxConfigNetworkFilterrefClass
+{
+ GObjectClass parent_class;
+
+ gpointer padding[LIBVIRT_SANDBOX_CLASS_PADDING];
+};
+
+GType gvir_sandbox_config_network_filterref_get_type(void);
+
+GVirSandboxConfigNetworkFilterref *gvir_sandbox_config_network_filterref_new(void);
+
+const gchar *gvir_sandbox_config_network_filterref_get_name(GVirSandboxConfigNetworkFilterref *config);
+void gvir_sandbox_config_network_filterref_set_name(GVirSandboxConfigNetworkFilterref *filter, const gchar *name);
+
+void gvir_sandbox_config_network_filterref_add_parameter(GVirSandboxConfigNetworkFilterref *filter,
+ GVirSandboxConfigNetworkFilterrefParameter *param);
+GList *gvir_sandbox_config_network_filterref_get_parameters(GVirSandboxConfigNetworkFilterref *filter);
+
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_SANDBOX_CONFIG_NETWORK_FILTERREF_H__ */
diff --git a/libvirt-sandbox/libvirt-sandbox-config-network.c b/libvirt-sandbox/libvirt-sandbox-config-network.c
index 7e7c015..555a360 100644
--- a/libvirt-sandbox/libvirt-sandbox-config-network.c
+++ b/libvirt-sandbox/libvirt-sandbox-config-network.c
@@ -47,6 +47,7 @@ struct _GVirSandboxConfigNetworkPrivate
gchar *mac;
GList *routes;
GList *addrs;
+ GVirSandboxConfigNetworkFilterref *filterref;
};
G_DEFINE_TYPE(GVirSandboxConfigNetwork, gvir_sandbox_config_network, G_TYPE_OBJECT);
@@ -285,6 +286,38 @@ GList *gvir_sandbox_config_network_get_addresses(GVirSandboxConfigNetwork *confi
}
/**
+ * gvir_sandbox_config_network_set_filterref:
+ * @config: (transfer none): the sandbox network configuration
+ * @ref: (transfer none): the network filterref
+ *
+ * Set a network filterref for the given network.
+ */
+void gvir_sandbox_config_network_set_filterref(GVirSandboxConfigNetwork *config,
+ GVirSandboxConfigNetworkFilterref *filterref)
+{
+ GVirSandboxConfigNetworkPrivate *priv = config->priv;
+ if (priv->filterref)
+ g_object_unref(priv->filterref);
+ priv->filterref = g_object_ref(filterref);
+}
+
+
+/**
+ * gvir_sandbox_config_network_get_filterref:
+ * @config: (transfer none): the sandbox network configuration
+ *
+ * Retrieve the associated filter reference.
+ *
+ * Returns: (transfer none): The associated filter reference.
+ */
+GVirSandboxConfigNetworkFilterref *gvir_sandbox_config_network_get_filterref(GVirSandboxConfigNetwork *config)
+{
+ GVirSandboxConfigNetworkPrivate *priv = config->priv;
+ return priv->filterref;
+}
+
+
+/**
* gvir_sandbox_config_network_add_route:
* @config: (transfer none): the sandbox network configuration
* @addr: (transfer none): the network route
diff --git a/libvirt-sandbox/libvirt-sandbox-config-network.h b/libvirt-sandbox/libvirt-sandbox-config-network.h
index d926fd1..4a52221 100644
--- a/libvirt-sandbox/libvirt-sandbox-config-network.h
+++ b/libvirt-sandbox/libvirt-sandbox-config-network.h
@@ -78,6 +78,10 @@ void gvir_sandbox_config_network_add_address(GVirSandboxConfigNetwork *config,
GVirSandboxConfigNetworkAddress *addr);
GList *gvir_sandbox_config_network_get_addresses(GVirSandboxConfigNetwork *config);
+void gvir_sandbox_config_network_set_filterref(GVirSandboxConfigNetwork *config,
+ GVirSandboxConfigNetworkFilterref *ref);
+GVirSandboxConfigNetworkFilterref *gvir_sandbox_config_network_get_filterref(GVirSandboxConfigNetwork *config);
+
void gvir_sandbox_config_network_add_route(GVirSandboxConfigNetwork *config,
GVirSandboxConfigNetworkRoute *addr);
GList *gvir_sandbox_config_network_get_routes(GVirSandboxConfigNetwork *config);
diff --git a/libvirt-sandbox/libvirt-sandbox-config.c b/libvirt-sandbox/libvirt-sandbox-config.c
index b1525a1..f996ea5 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.c
+++ b/libvirt-sandbox/libvirt-sandbox-config.c
@@ -911,6 +911,8 @@ gboolean gvir_sandbox_config_add_network_strv(GVirSandboxConfig *config,
* source=private,address=192.168.122.1/24%192.168.122.255,
* address=192.168.122.1/24%192.168.122.255,address=2001:212::204:2/64
* route=192.168.122.255/24%192.168.1.1
+ * filter=clean-traffic
+ * filter.ip=192.168.122.1
*/
gboolean gvir_sandbox_config_add_network_opts(GVirSandboxConfig *config,
const gchar *network,
@@ -924,8 +926,10 @@ gboolean gvir_sandbox_config_add_network_opts(GVirSandboxConfig *config,
gchar **params = g_strsplit(network, ",", 50);
gsize j = 0;
GVirSandboxConfigNetwork *net;
+ GVirSandboxConfigNetworkFilterref *filter;
net = gvir_sandbox_config_network_new();
+ filter = gvir_sandbox_config_network_filterref_new();
gvir_sandbox_config_network_set_dhcp(net, FALSE);
while (params && params[j]) {
@@ -947,6 +951,40 @@ gboolean gvir_sandbox_config_add_network_opts(GVirSandboxConfig *config,
} else if (g_str_has_prefix(param, "mac=")) {
gvir_sandbox_config_network_set_mac(net,
param + strlen("mac="));
+ } else if (g_str_has_prefix(param, "filter.")) {
+ GVirSandboxConfigNetworkFilterrefParameter *filter_param;
+ gchar *tail = g_strdup(param + strlen("filter."));
+ gchar *equ = g_strrstr(tail, "=");
+ gchar *name, *name_up, *value;
+
+ if (equ == NULL) {
+ g_free(tail);
+ g_set_error(error, GVIR_SANDBOX_CONFIG_ERROR, 0,
+ _("No assignment in filter parameter configuration"));
+ g_object_unref(net);
+ goto cleanup;
+ }
+
+ name = g_strndup(tail, equ - tail);
+ value = g_strdup(equ + 1);
+ /* Convert to upcase for convenience. */
+ name_up = g_ascii_strup(name, -1);
+ g_free(name);
+
+ filter_param = gvir_sandbox_config_network_filterref_parameter_new();
+ gvir_sandbox_config_network_filterref_parameter_set_name(filter_param, name_up);
+ gvir_sandbox_config_network_filterref_parameter_set_value(filter_param, value);
+ gvir_sandbox_config_network_filterref_add_parameter(filter, filter_param);
+
+ g_free(tail);
+ g_free(name_up);
+ g_free(value);
+ } else if (g_str_has_prefix(param, "filter=")) {
+ gchar *name = g_strdup(param + strlen("filter="));
+
+ gvir_sandbox_config_network_filterref_set_name(filter, name);
+ gvir_sandbox_config_network_set_filterref(net, filter);
+ g_free(name);
} else if (g_str_has_prefix(param, "address=")) {
GVirSandboxConfigNetworkAddress *addr;
GInetAddress *primaryaddr;
@@ -1090,6 +1128,7 @@ gboolean gvir_sandbox_config_add_network_opts(GVirSandboxConfig *config,
ret = TRUE;
cleanup:
+ g_object_unref(filter);
return ret;
}
diff --git a/libvirt-sandbox/libvirt-sandbox.h b/libvirt-sandbox/libvirt-sandbox.h
index a3f0b2c..adb21a1 100644
--- a/libvirt-sandbox/libvirt-sandbox.h
+++ b/libvirt-sandbox/libvirt-sandbox.h
@@ -25,6 +25,7 @@
/* External includes */
#include <libvirt-gobject/libvirt-gobject.h>
+#include <locale.h>
/* Local includes */
#include <libvirt-sandbox/libvirt-sandbox-main.h>
@@ -37,6 +38,8 @@
#include <libvirt-sandbox/libvirt-sandbox-config-mount-guest-bind.h>
#include <libvirt-sandbox/libvirt-sandbox-config-mount-ram.h>
#include <libvirt-sandbox/libvirt-sandbox-config-network-address.h>
+#include <libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h>
+#include <libvirt-sandbox/libvirt-sandbox-config-network-filterref.h>
#include <libvirt-sandbox/libvirt-sandbox-config-network-route.h>
#include <libvirt-sandbox/libvirt-sandbox-config-network.h>
#include <libvirt-sandbox/libvirt-sandbox-config.h>
diff --git a/libvirt-sandbox/libvirt-sandbox.sym b/libvirt-sandbox/libvirt-sandbox.sym
index 7b7c8be..c46ccd9 100644
--- a/libvirt-sandbox/libvirt-sandbox.sym
+++ b/libvirt-sandbox/libvirt-sandbox.sym
@@ -44,6 +44,7 @@ LIBVIRT_SANDBOX_0.2.1 {
gvir_sandbox_config_mount_ram_set_usage;
gvir_sandbox_config_network_add_address;
+ gvir_sandbox_config_network_set_filterref;
gvir_sandbox_config_network_add_route;
gvir_sandbox_config_network_get_type;
gvir_sandbox_config_network_get_dhcp;
@@ -51,6 +52,7 @@ LIBVIRT_SANDBOX_0.2.1 {
gvir_sandbox_config_network_get_source;
gvir_sandbox_config_network_get_routes;
gvir_sandbox_config_network_get_addresses;
+ gvir_sandbox_config_network_get_filterref;
gvir_sandbox_config_network_new;
gvir_sandbox_config_network_set_dhcp;
gvir_sandbox_config_network_set_mac;
@@ -65,6 +67,18 @@ LIBVIRT_SANDBOX_0.2.1 {
gvir_sandbox_config_network_address_set_primary;
gvir_sandbox_config_network_address_set_prefix;
+ gvir_sandbox_config_network_filterref_get_type;
+ gvir_sandbox_config_network_filterref_new;
+ gvir_sandbox_config_network_filterref_get_name;
+ gvir_sandbox_config_network_filterref_set_name;
+
+ gvir_sandbox_config_network_filterref_parameter_get_type;
+ gvir_sandbox_config_network_filterref_parameter_new;
+ gvir_sandbox_config_network_filterref_parameter_get_name;
+ gvir_sandbox_config_network_filterref_parameter_set_name;
+ gvir_sandbox_config_network_filterref_parameter_get_value;
+ gvir_sandbox_config_network_filterref_parameter_set_value;
+
gvir_sandbox_config_network_route_get_type;
gvir_sandbox_config_network_route_get_prefix;
gvir_sandbox_config_network_route_get_gateway;
--
1.8.1.4
10 years, 11 months
[libvirt] [PATCHv1.5 00/27] Gluster snapshot support (RFC) and refactors
by Peter Krempa
This version was rebased on top of Eric's gluster pool series and a few
small mistakes were fixed. As nobody actually reviewed the original posting
I did not bother putting the differences in the patches.
Peter Krempa (27):
conf: Export virStorageVolType enum helper functions
test: Implement fake storage pool driver in qemuxml2argv test
qemuxml2argv: Add test to verify correct usage of disk type="volume"
qemuxml2argv: Add test for disk type='volume' with iSCSI pools
qemu: Split out formatting of network disk source URI
qemu: Simplify call pattern of qemuBuildDriveURIString
qemu: Use qemuBuildNetworkDriveURI to handle http/ftp and friends
qemu: Migrate sheepdog source generation into common function
qemu: Split out NBD command generation
qemu: Unify formatting of RBD sources
qemu: Refactor disk source string formatting
conf: Support disk source formatting without needing a
virDomainDiskDefPtr
conf: Clean up virDomainDiskSourceDefFormatInternal
conf: Split out seclabel formating code for disk source
conf: Export disk source formatter and parser
snapshot: conf: Use common parsing and formatting functions for source
snapshot: conf: Fix NULL dereference when <driver> element is empty
conf: Add functions to copy and free network disk source definitions
qemu: snapshot: Detect internal snapshots also for sheepdog and RBD
conf: Add helper do clear disk source authentication struct
qemu: Clear old translated pool source
qemu: snapshot: Touch up error message
qemu: snapshot: Add functions similar to disk source pool translation
qemu: snapshots: Declare supported and unsupported snapshot configs
RFC: snapshot: Add support for specifying snapshot disk backing type
RFC: conf: snapshot: Parse more snapshot information
RFC: qemu: snapshot: Add support for external active snapshots on
gluster
src/conf/domain_conf.c | 261 ++++++---
src/conf/domain_conf.h | 25 +
src/conf/snapshot_conf.c | 69 ++-
src/conf/snapshot_conf.h | 14 +-
src/libvirt_private.syms | 6 +
src/qemu/qemu_command.c | 652 +++++++++++----------
src/qemu/qemu_command.h | 15 +
src/qemu/qemu_conf.c | 156 +++--
src/qemu/qemu_conf.h | 8 +
src/qemu/qemu_driver.c | 429 ++++++++++++--
.../qemuxml2argv-disk-source-pool-mode.args | 10 +
.../qemuxml2argv-disk-source-pool-mode.xml | 4 +-
.../qemuxml2argv-disk-source-pool.args | 8 +
.../qemuxml2argv-disk-source-pool.xml | 2 +-
tests/qemuxml2argvtest.c | 166 ++++++
15 files changed, 1298 insertions(+), 527 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args
--
1.8.4.3
10 years, 11 months
[libvirt] [PATCH v3] Pin guest to memory node on NUMA system
by Shivaprasad G Bhat
Version 3:
Addressed comments on V2.
Version 2:
Fixed the string formatting errors in v1.
The patch contains the fix for defect 1009880 reported at redhat bugzilla.
The root cause is, ever since the subcpusets(vcpu,emulator) were introduced, the
parent cpuset cannot be modified to remove the nodes that are in use by the
subcpusets.
The fix is to break the memory node modification into three steps as to assign
new nodes into the parent first. Change the nodes in the child nodes. Then
remove the old nodes on the parent node.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 110 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8a1eefd..4bc9d1d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8132,6 +8132,47 @@ cleanup:
}
static int
+qemuSetVcpuCpusetMems(virDomainObjPtr vm,
+ char *nodeset_str)
+{
+ size_t j = 0;
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virCgroupPtr cgroup_vcpu = NULL;
+
+ for (j = 0; j < priv->nvcpupids; j++) {
+ if (virCgroupNewVcpu(priv->cgroup, j, false, &cgroup_vcpu) < 0) {
+ return -1;
+ }
+ if (virCgroupSetCpusetMems(cgroup_vcpu, nodeset_str) < 0) {
+ virCgroupFree(&cgroup_vcpu);
+ return -1;
+ }
+ virCgroupFree(&cgroup_vcpu);
+ }
+
+ return 0;
+}
+
+static int
+qemuSetEmulatorCpusetMems(virDomainObjPtr vm,
+ char *nodeset_str)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virCgroupPtr cgroup_emulator = NULL;
+
+ if (virCgroupNewEmulator(priv->cgroup, false, &cgroup_emulator) < 0) {
+ return -1;
+ }
+ if (virCgroupSetCpusetMems(cgroup_emulator, nodeset_str) < 0) {
+ virCgroupFree(&cgroup_emulator);
+ return -1;
+ }
+ virCgroupFree(&cgroup_emulator);
+
+ return 0;
+}
+
+static int
qemuDomainSetNumaParameters(virDomainPtr dom,
virTypedParameterPtr params,
int nparams,
@@ -8198,7 +8239,11 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
}
} else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) {
virBitmapPtr nodeset = NULL;
+ virBitmapPtr old_nodeset = NULL;
+ virBitmapPtr temp_nodeset = NULL;
char *nodeset_str = NULL;
+ char *old_nodeset_str = NULL;
+ char *temp_nodeset_str = NULL;
if (virBitmapParse(params[i].value.s,
0, &nodeset,
@@ -8208,32 +8253,92 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ size_t j;
+
if (vm->def->numatune.memory.mode !=
VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("change of nodeset for running domain "
"requires strict numa mode"));
- virBitmapFree(nodeset);
ret = -1;
- continue;
+ goto next;
}
/* Ensure the cpuset string is formated before passing to cgroup */
if (!(nodeset_str = virBitmapFormat(nodeset))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to format nodeset"));
- virBitmapFree(nodeset);
ret = -1;
- continue;
+ goto next;
+ }
+
+ /*Get Exisitng nodeset values */
+ if (virCgroupGetCpusetMems(priv->cgroup, &old_nodeset_str) < 0) {
+ ret = -1;
+ goto next;
+ }
+ if (virBitmapParse(old_nodeset_str, 0, &old_nodeset,
+ VIR_DOMAIN_CPUMASK_LEN) < 0){
+ ret = -1;
+ goto next;
+ }
+
+ /* Merge the existing and new nodeset values */
+ if ((temp_nodeset = virBitmapNewCopy(old_nodeset)) == NULL) {
+ ret = -1;
+ goto next;
+ }
+
+ for (j = 0; j < caps->host.nnumaCell; j++) {
+ bool result;
+ if (virBitmapGetBit(nodeset, j, &result) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to get cpuset bit values"));
+ ret = -1;
+ goto next;
+ }
+ if (result && (virBitmapSetBit(temp_nodeset, j) < 0)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to set temporary cpuset bit values"));
+ ret = -1;
+ goto next;
+ }
+ }
+
+ if (!(temp_nodeset_str = virBitmapFormat(temp_nodeset))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to format nodeset"));
+ ret = -1;
+ goto next;
+ }
+
+ if (virCgroupSetCpusetMems(priv->cgroup, temp_nodeset_str) < 0) {
+ ret = -1;
+ goto next;
+ }
+
+ if (qemuSetVcpuCpusetMems(vm, nodeset_str) ||
+ qemuSetEmulatorCpusetMems(vm, nodeset_str)) {
+ ret = -1;
+ goto next;
}
if (virCgroupSetCpusetMems(priv->cgroup, nodeset_str) < 0) {
virBitmapFree(nodeset);
VIR_FREE(nodeset_str);
ret = -1;
- continue;
+ goto next;
}
+next :
VIR_FREE(nodeset_str);
+ VIR_FREE(old_nodeset_str);
+ virBitmapFree(old_nodeset);
+ VIR_FREE(temp_nodeset_str);
+ virBitmapFree(temp_nodeset);
+ if (ret) {
+ virBitmapFree(nodeset);
+ continue;
+ }
/* update vm->def here so that dumpxml can read the new
* values from vm->def. */
10 years, 11 months
[libvirt] [PATCH] Doc: Explicitly declaring that nodedev-destroy only works for vHBA
by Osier Yang
Though trying to destroy a physical HBA doesn't make sense at all,
it's still a bit misleading with saying "only works for HBA".
Signed-off-by: Osier Yang <jyang(a)redhat.com>
---
src/libvirt.c | 5 +++--
tools/virsh.pod | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index ae05300..4ebd13f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -16065,8 +16065,9 @@ error:
* virNodeDeviceDestroy:
* @dev: a device object
*
- * Destroy the device object. The virtual device is removed from the host operating system.
- * This function may require privileged access
+ * Destroy the device object. The virtual device (only works for vHBA
+ * currently) is removed from the host operating system. This function
+ * may require privileged access.
*
* Returns 0 in case of success and -1 in case of failure.
*/
diff --git a/tools/virsh.pod b/tools/virsh.pod
index dac9a08..557df9c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2158,9 +2158,9 @@ contains xml for a top-level <device> description of a node device.
=item B<nodedev-destroy> I<device>
Destroy (stop) a device on the host. I<device> can be either device
-name or wwn pair in "wwnn,wwpn" format (only works for HBA). Note
-that this makes libvirt quit managing a host device, and may even make
-that device unusable by the rest of the physical host until a reboot.
+name or wwn pair in "wwnn,wwpn" format (only works for vHBA currently).
+Note that this makes libvirt quit managing a host device, and may even
+make that device unusable by the rest of the physical host until a reboot.
=item B<nodedev-detach> I<nodedev> [I<--driver backend_driver>]
--
1.8.1.4
10 years, 11 months
[libvirt] [question] We can create two network of one same linux bridge or local ethernet. It is a bug?
by Sheldon
> We can create two network of one same linux bridge or local ethernet:
This is not harmful.
But I wonder should this case is allowed? Why?
more detail as follow.
>
> virsh # net-list --all
> Name State Autostart Persistent
> ----------------------------------------------------------
> br1 active yes yes
> br2 active yes yes
> default active yes yes
>
> virsh # net-dumpxml br1
> <network>
> <name>br1</name>
> <uuid>d5410814-1bea-b10d-04b8-9fbd3a1cfc65</uuid>
> <forward mode='bridge'/>
> <bridge name='br0' />
> </network>
>
> virsh # net-dumpxml br2
> <network>
> <name>br2</name>
> <uuid>99f20705-57cd-da31-f193-d13af4158792</uuid>
> <forward mode='bridge'/>
> <bridge name='br0' />
> </network>
>
> virsh # net-list --all
> Name State Autostart Persistent
> ----------------------------------------------------------
> br0 active yes yes
> br1 active yes yes
> default active yes yes
>
> virsh # net-dumpxml br0
> <network>
> <name>br0</name>
> <uuid>a35c840a-9bdc-070d-43f5-8e834040aa42</uuid>
> <forward dev='eth0' mode='bridge'>
> <interface dev='eth0'/>
> </forward>
> </network>
>
> virsh # net-dumpxml br1
> <network>
> <name>br1</name>
> <uuid>f1c87b80-2dfc-2a71-3fb6-56ef83daf29a</uuid>
> <forward dev='eth0' mode='bridge'>
> <interface dev='eth0'/>
> </forward>
> </network>
--
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center
10 years, 11 months