]> xenbits.xensource.com Git - libvirt.git/commitdiff
As suggested by danpb, to fix up the regression caused by last week's VIR_ENUM
authorChris Lalancette <clalance@redhat.com>
Thu, 23 Oct 2008 11:32:22 +0000 (11:32 +0000)
committerChris Lalancette <clalance@redhat.com>
Thu, 23 Oct 2008 11:32:22 +0000 (11:32 +0000)
cleanup patch, add a ".defaultFormat" member to .poolOptions.  In
storage_conf.c, if virXPathString(/pool/source/format/@type) returns NULL, then
set the pool type to .defaultFormat; otherwise, lookup the type via
formatFromString.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
ChangeLog
src/storage_backend.h
src/storage_backend_disk.c
src/storage_backend_fs.c
src/storage_backend_logical.c
src/storage_conf.c

index 19e67e2e893d65bc3a813aedcaa8ecfb0deab037..54c62c42950d02d3f7eef4afb3e6cac520e77e08 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Oct 23 13:31:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
+       * src/storage_backend.h src/storage_backend_disk.c
+       src/storage_backend_fs.c src/storage_backend_logical.c
+       src/storage_conf.c: Fix up a regression caused by the transition of
+       the storage backends to VIR_ENUM_IMPL.  Before, we would accept
+       no format type, which would then use whatever the default for the pool
+       was.  But the conversion caused this to instead cause a SEGFAULT,
+       which isn't good.  Introduce a .defaultFormat parameter so that we
+       restore the previous behavior, although in a more generic format.
+
 Wed Oct 22 09:53:00 EST 2008 Cole Robinson <crobinso@redhat.com>
 
        * configure.in: Fix syntax error which was breaking RPM builds.
index 201c1f262fe6c8480bc0c1112727b79779e9d522..ff7614cf30b830301bd7f478b1bc595093e2582b 100644 (file)
@@ -77,6 +77,7 @@ typedef struct _virStorageBackendPoolOptions virStorageBackendPoolOptions;
 typedef virStorageBackendPoolOptions *virStorageBackendPoolOptionsPtr;
 struct _virStorageBackendPoolOptions {
     int flags;
+    int defaultFormat;
     virStoragePoolFormatToString formatToString;
     virStoragePoolFormatFromString formatFromString;
 };
index a79b3c60a7075b9011664705b9996dddc21ec27f..b835cf011de34ab19fb1785e7c99458cfa2c24c5 100644 (file)
@@ -448,6 +448,7 @@ virStorageBackend virStorageBackendDisk = {
 
     .poolOptions = {
         .flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE),
+        .defaultFormat = VIR_STORAGE_POOL_DISK_UNKNOWN,
         .formatFromString = virStorageBackendPartTableTypeFromString,
         .formatToString = virStorageBackendPartTableTypeToString,
     },
index 6641de08a7386ced9b3f8fa6756db28b1be0f0a8..d261d71add3b40b74d6b8085421888bce29c02eb 100644 (file)
@@ -1083,6 +1083,7 @@ virStorageBackend virStorageBackendNetFileSystem = {
     .poolOptions = {
         .flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_HOST |
                   VIR_STORAGE_BACKEND_POOL_SOURCE_DIR),
+        .defaultFormat = VIR_STORAGE_POOL_FS_AUTO,
         .formatFromString = virStorageBackendFileSystemNetPoolTypeFromString,
         .formatToString = virStorageBackendFileSystemNetPoolTypeToString,
     },
index 89b36ca8646c139ec79850036841382917eb7399..3b0db7aafe1bcbd4dab6501c60c31f2175c79593 100644 (file)
@@ -616,6 +616,7 @@ virStorageBackend virStorageBackendLogical = {
     .poolOptions = {
         .flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_NAME |
                   VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE),
+        .defaultFormat = VIR_STORAGE_POOL_LOGICAL_LVM2,
         .formatFromString = virStorageBackendLogicalPoolTypeFromString,
         .formatToString = virStorageBackendLogicalPoolTypeToString,
     },
index 2ab5467841415b580ec623e1df91c255e726641c..e18b2d1b940282c179b6131e28b6c0a51208bf24 100644 (file)
@@ -275,7 +275,12 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
 
     if (options->formatFromString) {
         char *format = virXPathString(conn, "string(/pool/source/format/@type)", ctxt);
-        if ((ret->source.format = (options->formatFromString)(format)) < 0) {
+        if (format == NULL)
+            ret->source.format = options->defaultFormat;
+        else
+            ret->source.format = options->formatFromString(format);
+
+        if (ret->source.format < 0) {
             virStorageReportError(conn, VIR_ERR_XML_ERROR,
                                   _("unknown pool format type %s"), format);
             VIR_FREE(format);