|
Packit Service |
ea0369 |
/*
|
|
Packit Service |
ea0369 |
* libvirt-gconfig-storage-vol-target.c: libvirt storage vol target configuration
|
|
Packit Service |
ea0369 |
*
|
|
Packit Service |
ea0369 |
* Copyright (C) 2011 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 |
* Author: Christophe Fergeau <cfergeau@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 |
|
|
Packit Service |
ea0369 |
#define GVIR_CONFIG_STORAGE_VOL_TARGET_GET_PRIVATE(obj) \
|
|
Packit Service |
ea0369 |
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_STORAGE_VOL_TARGET, GVirConfigStorageVolTargetPrivate))
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
struct _GVirConfigStorageVolTargetPrivate
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
gboolean unused;
|
|
Packit Service |
ea0369 |
};
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
G_DEFINE_TYPE_WITH_PRIVATE(GVirConfigStorageVolTarget, gvir_config_storage_vol_target, GVIR_CONFIG_TYPE_OBJECT);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
static void gvir_config_storage_vol_target_class_init(GVirConfigStorageVolTargetClass *klass G_GNUC_UNUSED)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
static void gvir_config_storage_vol_target_init(GVirConfigStorageVolTarget *target)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
target->priv = GVIR_CONFIG_STORAGE_VOL_TARGET_GET_PRIVATE(target);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
GVirConfigStorageVolTarget *gvir_config_storage_vol_target_new(void)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
GVirConfigObject *object;
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
object = gvir_config_object_new(GVIR_CONFIG_TYPE_STORAGE_VOL_TARGET,
|
|
Packit Service |
ea0369 |
"target", NULL);
|
|
Packit Service |
ea0369 |
return GVIR_CONFIG_STORAGE_VOL_TARGET(object);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
GVirConfigStorageVolTarget *gvir_config_storage_vol_target_new_from_xml(const gchar *xml,
|
|
Packit Service |
ea0369 |
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_STORAGE_VOL_TARGET,
|
|
Packit Service |
ea0369 |
"target", NULL,
|
|
Packit Service |
ea0369 |
xml, error);
|
|
Packit Service |
ea0369 |
return GVIR_CONFIG_STORAGE_VOL_TARGET(object);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
void gvir_config_storage_vol_target_set_format(GVirConfigStorageVolTarget *target,
|
|
Packit Service |
ea0369 |
const char *format)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
GVirConfigObject *node;
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL_TARGET(target));
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(target), "format");
|
|
Packit Service |
ea0369 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit Service |
ea0369 |
gvir_config_object_set_attribute(node, "type", format, NULL);
|
|
Packit Service |
ea0369 |
g_object_unref(G_OBJECT(node));
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
/**
|
|
Packit Service |
ea0369 |
* gvir_config_storage_vol_target_set_permissions:
|
|
Packit Service |
ea0369 |
* @perms: (allow-none):
|
|
Packit Service |
ea0369 |
*/
|
|
Packit Service |
ea0369 |
void gvir_config_storage_vol_target_set_permissions(GVirConfigStorageVolTarget *target,
|
|
Packit Service |
ea0369 |
GVirConfigStoragePermissions *perms)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL_TARGET(target));
|
|
Packit Service |
ea0369 |
g_return_if_fail(perms == NULL ||
|
|
Packit Service |
ea0369 |
GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms));
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
|
|
Packit Service |
ea0369 |
"permissions",
|
|
Packit Service |
ea0369 |
GVIR_CONFIG_OBJECT(perms));
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
/**
|
|
Packit Service |
ea0369 |
* gvir_config_storage_vol_target_set_compat:
|
|
Packit Service |
ea0369 |
* @compat: (allow-none):
|
|
Packit Service |
ea0369 |
*/
|
|
Packit Service |
ea0369 |
void gvir_config_storage_vol_target_set_compat(GVirConfigStorageVolTarget *target,
|
|
Packit Service |
ea0369 |
const char *compat)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL_TARGET(target));
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(target),
|
|
Packit Service |
ea0369 |
"compat", compat);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
void gvir_config_storage_vol_target_set_features(GVirConfigStorageVolTarget *target,
|
|
Packit Service |
ea0369 |
guint64 features)
|
|
Packit Service |
ea0369 |
{
|
|
Packit Service |
ea0369 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL_TARGET(target));
|
|
Packit Service |
ea0369 |
g_return_if_fail((features & ~GVIR_CONFIG_STORAGE_VOL_TARGET_FEATURE_LAZY_REFCOUNT) == 0);
|
|
Packit Service |
ea0369 |
|
|
Packit Service |
ea0369 |
if ((features & GVIR_CONFIG_STORAGE_VOL_TARGET_FEATURE_LAZY_REFCOUNT) != 0) {
|
|
Packit Service |
ea0369 |
GVirConfigObject *features_node;
|
|
Packit Service |
ea0369 |
features_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(target), "features");
|
|
Packit Service |
ea0369 |
gvir_config_object_set_node_content(features_node, "lazy_refcount", "");
|
|
Packit Service |
ea0369 |
g_object_unref(features_node);
|
|
Packit Service |
ea0369 |
}
|
|
Packit Service |
ea0369 |
}
|