mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Parse backingStore before capacity in volume XML
So we can allow omitting the capacity element if backing store is present.
This commit is contained in:
parent
cbd788eba6
commit
21f58a5854
@ -1289,6 +1289,37 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((backingStore = virXPathString("string(./backingStore/path)", ctxt))) {
|
||||||
|
if (VIR_ALLOC(ret->target.backingStore) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
ret->target.backingStore->path = backingStore;
|
||||||
|
backingStore = NULL;
|
||||||
|
|
||||||
|
if (options->formatFromString) {
|
||||||
|
char *format = virXPathString("string(./backingStore/format/@type)", ctxt);
|
||||||
|
if (format == NULL)
|
||||||
|
ret->target.backingStore->format = options->defaultFormat;
|
||||||
|
else
|
||||||
|
ret->target.backingStore->format = (options->formatFromString)(format);
|
||||||
|
|
||||||
|
if (ret->target.backingStore->format < 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("unknown volume format type %s"), format);
|
||||||
|
VIR_FREE(format);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
VIR_FREE(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VIR_ALLOC(ret->target.backingStore->perms) < 0)
|
||||||
|
goto error;
|
||||||
|
if (virStorageDefParsePerms(ctxt, ret->target.backingStore->perms,
|
||||||
|
"./backingStore/permissions",
|
||||||
|
DEFAULT_VOL_PERM_MODE) < 0)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
capacity = virXPathString("string(./capacity)", ctxt);
|
capacity = virXPathString("string(./capacity)", ctxt);
|
||||||
unit = virXPathString("string(./capacity/@unit)", ctxt);
|
unit = virXPathString("string(./capacity/@unit)", ctxt);
|
||||||
if (capacity == NULL) {
|
if (capacity == NULL) {
|
||||||
@ -1341,37 +1372,6 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((backingStore = virXPathString("string(./backingStore/path)", ctxt))) {
|
|
||||||
if (VIR_ALLOC(ret->target.backingStore) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
ret->target.backingStore->path = backingStore;
|
|
||||||
backingStore = NULL;
|
|
||||||
|
|
||||||
if (options->formatFromString) {
|
|
||||||
char *format = virXPathString("string(./backingStore/format/@type)", ctxt);
|
|
||||||
if (format == NULL)
|
|
||||||
ret->target.backingStore->format = options->defaultFormat;
|
|
||||||
else
|
|
||||||
ret->target.backingStore->format = (options->formatFromString)(format);
|
|
||||||
|
|
||||||
if (ret->target.backingStore->format < 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("unknown volume format type %s"), format);
|
|
||||||
VIR_FREE(format);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
VIR_FREE(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_ALLOC(ret->target.backingStore->perms) < 0)
|
|
||||||
goto error;
|
|
||||||
if (virStorageDefParsePerms(ctxt, ret->target.backingStore->perms,
|
|
||||||
"./backingStore/permissions",
|
|
||||||
DEFAULT_VOL_PERM_MODE) < 0)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->target.compat = virXPathString("string(./target/compat)", ctxt);
|
ret->target.compat = virXPathString("string(./target/compat)", ctxt);
|
||||||
if (ret->target.compat) {
|
if (ret->target.compat) {
|
||||||
char **version = virStringSplit(ret->target.compat, ".", 2);
|
char **version = virStringSplit(ret->target.compat, ".", 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user