On Fri, May 11, 2012 at 04:18:16PM +0300, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
Not quite complete but its a good start.
---
libvirt-gconfig/Makefile.am | 8 +
.../libvirt-gconfig-capabilities-guest-arch.c | 125 ++++++++++++++++++
.../libvirt-gconfig-capabilities-guest-arch.h | 71 ++++++++++
.../libvirt-gconfig-capabilities-guest-domain.c | 73 ++++++++++
.../libvirt-gconfig-capabilities-guest-domain.h | 72 ++++++++++
.../libvirt-gconfig-capabilities-guest-feature.c | 61 +++++++++
.../libvirt-gconfig-capabilities-guest-feature.h | 67 ++++++++++
.../libvirt-gconfig-capabilities-guest.c | 139 ++++++++++++++++++++
.../libvirt-gconfig-capabilities-guest.h | 75 +++++++++++
libvirt-gconfig/libvirt-gconfig-capabilities.c | 55 ++++++++
libvirt-gconfig/libvirt-gconfig-capabilities.h | 1 +
libvirt-gconfig/libvirt-gconfig.h | 6 +-
libvirt-gconfig/libvirt-gconfig.sym | 18 +++
13 files changed, 770 insertions(+), 1 deletions(-)
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.h
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.h
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.h
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-guest.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 54899a3..4bc3ee1 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -15,6 +15,10 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-capabilities-host.h \
libvirt-gconfig-capabilities-cpu.h \
libvirt-gconfig-capabilities-cpu-feature.h \
+ libvirt-gconfig-capabilities-guest.h \
+ libvirt-gconfig-capabilities-guest-arch.h \
+ libvirt-gconfig-capabilities-guest-domain.h \
+ libvirt-gconfig-capabilities-guest-feature.h \
libvirt-gconfig-domain.h \
libvirt-gconfig-domain-address.h \
libvirt-gconfig-domain-address-pci.h \
@@ -78,6 +82,10 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-capabilities-host.c \
libvirt-gconfig-capabilities-cpu.c \
libvirt-gconfig-capabilities-cpu-feature.c \
+ libvirt-gconfig-capabilities-guest.c \
+ libvirt-gconfig-capabilities-guest-arch.c \
+ libvirt-gconfig-capabilities-guest-domain.c \
+ libvirt-gconfig-capabilities-guest-feature.c \
libvirt-gconfig-domain.c \
libvirt-gconfig-domain-address.c \
libvirt-gconfig-domain-address-pci.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.c
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.c
new file mode 100644
index 0000000..fe45525
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.c
@@ -0,0 +1,125 @@
+/*
+ * libvirt-gconfig-capabilities-cpu-arch.c: libvirt guest architecture capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_CAPABILITIES_GUEST_ARCH_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH,
GVirConfigCapabilitiesGuestArchPrivate))
+
+struct _GVirConfigCapabilitiesGuestArchPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigCapabilitiesGuestArch, gvir_config_capabilities_guest_arch,
GVIR_CONFIG_TYPE_OBJECT);
+
+static void
gvir_config_capabilities_guest_arch_class_init(GVirConfigCapabilitiesGuestArchClass
*klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesGuestArchPrivate));
+}
+
+static void gvir_config_capabilities_guest_arch_init(GVirConfigCapabilitiesGuestArch
*arch)
+{
+ g_debug("Init GVirConfigCapabilitiesGuestArch=%p", arch);
+
+ arch->priv = GVIR_CONFIG_CAPABILITIES_GUEST_ARCH_GET_PRIVATE(arch);
+}
+
+const gchar *
+gvir_config_capabilities_guest_arch_get_name(GVirConfigCapabilitiesGuestArch *arch)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST_ARCH(arch), NULL);
+
+ return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(arch),
+ NULL,
+ "name");
+}
+
+struct GetDomainData {
+ GVirConfigXmlDoc *doc;
+ const gchar *schema;
+ GList *domains;
+};
+
+static gboolean add_domain(xmlNodePtr node, gpointer opaque)
+{
+ struct GetDomainData* data = (struct GetDomainData*)opaque;
+ GVirConfigObject *object;
+
+ if (g_strcmp0((const gchar *)node->name, "domain") != 0)
+ return TRUE;
+
+ object = gvir_config_object_new_from_tree
+ (GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN,
+ data->doc,
+ data->schema,
+ node);
+ if (object != NULL)
+ data->domains = g_list_append(data->domains, object);
+ else
+ g_debug("Failed to parse %s node", node->name);
+
+ return TRUE;
+}
+
+/**
+ * gvir_config_capabilities_guest_arch_get_domains:
+ *
+ * Gets the possible domains for this architecture.
+ *
+ * Returns: (element-type LibvirtGConfig.CapabilitiesGuestDomain) (transfer full):
+ * a newly allocated #GList of #GVirConfigCapabilitiesGuestDomain.
+ */
+GList *
+gvir_config_capabilities_guest_arch_get_domains(GVirConfigCapabilitiesGuestArch *arch)
+{
+ struct GetDomainData data;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST_ARCH(arch), NULL);
+
+ g_object_get(G_OBJECT(arch), "doc", &data.doc, NULL);
+ g_return_val_if_fail(data.doc != NULL, NULL);
+ data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(arch));
+ data.domains = NULL;
+
+ gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(arch),
+ NULL,
+ add_domain,
+ &data);
+ g_clear_object(&data.doc);
+
+ return data.domains;
+}
+
+const gchar *
+gvir_config_capabilities_guest_arch_get_emulator(GVirConfigCapabilitiesGuestArch *arch)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST_ARCH(arch), NULL);
+
+ return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(arch),
+ "emulator");
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.h
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.h
new file mode 100644
index 0000000..08612f2
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.h
@@ -0,0 +1,71 @@
+/*
+ * libvirt-gconfig-capabilities-guest-arch.h: libvirt guest architecture capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)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_GUEST_ARCH_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_ARCH_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH
(gvir_config_capabilities_guest_arch_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_GUEST_ARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH, GVirConfigCapabilitiesGuestArch))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_ARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH,
GVirConfigCapabilitiesGuestArchClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST_ARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST_ARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_ARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH, GVirConfigCapabilitiesGuestArchClass))
+
+typedef struct _GVirConfigCapabilitiesGuestArch GVirConfigCapabilitiesGuestArch;
+typedef struct _GVirConfigCapabilitiesGuestArchPrivate
GVirConfigCapabilitiesGuestArchPrivate;
+typedef struct _GVirConfigCapabilitiesGuestArchClass
GVirConfigCapabilitiesGuestArchClass;
+
+struct _GVirConfigCapabilitiesGuestArch
+{
+ GVirConfigObject parent;
+
+ GVirConfigCapabilitiesGuestArchPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesGuestArchClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_capabilities_guest_arch_get_type(void);
+
+const gchar *
+gvir_config_capabilities_guest_arch_get_name(GVirConfigCapabilitiesGuestArch *arch);
+GList *
+gvir_config_capabilities_guest_arch_get_domains(GVirConfigCapabilitiesGuestArch *arch);
+const gchar *
+gvir_config_capabilities_guest_arch_get_emulator(GVirConfigCapabilitiesGuestArch
*arch);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_ARCH_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.c
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.c
new file mode 100644
index 0000000..0d6f269
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.c
@@ -0,0 +1,73 @@
+/*
+ * libvirt-gconfig-capabilities-guest-domain.c: libvirt guest domain capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_CAPABILITIES_GUEST_DOMAIN_GET_PRIVATE(obj)
\
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN,
GVirConfigCapabilitiesGuestDomainPrivate))
+
+struct _GVirConfigCapabilitiesGuestDomainPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigCapabilitiesGuestDomain, gvir_config_capabilities_guest_domain,
GVIR_CONFIG_TYPE_OBJECT);
+
+
+static void
gvir_config_capabilities_guest_domain_class_init(GVirConfigCapabilitiesGuestDomainClass
*klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesGuestDomainPrivate));
+}
+
+static void gvir_config_capabilities_guest_domain_init(GVirConfigCapabilitiesGuestDomain
*domain)
+{
+ g_debug("Init GVirConfigCapabilitiesGuestDomain=%p", domain);
+
+ domain->priv = GVIR_CONFIG_CAPABILITIES_GUEST_DOMAIN_GET_PRIVATE(domain);
+}
+
+const gchar *
+gvir_config_capabilities_guest_domain_get_emulator(GVirConfigCapabilitiesGuestDomain
*domain)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST_DOMAIN(domain), NULL);
+
+ return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(domain),
"emulator");
+}
+
+GVirConfigDomainVirtType
+gvir_config_capabilities_guest_domain_get_virt_type(GVirConfigCapabilitiesGuestDomain
*domain)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST_DOMAIN(domain),
+ GVIR_CONFIG_DOMAIN_VIRT_QEMU);
+
+ return gvir_config_object_get_attribute_genum
+ (GVIR_CONFIG_OBJECT(domain),
+ NULL,
+ "type",
+ GVIR_CONFIG_TYPE_DOMAIN_VIRT_TYPE,
+ GVIR_CONFIG_DOMAIN_VIRT_QEMU);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.h
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.h
new file mode 100644
index 0000000..2215bce
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.h
@@ -0,0 +1,72 @@
+/*
+ * libvirt-gconfig-capabilities-guest-domain.h: libvirt guest domain capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)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_GUEST_DOMAIN_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_DOMAIN_H__
+
+#include "libvirt-gconfig-domain.h"
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN
(gvir_config_capabilities_guest_domain_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_GUEST_DOMAIN(obj)
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN,
GVirConfigCapabilitiesGuestDomain))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN,
GVirConfigCapabilitiesGuestDomainClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST_DOMAIN(obj)
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_DOMAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_DOMAIN,
GVirConfigCapabilitiesGuestDomainClass))
+
+typedef struct _GVirConfigCapabilitiesGuestDomain GVirConfigCapabilitiesGuestDomain;
+typedef struct _GVirConfigCapabilitiesGuestDomainPrivate
GVirConfigCapabilitiesGuestDomainPrivate;
+typedef struct _GVirConfigCapabilitiesGuestDomainClass
GVirConfigCapabilitiesGuestDomainClass;
+
+struct _GVirConfigCapabilitiesGuestDomain
+{
+ GVirConfigObject parent;
+
+ GVirConfigCapabilitiesGuestDomainPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesGuestDomainClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_capabilities_guest_domain_get_type(void);
+
+const gchar *
+gvir_config_capabilities_guest_domain_get_emulator(GVirConfigCapabilitiesGuestDomain
*domain);
+
+GVirConfigDomainVirtType
+gvir_config_capabilities_guest_domain_get_virt_type(GVirConfigCapabilitiesGuestDomain
*domain);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_DOMAIN_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.c
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.c
new file mode 100644
index 0000000..52b4524
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.c
@@ -0,0 +1,61 @@
+/*
+ * libvirt-gconfig-capabilities-guest-feature.c: libvirt guest feature capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_CAPABILITIES_GUEST_FEATURE_GET_PRIVATE(obj)
\
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE,
GVirConfigCapabilitiesGuestFeaturePrivate))
+
+struct _GVirConfigCapabilitiesGuestFeaturePrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigCapabilitiesGuestFeature,
gvir_config_capabilities_guest_feature, GVIR_CONFIG_TYPE_OBJECT);
+
+static void
gvir_config_capabilities_guest_feature_class_init(GVirConfigCapabilitiesGuestFeatureClass
*klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesGuestFeaturePrivate));
+}
+
+static void
gvir_config_capabilities_guest_feature_init(GVirConfigCapabilitiesGuestFeature *feature)
+{
+ g_debug("Init GVirConfigCapabilitiesGuestFeature=%p", feature);
+
+ feature->priv = GVIR_CONFIG_CAPABILITIES_GUEST_FEATURE_GET_PRIVATE(feature);
+}
+
+const gchar *
+gvir_config_capabilities_guest_feature_get_name(GVirConfigCapabilitiesGuestFeature
*feature)
+{
+ xmlNodePtr node;
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(feature));
+ g_return_val_if_fail(node != NULL, NULL);
+
+ return (const gchar *)node->name;
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.h
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.h
new file mode 100644
index 0000000..83b3fea
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.h
@@ -0,0 +1,67 @@
+/*
+ * libvirt-gconfig-capabilities-guest-feature.h: libvirt guest feature capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)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_GUEST_FEATURE_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_FEATURE_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE
(gvir_config_capabilities_guest_feature_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_GUEST_FEATURE(obj)
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE,
GVirConfigCapabilitiesGuestFeature))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE,
GVirConfigCapabilitiesGuestFeatureClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST_FEATURE(obj)
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_FEATURE_GET_CLASS(obj)
(G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE,
GVirConfigCapabilitiesGuestFeatureClass))
+
+typedef struct _GVirConfigCapabilitiesGuestFeature GVirConfigCapabilitiesGuestFeature;
+typedef struct _GVirConfigCapabilitiesGuestFeaturePrivate
GVirConfigCapabilitiesGuestFeaturePrivate;
+typedef struct _GVirConfigCapabilitiesGuestFeatureClass
GVirConfigCapabilitiesGuestFeatureClass;
+
+struct _GVirConfigCapabilitiesGuestFeature
+{
+ GVirConfigObject parent;
+
+ GVirConfigCapabilitiesGuestFeaturePrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesGuestFeatureClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_capabilities_guest_feature_get_type(void);
+
+const gchar *
+gvir_config_capabilities_guest_feature_get_name(GVirConfigCapabilitiesGuestFeature
*feature);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_FEATURE_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest.c
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest.c
new file mode 100644
index 0000000..04b610a
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest.c
@@ -0,0 +1,139 @@
+/*
+ * libvirt-gconfig-capabilities-guest.c: libvirt guest capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_CAPABILITIES_GUEST_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST,
GVirConfigCapabilitiesGuestPrivate))
+
+struct _GVirConfigCapabilitiesGuestPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigCapabilitiesGuest, gvir_config_capabilities_guest,
GVIR_CONFIG_TYPE_OBJECT);
+
+
+static void gvir_config_capabilities_guest_class_init(GVirConfigCapabilitiesGuestClass
*klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesGuestPrivate));
+}
+
+static void gvir_config_capabilities_guest_init(GVirConfigCapabilitiesGuest *guest)
+{
+ g_debug("Init GVirConfigCapabilitiesGuest=%p", guest);
+
+ guest->priv = GVIR_CONFIG_CAPABILITIES_GUEST_GET_PRIVATE(guest);
+}
+
+GVirConfigDomainOsType
This is missing an additional patch adding the missing entries to
GVirConfigDomainOsType, ACK otherwise.
Christophe
+gvir_config_capabilities_guest_get_os_type(GVirConfigCapabilitiesGuest *guest)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST(guest),
+ GVIR_CONFIG_DOMAIN_OS_TYPE_LINUX);
+
+ return gvir_config_object_get_node_content_genum(GVIR_CONFIG_OBJECT(guest),
+ "os_type",
+ GVIR_CONFIG_TYPE_DOMAIN_OS_TYPE,
+ GVIR_CONFIG_DOMAIN_OS_TYPE_LINUX);
+}
+
+/**
+ * gvir_config_capabilities_guest_get_arch:
+ *
+ * Gets the CPU architecture capabilities of the guest.
+ *
+ * Returns: (transfer full): a new #GVirConfigCapabilitiesGuestArch.
+ */
+GVirConfigCapabilitiesGuestArch *
+gvir_config_capabilities_guest_get_arch(GVirConfigCapabilitiesGuest *guest)
+{
+ GVirConfigObject *object;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST(guest), NULL);
+
+ object = gvir_config_object_get_child_with_type
+ (GVIR_CONFIG_OBJECT(guest),
+ "arch",
+ GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_ARCH);
+
+ return GVIR_CONFIG_CAPABILITIES_GUEST_ARCH(object);
+}
+
+struct GetFeatureData {
+ GVirConfigXmlDoc *doc;
+ const gchar *schema;
+ GList *features;
+};
+
+static gboolean add_feature(xmlNodePtr node, gpointer opaque)
+{
+ struct GetFeatureData* data = (struct GetFeatureData*)opaque;
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new_from_tree
+ (GVIR_CONFIG_TYPE_CAPABILITIES_GUEST_FEATURE,
+ data->doc,
+ data->schema,
+ node);
+ if (object != NULL)
+ data->features = g_list_append(data->features, object);
+ else
+ g_debug("Failed to parse %s node", node->name);
+
+ return TRUE;
+}
+
+/**
+ * gvir_config_capabilities_guest_get_features:
+ *
+ * Gets the CPU features for this guest.
+ *
+ * Returns: (element-type LibvirtGConfig.CapabilitiesGuestFeature) (transfer full):
+ * a newly allocated #GList of #GVirConfigCapabilitiesGuestFeature.
+ */
+GList *
+gvir_config_capabilities_guest_get_features(GVirConfigCapabilitiesGuest *guest)
+{
+ struct GetFeatureData data;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_GUEST(guest), NULL);
+
+ g_object_get(G_OBJECT(guest), "doc", &data.doc, NULL);
+ g_return_val_if_fail(data.doc != NULL, NULL);
+ data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(guest));
+ data.features = NULL;
+
+ gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(guest),
+ "features",
+ add_feature,
+ &data);
+
+ g_clear_object(&data.doc);
+
+ return data.features;
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-guest.h
b/libvirt-gconfig/libvirt-gconfig-capabilities-guest.h
new file mode 100644
index 0000000..fd074f2
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-guest.h
@@ -0,0 +1,75 @@
+/*
+ * libvirt-gconfig-capabilities-guest.h: libvirt guest capabilities
+ *
+ * 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(a)redhat.com>
+ * Daniel P. Berrange <berrange(a)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_GUEST_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_H__
+
+#include "libvirt-gconfig-domain-os.h"
+#include "libvirt-gconfig-capabilities-guest-arch.h"
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_GUEST
(gvir_config_capabilities_guest_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_GUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST, GVirConfigCapabilitiesGuest))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST, GVirConfigCapabilitiesGuestClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST))
+#define GVIR_CONFIG_IS_CAPABILITIES_GUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST))
+#define GVIR_CONFIG_CAPABILITIES_GUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_GUEST, GVirConfigCapabilitiesGuestClass))
+
+typedef struct _GVirConfigCapabilitiesGuest GVirConfigCapabilitiesGuest;
+typedef struct _GVirConfigCapabilitiesGuestPrivate GVirConfigCapabilitiesGuestPrivate;
+typedef struct _GVirConfigCapabilitiesGuestClass GVirConfigCapabilitiesGuestClass;
+
+struct _GVirConfigCapabilitiesGuest
+{
+ GVirConfigObject parent;
+
+ GVirConfigCapabilitiesGuestPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesGuestClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_capabilities_guest_get_type(void);
+
+GVirConfigDomainOsType
+gvir_config_capabilities_guest_get_os_type(GVirConfigCapabilitiesGuest *guest);
+
+GVirConfigCapabilitiesGuestArch *
+gvir_config_capabilities_guest_get_arch(GVirConfigCapabilitiesGuest *guest);
+GList *
+gvir_config_capabilities_guest_get_features(GVirConfigCapabilitiesGuest *guest);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_GUEST_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities.c
b/libvirt-gconfig/libvirt-gconfig-capabilities.c
index 43b91e0..d2664cc 100644
--- a/libvirt-gconfig/libvirt-gconfig-capabilities.c
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities.c
@@ -94,3 +94,58 @@ gvir_config_capabilities_get_host(GVirConfigCapabilities *caps)
return GVIR_CONFIG_CAPABILITIES_HOST(object);
}
+
+struct GetGuestData {
+ GVirConfigXmlDoc *doc;
+ const gchar *schema;
+ GList *guests;
+};
+
+static gboolean add_guest(xmlNodePtr node, gpointer opaque)
+{
+ struct GetGuestData* data = (struct GetGuestData*)opaque;
+ GVirConfigObject *object;
+
+ if (g_strcmp0((const gchar *)node->name, "guest") != 0)
+ return TRUE;
+
+ object = gvir_config_object_new_from_tree(GVIR_CONFIG_TYPE_CAPABILITIES_GUEST,
+ data->doc,
+ data->schema,
+ node);
+ if (object != NULL)
+ data->guests = g_list_append(data->guests, object);
+ else
+ g_debug("Failed to parse %s node", node->name);
+
+ return TRUE;
+}
+
+/**
+ * gvir_config_capabilities_get_guests:
+ *
+ * Gets the list of guest capabilities.
+ *
+ * Returns: (element-type LibvirtGConfig.CapabilitiesGuest) (transfer full):
+ * a newly allocated #GList of #GVirConfigCapabilitiesGuest.
+ */
+GList *
+gvir_config_capabilities_get_guests(GVirConfigCapabilities *caps)
+{
+ struct GetGuestData data;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES(caps), NULL);
+
+ g_object_get(G_OBJECT(caps), "doc", &data.doc, NULL);
+ data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(caps));
+ data.guests = NULL;
+
+ gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(caps),
+ NULL,
+ add_guest,
+ &data);
+
+ g_clear_object(&data.doc);
+
+ return data.guests;
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities.h
b/libvirt-gconfig/libvirt-gconfig-capabilities.h
index 2ec8369..2e373c9 100644
--- a/libvirt-gconfig/libvirt-gconfig-capabilities.h
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities.h
@@ -65,6 +65,7 @@ GVirConfigCapabilities *gvir_config_capabilities_new_from_xml(const
gchar *xml,
GError **error);
GVirConfigCapabilitiesHost *
gvir_config_capabilities_get_host(GVirConfigCapabilities *caps);
+GList *gvir_config_capabilities_get_guests(GVirConfigCapabilities *caps);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index f9be83f..1201eb8 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -29,8 +29,12 @@
#include <libvirt-gconfig/libvirt-gconfig-main.h>
#include <libvirt-gconfig/libvirt-gconfig-object.h>
#include <libvirt-gconfig/libvirt-gconfig-capabilities.h>
-#include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.h>
#include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h>
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.h>
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-guest.h>
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-guest-arch.h>
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.h>
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.h>
#include <libvirt-gconfig/libvirt-gconfig-capabilities-host.h>
#include <libvirt-gconfig/libvirt-gconfig-domain.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-address.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 7d015f5..21fff46 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -380,6 +380,7 @@ LIBVIRT_GCONFIG_0.0.9 {
gvir_config_domain_os_get_boot_devices;
gvir_config_capabilities_get_host;
+ gvir_config_capabilities_get_guests;
gvir_config_capabilities_cpu_get_type;
gvir_config_capabilities_cpu_get_arch;
@@ -388,6 +389,23 @@ LIBVIRT_GCONFIG_0.0.9 {
gvir_config_capabilities_cpu_feature_get_type;
gvir_config_capabilities_cpu_feature_get_name;
+ gvir_config_capabilities_guest_get_type;
+ gvir_config_capabilities_guest_get_arch;
+ gvir_config_capabilities_guest_get_features;
+ gvir_config_capabilities_guest_get_os_type;
+
+ gvir_config_capabilities_guest_arch_get_type;
+ gvir_config_capabilities_guest_arch_get_domains;
+ gvir_config_capabilities_guest_arch_get_emulator;
+ gvir_config_capabilities_guest_arch_get_name;
+
+ gvir_config_capabilities_guest_domain_get_type;
+ gvir_config_capabilities_guest_domain_get_emulator;
+ gvir_config_capabilities_guest_domain_get_virt_type;
+
+ gvir_config_capabilities_guest_feature_get_type;
+ gvir_config_capabilities_guest_feature_get_name;
+
gvir_config_capabilities_host_get_type;
gvir_config_capabilities_host_get_uuid;
gvir_config_capabilities_host_get_cpu;
--
1.7.7.6
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list