|
Packit |
a07778 |
/*
|
|
Packit |
a07778 |
* libvirt-gconfig-capabilities-host.c: libvirt host capabilities
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Copyright (C) 2008 Daniel P. Berrange
|
|
Packit |
a07778 |
* Copyright (C) 2010-2012 Red Hat, Inc.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
a07778 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
a07778 |
* License as published by the Free Software Foundation; either
|
|
Packit |
a07778 |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
a07778 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
a07778 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
a07778 |
* Lesser General Public License for more details.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
a07778 |
* License along with this library. If not, see
|
|
Packit |
a07778 |
* <http://www.gnu.org/licenses/>.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Authors: Zeeshan Ali <zeenix@redhat.com>
|
|
Packit |
a07778 |
* Daniel P. Berrange <berrange@redhat.com>
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
#include <config.h>
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
#include "libvirt-gconfig/libvirt-gconfig.h"
|
|
Packit |
a07778 |
#include "libvirt-gconfig/libvirt-gconfig-private.h"
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
#define GVIR_CONFIG_CAPABILITIES_HOST_GET_PRIVATE(obj) \
|
|
Packit |
a07778 |
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST, GVirConfigCapabilitiesHostPrivate))
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
struct _GVirConfigCapabilitiesHostPrivate
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
gboolean unused;
|
|
Packit |
a07778 |
};
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
G_DEFINE_TYPE_WITH_PRIVATE(GVirConfigCapabilitiesHost, gvir_config_capabilities_host, GVIR_CONFIG_TYPE_OBJECT);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
static void gvir_config_capabilities_host_class_init(GVirConfigCapabilitiesHostClass *klass G_GNUC_UNUSED)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
static void gvir_config_capabilities_host_init(GVirConfigCapabilitiesHost *host)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
host->priv = GVIR_CONFIG_CAPABILITIES_HOST_GET_PRIVATE(host);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
const gchar *
|
|
Packit |
a07778 |
gvir_config_capabilities_host_get_uuid(GVirConfigCapabilitiesHost *host)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(host), "uuid");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_capabilities_host_get_cpu:
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Gets the CPU capabilities of the host.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: (transfer full): a new #GVirConfigCapabilitiesCpu.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
GVirConfigCapabilitiesCpu *
|
|
Packit |
a07778 |
gvir_config_capabilities_host_get_cpu(GVirConfigCapabilitiesHost *host)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *object;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_HOST(host), NULL);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
object = gvir_config_object_get_child_with_type
|
|
Packit |
a07778 |
(GVIR_CONFIG_OBJECT(host),
|
|
Packit |
a07778 |
"cpu",
|
|
Packit |
a07778 |
GVIR_CONFIG_TYPE_CAPABILITIES_CPU);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
return GVIR_CONFIG_CAPABILITIES_CPU(object);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
struct GetSecModelData {
|
|
Packit |
a07778 |
GVirConfigXmlDoc *doc;
|
|
Packit |
a07778 |
const gchar *schema;
|
|
Packit |
a07778 |
GList *secmodels;
|
|
Packit |
a07778 |
GType type;
|
|
Packit |
a07778 |
};
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
static gboolean add_secmodel(xmlNodePtr node, gpointer opaque)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
struct GetSecModelData* data = (struct GetSecModelData*)opaque;
|
|
Packit |
a07778 |
GVirConfigObject *secmodel;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
if (g_strcmp0((const gchar *)node->name, "secmodel") != 0)
|
|
Packit |
a07778 |
return TRUE;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
secmodel = gvir_config_object_new_from_tree
|
|
Packit |
a07778 |
(data->type,
|
|
Packit |
a07778 |
data->doc,
|
|
Packit |
a07778 |
data->schema,
|
|
Packit |
a07778 |
node);
|
|
Packit |
a07778 |
if (secmodel != NULL)
|
|
Packit |
a07778 |
data->secmodels = g_list_append(data->secmodels, secmodel);
|
|
Packit |
a07778 |
else
|
|
Packit |
a07778 |
g_debug("Failed to parse %s node", node->name);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
return TRUE;
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_capabilities_host_get_secmodels:
|
|
Packit |
a07778 |
* @host: a #GVirConfigCapabilitiesHost
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Get the security models listed in @host capabilities.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: (element-type LibvirtGConfig.CapabilitiesHostSecModel) (transfer full):
|
|
Packit |
a07778 |
* a newly allocated #GList of #GVirConfigCapabilitiesHostSecModel.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
GList *
|
|
Packit |
a07778 |
gvir_config_capabilities_host_get_secmodels(GVirConfigCapabilitiesHost *host)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
struct GetSecModelData data;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_HOST(host), NULL);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(host));
|
|
Packit |
a07778 |
g_object_get(G_OBJECT(host), "doc", &data.doc, NULL);
|
|
Packit |
a07778 |
g_return_val_if_fail(data.doc != NULL, NULL);
|
|
Packit |
a07778 |
data.secmodels = NULL;
|
|
Packit |
a07778 |
data.type = GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(host),
|
|
Packit |
a07778 |
NULL,
|
|
Packit |
a07778 |
add_secmodel,
|
|
Packit |
a07778 |
&data);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_clear_object(&data.doc);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
return data.secmodels;
|
|
Packit |
a07778 |
}
|