|
Packit Service |
ea0369 |
/*
|
|
Packit Service |
ea0369 |
* libvirt-gconfig-capabilities-cpu-topology.c: libvirt CPU topology capabilities
|
|
Packit Service |
ea0369 |
*
|
|
Packit Service |
ea0369 |
* Copyright (C) 2008 Daniel P. Berrange
|
|
Packit Service |
ea0369 |
* Copyright (C) 2010-2012 Red Hat, Inc.
|
|
Packit Service |
ea0369 |
*
|
|
Packit Service |
ea0369 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
ea0369 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
ea0369 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
ea0369 |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
ea0369 |
*
|
|
Packit Service |
ea0369 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
ea0369 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
ea0369 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
ea0369 |
* Lesser General Public License for more details.
|
|
Packit Service |
ea0369 |
*
|
|
Packit Service |
ea0369 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
ea0369 |
* License along with this library. If not, see
|
|
Packit Service |
ea0369 |
* <http://www.gnu.org/licenses/>.
|
|
Packit Service |
ea0369 |
*
|
|
Packit Service |
ea0369 |
* Authors: Zeeshan Ali <zeenix@redhat.com>
|
|
Packit Service |
ea0369 |
* Daniel P. Berrange <berrange@redhat.com>
|
|
Packit Service |
ea0369 |
*/
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
#include <config.h>
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
#include "libvirt-gconfig/libvirt-gconfig.h"
|
|
Packit Service |
ea0369 |
#include "libvirt-gconfig/libvirt-gconfig-private.h"
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
#define GVIR_CONFIG_CAPABILITIES_CPU_TOPOLOGY_GET_PRIVATE(obj) \
|
|
Packit Service |
ea0369 |
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_CPU_TOPOLOGY, GVirConfigCapabilitiesCpuTopologyPrivate))
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
struct _GVirConfigCapabilitiesCpuTopologyPrivate
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
gboolean unused;
|
|
Packit Service |
ea0369 |
};
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
G_DEFINE_TYPE_WITH_PRIVATE(GVirConfigCapabilitiesCpuTopology, gvir_config_capabilities_cpu_topology, GVIR_CONFIG_TYPE_OBJECT);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
static void gvir_config_capabilities_cpu_topology_class_init(GVirConfigCapabilitiesCpuTopologyClass *klass G_GNUC_UNUSED)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
static void gvir_config_capabilities_cpu_topology_init(GVirConfigCapabilitiesCpuTopology *topology)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
topology->priv = GVIR_CONFIG_CAPABILITIES_CPU_TOPOLOGY_GET_PRIVATE(topology);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
GVirConfigCapabilitiesCpuTopology *gvir_config_capabilities_cpu_topology_new(void)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
GVirConfigObject *object;
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
object = gvir_config_object_new(GVIR_CONFIG_TYPE_CAPABILITIES_CPU_TOPOLOGY,
|
|
Packit Service |
ea0369 |
"topology",
|
|
Packit Service |
ea0369 |
NULL);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
return GVIR_CONFIG_CAPABILITIES_CPU_TOPOLOGY(object);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
GVirConfigCapabilitiesCpuTopology *
|
|
Packit Service |
ea0369 |
gvir_config_capabilities_cpu_topology_new_from_xml(const gchar *xml, GError **error)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
GVirConfigObject *object;
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_CAPABILITIES_CPU_TOPOLOGY,
|
|
Packit Service |
ea0369 |
"topology",
|
|
Packit Service |
ea0369 |
NULL,
|
|
Packit Service |
ea0369 |
xml,
|
|
Packit Service |
ea0369 |
error);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
return GVIR_CONFIG_CAPABILITIES_CPU_TOPOLOGY(object);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
guint64
|
|
Packit Service |
ea0369 |
gvir_config_capabilities_cpu_topology_get_sockets(GVirConfigCapabilitiesCpuTopology *topology)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU_TOPOLOGY(topology), 0);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(topology),
|
|
Packit Service |
ea0369 |
NULL,
|
|
Packit Service |
ea0369 |
"sockets",
|
|
Packit Service |
ea0369 |
0);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
void
|
|
Packit Service |
ea0369 |
gvir_config_capabilities_cpu_topology_set_sockets(GVirConfigCapabilitiesCpuTopology *topology,
|
|
Packit Service |
ea0369 |
guint64 sockets)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
gvir_config_object_set_attribute_with_type(GVIR_CONFIG_OBJECT(topology),
|
|
Packit Service |
ea0369 |
"sockets", G_TYPE_UINT64, sockets,
|
|
Packit Service |
ea0369 |
NULL);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
guint64
|
|
Packit Service |
ea0369 |
gvir_config_capabilities_cpu_topology_get_cores(GVirConfigCapabilitiesCpuTopology *topology)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU_TOPOLOGY(topology), 0);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(topology),
|
|
Packit Service |
ea0369 |
NULL,
|
|
Packit Service |
ea0369 |
"cores",
|
|
Packit Service |
ea0369 |
0);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
void
|
|
Packit Service |
ea0369 |
gvir_config_capabilities_cpu_topology_set_cores(GVirConfigCapabilitiesCpuTopology *topology,
|
|
Packit Service |
ea0369 |
guint64 cores)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
gvir_config_object_set_attribute_with_type(GVIR_CONFIG_OBJECT(topology),
|
|
Packit Service |
ea0369 |
"cores", G_TYPE_UINT64, cores,
|
|
Packit Service |
ea0369 |
NULL);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
guint64
|
|
Packit Service |
ea0369 |
gvir_config_capabilities_cpu_topology_get_threads(GVirConfigCapabilitiesCpuTopology *topology)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_CPU_TOPOLOGY(topology), 0);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(topology),
|
|
Packit Service |
ea0369 |
NULL,
|
|
Packit Service |
ea0369 |
"threads",
|
|
Packit Service |
ea0369 |
0);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
void
|
|
Packit Service |
ea0369 |
gvir_config_capabilities_cpu_topology_set_threads(GVirConfigCapabilitiesCpuTopology *topology,
|
|
Packit Service |
ea0369 |
guint64 threads)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
gvir_config_object_set_attribute_with_type(GVIR_CONFIG_OBJECT(topology),
|
|
Packit Service |
ea0369 |
"threads", G_TYPE_UINT64, threads,
|
|
Packit Service |
ea0369 |
NULL);
|
|
Packit Service |
ea0369 |
}
|