[libvirt] [libvirt-glib v3 1/4] Add GVirConfigCapabilitiesCpuModel class

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Tue Jul 15 22:42:29 UTC 2014


Add a class to represent 'model' node under capabilities/host/cpu.
---
 libvirt-gconfig/Makefile.am                        |  2 +
 .../libvirt-gconfig-capabilities-cpu-model.c       | 94 ++++++++++++++++++++++
 .../libvirt-gconfig-capabilities-cpu-model.h       | 72 +++++++++++++++++
 libvirt-gconfig/libvirt-gconfig.h                  |  1 +
 libvirt-gconfig/libvirt-gconfig.sym                |  5 ++
 5 files changed, 174 insertions(+)
 create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.c
 create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.h

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 8a3ff0d..02240d4 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -15,6 +15,7 @@ GCONFIG_HEADER_FILES = \
 			libvirt-gconfig-capabilities-host.h \
 			libvirt-gconfig-capabilities-cpu.h \
 			libvirt-gconfig-capabilities-cpu-feature.h \
+			libvirt-gconfig-capabilities-cpu-model.h \
 			libvirt-gconfig-capabilities-cpu-topology.h \
 			libvirt-gconfig-capabilities-guest.h \
 			libvirt-gconfig-capabilities-guest-arch.h \
@@ -103,6 +104,7 @@ GCONFIG_SOURCE_FILES = \
 			libvirt-gconfig-capabilities-host.c \
 			libvirt-gconfig-capabilities-cpu.c \
 			libvirt-gconfig-capabilities-cpu-feature.c \
+			libvirt-gconfig-capabilities-cpu-model.c \
 			libvirt-gconfig-capabilities-cpu-topology.c \
 			libvirt-gconfig-capabilities-guest.c \
 			libvirt-gconfig-capabilities-guest-arch.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.c b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.c
new file mode 100644
index 0000000..002b77f
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.c
@@ -0,0 +1,94 @@
+/*
+ * libvirt-gconfig-capabilities-cpu-model.c: libvirt CPU model capabilities
+ *
+ * Copyright (C) 2014 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: Zeeshan Ali <zeenix at redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_CAPABILITIES_CPU_MODEL_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL, GVirConfigCapabilitiesCpuModelPrivate))
+
+struct _GVirConfigCapabilitiesCpuModelPrivate
+{
+    gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigCapabilitiesCpuModel, gvir_config_capabilities_cpu_model, GVIR_CONFIG_TYPE_OBJECT);
+
+static void gvir_config_capabilities_cpu_model_class_init(GVirConfigCapabilitiesCpuModelClass *klass)
+{
+    g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesCpuModelPrivate));
+}
+
+static void gvir_config_capabilities_cpu_model_init(GVirConfigCapabilitiesCpuModel *model)
+{
+    g_debug("Init GVirConfigCapabilitiesCpuModel=%p", model);
+
+    model->priv = GVIR_CONFIG_CAPABILITIES_CPU_MODEL_GET_PRIVATE(model);
+}
+
+GVirConfigCapabilitiesCpuModel *gvir_config_capabilities_cpu_model_new(void)
+{
+    GVirConfigObject *object;
+
+    object = gvir_config_object_new(GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL,
+                                    "model",
+                                    NULL);
+
+    return GVIR_CONFIG_CAPABILITIES_CPU_MODEL(object);
+}
+
+GVirConfigCapabilitiesCpuModel *
+gvir_config_capabilities_cpu_model_new_from_xml(const gchar *xml, GError **error)
+{
+    GVirConfigObject *object;
+
+    object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL,
+                                             "model",
+                                             NULL,
+                                             xml,
+                                             error);
+
+    return GVIR_CONFIG_CAPABILITIES_CPU_MODEL(object);
+}
+
+void
+gvir_config_capabilities_cpu_model_set_name(GVirConfigCapabilitiesCpuModel *model,
+                                            const gchar *name)
+{
+    g_return_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU_MODEL(model));
+
+    gvir_config_object_set_node_content
+                (GVIR_CONFIG_OBJECT(model),
+                 NULL,
+                 name);
+}
+
+const gchar *
+gvir_config_capabilities_cpu_model_get_name(GVirConfigCapabilitiesCpuModel *model)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU_MODEL(model), NULL);
+
+    return gvir_config_object_get_node_content (GVIR_CONFIG_OBJECT(model),
+                                                NULL);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.h b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.h
new file mode 100644
index 0000000..e5ace4e
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.h
@@ -0,0 +1,72 @@
+/*
+ * libvirt-gconfig-capabilities-cpu-model.h: libvirt CPU model capabilities
+ *
+ * Copyright (C) 2014 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: Zeeshan Ali <zeenix at 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_CAPABILITIES_CPU_MODEL_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_CPU_MODEL_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL            (gvir_config_capabilities_cpu_model_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_CPU_MODEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL, GVirConfigCapabilitiesCpuModel))
+#define GVIR_CONFIG_CAPABILITIES_CPU_MODEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL, GVirConfigCapabilitiesCpuModelClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_CPU_MODEL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL))
+#define GVIR_CONFIG_IS_CAPABILITIES_CPU_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL))
+#define GVIR_CONFIG_CAPABILITIES_CPU_MODEL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL, GVirConfigCapabilitiesCpuModelClass))
+
+typedef struct _GVirConfigCapabilitiesCpuModel GVirConfigCapabilitiesCpuModel;
+typedef struct _GVirConfigCapabilitiesCpuModelPrivate GVirConfigCapabilitiesCpuModelPrivate;
+typedef struct _GVirConfigCapabilitiesCpuModelClass GVirConfigCapabilitiesCpuModelClass;
+
+struct _GVirConfigCapabilitiesCpuModel
+{
+    GVirConfigObject parent;
+
+    GVirConfigCapabilitiesCpuModelPrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesCpuModelClass
+{
+    GVirConfigObjectClass parent_class;
+
+    gpointer padding[20];
+};
+
+GType gvir_config_capabilities_cpu_model_get_type(void);
+GVirConfigCapabilitiesCpuModel *gvir_config_capabilities_cpu_model_new(void);
+GVirConfigCapabilitiesCpuModel *
+gvir_config_capabilities_cpu_model_new_from_xml(const gchar *xml, GError **error);
+
+void
+gvir_config_capabilities_cpu_model_set_name(GVirConfigCapabilitiesCpuModel *model,
+                                            const gchar *name);
+const gchar *
+gvir_config_capabilities_cpu_model_get_name(GVirConfigCapabilitiesCpuModel *model);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_CPU_MODEL_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index b494154..7fed91d 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -31,6 +31,7 @@
 #include <libvirt-gconfig/libvirt-gconfig-capabilities.h>
 #include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h>
 #include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.h>
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu-model.h>
 #include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu-topology.h>
 #include <libvirt-gconfig/libvirt-gconfig-capabilities-guest.h>
 #include <libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 0d33fdb..76dde70 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -689,6 +689,11 @@ global:
 
 LIBVIRT_GCONFIG_0.1.9 {
 global:
+	gvir_config_capabilities_cpu_model_get_name;
+	gvir_config_capabilities_cpu_model_get_type;
+	gvir_config_capabilities_cpu_model_new;
+	gvir_config_capabilities_cpu_model_set_name;
+
 	gvir_config_capabilities_host_get_secmodels;
 
 	gvir_config_capabilities_host_secmodel_get_doi;
-- 
1.9.3




More information about the libvir-list mailing list