|
Packit |
a07778 |
/*
|
|
Packit |
a07778 |
* libvirt-gconfig-storage-pool-source.c: libvirt storage pool source 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_SOURCE_GET_PRIVATE(obj) \
|
|
Packit |
a07778 |
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_STORAGE_POOL_SOURCE, GVirConfigStoragePoolSourcePrivate))
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
struct _GVirConfigStoragePoolSourcePrivate
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
gboolean unused;
|
|
Packit |
a07778 |
};
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
G_DEFINE_TYPE_WITH_PRIVATE(GVirConfigStoragePoolSource, gvir_config_storage_pool_source, GVIR_CONFIG_TYPE_OBJECT);
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
static void gvir_config_storage_pool_source_class_init(GVirConfigStoragePoolSourceClass *klass G_GNUC_UNUSED)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
static void gvir_config_storage_pool_source_init(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
source->priv = GVIR_CONFIG_STORAGE_POOL_SOURCE_GET_PRIVATE(source);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new(void)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *object;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
object = gvir_config_object_new(GVIR_CONFIG_TYPE_STORAGE_POOL_SOURCE,
|
|
Packit |
a07778 |
"source", NULL);
|
|
Packit |
a07778 |
return GVIR_CONFIG_STORAGE_POOL_SOURCE(object);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
GVirConfigStoragePoolSource *gvir_config_storage_pool_source_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_SOURCE,
|
|
Packit |
a07778 |
"source", NULL,
|
|
Packit |
a07778 |
xml, error);
|
|
Packit |
a07778 |
return GVIR_CONFIG_STORAGE_POOL_SOURCE(object);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_adapter:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* For pools backed by a SCSI adapter, returns the SCSI adapter name
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: the SCSI adapter name.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_adapter(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"adapter",
|
|
Packit |
a07778 |
"name");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *adapter)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *node;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(source), "adapter");
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit |
a07778 |
gvir_config_object_set_attribute(node, "name", adapter, NULL);
|
|
Packit |
a07778 |
g_object_unref(G_OBJECT(node));
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_device_path:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* For pools backed by a physical device, returns the path to the block
|
|
Packit |
a07778 |
* device node
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: fully qualified path to the block device node.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_device_path(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"device",
|
|
Packit |
a07778 |
"path");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *device_path)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *node;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(source), "device");
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit |
a07778 |
gvir_config_object_set_attribute(node, "path", device_path, NULL);
|
|
Packit |
a07778 |
g_object_unref(G_OBJECT(node));
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_directory:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* For pools backed by a directory, returns the path to the backing directory
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: path to the directory backing directory.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_directory(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"directory",
|
|
Packit |
a07778 |
"path");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *directory)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *node;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(source), "directory");
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit |
a07778 |
gvir_config_object_set_attribute(node, "path", directory, NULL);
|
|
Packit |
a07778 |
g_object_unref(G_OBJECT(node));
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_format:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Provides information about the format of the pool. This format is
|
|
Packit |
a07778 |
* backend-specific but is typically used to indicate filesystem type, or
|
|
Packit |
a07778 |
* network filesystem type, or partition table type, or LVM metadata type.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: the storage pool format.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_format(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"format",
|
|
Packit |
a07778 |
"type");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *format)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *node;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(source), "format");
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit |
a07778 |
gvir_config_object_set_attribute(node, "type", format, NULL);
|
|
Packit |
a07778 |
g_object_unref(G_OBJECT(node));
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_host:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* For pools backed by storage from remote server, returns the hostname
|
|
Packit |
a07778 |
* of the remote server.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: hostname or IP address of the remote server.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_host(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"host",
|
|
Packit |
a07778 |
"name");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *host)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *node;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(source), "host");
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit |
a07778 |
gvir_config_object_set_attribute(node, "name", host, NULL);
|
|
Packit |
a07778 |
g_object_unref(G_OBJECT(node));
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_name:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* For pools backed by storage from a named element (for example, LV
|
|
Packit |
a07778 |
* groups), returns the name of the element
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: name of the element used by @source
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_name(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"name");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_set_name:
|
|
Packit |
a07778 |
* @name: (allow-none):
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_name(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *name)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"name", name);
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_product:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Gets the product name of the storage device.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: product name of the storage device.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_product(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"product",
|
|
Packit |
a07778 |
"name");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_product(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *product)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *node;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(source), "product");
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit |
a07778 |
gvir_config_object_set_attribute(node, "name", product, NULL);
|
|
Packit |
a07778 |
g_object_unref(G_OBJECT(node));
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
/**
|
|
Packit |
a07778 |
* gvir_config_storage_pool_source_get_vendor:
|
|
Packit |
a07778 |
* @source: a #GVirConfigStoragePoolSource
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Gets the vendor name of the storage device.
|
|
Packit |
a07778 |
*
|
|
Packit |
a07778 |
* Returns: vendor name of the storage device.
|
|
Packit |
a07778 |
*/
|
|
Packit |
a07778 |
const char *gvir_config_storage_pool_source_get_vendor(GVirConfigStoragePoolSource *source)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL);
|
|
Packit |
a07778 |
return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source),
|
|
Packit |
a07778 |
"vendor",
|
|
Packit |
a07778 |
"name");
|
|
Packit |
a07778 |
}
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
void gvir_config_storage_pool_source_set_vendor(GVirConfigStoragePoolSource *source,
|
|
Packit |
a07778 |
const char *vendor)
|
|
Packit |
a07778 |
{
|
|
Packit |
a07778 |
GVirConfigObject *node;
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
|
|
Packit |
a07778 |
|
|
Packit |
a07778 |
node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(source), "vendor");
|
|
Packit |
a07778 |
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
|
|
Packit |
a07778 |
gvir_config_object_set_attribute(node, "name", vendor, NULL);
|
|
Packit |
a07778 |
g_object_unref(G_OBJECT(node));
|
|
Packit |
a07778 |
}
|