]> xenbits.xensource.com Git - libvirt.git/commitdiff
Format FS pools on creation
authorDave Allan <dallan@redhat.com>
Wed, 24 Feb 2010 08:51:34 +0000 (09:51 +0100)
committerDaniel Veillard <veillard@redhat.com>
Wed, 24 Feb 2010 08:51:34 +0000 (09:51 +0100)
Create the filesystem on the partition used by the pool
* configure.ac: check for mkfs availability
* libvirt.spec.in: add extra require on util-linux for mkfs
* src/storage/storage_backend_fs.c: run mkfs with the expected
  fs type when creating a filesystem pool

.gnulib
configure.ac
libvirt.spec.in
src/storage/storage_backend_fs.c

diff --git a/.gnulib b/.gnulib
index 2709233ead439b582d82af48bd25e709378cda44..11fbc57405a118e6ec9a3ebc19bbf5ececdae4d6 160000 (submodule)
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 2709233ead439b582d82af48bd25e709378cda44
+Subproject commit 11fbc57405a118e6ec9a3ebc19bbf5ececdae4d6
index 743a3571adbe6be78385cb9527edfe98ee510348..117cb201a4f4968b9ce1f145772e96c0eec10741 100644 (file)
@@ -1252,12 +1252,15 @@ AM_CONDITIONAL([WITH_STORAGE_DIR], [test "$with_storage_dir" = "yes"])
 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])
+  AC_PATH_PROG([MKFS], [mkfs], [], [$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 umount for FS storage driver]) ; fi
+    if test -z "$MKFS" ; then AC_MSG_ERROR([We need mkfs 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 -z "$MKFS" ; then with_storage_fs=no ; fi
 
     if test "$with_storage_fs" = "check" ; then with_storage_fs=yes ; fi
   fi
@@ -1268,6 +1271,8 @@ if test "$with_storage_fs" = "yes" -o "$with_storage_fs" = "check"; then
         [Location or name of the mount program])
     AC_DEFINE_UNQUOTED([UMOUNT],["$UMOUNT"],
         [Location or name of the mount program])
+    AC_DEFINE_UNQUOTED([MKFS],["$MKFS"],
+        [Location or name of the mkfs program])
   fi
 fi
 AM_CONDITIONAL([WITH_STORAGE_FS], [test "$with_storage_fs" = "yes"])
index b1c1c9956549561665f046c802b4c7722b2b9b47..0670f8f3e7ed3fdbac27dca7ff725b4cb82ca772 100644 (file)
@@ -209,6 +209,8 @@ BuildRequires: util-linux
 # For showmount in FS driver (netfs discovery)
 BuildRequires: nfs-utils
 Requires: nfs-utils
+# For mkfs
+Requires: util-linux
 # For glusterfs
 %if 0%{?fedora} >= 11
 Requires: glusterfs-client >= 2.0.1
index 8279d781f152b7e4d77fcf04cfe390b7e2871c6e..0444fcf6d5e9419b394d57b49964fec87f76b470 100644 (file)
@@ -45,6 +45,7 @@
 #include "util.h"
 #include "memory.h"
 #include "xml.h"
+#include "logging.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
@@ -500,6 +501,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
                                  virStoragePoolObjPtr pool,
                                  unsigned int flags ATTRIBUTE_UNUSED)
 {
+    const char *mke2fsargv[5], *device = NULL, *format = NULL;
     int err, ret = -1;
     char *parent;
     char *p;
@@ -540,6 +542,26 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
                              pool->def->target.path);
         goto error;
     }
+
+    device = pool->def->source.devices[0].path;
+    format = virStoragePoolFormatFileSystemTypeToString(pool->def->source.format);
+
+    VIR_DEBUG("source device: '%s' format: '%s'", device, format);
+
+    mke2fsargv[0] = MKFS;
+    mke2fsargv[1] = "-t";
+    mke2fsargv[2] = format;
+    mke2fsargv[3] = device;
+    mke2fsargv[4] = NULL;
+
+    if (virRun(mke2fsargv, NULL) < 0) {
+        virReportSystemError(errno,
+                             _("Failed to make filesystem of "
+                               "type '%s' on device '%s'"),
+                               format, device);
+        goto error;
+    }
+
     ret = 0;
 error:
     VIR_FREE(parent);