|
Packit |
a07778 |
/*
|
|
Packit |
a07778 |
* libvirt-gconfig-storage-pool-target.c: libvirt storage pool target configuration
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Copyright (C) 2011 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 |
* Author: Christophe Fergeau <cfergeau@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 |
|
|
Packit |
a07778 |
#define GVIR_CONFIG_STORAGE_POOL_TARGET_GET_PRIVATE(obj) \
|
|
Packit |
a07778 |
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_STORAGE_POOL_TARGET, GVirConfigStoragePoolTargetPrivate))
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
struct _GVirConfigStoragePoolTargetPrivate
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
gboolean unused;
|
|
Packit |
a07778 |
};
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
G_DEFINE_TYPE_WITH_PRIVATE(GVirConfigStoragePoolTarget, gvir_config_storage_pool_target, GVIR_CONFIG_TYPE_OBJECT);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
static void gvir_config_storage_pool_target_class_init(GVirConfigStoragePoolTargetClass *klass G_GNUC_UNUSED)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
static void gvir_config_storage_pool_target_init(GVirConfigStoragePoolTarget *target)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
target->priv = GVIR_CONFIG_STORAGE_POOL_TARGET_GET_PRIVATE(target);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new(void)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *object;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
object = gvir_config_object_new(GVIR_CONFIG_TYPE_STORAGE_POOL_TARGET,
|
|
Packit |
a07778 |
"target", NULL);
|
|
Packit |
a07778 |
return GVIR_CONFIG_STORAGE_POOL_TARGET(object);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new_from_xml(const gchar *xml,
|
|
Packit |
a07778 |
GError **error)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *object;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_STORAGE_POOL_TARGET,
|
|
Packit |
a07778 |
"target", NULL,
|
|
Packit |
a07778 |
xml, error);
|
|
Packit |
a07778 |
return GVIR_CONFIG_STORAGE_POOL_TARGET(object);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_target_get_path:
|
|
Packit |
a07778 |
* @target: a #GVirConfigStoragePoolTarget
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Provides the location at which the storage pool associated with @target
|
|
Packit |
a07778 |
* will be mapped into the local filesystem namespace.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: local filesystem path the storage pool is mapped at.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_target_get_path(GVirConfigStoragePoolTarget *target)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target), NULL);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(target),
|
|
Packit |
a07778 |
"path");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_target_set_path:
|
|
Packit |
a07778 |
* @path: (allow-none):
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
void gvir_config_storage_pool_target_set_path(GVirConfigStoragePoolTarget *target,
|
|
Packit |
a07778 |
const char *path)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(target),
|
|
Packit |
a07778 |
"path", path);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_target_get_permissions:
|
|
Packit |
a07778 |
* @target: a #GVirConfigStoragePoolTarget
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Gets the permissions associated with @target
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: (transfer full): a new #GVirConfigStoragePoolPermissions instance.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
GVirConfigStoragePermissions *gvir_config_storage_pool_target_get_permissions(GVirConfigStoragePoolTarget *target)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *object;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target), NULL);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
object = gvir_config_object_get_child_with_type
|
|
Packit |
a07778 |
(GVIR_CONFIG_OBJECT(target),
|
|
Packit |
a07778 |
"permissions",
|
|
Packit |
a07778 |
GVIR_CONFIG_TYPE_STORAGE_PERMISSIONS);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
return GVIR_CONFIG_STORAGE_PERMISSIONS(object);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_perms_set_permissions:
|
|
Packit |
a07778 |
* @perms: (allow-none):
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
void gvir_config_storage_pool_target_set_permissions(GVirConfigStoragePoolTarget *target,
|
|
Packit |
a07778 |
GVirConfigStoragePermissions *perms)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target));
|
|
Packit |
a07778 |
g_return_if_fail(perms == NULL ||
|
|
Packit |
a07778 |
GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
|
|
Packit |
a07778 |
"permissions",
|
|
Packit |
a07778 |
GVIR_CONFIG_OBJECT(perms));
|
|
Packit |
a07778 |
}
|