From c0c0fb8eefe4f187eb556285f0ac76e4a0177756 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Thu, 23 Oct 2008 11:32:22 +0000 Subject: [PATCH] As suggested by danpb, to fix up the regression caused by last week's VIR_ENUM 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 --- ChangeLog | 10 ++++++++++ src/storage_backend.h | 1 + src/storage_backend_disk.c | 1 + src/storage_backend_fs.c | 1 + src/storage_backend_logical.c | 1 + src/storage_conf.c | 7 ++++++- 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 19e67e2e89..54c62c4295 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Thu Oct 23 13:31:00 CEST 2008 Chris Lalancette + * 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 * configure.in: Fix syntax error which was breaking RPM builds. diff --git a/src/storage_backend.h b/src/storage_backend.h index 201c1f262f..ff7614cf30 100644 --- a/src/storage_backend.h +++ b/src/storage_backend.h @@ -77,6 +77,7 @@ typedef struct _virStorageBackendPoolOptions virStorageBackendPoolOptions; typedef virStorageBackendPoolOptions *virStorageBackendPoolOptionsPtr; struct _virStorageBackendPoolOptions { int flags; + int defaultFormat; virStoragePoolFormatToString formatToString; virStoragePoolFormatFromString formatFromString; }; diff --git a/src/storage_backend_disk.c b/src/storage_backend_disk.c index a79b3c60a7..b835cf011d 100644 --- a/src/storage_backend_disk.c +++ b/src/storage_backend_disk.c @@ -448,6 +448,7 @@ virStorageBackend virStorageBackendDisk = { .poolOptions = { .flags = (VIR_STORAGE_BACKEND_POOL_SOURCE_DEVICE), + .defaultFormat = VIR_STORAGE_POOL_DISK_UNKNOWN, .formatFromString = virStorageBackendPartTableTypeFromString, .formatToString = virStorageBackendPartTableTypeToString, }, diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c index 6641de08a7..d261d71add 100644 --- a/src/storage_backend_fs.c +++ b/src/storage_backend_fs.c @@ -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, }, diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c index 89b36ca864..3b0db7aafe 100644 --- a/src/storage_backend_logical.c +++ b/src/storage_backend_logical.c @@ -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, }, diff --git a/src/storage_conf.c b/src/storage_conf.c index 2ab5467841..e18b2d1b94 100644 --- a/src/storage_conf.c +++ b/src/storage_conf.c @@ -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);