提交 1d9a22b7 编写于 作者: D Daniel Veillard

fix crash and regression when defining a storage volume without a format

* src/storage_conf.c: fix crash and regression when defining
  a storage volume without a format (Cole Robinson)
Daniel
上级 76944e81
Thu Dec 4 16:20:20 CET 2008 Daniel Veillard <veillard@redhat.com>
* src/storage_conf.c: fix crash and regression when defining
a storage volume without a format (Cole Robinson)
Thu Dec 4 09:45:00 EST 2008 Cole Robinson <crobinso@redhat.com>
* docs/formatstorage.html.in docs/storage.html.in : Fix some
......
......@@ -94,6 +94,7 @@ typedef int (*virStoragePoolFormatFromString)(const char *format);
typedef struct _virStorageVolOptions virStorageVolOptions;
typedef virStorageVolOptions *virStorageVolOptionsPtr;
struct _virStorageVolOptions {
int defaultFormat;
virStorageVolFormatToString formatToString;
virStorageVolFormatFromString formatFromString;
};
......@@ -139,6 +140,7 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
},
{ .poolType = VIR_STORAGE_POOL_DIR,
.volOptions = {
.defaultFormat = VIR_STORAGE_VOL_FILE_RAW,
.formatFromString = virStorageVolFormatFileSystemTypeFromString,
.formatToString = virStorageVolFormatFileSystemTypeToString,
},
......@@ -150,6 +152,7 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
.formatToString = virStoragePoolFormatFileSystemTypeToString,
},
.volOptions = {
.defaultFormat = VIR_STORAGE_VOL_FILE_RAW,
.formatFromString = virStorageVolFormatFileSystemTypeFromString,
.formatToString = virStorageVolFormatFileSystemTypeToString,
},
......@@ -163,6 +166,7 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
.formatToString = virStoragePoolFormatFileSystemNetTypeToString,
},
.volOptions = {
.defaultFormat = VIR_STORAGE_VOL_FILE_RAW,
.formatFromString = virStorageVolFormatFileSystemTypeFromString,
.formatToString = virStorageVolFormatFileSystemTypeToString,
},
......@@ -184,6 +188,7 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
.formatToString = virStoragePoolFormatDiskTypeToString,
},
.volOptions = {
.defaultFormat = VIR_STORAGE_VOL_DISK_NONE,
.formatFromString = virStorageVolFormatDiskTypeFromString,
.formatToString = virStorageVolFormatDiskTypeToString,
},
......@@ -961,7 +966,12 @@ virStorageVolDefParseDoc(virConnectPtr conn,
ret->target.path = virXPathString(conn, "string(/volume/target/path)", ctxt);
if (options->formatFromString) {
char *format = virXPathString(conn, "string(/volume/target/format/@type)", ctxt);
if ((ret->target.format = (options->formatFromString)(format)) < 0) {
if (format == NULL)
ret->target.format = options->defaultFormat;
else
ret->target.format = (options->formatFromString)(format);
if (ret->target.format < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
_("unknown volume format type %s"), format);
VIR_FREE(format);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册