[libvirt-glib][PATCH V3] Add filterref and filterref parameter support.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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@xxxxxxxxxx>
+ *          Daniel P. Berrange <berrange@xxxxxxxxxx>
+ */
+
+#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@xxxxxxxxxx>
+ *          Daniel P. Berrange <berrange@xxxxxxxxxx>
+ */
+
+#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@xxxxxxxxxx>
+ */
+
+#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@xxxxxxxxxx>
+ */
+
+#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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]