On Tue, May 01, 2012 at 08:30:40PM +0300, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
Not quite complete but its a good start.
+
+#ifndef __LIBVIRT_GCONFIG_CAPABILITIES_CPU_ARCH_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_CPU_ARCH_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_CPU_ARCH
(gvir_config_capabilities_cpu_arch_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_CPU_ARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_ARCH, GVirConfigCapabilitiesCPUArch))
+#define GVIR_CONFIG_CAPABILITIES_CPU_ARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_ARCH, GVirConfigCapabilitiesCPUArchClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_CPU_ARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_ARCH))
+#define GVIR_CONFIG_IS_CAPABILITIES_CPU_ARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_ARCH))
+#define GVIR_CONFIG_CAPABILITIES_CPU_ARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_ARCH, GVirConfigCapabilitiesCPUArchClass))
+
+typedef struct _GVirConfigCapabilitiesCPUArch GVirConfigCapabilitiesCPUArch;
+typedef struct _GVirConfigCapabilitiesCPUArchPrivate
GVirConfigCapabilitiesCPUArchPrivate;
+typedef struct _GVirConfigCapabilitiesCPUArchClass GVirConfigCapabilitiesCPUArchClass;
+
+struct _GVirConfigCapabilitiesCPUArch
+{
+ GVirConfigObject parent;
+
+ GVirConfigCapabilitiesCPUArchPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesCPUArchClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_capabilities_cpu_arch_get_type(void);
+
+const gchar *
+gvir_config_capabilities_cpu_arch_get_name(GVirConfigCapabilitiesCPUArch *caps);
+GList *
+gvir_config_capabilities_cpu_arch_get_domains(GVirConfigCapabilitiesCPUArch *caps);
+const gchar *
+gvir_config_capabilities_cpu_arch_get_emulator(GVirConfigCapabilitiesCPUArch *caps);
I think this should be calling GVirConfigCapabilitiesGuestArch
to avoid confusion with CPU model types.
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-domain.c
b/libvirt-gconfig/libvirt-gconfig-capabilities-domain.c
new file mode 100644
index 0000000..1023f9d
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-domain.c
@@ -0,0 +1,93 @@
+/*
+ * libvirt-gconfig-capabilities-domain.c: libvirt 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_DOMAIN_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN,
GVirConfigCapabilitiesDomainPrivate))
+
+struct _GVirConfigCapabilitiesDomainPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigCapabilitiesDomain, gvir_config_capabilities_domain,
GVIR_CONFIG_TYPE_OBJECT);
+
+
+static void gvir_config_capabilities_domain_class_init(GVirConfigCapabilitiesDomainClass
*klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesDomainPrivate));
+}
+
+static void gvir_config_capabilities_domain_init(GVirConfigCapabilitiesDomain *conn)
+{
+ g_debug("Init GVirConfigCapabilitiesDomain=%p", conn);
+
+ conn->priv = GVIR_CONFIG_CAPABILITIES_DOMAIN_GET_PRIVATE(conn);
+}
+
+G_GNUC_INTERNAL GVirConfigCapabilitiesDomain *
+gvir_config_capabilities_domain_new_from_tree(GVirConfigXmlDoc *doc,
+ xmlNodePtr tree)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new_from_tree(GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN,
+ doc,
+ NULL,
+ tree);
+
+ return GVIR_CONFIG_CAPABILITIES_DOMAIN(object);
+}
+
+const gchar *
+gvir_config_capabilities_domain_get_emulator(GVirConfigCapabilitiesDomain *caps)
+{
+ xmlNodePtr node;
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(caps));
+
+ return gvir_config_xml_get_child_element_content(node, "emulator");
+}
+
+GVirConfigDomainVirtType
+gvir_config_capabilities_domain_get_virt_type(GVirConfigCapabilitiesDomain *caps)
+{
+ xmlNodePtr node;
+ const gchar *str;
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(caps));
+
+ str = gvir_config_xml_get_attribute_content(node, "type");
+ if (str == NULL)
+ return GVIR_CONFIG_DOMAIN_VIRT_QEMU;
+
+ return gvir_config_genum_get_value(GVIR_CONFIG_TYPE_DOMAIN_VIRT_TYPE,
+ str,
+ GVIR_CONFIG_DOMAIN_VIRT_QEMU);
+}
+
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-domain.h
b/libvirt-gconfig/libvirt-gconfig-capabilities-domain.h
new file mode 100644
index 0000000..6c20191
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-domain.h
@@ -0,0 +1,72 @@
+/*
+ * libvirt-gconfig-capabilities-domain.h: libvirt 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_DOMAIN_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_DOMAIN_H__
+
+#include "libvirt-gconfig-domain.h"
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN
(gvir_config_capabilities_domain_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_DOMAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN, GVirConfigCapabilitiesDomain))
+#define GVIR_CONFIG_CAPABILITIES_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN, GVirConfigCapabilitiesDomainClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_DOMAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN))
+#define GVIR_CONFIG_IS_CAPABILITIES_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN))
+#define GVIR_CONFIG_CAPABILITIES_DOMAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS
((obj), GVIR_CONFIG_TYPE_CAPABILITIES_DOMAIN, GVirConfigCapabilitiesDomainClass))
+
+typedef struct _GVirConfigCapabilitiesDomain GVirConfigCapabilitiesDomain;
+typedef struct _GVirConfigCapabilitiesDomainPrivate
GVirConfigCapabilitiesDomainPrivate;
+typedef struct _GVirConfigCapabilitiesDomainClass GVirConfigCapabilitiesDomainClass;
+
+struct _GVirConfigCapabilitiesDomain
+{
+ GVirConfigObject parent;
+
+ GVirConfigCapabilitiesDomainPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesDomainClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_capabilities_domain_get_type(void);
+
+const gchar *
+gvir_config_capabilities_domain_get_emulator(GVirConfigCapabilitiesDomain *caps);
+
+GVirConfigDomainVirtType
+gvir_config_capabilities_domain_get_virt_type(GVirConfigCapabilitiesDomain *caps);
And use GVirConfigCapabilitiesGuestDomain here
+struct GetFeatureData {
+ GVirConfigXmlDoc *doc;
+ GList *features;
+};
+
+static gboolean add_feature(xmlNodePtr node, gpointer opaque)
+{
+ struct GetFeatureData* data = (struct GetFeatureData*)opaque;
+ GVirConfigCapabilitiesCPUFeature *feature;
+
+ feature = gvir_config_capabilities_cpu_feature_new_from_tree(data->doc, node);
+ if (feature != NULL)
+ data->features = g_list_append(data->features, feature);
+ else
+ g_debug("Failed to parse %s node", node->name);
+
+ return TRUE;
+}
+
+/**
+ * gvir_config_capabilities_guest_get_cpu_features:
+ *
+ * Gets the CPU features for this guest.
+ *
+ * Returns: (element-type LibvirtGConfig.CapabilitiesCPUFeature) (transfer full):
+ * a newly allocated #GList of #GVirConfigCapabilitiesCPUFeature.
+ */
This isn't right - the things in the /capabilities/guest/features XML
is nothing at all todo with the /capabilities/host/cpu/feature XML.
We should have a separate GVirConfigCapabilitiesGuestFeature
object for these, and remove 'cpu' from the method name here.
diff --git a/libvirt-gconfig/libvirt-gconfig.sym
b/libvirt-gconfig/libvirt-gconfig.sym
index b1df17b..51f6ce6 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -7,6 +7,7 @@ LIBVIRT_GCONFIG_0.0.8 {
gvir_config_capabilities_new;
gvir_config_capabilities_new_from_xml;
gvir_config_capabilities_get_host;
+ gvir_config_capabilities_get_guests;
gvir_config_capabilities_host_get_type;
gvir_config_capabilities_host_new_from_tree;
@@ -20,6 +21,21 @@ LIBVIRT_GCONFIG_0.0.8 {
gvir_config_capabilities_cpu_feature_get_type;
gvir_config_capabilities_cpu_feature_get_name;
+ gvir_config_capabilities_guest_get_type;
+ gvir_config_capabilities_guest_new_from_tree;
+ gvir_config_capabilities_guest_get_os_type;
+ gvir_config_capabilities_guest_get_cpu_arch;
+ gvir_config_capabilities_guest_get_cpu_features;
+
+ gvir_config_capabilities_cpu_arch_get_type;
+ gvir_config_capabilities_cpu_arch_get_name;
+ gvir_config_capabilities_cpu_arch_get_domains;
+ gvir_config_capabilities_cpu_arch_get_emulator;
+
+ gvir_config_capabilities_domain_get_type;
+ gvir_config_capabilities_domain_get_emulator;
+ gvir_config_capabilities_domain_get_virt_type;
+
gvir_config_domain_add_device;
gvir_config_domain_get_type;
gvir_config_domain_lifecycle_action_get_type;
Again, add these in a new version block
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|