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

[libvirt] [libvirt-glib 5/8] Add GVirConfigDomainCpuFeature class



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

API to handle 'domain/cpu/feature' nodes.
---
 libvirt-gconfig/Makefile.am                        |    2 +
 .../libvirt-gconfig-domain-cpu-feature.c           |  100 ++++++++++++++++++++
 .../libvirt-gconfig-domain-cpu-feature.h           |   81 ++++++++++++++++
 libvirt-gconfig/libvirt-gconfig.h                  |    1 +
 libvirt-gconfig/libvirt-gconfig.sym                |    7 ++
 5 files changed, 191 insertions(+)
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.c
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.h

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 19aa6ba..7f0ea3b 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -33,6 +33,7 @@ GCONFIG_HEADER_FILES = \
 			libvirt-gconfig-domain-console.h \
 			libvirt-gconfig-domain-controller.h \
 			libvirt-gconfig-domain-controller-usb.h \
+			libvirt-gconfig-domain-cpu-feature.h \
 			libvirt-gconfig-domain-device.h \
 			libvirt-gconfig-domain-disk.h \
 			libvirt-gconfig-domain-filesys.h \
@@ -101,6 +102,7 @@ GCONFIG_SOURCE_FILES = \
 			libvirt-gconfig-domain-console.c \
 			libvirt-gconfig-domain-controller.c \
 			libvirt-gconfig-domain-controller-usb.c \
+			libvirt-gconfig-domain-cpu-feature.c \
 			libvirt-gconfig-domain-device.c \
 			libvirt-gconfig-domain-disk.c \
 			libvirt-gconfig-domain-filesys.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.c b/libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.c
new file mode 100644
index 0000000..55dd375
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.c
@@ -0,0 +1,100 @@
+/*
+ * libvirt-gconfig-capabilities-cpu-feature.c: libvirt domain CPU feature
+ *
+ * Copyright (C) 2008 Daniel P. Berrange
+ * Copyright (C) 2010-2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Authors: Zeeshan Ali <zeenix redhat com>
+ *          Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_CPU_FEATURE_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE, GVirConfigDomainCpuFeaturePrivate))
+
+struct _GVirConfigDomainCpuFeaturePrivate
+{
+    gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainCpuFeature, gvir_config_domain_cpu_feature, GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE);
+
+static void gvir_config_domain_cpu_feature_class_init(GVirConfigDomainCpuFeatureClass *klass)
+{
+    g_type_class_add_private(klass, sizeof(GVirConfigDomainCpuFeaturePrivate));
+}
+
+static void gvir_config_domain_cpu_feature_init(GVirConfigDomainCpuFeature *feature)
+{
+    g_debug("Init GVirConfigDomainCpuFeature=%p", feature);
+
+    feature->priv = GVIR_CONFIG_DOMAIN_CPU_FEATURE_GET_PRIVATE(feature);
+}
+
+GVirConfigDomainCpuFeature *gvir_config_domain_cpu_feature_new(void)
+{
+    GVirConfigObject *object;
+
+    object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE,
+                                    "feature",
+                                    NULL);
+
+    return GVIR_CONFIG_DOMAIN_CPU_FEATURE(object);
+}
+
+GVirConfigDomainCpuFeature *
+gvir_config_domain_cpu_feature_new_from_xml(const gchar *xml, GError **error)
+{
+    GVirConfigObject *object;
+
+    object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE,
+                                             "feature",
+                                             NULL,
+                                             xml,
+                                             error);
+
+    return GVIR_CONFIG_DOMAIN_CPU_FEATURE(object);
+}
+
+GVirConfigDomainCpuFeaturePolicy
+gvir_config_domain_cpu_feature_get_policy(GVirConfigDomainCpuFeature *feature)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_CPU_FEATURE(feature),
+                         GVIR_CONFIG_DOMAIN_CPU_FEATURE_POLICY_REQUIRE);
+
+    return gvir_config_object_get_attribute_genum
+                (GVIR_CONFIG_OBJECT(feature),
+                 NULL,
+                 "policy",
+                 GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE_POLICY,
+                 GVIR_CONFIG_DOMAIN_CPU_FEATURE_POLICY_REQUIRE);
+}
+
+void gvir_config_domain_cpu_feature_set_policy(GVirConfigDomainCpuFeature *feature,
+                                               GVirConfigDomainCpuFeaturePolicy policy)
+{
+    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CPU_FEATURE(feature));
+
+    gvir_config_object_set_attribute_with_type
+                (GVIR_CONFIG_OBJECT(feature),
+                 "policy", GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE_POLICY, policy,
+                 NULL);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.h b/libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.h
new file mode 100644
index 0000000..e190380
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.h
@@ -0,0 +1,81 @@
+/*
+ * libvirt-gconfig-capabilities-cpu-feature.h: libvirt domain CPU feature
+ *
+ * Copyright (C) 2010-2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Authors: Zeeshan Ali <zeenix redhat com>
+ *          Daniel P. Berrange <berrange 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_CPU_FEATURE_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_CPU_FEATURE_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE            (gvir_config_domain_cpu_feature_get_type ())
+#define GVIR_CONFIG_DOMAIN_CPU_FEATURE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE, GVirConfigDomainCpuFeature))
+#define GVIR_CONFIG_DOMAIN_CPU_FEATURE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE, GVirConfigDomainCpuFeatureClass))
+#define GVIR_CONFIG_IS_DOMAIN_CPU_FEATURE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE))
+#define GVIR_CONFIG_IS_DOMAIN_CPU_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE))
+#define GVIR_CONFIG_DOMAIN_CPU_FEATURE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_FEATURE, GVirConfigDomainCpuFeatureClass))
+
+typedef struct _GVirConfigDomainCpuFeature GVirConfigDomainCpuFeature;
+typedef struct _GVirConfigDomainCpuFeaturePrivate GVirConfigDomainCpuFeaturePrivate;
+typedef struct _GVirConfigDomainCpuFeatureClass GVirConfigDomainCpuFeatureClass;
+
+struct _GVirConfigDomainCpuFeature
+{
+    GVirConfigCapabilitiesCpu parent;
+
+    GVirConfigDomainCpuFeaturePrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainCpuFeatureClass
+{
+    GVirConfigCapabilitiesCpuClass parent_class;
+
+    gpointer padding[20];
+};
+
+typedef enum {
+    GVIR_CONFIG_DOMAIN_CPU_FEATURE_POLICY_FORCE,
+    GVIR_CONFIG_DOMAIN_CPU_FEATURE_POLICY_REQUIRE,
+    GVIR_CONFIG_DOMAIN_CPU_FEATURE_POLICY_OPTIONAL,
+    GVIR_CONFIG_DOMAIN_CPU_FEATURE_POLICY_DISABLE,
+    GVIR_CONFIG_DOMAIN_CPU_FEATURE_POLICY_FORBID
+} GVirConfigDomainCpuFeaturePolicy;
+
+GType gvir_config_domain_cpu_feature_get_type(void);
+GVirConfigDomainCpuFeature *gvir_config_domain_cpu_feature_new(void);
+GVirConfigDomainCpuFeature *
+gvir_config_domain_cpu_feature_new_from_xml(const gchar *xml, GError **error);
+
+void
+gvir_config_domain_cpu_feature_set_policy(GVirConfigDomainCpuFeature *feature,
+                                          GVirConfigDomainCpuFeaturePolicy policy);
+GVirConfigDomainCpuFeaturePolicy
+gvir_config_domain_cpu_feature_get_policy(GVirConfigDomainCpuFeature *feature);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_CPU_FEATURE_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 1e69962..41c3d80 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -50,6 +50,7 @@
 #include <libvirt-gconfig/libvirt-gconfig-domain-console.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-controller.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-controller-usb.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-device.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-disk.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-filesys.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index f66a22e..fb93931 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -429,6 +429,13 @@ LIBVIRT_GCONFIG_0.0.9 {
 	gvir_config_capabilities_host_get_type;
 	gvir_config_capabilities_host_get_uuid;
 	gvir_config_capabilities_host_get_cpu;
+
+	gvir_config_domain_cpu_feature_get_type;
+	gvir_config_domain_cpu_feature_policy_get_type;
+	gvir_config_domain_cpu_feature_get_policy;
+	gvir_config_domain_cpu_feature_set_policy;
+	gvir_config_domain_cpu_feature_new;
+	gvir_config_domain_cpu_feature_new_from_xml;
 } LIBVIRT_GCONFIG_0.0.8;
 
 # .... define new API here using predicted next version number ....
-- 
1.7.10.4


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