]> xenbits.xensource.com Git - libvirt.git/commitdiff
Added directory/filesystem/netfs based storage pool backend
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 20 Feb 2008 15:42:30 +0000 (15:42 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 20 Feb 2008 15:42:30 +0000 (15:42 +0000)
ChangeLog
configure.in
libvirt.spec.in
po/POTFILES.in
src/Makefile.am
src/storage_backend.c

index b675cadedbccab86185aeaaf70179f8924dc9179..8bf04fbcfebca1d255b721d47b6aeb8af50c5c82 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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
index 15c91aba315dbb496e7ef2dcc51aedb9cc41ac5d..5c75e7f2e30600045ec5ce7e129f3f4582632a1b 100644 (file)
@@ -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])
index 15f38c2c325edc2a0ebdcc180ab27e833886196a..677b40698a04b89acc7d3297f2727d5efd055896 100644 (file)
@@ -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
 
index f6c4dd8fa185c6e0a1ed7d94149ef86dc714a708..e0a917f3bc754ca325dd6e6df5fec20d0c3be46a 100644 (file)
@@ -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
index f9750e9e11bbb06d4c3df8215eddb20d1ecb9183..38efa66734396b58997b4462fbdc64bd6585fbb7 100644 (file)
@@ -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 =                                               \
index b350b753c095437c2f9bc2c6a2de37b61a6d49df..4d3a8cb53d1298b6dfb5baa4b478269038423f6f 100644 (file)
 #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;