提交 e39438e8 编写于 作者: D Daniel P. Berrange

Added directory/filesystem/netfs based storage pool backend

上级 4a4e272f
Wed Feb 20 10:32:27 EST 2008 Daniel P. Berrange <berrange@redhat.com>
* configure.in: Add checks for mount/unmount/qemu-img/qcow-create
* docs/storage/*.xml: Add some example XML configs for storage
* libvirt.spec.in: Added deps on qemu-img and/or qcow-create,
and util-linux
* src/Makefile.am, src/storage_backend.c, src/storage_backend_fs.c,
src/storage_backend_fs.h: Add impl of directory, filesystem &
network filesystem pools.
* po/POTFILES.in: Added storage_backend_fs.c
Wed Feb 20 10:32:27 EST 2008 Daniel P. Berrange <berrange@redhat.com>
* configure.in: Add check for selinux library
......
......@@ -552,6 +552,52 @@ AC_SUBST(VIRSH_LIBS)
AC_SUBST(WITH_XEN)
AC_SUBST(LIBVIRT_FEATURES)
dnl
dnl Storage driver checks
dnl
AC_ARG_WITH(storage-fs,
[ --with-storage-fs with FileSystem backend for the storage driver (on)],[],[with_storage_fs=check])
if test "$with_storage_fs" = "yes" -o "$with_storage_fs" = "check"; then
AC_PATH_PROG(MOUNT, [mount], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG(UMOUNT, [umount], [], [$PATH:/sbin:/usr/sbin])
if test "$with_storage_fs" = "yes" ; then
if test -z "$MOUNT" ; then AC_MSG_ERROR(We need mount for FS storage driver) ; fi
if test -z "$UMOUNT" ; then AC_MSG_ERROR(We need mount for FS storage driver) ; fi
else
if test -z "$MOUNT" ; then with_storage_fs=no ; fi
if test -z "$UMOUNT" ; then with_storage_fs=no ; fi
if test "$with_storage_fs" = "check" ; then with_storage_fs=yes ; fi
fi
if test "$with_storage_fs" = "yes" ; then
AC_DEFINE_UNQUOTED(WITH_STORAGE_FS, 1, [whether FS backend for storage driver is enabled])
AC_DEFINE_UNQUOTED([MOUNT],["$MOUNT"],
[Location or name of the mount program])
AC_DEFINE_UNQUOTED([UMOUNT],["$UMOUNT"],
[Location or name of the mount program])
fi
fi
AM_CONDITIONAL(WITH_STORAGE_FS, [test "$with_storage_fs" = "yes"])
AC_PATH_PROG(QEMU_IMG, [qemu-img], [], [$PATH:/sbin:/usr/sbin:/bin:/usr/bin])
if test -n "$QEMU_IMG" ; then
AC_DEFINE_UNQUOTED(HAVE_QEMU_IMG, 1, [whether qemu-img is available for non-raw files])
AC_DEFINE_UNQUOTED([QEMU_IMG],["$QEMU_IMG"],
[Location or name of the qemu-img program])
fi
AC_PATH_PROG(QCOW_CREATE, [qcow-create], [], [$PATH:/sbin:/usr/sbin:/bin:/usr/bin])
if test -n "$QCOW_CREATE" ; then
AC_DEFINE_UNQUOTED(HAVE_QCOW_CREATE, 1, [whether qcow-create is available for non-raw files])
AC_DEFINE_UNQUOTED([QCOW_CREATE],["$QCOW_CREATE"],
[Location or name of the qcow-create program])
fi
dnl
dnl check for python
dnl
......@@ -760,6 +806,12 @@ AC_MSG_NOTICE([ Test: $with_test])
AC_MSG_NOTICE([ Remote: $with_remote])
AC_MSG_NOTICE([Libvirtd: $with_libvirtd])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Storage Drivers])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Dir: yes])
AC_MSG_NOTICE([ FS: $with_storage_fs])
AC_MSG_NOTICE([ NetFS: $with_storage_fs])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Libraries])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
......
......@@ -8,6 +8,12 @@
%define with_proxy yes
%endif
%if "%{fedora}"
%define with_qemu 1
%else
%define with_qemu 0
%endif
Summary: Library providing a simple API virtualization
Name: libvirt
Version: @VERSION@
......@@ -34,6 +40,15 @@ Requires: cyrus-sasl-md5
%if %{with_polkit}
Requires: PolicyKit >= 0.6
%endif
# For mount/umount in FS driver
BuildRequires: util-linux
%if %{with_qemu}
# From QEMU RPMs
Requires: /usr/bin/qemu-img
%else
# From Xen RPMs
Requires: /usr/sbin/qcow-create
%endif
BuildRequires: xen-devel
BuildRequires: libxml2-devel
BuildRequires: readline-devel
......@@ -49,6 +64,15 @@ BuildRequires: cyrus-sasl-devel
%if %{with_polkit}
BuildRequires: PolicyKit-devel >= 0.6
%endif
# For mount/umount in FS driver
BuildRequires: util-linux
%if %{with_qemu}
# From QEMU RPMs
BuildRequires: /usr/bin/qemu-img
%else
# From Xen RPMs
BuildRequires: /usr/sbin/qcow-create
%endif
Obsoletes: libvir
ExclusiveArch: i386 x86_64 ia64
......
......@@ -11,6 +11,7 @@ src/qemu_conf.c
src/qemu_driver.c
src/remote_internal.c
src/storage_backend.c
src/storage_backend_fs.c
src/storage_conf.c
src/storage_driver.c
src/sexpr.c
......
......@@ -62,6 +62,7 @@ CLIENT_SOURCES = \
storage_conf.h storage_conf.c \
storage_driver.h storage_driver.c \
storage_backend.h storage_backend.c \
storage_backend_fs.h storage_backend_fs.c \
util.c util.h
SERVER_SOURCES = \
......
......@@ -40,10 +40,24 @@
#include "util.h"
#include "storage_backend.h"
#include "storage_backend_fs.h"
static virStorageBackendPtr backends[] = {
&virStorageBackendDirectory,
#if WITH_STORAGE_FS
&virStorageBackendFileSystem,
&virStorageBackendNetFileSystem,
#endif
};
virStorageBackendPtr
virStorageBackendForType(int type) {
unsigned int i;
for (i = 0 ; i < (sizeof(backends)/sizeof(backends[0])) ; i++)
if (backends[i]->type == type)
return backends[i];
virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
_("missing backend for pool type %d"), type);
return NULL;
......@@ -68,6 +82,15 @@ virStorageBackendVolOptionsForType(int type) {
int
virStorageBackendFromString(const char *type) {
if (STREQ(type, "dir"))
return VIR_STORAGE_POOL_DIR;
#if WITH_STORAGE_FS
if (STREQ(type, "fs"))
return VIR_STORAGE_POOL_FS;
if (STREQ(type, "netfs"))
return VIR_STORAGE_POOL_NETFS;
#endif
virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
_("unknown storage backend type %s"), type);
return -1;
......@@ -75,6 +98,17 @@ virStorageBackendFromString(const char *type) {
const char *
virStorageBackendToString(int type) {
switch (type) {
case VIR_STORAGE_POOL_DIR:
return "dir";
#if WITH_STORAGE_FS
case VIR_STORAGE_POOL_FS:
return "fs";
case VIR_STORAGE_POOL_NETFS:
return "netfs";
#endif
}
virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
_("unknown storage backend type %d"), type);
return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册