[libvirt] CPU model API (v3)

v3: Two classes for CPU model: * CapabilitiesCpuModel * DomainCpuModel that derives from CapabilitiesCpuModel.

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@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@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

Looks good, ACK, Christophe On Tue, Jul 15, 2014 at 11:42:29PM +0100, Zeeshan Ali (Khattak) wrote:
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@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@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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Add a method to get the model of the CPU from capabilities. --- libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c | 23 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ 3 files changed, 28 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c index f4753ff..a2d5c3e 100644 --- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c @@ -185,3 +185,26 @@ gvir_config_capabilities_cpu_set_topology(GVirConfigCapabilitiesCpu *cpu, "topology", GVIR_CONFIG_OBJECT(topology)); } + +/** + * gvir_config_capabilities_cpu_get_model: + * + * Gets the model of the cpu. + * + * Returns: (transfer full): a new #GVirConfigCapabilitiesCpuModel. + */ +GVirConfigCapabilitiesCpuModel * +gvir_config_capabilities_cpu_get_model(GVirConfigCapabilitiesCpu *cpu) +{ + GVirConfigObject *object; + + g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU(cpu), NULL); + + object = gvir_config_object_get_child_with_type + (GVIR_CONFIG_OBJECT(cpu), + "model", + GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL); + + return GVIR_CONFIG_CAPABILITIES_CPU_MODEL(object); +} + diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h index ce3613f..57ad48b 100644 --- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h @@ -30,6 +30,7 @@ #include "libvirt-gconfig-capabilities-cpu-topology.h" #include "libvirt-gconfig-capabilities-cpu-feature.h" +#include "libvirt-gconfig-capabilities-cpu-model.h" G_BEGIN_DECLS @@ -75,6 +76,8 @@ gvir_config_capabilities_cpu_get_topology(GVirConfigCapabilitiesCpu *cpu); void gvir_config_capabilities_cpu_set_topology(GVirConfigCapabilitiesCpu *cpu, GVirConfigCapabilitiesCpuTopology *topology); +GVirConfigCapabilitiesCpuModel * +gvir_config_capabilities_cpu_get_model(GVirConfigCapabilitiesCpu *cpu); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 76dde70..76b0d03 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -689,6 +689,8 @@ global: LIBVIRT_GCONFIG_0.1.9 { global: + gvir_config_capabilities_cpu_get_model; + gvir_config_capabilities_cpu_model_get_name; gvir_config_capabilities_cpu_model_get_type; gvir_config_capabilities_cpu_model_new; -- 1.9.3

On Tue, Jul 15, 2014 at 11:42:30PM +0100, Zeeshan Ali (Khattak) wrote:
Add a method to get the model of the CPU from capabilities. --- libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c | 23 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h | 3 +++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ 3 files changed, 28 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c index f4753ff..a2d5c3e 100644 --- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c @@ -185,3 +185,26 @@ gvir_config_capabilities_cpu_set_topology(GVirConfigCapabilitiesCpu *cpu, "topology", GVIR_CONFIG_OBJECT(topology)); } + +/** + * gvir_config_capabilities_cpu_get_model: + * + * Gets the model of the cpu. + * + * Returns: (transfer full): a new #GVirConfigCapabilitiesCpuModel. + */ +GVirConfigCapabilitiesCpuModel * +gvir_config_capabilities_cpu_get_model(GVirConfigCapabilitiesCpu *cpu) +{ + GVirConfigObject *object; + + g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU(cpu), NULL); + + object = gvir_config_object_get_child_with_type + (GVIR_CONFIG_OBJECT(cpu), + "model", + GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL); + + return GVIR_CONFIG_CAPABILITIES_CPU_MODEL(object); +} +
Applying: Add gvir_config_capabilities_cpu_get_model() /home/teuf/redhat/virt/libvirt-glib/.git/rebase-apply/patch:37: new blank line at EOF. + warning: 1 line adds whitespace errors. Looks good otherwise, ACK. Christophe
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h index ce3613f..57ad48b 100644 --- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h @@ -30,6 +30,7 @@
#include "libvirt-gconfig-capabilities-cpu-topology.h" #include "libvirt-gconfig-capabilities-cpu-feature.h" +#include "libvirt-gconfig-capabilities-cpu-model.h"
G_BEGIN_DECLS
@@ -75,6 +76,8 @@ gvir_config_capabilities_cpu_get_topology(GVirConfigCapabilitiesCpu *cpu); void gvir_config_capabilities_cpu_set_topology(GVirConfigCapabilitiesCpu *cpu, GVirConfigCapabilitiesCpuTopology *topology); +GVirConfigCapabilitiesCpuModel * +gvir_config_capabilities_cpu_get_model(GVirConfigCapabilitiesCpu *cpu);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 76dde70..76b0d03 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -689,6 +689,8 @@ global:
LIBVIRT_GCONFIG_0.1.9 { global: + gvir_config_capabilities_cpu_get_model; + gvir_config_capabilities_cpu_model_get_name; gvir_config_capabilities_cpu_model_get_type; gvir_config_capabilities_cpu_model_new; -- 1.9.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Add a class to represent 'model' node under domain/cpu. --- libvirt-gconfig/Makefile.am | 2 + libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c | 75 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h | 68 ++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 3 + 5 files changed, 149 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 02240d4..a9a6591 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -38,6 +38,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-controller-usb.h \ libvirt-gconfig-domain-cpu.h \ libvirt-gconfig-domain-cpu-feature.h \ + libvirt-gconfig-domain-cpu-model.h \ libvirt-gconfig-domain-device.h \ libvirt-gconfig-domain-disk.h \ libvirt-gconfig-domain-disk-driver.h \ @@ -127,6 +128,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-controller-usb.c \ libvirt-gconfig-domain-cpu.c \ libvirt-gconfig-domain-cpu-feature.c \ + libvirt-gconfig-domain-cpu-model.c \ libvirt-gconfig-domain-device.c \ libvirt-gconfig-domain-disk.c \ libvirt-gconfig-domain-disk-driver.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c new file mode 100644 index 0000000..03024a6 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c @@ -0,0 +1,75 @@ +/* + * libvirt-gconfig-domain-cpu-model.c: libvirt domain CPU model + * + * 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@redhat.com> + */ + +#include <config.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModelPrivate)) + +struct _GVirConfigDomainCpuModelPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainCpuModel, + gvir_config_domain_cpu_model, + GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL); + +static void gvir_config_domain_cpu_model_class_init(GVirConfigDomainCpuModelClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainCpuModelPrivate)); +} + +static void gvir_config_domain_cpu_model_init(GVirConfigDomainCpuModel *model) +{ + g_debug("Init GVirConfigDomainCpuModel=%p", model); + + model->priv = GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_PRIVATE(model); +} + +GVirConfigDomainCpuModel *gvir_config_domain_cpu_model_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, + "model", + NULL); + + return GVIR_CONFIG_DOMAIN_CPU_MODEL(object); +} + +GVirConfigDomainCpuModel * +gvir_config_domain_cpu_model_new_from_xml(const gchar *xml, GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, + "model", + NULL, + xml, + error); + + return GVIR_CONFIG_DOMAIN_CPU_MODEL(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h new file mode 100644 index 0000000..c6cb36f --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h @@ -0,0 +1,68 @@ +/* + * libvirt-gconfig-domain-cpu-model.h: libvirt domain CPU model + * + * 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@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_MODEL_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_CPU_MODEL_H__ + +#include "libvirt-gconfig-capabilities-cpu-model.h" + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL (gvir_config_domain_cpu_model_get_type ()) +#define GVIR_CONFIG_DOMAIN_CPU_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModel)) +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModelClass)) +#define GVIR_CONFIG_IS_DOMAIN_CPU_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL)) +#define GVIR_CONFIG_IS_DOMAIN_CPU_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL)) +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModelClass)) + +typedef struct _GVirConfigDomainCpuModel GVirConfigDomainCpuModel; +typedef struct _GVirConfigDomainCpuModelPrivate GVirConfigDomainCpuModelPrivate; +typedef struct _GVirConfigDomainCpuModelClass GVirConfigDomainCpuModelClass; + +struct _GVirConfigDomainCpuModel +{ + GVirConfigCapabilitiesCpuModel parent; + + GVirConfigDomainCpuModelPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainCpuModelClass +{ + GVirConfigCapabilitiesCpuModelClass parent_class; + + gpointer padding[20]; +}; + +GType gvir_config_domain_cpu_model_get_type(void); +GVirConfigDomainCpuModel *gvir_config_domain_cpu_model_new(void); +GVirConfigDomainCpuModel * +gvir_config_domain_cpu_model_new_from_xml(const gchar *xml, GError **error); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_CPU_MODEL_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 7fed91d..afb9b7b 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -55,6 +55,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-controller-usb.h> #include <libvirt-gconfig/libvirt-gconfig-domain-cpu.h> #include <libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h> #include <libvirt-gconfig/libvirt-gconfig-domain-device.h> #include <libvirt-gconfig/libvirt-gconfig-domain-disk.h> #include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 76b0d03..7b49126 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -707,6 +707,9 @@ global: gvir_config_domain_chardev_source_spiceport_new; gvir_config_domain_chardev_source_spiceport_new_from_xml; gvir_config_domain_chardev_source_spiceport_set_channel; + + gvir_config_domain_cpu_model_get_type; + gvir_config_domain_cpu_model_new; } LIBVIRT_GCONFIG_0.1.8; # .... define new API here using predicted next version number .... -- 1.9.3

Hey, Looks good, ACK. It would have been worth adding support for 'fallback' and 'vendor_id' while you were digging in that code, easier than having to come back dive in that code later when that's needed imo. Christophe On Tue, Jul 15, 2014 at 11:42:31PM +0100, Zeeshan Ali (Khattak) wrote:
Add a class to represent 'model' node under domain/cpu. --- libvirt-gconfig/Makefile.am | 2 + libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c | 75 ++++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h | 68 ++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 3 + 5 files changed, 149 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 02240d4..a9a6591 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -38,6 +38,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-controller-usb.h \ libvirt-gconfig-domain-cpu.h \ libvirt-gconfig-domain-cpu-feature.h \ + libvirt-gconfig-domain-cpu-model.h \ libvirt-gconfig-domain-device.h \ libvirt-gconfig-domain-disk.h \ libvirt-gconfig-domain-disk-driver.h \ @@ -127,6 +128,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-controller-usb.c \ libvirt-gconfig-domain-cpu.c \ libvirt-gconfig-domain-cpu-feature.c \ + libvirt-gconfig-domain-cpu-model.c \ libvirt-gconfig-domain-device.c \ libvirt-gconfig-domain-disk.c \ libvirt-gconfig-domain-disk-driver.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c new file mode 100644 index 0000000..03024a6 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c @@ -0,0 +1,75 @@ +/* + * libvirt-gconfig-domain-cpu-model.c: libvirt domain CPU model + * + * 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@redhat.com> + */ + +#include <config.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModelPrivate)) + +struct _GVirConfigDomainCpuModelPrivate +{ + gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainCpuModel, + gvir_config_domain_cpu_model, + GVIR_CONFIG_TYPE_CAPABILITIES_CPU_MODEL); + +static void gvir_config_domain_cpu_model_class_init(GVirConfigDomainCpuModelClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainCpuModelPrivate)); +} + +static void gvir_config_domain_cpu_model_init(GVirConfigDomainCpuModel *model) +{ + g_debug("Init GVirConfigDomainCpuModel=%p", model); + + model->priv = GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_PRIVATE(model); +} + +GVirConfigDomainCpuModel *gvir_config_domain_cpu_model_new(void) +{ + GVirConfigObject *object; + + object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, + "model", + NULL); + + return GVIR_CONFIG_DOMAIN_CPU_MODEL(object); +} + +GVirConfigDomainCpuModel * +gvir_config_domain_cpu_model_new_from_xml(const gchar *xml, GError **error) +{ + GVirConfigObject *object; + + object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, + "model", + NULL, + xml, + error); + + return GVIR_CONFIG_DOMAIN_CPU_MODEL(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h new file mode 100644 index 0000000..c6cb36f --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h @@ -0,0 +1,68 @@ +/* + * libvirt-gconfig-domain-cpu-model.h: libvirt domain CPU model + * + * 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@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_MODEL_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_CPU_MODEL_H__ + +#include "libvirt-gconfig-capabilities-cpu-model.h" + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL (gvir_config_domain_cpu_model_get_type ()) +#define GVIR_CONFIG_DOMAIN_CPU_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModel)) +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModelClass)) +#define GVIR_CONFIG_IS_DOMAIN_CPU_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL)) +#define GVIR_CONFIG_IS_DOMAIN_CPU_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL)) +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModelClass)) + +typedef struct _GVirConfigDomainCpuModel GVirConfigDomainCpuModel; +typedef struct _GVirConfigDomainCpuModelPrivate GVirConfigDomainCpuModelPrivate; +typedef struct _GVirConfigDomainCpuModelClass GVirConfigDomainCpuModelClass; + +struct _GVirConfigDomainCpuModel +{ + GVirConfigCapabilitiesCpuModel parent; + + GVirConfigDomainCpuModelPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainCpuModelClass +{ + GVirConfigCapabilitiesCpuModelClass parent_class; + + gpointer padding[20]; +}; + +GType gvir_config_domain_cpu_model_get_type(void); +GVirConfigDomainCpuModel *gvir_config_domain_cpu_model_new(void); +GVirConfigDomainCpuModel * +gvir_config_domain_cpu_model_new_from_xml(const gchar *xml, GError **error); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_CPU_MODEL_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 7fed91d..afb9b7b 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -55,6 +55,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-controller-usb.h> #include <libvirt-gconfig/libvirt-gconfig-domain-cpu.h> #include <libvirt-gconfig/libvirt-gconfig-domain-cpu-feature.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h> #include <libvirt-gconfig/libvirt-gconfig-domain-device.h> #include <libvirt-gconfig/libvirt-gconfig-domain-disk.h> #include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 76b0d03..7b49126 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -707,6 +707,9 @@ global: gvir_config_domain_chardev_source_spiceport_new; gvir_config_domain_chardev_source_spiceport_new_from_xml; gvir_config_domain_chardev_source_spiceport_set_channel; + + gvir_config_domain_cpu_model_get_type; + gvir_config_domain_cpu_model_new; } LIBVIRT_GCONFIG_0.1.8;
# .... define new API here using predicted next version number .... -- 1.9.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Jul 25, 2014 at 3:20 PM, Christophe Fergeau <cfergeau@redhat.com> wrote:
Hey,
Looks good, ACK. It would have been worth adding support for 'fallback' and 'vendor_id' while you were digging in that code, easier than having to come back dive in that code later when that's needed imo.
Sure, I'll submit an additional patch for that. -- Regards, Zeeshan Ali (Khattak) ________________________________________ Befriend GNOME: http://www.gnome.org/friends/

Add a method to set model of domain CPU. --- libvirt-gconfig/libvirt-gconfig-domain-cpu.c | 11 +++++++++++ libvirt-gconfig/libvirt-gconfig-domain-cpu.h | 4 ++++ libvirt-gconfig/libvirt-gconfig.sym | 2 ++ 3 files changed, 17 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu.c b/libvirt-gconfig/libvirt-gconfig-domain-cpu.c index e7b9575..0037763 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-cpu.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu.c @@ -136,3 +136,14 @@ void gvir_config_domain_cpu_set_mode(GVirConfigDomainCpu *cpu, "mode", GVIR_CONFIG_TYPE_DOMAIN_CPU_MODE, mode, NULL); } + +void gvir_config_domain_cpu_set_model(GVirConfigDomainCpu *cpu, + GVirConfigDomainCpuModel *model) +{ + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CPU(cpu)); + g_return_if_fail(model == NULL || GVIR_CONFIG_IS_DOMAIN_CPU_MODEL(model)); + + gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(cpu), + "model", + GVIR_CONFIG_OBJECT(model)); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu.h b/libvirt-gconfig/libvirt-gconfig-domain-cpu.h index 7efb7eb..f7c0a93 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-cpu.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu.h @@ -28,6 +28,8 @@ #ifndef __LIBVIRT_GCONFIG_DOMAIN_CPU_H__ #define __LIBVIRT_GCONFIG_DOMAIN_CPU_H__ +#include <libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h> + G_BEGIN_DECLS #define GVIR_CONFIG_TYPE_DOMAIN_CPU (gvir_config_domain_cpu_get_type ()) @@ -80,6 +82,8 @@ GVirConfigDomainCpuMatchPolicy gvir_config_domain_cpu_get_match_policy(GVirConfigDomainCpu *cpu); void gvir_config_domain_cpu_set_mode(GVirConfigDomainCpu *cpu, GVirConfigDomainCpuMode mode); +void gvir_config_domain_cpu_set_model(GVirConfigDomainCpu *cpu, + GVirConfigDomainCpuModel *model); GVirConfigDomainCpuMode gvir_config_domain_cpu_get_mode(GVirConfigDomainCpu *cpu); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 7b49126..8614126 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -710,6 +710,8 @@ global: gvir_config_domain_cpu_model_get_type; gvir_config_domain_cpu_model_new; + + gvir_config_domain_cpu_set_model; } LIBVIRT_GCONFIG_0.1.8; # .... define new API here using predicted next version number .... -- 1.9.3

On Tue, Jul 15, 2014 at 11:42 PM, Zeeshan Ali (Khattak) <zeeshanak@gnome.org> wrote:
v3: Two classes for CPU model: * CapabilitiesCpuModel * DomainCpuModel that derives from CapabilitiesCpuModel.
Ping! I need these patches to fix the broken case of non-kvm in Boxes in a nice way: https://bugzilla.gnome.org/show_bug.cgi?id=732680 -- Regards, Zeeshan Ali (Khattak) ________________________________________ Befriend GNOME: http://www.gnome.org/friends/

On Fri, Jul 18, 2014 at 12:54 AM, Zeeshan Ali (Khattak) <zeeshanak@gnome.org> wrote:
On Tue, Jul 15, 2014 at 11:42 PM, Zeeshan Ali (Khattak) <zeeshanak@gnome.org> wrote:
v3: Two classes for CPU model: * CapabilitiesCpuModel * DomainCpuModel that derives from CapabilitiesCpuModel.
Ping! I need these patches to fix the broken case of non-kvm in Boxes in a nice way:
Hello? -- Regards, Zeeshan Ali (Khattak) ________________________________________ Befriend GNOME: http://www.gnome.org/friends/
participants (2)
-
Christophe Fergeau
-
Zeeshan Ali (Khattak)