mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-29 17:33:09 +00:00
Added main internal storage driver impl
This commit is contained in:
parent
f43e709842
commit
20878720c0
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Wed Feb 20 10:26:27 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* Makefile.maint: Add virStorageReportError to locale check rule
|
||||||
|
* configure.in: Turn on large file support
|
||||||
|
* po/POTFILES.in: Add storage driver files
|
||||||
|
* include/libvirt/virterror.h, src/virterror.c: Add more error codes
|
||||||
|
* src/storage_driver.c, src/storage_driver.h: Add impl of all the
|
||||||
|
storage APIs
|
||||||
|
* src/storage_conf.c, src/storage_conf.h: Support routines for
|
||||||
|
parsing and formatting XML, and persisting storage pool configs
|
||||||
|
* src/storage_backend.c, src/storage_backend.h: Contract for
|
||||||
|
internal storage backends to interface with driver
|
||||||
|
* src/Makefile.am: Add new storage source files to library build
|
||||||
|
|
||||||
Wed Feb 20 10:23:27 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
Wed Feb 20 10:23:27 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* src/virsh.c: Added convenience methods for creating pools
|
* src/virsh.c: Added convenience methods for creating pools
|
||||||
|
@ -289,7 +289,7 @@ sc_two_space_separator_in_usage:
|
|||||||
1>&2; exit 1; } || :
|
1>&2; exit 1; } || :
|
||||||
|
|
||||||
err_func_re = \
|
err_func_re = \
|
||||||
(DISABLE_fprintf|qemudLog|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn))Error)
|
(DISABLE_fprintf|qemudLog|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn|StorageReport))Error)
|
||||||
|
|
||||||
# Look for diagnostics that aren't marked for translation.
|
# Look for diagnostics that aren't marked for translation.
|
||||||
# This won't find any for which error's format string is on a separate line.
|
# This won't find any for which error's format string is on a separate line.
|
||||||
|
@ -689,6 +689,8 @@ AC_SUBST(CYGWIN_EXTRA_LIBADD)
|
|||||||
AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
|
AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
|
||||||
AC_SUBST(MINGW_EXTRA_LDFLAGS)
|
AC_SUBST(MINGW_EXTRA_LDFLAGS)
|
||||||
|
|
||||||
|
AC_SYS_LARGEFILE
|
||||||
|
|
||||||
# very annoying
|
# very annoying
|
||||||
rm -f COPYING
|
rm -f COPYING
|
||||||
cp COPYING.LIB COPYING
|
cp COPYING.LIB COPYING
|
||||||
|
@ -136,6 +136,8 @@ typedef enum {
|
|||||||
VIR_ERR_INVALID_STORAGE_POOL, /* invalid storage pool object */
|
VIR_ERR_INVALID_STORAGE_POOL, /* invalid storage pool object */
|
||||||
VIR_ERR_INVALID_STORAGE_VOL, /* invalid storage vol object */
|
VIR_ERR_INVALID_STORAGE_VOL, /* invalid storage vol object */
|
||||||
VIR_WAR_NO_STORAGE, /* failed to start storage */
|
VIR_WAR_NO_STORAGE, /* failed to start storage */
|
||||||
|
VIR_ERR_NO_STORAGE_POOL, /* storage pool not found */
|
||||||
|
VIR_ERR_NO_STORAGE_VOL, /* storage pool not found */
|
||||||
} virErrorNumber;
|
} virErrorNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,9 @@ src/proxy_internal.c
|
|||||||
src/qemu_conf.c
|
src/qemu_conf.c
|
||||||
src/qemu_driver.c
|
src/qemu_driver.c
|
||||||
src/remote_internal.c
|
src/remote_internal.c
|
||||||
|
src/storage_backend.c
|
||||||
|
src/storage_conf.c
|
||||||
|
src/storage_driver.c
|
||||||
src/sexpr.c
|
src/sexpr.c
|
||||||
src/test.c
|
src/test.c
|
||||||
src/uuid.c
|
src/uuid.c
|
||||||
|
@ -58,6 +58,9 @@ CLIENT_SOURCES = \
|
|||||||
openvz_conf.c openvz_conf.h \
|
openvz_conf.c openvz_conf.h \
|
||||||
openvz_driver.c openvz_driver.h \
|
openvz_driver.c openvz_driver.h \
|
||||||
nodeinfo.h nodeinfo.c \
|
nodeinfo.h nodeinfo.c \
|
||||||
|
storage_conf.h storage_conf.c \
|
||||||
|
storage_driver.h storage_driver.c \
|
||||||
|
storage_backend.h storage_backend.c \
|
||||||
util.c util.h
|
util.c util.h
|
||||||
|
|
||||||
SERVER_SOURCES = \
|
SERVER_SOURCES = \
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "xen_unified.h"
|
#include "xen_unified.h"
|
||||||
#include "remote_internal.h"
|
#include "remote_internal.h"
|
||||||
#include "qemu_driver.h"
|
#include "qemu_driver.h"
|
||||||
|
#include "storage_driver.h"
|
||||||
#ifdef WITH_OPENVZ
|
#ifdef WITH_OPENVZ
|
||||||
#include "openvz_driver.h"
|
#include "openvz_driver.h"
|
||||||
#endif
|
#endif
|
||||||
@ -215,6 +216,7 @@ virInitialize(void)
|
|||||||
#ifdef WITH_OPENVZ
|
#ifdef WITH_OPENVZ
|
||||||
if (openvzRegister() == -1) return -1;
|
if (openvzRegister() == -1) return -1;
|
||||||
#endif
|
#endif
|
||||||
|
if (storageRegister() == -1) return -1;
|
||||||
#ifdef WITH_REMOTE
|
#ifdef WITH_REMOTE
|
||||||
if (remoteRegister () == -1) return -1;
|
if (remoteRegister () == -1) return -1;
|
||||||
#endif
|
#endif
|
||||||
|
88
src/storage_backend.c
Normal file
88
src/storage_backend.c
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* storage_backend.h: internal storage driver backend contract
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <regex.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "storage_backend.h"
|
||||||
|
|
||||||
|
|
||||||
|
virStorageBackendPtr
|
||||||
|
virStorageBackendForType(int type) {
|
||||||
|
virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("missing backend for pool type %d"), type);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virStorageBackendPoolOptionsPtr
|
||||||
|
virStorageBackendPoolOptionsForType(int type) {
|
||||||
|
virStorageBackendPtr backend = virStorageBackendForType(type);
|
||||||
|
if (backend == NULL)
|
||||||
|
return NULL;
|
||||||
|
return &backend->poolOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
virStorageBackendVolOptionsPtr
|
||||||
|
virStorageBackendVolOptionsForType(int type) {
|
||||||
|
virStorageBackendPtr backend = virStorageBackendForType(type);
|
||||||
|
if (backend == NULL)
|
||||||
|
return NULL;
|
||||||
|
return &backend->volOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virStorageBackendFromString(const char *type) {
|
||||||
|
virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("unknown storage backend type %s"), type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
virStorageBackendToString(int type) {
|
||||||
|
virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("unknown storage backend type %d"), type);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: set tabstop=4:
|
||||||
|
* vim: set shiftwidth=4:
|
||||||
|
* vim: set expandtab:
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* c-indent-level: 4
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* tab-width: 4
|
||||||
|
* End:
|
||||||
|
*/
|
121
src/storage_backend.h
Normal file
121
src/storage_backend.h
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* storage_backend.h: internal storage driver backend contract
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2008 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VIR_STORAGE_BACKEND_H__
|
||||||
|
#define __VIR_STORAGE_BACKEND_H__
|
||||||
|
|
||||||
|
#include <libvirt/libvirt.h>
|
||||||
|
#include "storage_conf.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef const char *(*virStorageVolFormatToString)(virConnectPtr conn,
|
||||||
|
int format);
|
||||||
|
typedef int (*virStorageVolFormatFromString)(virConnectPtr conn,
|
||||||
|
const char *format);
|
||||||
|
|
||||||
|
typedef const char *(*virStoragePoolFormatToString)(virConnectPtr conn,
|
||||||
|
int format);
|
||||||
|
typedef int (*virStoragePoolFormatFromString)(virConnectPtr conn,
|
||||||
|
const char *format);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStorageBackendVolOptions virStorageBackendVolOptions;
|
||||||
|
typedef virStorageBackendVolOptions *virStorageBackendVolOptionsPtr;
|
||||||
|
struct _virStorageBackendVolOptions {
|
||||||
|
virStorageVolFormatToString formatToString;
|
||||||
|
virStorageVolFormatFromString formatFromString;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Flags to indicate mandatory components in the pool source */
|
||||||
|
enum {
|
||||||
|
VIR_STORAGE_BACKEND_POOL_SOURCE_HOST = (1<<0),
|
||||||
|
VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE = (1<<1),
|
||||||
|
VIR_STORAGE_BACKEND_POOL_SOURCE_DIR = (1<<2),
|
||||||
|
VIR_STORAGE_BACKEND_POOL_SOURCE_ADAPTER = (1<<3),
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _virStorageBackendPoolOptions virStorageBackendPoolOptions;
|
||||||
|
typedef virStorageBackendPoolOptions *virStorageBackendPoolOptionsPtr;
|
||||||
|
struct _virStorageBackendPoolOptions {
|
||||||
|
int flags;
|
||||||
|
virStoragePoolFormatToString formatToString;
|
||||||
|
virStoragePoolFormatFromString formatFromString;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int (*virStorageBackendStartPool)(virConnectPtr conn, virStoragePoolObjPtr pool);
|
||||||
|
typedef int (*virStorageBackendBuildPool)(virConnectPtr conn, virStoragePoolObjPtr pool, unsigned int flags);
|
||||||
|
typedef int (*virStorageBackendRefreshPool)(virConnectPtr conn, virStoragePoolObjPtr pool);
|
||||||
|
typedef int (*virStorageBackendStopPool)(virConnectPtr conn, virStoragePoolObjPtr pool);
|
||||||
|
typedef int (*virStorageBackendDeletePool)(virConnectPtr conn, virStoragePoolObjPtr pool, unsigned int flags);
|
||||||
|
|
||||||
|
typedef int (*virStorageBackendCreateVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol);
|
||||||
|
typedef int (*virStorageBackendRefreshVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol);
|
||||||
|
typedef int (*virStorageBackendDeleteVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStorageBackend virStorageBackend;
|
||||||
|
typedef virStorageBackend *virStorageBackendPtr;
|
||||||
|
|
||||||
|
struct _virStorageBackend {
|
||||||
|
int type;
|
||||||
|
|
||||||
|
virStorageBackendStartPool startPool;
|
||||||
|
virStorageBackendBuildPool buildPool;
|
||||||
|
virStorageBackendRefreshPool refreshPool;
|
||||||
|
virStorageBackendStopPool stopPool;
|
||||||
|
virStorageBackendDeletePool deletePool;
|
||||||
|
|
||||||
|
virStorageBackendCreateVol createVol;
|
||||||
|
virStorageBackendRefreshVol refreshVol;
|
||||||
|
virStorageBackendDeleteVol deleteVol;
|
||||||
|
|
||||||
|
virStorageBackendPoolOptions poolOptions;
|
||||||
|
virStorageBackendVolOptions volOptions;
|
||||||
|
|
||||||
|
int volType;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
virStorageBackendPtr virStorageBackendForType(int type);
|
||||||
|
virStorageBackendPoolOptionsPtr virStorageBackendPoolOptionsForType(int type);
|
||||||
|
virStorageBackendVolOptionsPtr virStorageBackendVolOptionsForType(int type);
|
||||||
|
int virStorageBackendFromString(const char *type);
|
||||||
|
const char *virStorageBackendToString(int type);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __VIR_STORAGE_BACKEND_H__ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: set tabstop=4:
|
||||||
|
* vim: set shiftwidth=4:
|
||||||
|
* vim: set expandtab:
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* c-indent-level: 4
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* tab-width: 4
|
||||||
|
* End:
|
||||||
|
*/
|
1251
src/storage_conf.c
Normal file
1251
src/storage_conf.c
Normal file
File diff suppressed because it is too large
Load Diff
314
src/storage_conf.h
Normal file
314
src/storage_conf.h
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
/*
|
||||||
|
* storage_conf.h: config handling for storage driver
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2008 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VIR_STORAGE_CONF_H__
|
||||||
|
#define __VIR_STORAGE_CONF_H__
|
||||||
|
|
||||||
|
#include <libvirt/libvirt.h>
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* Shared structs */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStoragePerms virStoragePerms;
|
||||||
|
typedef virStoragePerms *virStoragePermsPtr;
|
||||||
|
struct _virStoragePerms {
|
||||||
|
int mode;
|
||||||
|
int uid;
|
||||||
|
int gid;
|
||||||
|
char *label;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Storage volumes */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* How the volume's data is stored on underlying
|
||||||
|
* physical devices - can potentially span many
|
||||||
|
* devices in LVM case.
|
||||||
|
*/
|
||||||
|
typedef struct _virStorageVolSourceExtent virStorageVolSourceExtent;
|
||||||
|
typedef virStorageVolSourceExtent *virStorageVolSourceExtentPtr;
|
||||||
|
struct _virStorageVolSourceExtent {
|
||||||
|
char *path;
|
||||||
|
unsigned long long start;
|
||||||
|
unsigned long long end;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _virStorageVolSource virStorageVolSource;
|
||||||
|
typedef virStorageVolSource *virStorageVolSourcePtr;
|
||||||
|
struct _virStorageVolSource {
|
||||||
|
int nextent;
|
||||||
|
virStorageVolSourceExtentPtr extents;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* How the volume appears on the host
|
||||||
|
*/
|
||||||
|
typedef struct _virStorageVolTarget virStorageVolTarget;
|
||||||
|
typedef virStorageVolTarget *virStorageVolTargetPtr;
|
||||||
|
struct _virStorageVolTarget {
|
||||||
|
char *path;
|
||||||
|
int format;
|
||||||
|
virStoragePerms perms;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStorageVolDef virStorageVolDef;
|
||||||
|
typedef virStorageVolDef *virStorageVolDefPtr;
|
||||||
|
struct _virStorageVolDef {
|
||||||
|
char *name;
|
||||||
|
char *key;
|
||||||
|
|
||||||
|
unsigned long long allocation;
|
||||||
|
unsigned long long capacity;
|
||||||
|
|
||||||
|
virStorageVolSource source;
|
||||||
|
virStorageVolTarget target;
|
||||||
|
|
||||||
|
virStorageVolDefPtr next;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Storage pools */
|
||||||
|
|
||||||
|
enum virStoragePoolType {
|
||||||
|
VIR_STORAGE_POOL_DIR = 1, /* Local directory */
|
||||||
|
VIR_STORAGE_POOL_FS, /* Local filesystem */
|
||||||
|
VIR_STORAGE_POOL_NETFS, /* Networked filesystem - eg NFS, GFS, etc */
|
||||||
|
VIR_STORAGE_POOL_LOGICAL, /* Logical volume groups / volumes */
|
||||||
|
VIR_STORAGE_POOL_DISK, /* Disk partitions */
|
||||||
|
VIR_STORAGE_POOL_ISCSI, /* iSCSI targets */
|
||||||
|
VIR_STORAGE_POOL_SCSI, /* SCSI HBA */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum virStoragePoolAuthType {
|
||||||
|
VIR_STORAGE_POOL_AUTH_NONE,
|
||||||
|
VIR_STORAGE_POOL_AUTH_CHAP,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _virStoragePoolAuthChap virStoragePoolAuthChap;
|
||||||
|
typedef virStoragePoolAuthChap *virStoragePoolAuthChapPtr;
|
||||||
|
struct _virStoragePoolAuthChap {
|
||||||
|
char *login;
|
||||||
|
char *passwd;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For remote pools, info on how to reach the host
|
||||||
|
*/
|
||||||
|
typedef struct _virStoragePoolSourceHost virStoragePoolSourceHost;
|
||||||
|
typedef virStoragePoolSourceHost *virStoragePoolSourceHostPtr;
|
||||||
|
struct _virStoragePoolSourceHost {
|
||||||
|
char *name;
|
||||||
|
int port;
|
||||||
|
int protocol;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Available extents on the underlying storage
|
||||||
|
*/
|
||||||
|
typedef struct _virStoragePoolSourceDeviceExtent virStoragePoolSourceDeviceExtent;
|
||||||
|
typedef virStoragePoolSourceDeviceExtent *virStoragePoolSourceDeviceExtentPtr;
|
||||||
|
struct _virStoragePoolSourceDeviceExtent {
|
||||||
|
unsigned long long start;
|
||||||
|
unsigned long long end;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pools can be backed by one or more devices, and some
|
||||||
|
* allow us to track free space on underlying devices.
|
||||||
|
*/
|
||||||
|
typedef struct _virStoragePoolSourceDevice virStoragePoolSourceDevice;
|
||||||
|
typedef virStoragePoolSourceDevice *virStoragePoolSourceDevicePtr;
|
||||||
|
struct _virStoragePoolSourceDevice {
|
||||||
|
int nfreeExtent;
|
||||||
|
virStoragePoolSourceDeviceExtentPtr freeExtents;
|
||||||
|
char *path;
|
||||||
|
int format; /* Pool specific source format */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStoragePoolSource virStoragePoolSource;
|
||||||
|
typedef virStoragePoolSource *virStoragePoolSourcePtr;
|
||||||
|
struct _virStoragePoolSource {
|
||||||
|
/* An optional host */
|
||||||
|
virStoragePoolSourceHost host;
|
||||||
|
|
||||||
|
/* And either one or more devices ... */
|
||||||
|
int ndevice;
|
||||||
|
virStoragePoolSourceDevicePtr devices;
|
||||||
|
|
||||||
|
/* Or a directory */
|
||||||
|
char *dir;
|
||||||
|
|
||||||
|
/* Or an adapter */
|
||||||
|
char *adapter;
|
||||||
|
|
||||||
|
int authType; /* virStoragePoolAuthType */
|
||||||
|
union {
|
||||||
|
virStoragePoolAuthChap chap;
|
||||||
|
} auth;
|
||||||
|
|
||||||
|
int format; /* Pool type specific format such as filesystem type, or lvm version, etc */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStoragePoolTarget virStoragePoolTarget;
|
||||||
|
typedef virStoragePoolTarget *virStoragePoolTargetPtr;
|
||||||
|
struct _virStoragePoolTarget {
|
||||||
|
char *path; /* Optional local filesystem mapping */
|
||||||
|
virStoragePerms perms; /* Default permissions for volumes */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStoragePoolDef virStoragePoolDef;
|
||||||
|
typedef virStoragePoolDef *virStoragePoolDefPtr;
|
||||||
|
struct _virStoragePoolDef {
|
||||||
|
/* General metadata */
|
||||||
|
char *name;
|
||||||
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||||
|
int type; /* virStoragePoolType */
|
||||||
|
|
||||||
|
unsigned long long allocation;
|
||||||
|
unsigned long long capacity;
|
||||||
|
unsigned long long available;
|
||||||
|
|
||||||
|
virStoragePoolSource source;
|
||||||
|
virStoragePoolTarget target;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _virStoragePoolObj virStoragePoolObj;
|
||||||
|
typedef virStoragePoolObj *virStoragePoolObjPtr;
|
||||||
|
|
||||||
|
struct _virStoragePoolObj {
|
||||||
|
char *configFile;
|
||||||
|
char *autostartLink;
|
||||||
|
int active;
|
||||||
|
int autostart;
|
||||||
|
|
||||||
|
virStoragePoolDefPtr def;
|
||||||
|
virStoragePoolDefPtr newDef;
|
||||||
|
|
||||||
|
int nvolumes;
|
||||||
|
virStorageVolDefPtr volumes;
|
||||||
|
|
||||||
|
virStoragePoolObjPtr next;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _virStorageDriverState virStorageDriverState;
|
||||||
|
typedef virStorageDriverState *virStorageDriverStatePtr;
|
||||||
|
|
||||||
|
struct _virStorageDriverState {
|
||||||
|
int nactivePools;
|
||||||
|
int ninactivePools;
|
||||||
|
virStoragePoolObjPtr pools;
|
||||||
|
char *configDir;
|
||||||
|
char *autostartDir;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static inline int virStoragePoolObjIsActive(virStoragePoolObjPtr pool) {
|
||||||
|
return pool->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
void virStorageReportError(virConnectPtr conn,
|
||||||
|
int code,
|
||||||
|
const char *fmt, ...)
|
||||||
|
ATTRIBUTE_FORMAT(printf, 3, 4);
|
||||||
|
|
||||||
|
int virStoragePoolObjScanConfigs(virStorageDriverStatePtr driver);
|
||||||
|
|
||||||
|
virStoragePoolObjPtr virStoragePoolObjFindByUUID(virStorageDriverStatePtr driver,
|
||||||
|
const unsigned char *uuid);
|
||||||
|
virStoragePoolObjPtr virStoragePoolObjFindByName(virStorageDriverStatePtr driver,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
virStorageVolDefPtr virStorageVolDefFindByKey(virStoragePoolObjPtr pool,
|
||||||
|
const char *key);
|
||||||
|
virStorageVolDefPtr virStorageVolDefFindByPath(virStoragePoolObjPtr pool,
|
||||||
|
const char *path);
|
||||||
|
virStorageVolDefPtr virStorageVolDefFindByName(virStoragePoolObjPtr pool,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
void virStoragePoolObjClearVols(virStoragePoolObjPtr pool);
|
||||||
|
|
||||||
|
virStoragePoolDefPtr virStoragePoolDefParse(virConnectPtr conn,
|
||||||
|
const char *xml,
|
||||||
|
const char *filename);
|
||||||
|
char *virStoragePoolDefFormat(virConnectPtr conn,
|
||||||
|
virStoragePoolDefPtr def);
|
||||||
|
|
||||||
|
virStorageVolDefPtr virStorageVolDefParse(virConnectPtr conn,
|
||||||
|
virStoragePoolDefPtr pool,
|
||||||
|
const char *xml,
|
||||||
|
const char *filename);
|
||||||
|
char *virStorageVolDefFormat(virConnectPtr conn,
|
||||||
|
virStoragePoolDefPtr pool,
|
||||||
|
virStorageVolDefPtr def);
|
||||||
|
|
||||||
|
virStoragePoolObjPtr virStoragePoolObjAssignDef(virConnectPtr conn,
|
||||||
|
virStorageDriverStatePtr driver,
|
||||||
|
virStoragePoolDefPtr def);
|
||||||
|
|
||||||
|
int virStoragePoolObjSaveDef(virConnectPtr conn,
|
||||||
|
virStorageDriverStatePtr driver,
|
||||||
|
virStoragePoolObjPtr pool,
|
||||||
|
virStoragePoolDefPtr def);
|
||||||
|
int virStoragePoolObjDeleteDef(virConnectPtr conn,
|
||||||
|
virStoragePoolObjPtr pool);
|
||||||
|
|
||||||
|
void virStorageVolDefFree(virStorageVolDefPtr def);
|
||||||
|
void virStoragePoolDefFree(virStoragePoolDefPtr def);
|
||||||
|
void virStoragePoolObjFree(virStoragePoolObjPtr pool);
|
||||||
|
void virStoragePoolObjRemove(virStorageDriverStatePtr driver,
|
||||||
|
virStoragePoolObjPtr pool);
|
||||||
|
|
||||||
|
#endif /* __VIR_STORAGE_DRIVER_H__ */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: set tabstop=4:
|
||||||
|
* vim: set shiftwidth=4:
|
||||||
|
* vim: set expandtab:
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* c-indent-level: 4
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* tab-width: 4
|
||||||
|
* End:
|
||||||
|
*/
|
1261
src/storage_driver.c
Normal file
1261
src/storage_driver.c
Normal file
File diff suppressed because it is too large
Load Diff
45
src/storage_driver.h
Normal file
45
src/storage_driver.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* storage_driver.h: core driver for storage APIs
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2008 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __VIR_STORAGE_DRIVER_H__
|
||||||
|
#define __VIR_STORAGE_DRIVER_H__
|
||||||
|
|
||||||
|
#include "storage_conf.h"
|
||||||
|
|
||||||
|
int storageRegister(void);
|
||||||
|
|
||||||
|
#endif /* __VIR_STORAGE_DRIVER_H__ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vim: set tabstop=4:
|
||||||
|
* vim: set shiftwidth=4:
|
||||||
|
* vim: set expandtab:
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* c-indent-level: 4
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* tab-width: 4
|
||||||
|
* End:
|
||||||
|
*/
|
@ -678,6 +678,18 @@ __virErrorMsg(virErrorNumber error, const char *info)
|
|||||||
else
|
else
|
||||||
errmsg = _("authentication failed: %s");
|
errmsg = _("authentication failed: %s");
|
||||||
break;
|
break;
|
||||||
|
case VIR_ERR_NO_STORAGE_POOL:
|
||||||
|
if (info == NULL)
|
||||||
|
errmsg = _("Storage pool not found");
|
||||||
|
else
|
||||||
|
errmsg = _("Storage pool not found: %s");
|
||||||
|
break;
|
||||||
|
case VIR_ERR_NO_STORAGE_VOL:
|
||||||
|
if (info == NULL)
|
||||||
|
errmsg = _("Storage volume not found");
|
||||||
|
else
|
||||||
|
errmsg = _("Storage volume not found: %s");
|
||||||
|
break;
|
||||||
case VIR_ERR_INVALID_STORAGE_POOL:
|
case VIR_ERR_INVALID_STORAGE_POOL:
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
errmsg = _("invalid storage pool pointer in");
|
errmsg = _("invalid storage pool pointer in");
|
||||||
|
Loading…
Reference in New Issue
Block a user