Re: [libvirt] [PATCH 1/2] Format fs pool during pool build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 04, 2010 at 02:42:38PM -0500, David Allan wrote:
> ---
>  configure.in                     |    5 +++++
>  src/storage/storage_backend_fs.c |   36 +++++++++++++++++++++++++++++++++---
>  2 files changed, 38 insertions(+), 3 deletions(-)

  I'm rediscovering that patch, I rebased it since the function changed,
I'm just also worried by the potentially destructive nature of this
change, so I'm not applying it now, but providing the rebase,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
diff --git a/configure.in b/configure.in
index 8cbbfe5..9da41b2 100644
--- a/configure.in
+++ b/configure.in
@@ -1251,12 +1251,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([MKE2FS], [mke2fs], [], [$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 "$MKE2FS" ; then AC_MSG_ERROR([We need mke2fs 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 "$MKE2FS" ; then with_storage_fs=no ; fi
 
     if test "$with_storage_fs" = "check" ; then with_storage_fs=yes ; fi
   fi
@@ -1267,6 +1270,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([MKE2FS],["$MKE2FS"],
+        [Location or name of the mke2fs program])
   fi
 fi
 AM_CONDITIONAL([WITH_STORAGE_FS], [test "$with_storage_fs" = "yes"])
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 0d1c7a7..8d4d6a2 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -45,6 +45,7 @@
 #include "util.h"
 #include "memory.h"
 #include "xml.h"
+#include "logging.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
@@ -505,6 +506,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn,
                                  virStoragePoolObjPtr pool,
                                  unsigned int flags ATTRIBUTE_UNUSED)
 {
+    const char *mke2fsargv[5], *device = NULL, *format = NULL;
     int err, ret = -1;
     char *parent;
     char *p;
@@ -545,6 +547,33 @@ virStorageBackendFileSystemBuild(virConnectPtr conn,
                              pool->def->target.path);
         goto error;
     }
+
+    if (pool->def->source.ndevice != 1) {
+        virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
+                              "Exactly one source device "
+                              "may be specified for pool type '%s'",
+          virStoragePoolFormatFileSystemTypeToString(pool->def->source.format));
+        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] = MKE2FS;
+    mke2fsargv[1] = "-t";
+    mke2fsargv[2] = format;
+    mke2fsargv[3] = device;
+    mke2fsargv[4] = NULL;
+
+    if (virRun(conn, mke2fsargv, NULL) < 0) {
+        VIR_ERROR("Failed to make '%s' filesystem on device '%s'",
+                  format, device);
+        goto error;
+    }
+
     ret = 0;
 error:
     VIR_FREE(parent);
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]