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

[libvirt] [libvirt-glib PATCHv3 20/27] Add GVirConfigDomainInterfaceNetwork



--
v2: use g_return_if_fail to test function args for sanity
v3: rename to GVirConfigDomainInterfaceNetwork
---
 libvirt-gconfig/Makefile.am                        |    2 +
 .../libvirt-gconfig-domain-interface-network.c     |   92 ++++++++++++++++++++
 .../libvirt-gconfig-domain-interface-network.h     |   67 ++++++++++++++
 libvirt-gconfig/libvirt-gconfig.h                  |    1 +
 libvirt-gconfig/libvirt-gconfig.sym                |    4 +
 5 files changed, 166 insertions(+), 0 deletions(-)
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface-network.h

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index a797db0..bd7f41b 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -16,6 +16,7 @@ GCONFIG_HEADER_FILES = \
 			libvirt-gconfig-domain-device.h \
 			libvirt-gconfig-domain-disk.h \
 			libvirt-gconfig-domain-interface.h \
+			libvirt-gconfig-domain-interface-network.h \
 			libvirt-gconfig-domain-os.h \
 			libvirt-gconfig-domain-snapshot.h \
 			libvirt-gconfig-domain-timer.h \
@@ -38,6 +39,7 @@ GCONFIG_SOURCE_FILES = \
 			libvirt-gconfig-domain-device.c \
 			libvirt-gconfig-domain-disk.c \
 			libvirt-gconfig-domain-interface.c \
+			libvirt-gconfig-domain-interface-network.c \
 			libvirt-gconfig-domain-os.c \
 			libvirt-gconfig-domain-snapshot.c \
 			libvirt-gconfig-domain-timer.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
new file mode 100644
index 0000000..fa2fb36
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
@@ -0,0 +1,92 @@
+/*
+ * libvirt-gobject-config-interface-network.c: libvirt glib integration
+ *
+ * Copyright (C) 2008 Daniel P. Berrange
+ * Copyright (C) 2011 Red Hat
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Daniel P. Berrange <berrange redhat com>
+ * Author: Christophe Fergeau <cfergeau redhat com>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+
+extern gboolean debugFlag;
+
+#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0)
+
+#define GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE_NETWORK, GVirConfigDomainInterfaceNetworkPrivate))
+
+struct _GVirConfigDomainInterfaceNetworkPrivate
+{
+    gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainInterfaceNetwork, gvir_config_domain_interface_network, GVIR_TYPE_CONFIG_DOMAIN_INTERFACE);
+
+
+static void gvir_config_domain_interface_network_class_init(GVirConfigDomainInterfaceNetworkClass *klass)
+{
+    g_type_class_add_private(klass, sizeof(GVirConfigDomainInterfaceNetworkPrivate));
+}
+
+
+static void gvir_config_domain_interface_network_init(GVirConfigDomainInterfaceNetwork *conn)
+{
+    GVirConfigDomainInterfaceNetworkPrivate *priv;
+
+    DEBUG("Init GVirConfigDomainInterfaceNetwork=%p", conn);
+
+    priv = conn->priv = GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK_GET_PRIVATE(conn);
+
+    memset(priv, 0, sizeof(*priv));
+}
+
+
+GVirConfigDomainInterfaceNetwork *gvir_config_domain_interface_network_new(void)
+{
+    xmlDocPtr doc;
+    xmlNodePtr node;
+
+    doc = xmlNewDoc((xmlChar *)"1.0");
+    node= xmlNewDocNode(doc, NULL, (xmlChar *)"interface", NULL);
+    xmlNewProp(doc->children, (xmlChar*)"type", (xmlChar*)"network");
+    xmlDocSetRootElement(doc, node);
+    return GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK(g_object_new(GVIR_TYPE_CONFIG_DOMAIN_INTERFACE_NETWORK,
+                                                "node", node,
+                                                NULL));
+}
+
+GVirConfigDomainInterfaceNetwork *gvir_config_domain_interface_network_new_from_xml(const gchar *xml,
+                                                                             GError **error)
+{
+    xmlNodePtr node;
+
+    node = gvir_config_xml_parse(xml, "interface", error);
+    if ((error != NULL) && (*error != NULL))
+        return NULL;
+    xmlNewProp(node, (xmlChar*)"type", (xmlChar*)"network");
+    return GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK(g_object_new(GVIR_TYPE_CONFIG_DOMAIN_INTERFACE_NETWORK,
+                                                "node", node,
+                                                NULL));
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.h b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.h
new file mode 100644
index 0000000..f6a355e
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.h
@@ -0,0 +1,67 @@
+/*
+ * libvirt-gobject-config-interface-network.c: libvirt gobject integration
+ *
+ * Copyright (C) 2011 Red Hat
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Daniel P. Berrange <berrange redhat com>
+ * Author: Christophe Fergeau <cfergeau 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_NETWORK_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_NETWORK_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_TYPE_CONFIG_DOMAIN_INTERFACE_NETWORK            (gvir_config_domain_interface_network_get_type ())
+#define GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterfaceNetwork))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterfaceNetworkClass))
+#define GVIR_IS_CONFIG_DOMAIN_INTERFACE_NETWORK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE))
+#define GVIR_IS_CONFIG_DOMAIN_INTERFACE_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterfaceNetworkClass))
+
+typedef struct _GVirConfigDomainInterfaceNetwork GVirConfigDomainInterfaceNetwork;
+typedef struct _GVirConfigDomainInterfaceNetworkPrivate GVirConfigDomainInterfaceNetworkPrivate;
+typedef struct _GVirConfigDomainInterfaceNetworkClass GVirConfigDomainInterfaceNetworkClass;
+
+struct _GVirConfigDomainInterfaceNetwork
+{
+    GVirConfigDomainInterface parent;
+
+    GVirConfigDomainInterfaceNetworkPrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainInterfaceNetworkClass
+{
+    GVirConfigDomainInterfaceClass parent_class;
+
+    gpointer padding[20];
+};
+
+GType gvir_config_domain_interface_network_get_type(void);
+
+GVirConfigDomainInterfaceNetwork *gvir_config_domain_interface_network_new(void);
+GVirConfigDomainInterfaceNetwork *gvir_config_domain_interface_network_new_from_xml(const gchar *xml,
+                                                                       GError **error);
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_NETWORK_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 151d09a..9940c4e 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -33,6 +33,7 @@
 #include <libvirt-gconfig/libvirt-gconfig-domain-device.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-disk.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-interface.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-interface-network.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-os.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-timer.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 6244d6d..04b0bb9 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -46,6 +46,10 @@ LIBVIRT_GOBJECT_0.0.1 {
 
 	gvir_config_domain_interface_get_type;
 
+	gvir_config_domain_interface_network_get_type;
+	gvir_config_domain_interface_network_new;
+	gvir_config_domain_interface_network_new_from_xml;
+
 	gvir_config_domain_os_get_type;
 	gvir_config_domain_os_boot_device_get_type;
 	gvir_config_domain_os_sm_bios_mode_get_type;
-- 
1.7.7.3


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