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

Re: [libvirt] [libvirt-glib 2/4] Add host capabilities API



This does not seem to apply on top of master + PATCH 1/4 :-/

Christophe 

On Wed, May 09, 2012 at 04:16:14AM +0300, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>
> 
> Not quite complete but its a good start.
> ---
>  libvirt-gconfig/Makefile.am                        |    6 +
>  .../libvirt-gconfig-capabilities-cpu-feature.c     |   58 ++++++++++
>  .../libvirt-gconfig-capabilities-cpu-feature.h     |   67 ++++++++++++
>  libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c |  115 ++++++++++++++++++++
>  libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h |   69 ++++++++++++
>  .../libvirt-gconfig-capabilities-host.c            |   80 ++++++++++++++
>  .../libvirt-gconfig-capabilities-host.h            |   72 ++++++++++++
>  libvirt-gconfig/libvirt-gconfig-capabilities.c     |   23 ++++
>  libvirt-gconfig/libvirt-gconfig-capabilities.h     |    5 +-
>  libvirt-gconfig/libvirt-gconfig-object.c           |    1 -
>  libvirt-gconfig/libvirt-gconfig.h                  |    3 +
>  libvirt-gconfig/libvirt-gconfig.sym                |   13 +++
>  12 files changed, 510 insertions(+), 2 deletions(-)
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.c
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.h
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-host.c
>  create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-host.h
> 
> diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
> index fd32c3d..54899a3 100644
> --- a/libvirt-gconfig/Makefile.am
> +++ b/libvirt-gconfig/Makefile.am
> @@ -12,6 +12,9 @@ GCONFIG_HEADER_FILES = \
>  			libvirt-gconfig-main.h \
>  			libvirt-gconfig-object.h \
>  			libvirt-gconfig-capabilities.h \
> +			libvirt-gconfig-capabilities-host.h \
> +			libvirt-gconfig-capabilities-cpu.h \
> +			libvirt-gconfig-capabilities-cpu-feature.h \
>  			libvirt-gconfig-domain.h \
>  			libvirt-gconfig-domain-address.h \
>  			libvirt-gconfig-domain-address-pci.h \
> @@ -72,6 +75,9 @@ GCONFIG_SOURCE_FILES = \
>  			libvirt-gconfig-object.c \
>  			libvirt-gconfig-main.c \
>  			libvirt-gconfig-capabilities.c \
> +			libvirt-gconfig-capabilities-host.c \
> +			libvirt-gconfig-capabilities-cpu.c \
> +			libvirt-gconfig-capabilities-cpu-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-cpu-feature.c b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.c
> new file mode 100644
> index 0000000..b7902a5
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.c
> @@ -0,0 +1,58 @@
> +/*
> + * libvirt-gconfig-capabilities-cpu-feature.c: libvirt CPU 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 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_CAPABILITIES_CPU_FEATURE_GET_PRIVATE(obj)                         \
> +        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE, GVirConfigCapabilitiesCpuFeaturePrivate))
> +
> +struct _GVirConfigCapabilitiesCpuFeaturePrivate
> +{
> +    gboolean unused;
> +};
> +
> +G_DEFINE_TYPE(GVirConfigCapabilitiesCpuFeature, gvir_config_capabilities_cpu_feature, GVIR_CONFIG_TYPE_OBJECT);
> +
> +static void gvir_config_capabilities_cpu_feature_class_init(GVirConfigCapabilitiesCpuFeatureClass *klass)
> +{
> +    g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesCpuFeaturePrivate));
> +}
> +
> +static void gvir_config_capabilities_cpu_feature_init(GVirConfigCapabilitiesCpuFeature *feature)
> +{
> +    g_debug("Init GVirConfigCapabilitiesCpuFeature=%p", feature);
> +
> +    feature->priv = GVIR_CONFIG_CAPABILITIES_CPU_FEATURE_GET_PRIVATE(feature);
> +}
> +
> +const gchar *
> +gvir_config_capabilities_cpu_feature_get_name(GVirConfigCapabilitiesCpuFeature *caps)
> +{
> +    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(caps),
> +                                            NULL,
> +                                            "name");
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.h b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.h
> new file mode 100644
> index 0000000..e1c7835
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-feature.h
> @@ -0,0 +1,67 @@
> +/*
> + * libvirt-gconfig-capabilities-cpu-feature.h: libvirt CPU 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 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_CAPABILITIES_CPU_FEATURE_H__
> +#define __LIBVIRT_GCONFIG_CAPABILITIES_CPU_FEATURE_H__
> +
> +G_BEGIN_DECLS
> +
> +#define GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE            (gvir_config_capabilities_cpu_feature_get_type ())
> +#define GVIR_CONFIG_CAPABILITIES_CPU_FEATURE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE, GVirConfigCapabilitiesCpuFeature))
> +#define GVIR_CONFIG_CAPABILITIES_CPU_FEATURE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE, GVirConfigCapabilitiesCpuFeatureClass))
> +#define GVIR_CONFIG_IS_CAPABILITIES_CPU_FEATURE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE))
> +#define GVIR_CONFIG_IS_CAPABILITIES_CPU_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE))
> +#define GVIR_CONFIG_CAPABILITIES_CPU_FEATURE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE, GVirConfigCapabilitiesCpuFeatureClass))
> +
> +typedef struct _GVirConfigCapabilitiesCpuFeature GVirConfigCapabilitiesCpuFeature;
> +typedef struct _GVirConfigCapabilitiesCpuFeaturePrivate GVirConfigCapabilitiesCpuFeaturePrivate;
> +typedef struct _GVirConfigCapabilitiesCpuFeatureClass GVirConfigCapabilitiesCpuFeatureClass;
> +
> +struct _GVirConfigCapabilitiesCpuFeature
> +{
> +    GVirConfigObject parent;
> +
> +    GVirConfigCapabilitiesCpuFeaturePrivate *priv;
> +
> +    /* Do not add fields to this struct */
> +};
> +
> +struct _GVirConfigCapabilitiesCpuFeatureClass
> +{
> +    GVirConfigObjectClass parent_class;
> +
> +    gpointer padding[20];
> +};
> +
> +GType gvir_config_capabilities_cpu_feature_get_type(void);
> +
> +const gchar *
> +gvir_config_capabilities_cpu_feature_get_name(GVirConfigCapabilitiesCpuFeature *caps);
> +
> +G_END_DECLS
> +
> +#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_CPU_FEATURE_H__ */
> diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
> new file mode 100644
> index 0000000..c4cba88
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
> @@ -0,0 +1,115 @@
> +/*
> + * libvirt-gconfig-capabilities-cpu.c: libvirt CPU 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 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_CAPABILITIES_CPU_GET_PRIVATE(obj)                         \
> +        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU, GVirConfigCapabilitiesCpuPrivate))
> +
> +struct _GVirConfigCapabilitiesCpuPrivate
> +{
> +    gboolean unused;
> +};
> +
> +G_DEFINE_TYPE(GVirConfigCapabilitiesCpu, gvir_config_capabilities_cpu, GVIR_CONFIG_TYPE_OBJECT);
> +
> +
> +static void gvir_config_capabilities_cpu_class_init(GVirConfigCapabilitiesCpuClass *klass)
> +{
> +    g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesCpuPrivate));
> +}
> +
> +static void gvir_config_capabilities_cpu_init(GVirConfigCapabilitiesCpu *cpu)
> +{
> +    g_debug("Init GVirConfigCapabilitiesCpu=%p", cpu);
> +
> +    cpu->priv = GVIR_CONFIG_CAPABILITIES_CPU_GET_PRIVATE(cpu);
> +}
> +
> +const gchar *
> +gvir_config_capabilities_cpu_get_arch(GVirConfigCapabilitiesCpu *caps)
> +{
> +    return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(caps), "arch");
> +}
> +
> +struct GetFeatureData {
> +    GVirConfigXmlDoc *doc;
> +    const gchar *schema;
> +    GList *features;
> +};
> +
> +static gboolean add_feature(xmlNodePtr node, gpointer opaque)
> +{
> +    struct GetFeatureData* data = (struct GetFeatureData*)opaque;
> +    GVirConfigObject *feature;
> +
> +    if (g_strcmp0((const gchar *)node->name, "feature") != 0)
> +        return TRUE;
> +
> +    feature = gvir_config_object_new_from_tree
> +                                (GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE,
> +                                 data->doc,
> +                                 data->schema,
> +                                 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_cpu_get_features:
> + *
> + * Gets the features of this CPU.
> + *
> + * Returns: (element-type LibvirtGConfig.CapabilitiesCpuFeature) (transfer full):
> + * a newly allocated #GList of #GVirConfigCapabilitiesCpuFeature.
> + */
> +GList *
> +gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *caps)
> +{
> +    struct GetFeatureData data;
> +
> +    g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU(caps), NULL);
> +
> +    data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(caps));
> +    g_return_val_if_fail(data.schema != NULL, NULL);
> +    g_object_get(G_OBJECT(caps), "doc", &data.doc, NULL);
> +    g_return_val_if_fail(data.doc != NULL, NULL);
> +    data.features = NULL;
> +
> +    gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(caps),
> +                                     NULL,
> +                                     add_feature,
> +                                     &data);
> +    g_clear_object(&data.doc);
> +
> +    return data.features;
> +}
> +
> diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
> new file mode 100644
> index 0000000..a414523
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
> @@ -0,0 +1,69 @@
> +/*
> + * libvirt-gconfig-capabilities-cpu.h: libvirt CPU 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 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_CAPABILITIES_CPU_H__
> +#define __LIBVIRT_GCONFIG_CAPABILITIES_CPU_H__
> +
> +G_BEGIN_DECLS
> +
> +#define GVIR_CONFIG_TYPE_CAPABILITIES_CPU            (gvir_config_capabilities_cpu_get_type ())
> +#define GVIR_CONFIG_CAPABILITIES_CPU(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU, GVirConfigCapabilitiesCpu))
> +#define GVIR_CONFIG_CAPABILITIES_CPU_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU, GVirConfigCapabilitiesCpuClass))
> +#define GVIR_CONFIG_IS_CAPABILITIES_CPU(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU))
> +#define GVIR_CONFIG_IS_CAPABILITIES_CPU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_CPU))
> +#define GVIR_CONFIG_CAPABILITIES_CPU_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU, GVirConfigCapabilitiesCpuClass))
> +
> +typedef struct _GVirConfigCapabilitiesCpu GVirConfigCapabilitiesCpu;
> +typedef struct _GVirConfigCapabilitiesCpuPrivate GVirConfigCapabilitiesCpuPrivate;
> +typedef struct _GVirConfigCapabilitiesCpuClass GVirConfigCapabilitiesCpuClass;
> +
> +struct _GVirConfigCapabilitiesCpu
> +{
> +    GVirConfigObject parent;
> +
> +    GVirConfigCapabilitiesCpuPrivate *priv;
> +
> +    /* Do not add fields to this struct */
> +};
> +
> +struct _GVirConfigCapabilitiesCpuClass
> +{
> +    GVirConfigObjectClass parent_class;
> +
> +    gpointer padding[20];
> +};
> +
> +GType gvir_config_capabilities_cpu_get_type(void);
> +
> +const gchar *
> +gvir_config_capabilities_cpu_get_arch(GVirConfigCapabilitiesCpu *caps);
> +GList *
> +gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *caps);
> +
> +G_END_DECLS
> +
> +#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_CPU_H__ */
> diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-host.c b/libvirt-gconfig/libvirt-gconfig-capabilities-host.c
> new file mode 100644
> index 0000000..c579ef9
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-host.c
> @@ -0,0 +1,80 @@
> +/*
> + * libvirt-gconfig-capabilities-host.c: libvirt host 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 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_CAPABILITIES_HOST_GET_PRIVATE(obj)                         \
> +        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST, GVirConfigCapabilitiesHostPrivate))
> +
> +struct _GVirConfigCapabilitiesHostPrivate
> +{
> +    gboolean unused;
> +};
> +
> +G_DEFINE_TYPE(GVirConfigCapabilitiesHost, gvir_config_capabilities_host, GVIR_CONFIG_TYPE_OBJECT);
> +
> +
> +static void gvir_config_capabilities_host_class_init(GVirConfigCapabilitiesHostClass *klass)
> +{
> +    g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesHostPrivate));
> +}
> +
> +static void gvir_config_capabilities_host_init(GVirConfigCapabilitiesHost *host)
> +{
> +    g_debug("Init GVirConfigCapabilitiesHost=%p", host);
> +
> +    host->priv = GVIR_CONFIG_CAPABILITIES_HOST_GET_PRIVATE(host);
> +}
> +
> +const gchar *
> +gvir_config_capabilities_host_get_uuid(GVirConfigCapabilitiesHost *caps)
> +{
> +    return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(caps), "uuid");
> +}
> +
> +/**
> + * gvir_config_capabilities_host_get_cpu:
> + *
> + * Gets the CPU capabilities of the host.
> + *
> + * Returns: (transfer full): a new #GVirConfigCapabilitiesCpu.
> + */
> +GVirConfigCapabilitiesCpu *
> +gvir_config_capabilities_host_get_cpu(GVirConfigCapabilitiesHost *caps)
> +{
> +    GVirConfigObject *object;
> +
> +    g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_HOST(caps), NULL);
> +
> +    object = gvir_config_object_get_child_with_type
> +                                (GVIR_CONFIG_OBJECT(caps),
> +                                 "cpu",
> +                                 GVIR_CONFIG_TYPE_CAPABILITIES_CPU);
> +
> +    return GVIR_CONFIG_CAPABILITIES_CPU(object);
> +}
> +
> diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-host.h b/libvirt-gconfig/libvirt-gconfig-capabilities-host.h
> new file mode 100644
> index 0000000..67b61ab
> --- /dev/null
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-host.h
> @@ -0,0 +1,72 @@
> +/*
> + * libvirt-gconfig-capabilities-host.h: libvirt host 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 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_CAPABILITIES_HOST_H__
> +#define __LIBVIRT_GCONFIG_CAPABILITIES_HOST_H__
> +
> +#include "libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h"
> +
> +G_BEGIN_DECLS
> +
> +#define GVIR_CONFIG_TYPE_CAPABILITIES_HOST            (gvir_config_capabilities_host_get_type ())
> +#define GVIR_CONFIG_CAPABILITIES_HOST(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST, GVirConfigCapabilitiesHost))
> +#define GVIR_CONFIG_CAPABILITIES_HOST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_HOST, GVirConfigCapabilitiesHostClass))
> +#define GVIR_CONFIG_IS_CAPABILITIES_HOST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST))
> +#define GVIR_CONFIG_IS_CAPABILITIES_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_HOST))
> +#define GVIR_CONFIG_CAPABILITIES_HOST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST, GVirConfigCapabilitiesHostClass))
> +
> +typedef struct _GVirConfigCapabilitiesHost GVirConfigCapabilitiesHost;
> +typedef struct _GVirConfigCapabilitiesHostPrivate GVirConfigCapabilitiesHostPrivate;
> +typedef struct _GVirConfigCapabilitiesHostClass GVirConfigCapabilitiesHostClass;
> +
> +struct _GVirConfigCapabilitiesHost
> +{
> +    GVirConfigObject parent;
> +
> +    GVirConfigCapabilitiesHostPrivate *priv;
> +
> +    /* Do not add fields to this struct */
> +};
> +
> +struct _GVirConfigCapabilitiesHostClass
> +{
> +    GVirConfigObjectClass parent_class;
> +
> +    gpointer padding[20];
> +};
> +
> +GType gvir_config_capabilities_host_get_type(void);
> +
> +const gchar *
> +gvir_config_capabilities_host_get_uuid(GVirConfigCapabilitiesHost *caps);
> +
> +GVirConfigCapabilitiesCpu *
> +gvir_config_capabilities_host_get_cpu(GVirConfigCapabilitiesHost *caps);
> +
> +G_END_DECLS
> +
> +#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_HOST_H__ */
> diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities.c b/libvirt-gconfig/libvirt-gconfig-capabilities.c
> index 3d9d036..0bba874 100644
> --- a/libvirt-gconfig/libvirt-gconfig-capabilities.c
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities.c
> @@ -24,6 +24,7 @@
>  #include <config.h>
>  
>  #include "libvirt-gconfig/libvirt-gconfig.h"
> +#include "libvirt-gconfig/libvirt-gconfig-private.h"
>  
>  #define GVIR_CONFIG_CAPABILITIES_GET_PRIVATE(obj)                         \
>          (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES, GVirConfigCapabilitiesPrivate))
> @@ -71,3 +72,25 @@ GVirConfigCapabilities *gvir_config_capabilities_new_from_xml(const gchar *xml,
>                                               xml, error);
>      return GVIR_CONFIG_CAPABILITIES(object);
>  }
> +
> +/**
> + * gvir_config_capabilities_get_host:
> + *
> + * Gets the host capabilities.
> + *
> + * Returns: (transfer full): a new #GVirConfigCapabilitiesHost.
> + */
> +GVirConfigCapabilitiesHost *
> +gvir_config_capabilities_get_host(GVirConfigCapabilities *caps)
> +{
> +    GVirConfigObject *object;
> +
> +    g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES(caps), NULL);
> +
> +    object = gvir_config_object_get_child_with_type
> +                                (GVIR_CONFIG_OBJECT(caps),
> +                                 "host",
> +                                 GVIR_CONFIG_TYPE_CAPABILITIES_HOST);
> +
> +    return GVIR_CONFIG_CAPABILITIES_HOST(object);
> +}
> diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities.h b/libvirt-gconfig/libvirt-gconfig-capabilities.h
> index 733886d..2ec8369 100644
> --- a/libvirt-gconfig/libvirt-gconfig-capabilities.h
> +++ b/libvirt-gconfig/libvirt-gconfig-capabilities.h
> @@ -27,6 +27,8 @@
>  #ifndef __LIBVIRT_GCONFIG_CAPABILITIES_H__
>  #define __LIBVIRT_GCONFIG_CAPABILITIES_H__
>  
> +#include "libvirt-gconfig/libvirt-gconfig-capabilities-host.h"
> +
>  G_BEGIN_DECLS
>  
>  #define GVIR_CONFIG_TYPE_CAPABILITIES            (gvir_config_capabilities_get_type ())
> @@ -56,12 +58,13 @@ struct _GVirConfigCapabilitiesClass
>      gpointer padding[20];
>  };
>  
> -
>  GType gvir_config_capabilities_get_type(void);
>  
>  GVirConfigCapabilities *gvir_config_capabilities_new(void);
>  GVirConfigCapabilities *gvir_config_capabilities_new_from_xml(const gchar *xml,
>                                                                GError **error);
> +GVirConfigCapabilitiesHost *
> +gvir_config_capabilities_get_host(GVirConfigCapabilities *caps);
>  
>  G_END_DECLS
>  
> diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
> index 0495a3f..30d80a4 100644
> --- a/libvirt-gconfig/libvirt-gconfig-object.c
> +++ b/libvirt-gconfig/libvirt-gconfig-object.c
> @@ -915,4 +915,3 @@ gvir_config_object_get_child(GVirConfigObject *object,
>                                                    child_name,
>                                                    GVIR_CONFIG_TYPE_OBJECT);
>  }
> -
> diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
> index bd16244..f9be83f 100644
> --- a/libvirt-gconfig/libvirt-gconfig.h
> +++ b/libvirt-gconfig/libvirt-gconfig.h
> @@ -29,6 +29,9 @@
>  #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-host.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-address.h>
>  #include <libvirt-gconfig/libvirt-gconfig-domain-address-pci.h>
> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
> index 7bc9e2d..7d015f5 100644
> --- a/libvirt-gconfig/libvirt-gconfig.sym
> +++ b/libvirt-gconfig/libvirt-gconfig.sym
> @@ -378,6 +378,19 @@ LIBVIRT_GCONFIG_0.0.9 {
>    global:
>  	gvir_config_domain_get_os;
>  	gvir_config_domain_os_get_boot_devices;
> +
> +	gvir_config_capabilities_get_host;
> +
> +	gvir_config_capabilities_cpu_get_type;
> +	gvir_config_capabilities_cpu_get_arch;
> +	gvir_config_capabilities_cpu_get_features;
> +
> +	gvir_config_capabilities_cpu_feature_get_type;
> +	gvir_config_capabilities_cpu_feature_get_name;
> +
> +	gvir_config_capabilities_host_get_type;
> +	gvir_config_capabilities_host_get_uuid;
> +	gvir_config_capabilities_host_get_cpu;
>  } LIBVIRT_GCONFIG_0.0.8;
>  
>  # .... define new API here using predicted next version number ....
> -- 
> 1.7.7.6
> 
> --
> libvir-list mailing list
> libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgpUaRcnU02Iv.pgp
Description: PGP signature


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