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 <clalance@redhat.com>
This commit is contained in:
Chris Lalancette 2008-10-23 11:32:22 +00:00
parent 6d035f67e0
commit c0c0fb8eef
6 changed files with 20 additions and 1 deletions

View File

@ -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.

View File

@ -77,6 +77,7 @@ typedef struct _virStorageBackendPoolOptions virStorageBackendPoolOptions;
typedef virStorageBackendPoolOptions *virStorageBackendPoolOptionsPtr;
struct _virStorageBackendPoolOptions {
int flags;
int defaultFormat;
virStoragePoolFormatToString formatToString;
virStoragePoolFormatFromString formatFromString;
};

View 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,
},

View 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,
},

View 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,
},

View 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);