mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Allow parsing volumes without specifying the capacity
Add VIR_VOL_XML_PARSE_NO_CAPACITY flag to the volume XML parser. When set, it allows the capacity element to be omitted.
This commit is contained in:
parent
21f58a5854
commit
2bd47d9c64
@ -1260,7 +1260,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY, NULL);
|
||||||
|
|
||||||
options = virStorageVolOptionsForPoolType(pool->type);
|
options = virStorageVolOptionsForPoolType(pool->type);
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
@ -1322,13 +1322,13 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
|
|
||||||
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) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
if (virStorageSize(unit, capacity, &ret->target.capacity) < 0)
|
||||||
_("missing capacity element"));
|
goto error;
|
||||||
|
} else if (!(flags & VIR_VOL_XML_PARSE_NO_CAPACITY)) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s", _("missing capacity element"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStorageSize(unit, capacity, &ret->target.capacity) < 0)
|
|
||||||
goto error;
|
|
||||||
VIR_FREE(unit);
|
VIR_FREE(unit);
|
||||||
|
|
||||||
allocation = virXPathString("string(./allocation)", ctxt);
|
allocation = virXPathString("string(./allocation)", ctxt);
|
||||||
|
@ -345,6 +345,10 @@ virStoragePoolDefPtr virStoragePoolDefParseNode(xmlDocPtr xml,
|
|||||||
xmlNodePtr root);
|
xmlNodePtr root);
|
||||||
char *virStoragePoolDefFormat(virStoragePoolDefPtr def);
|
char *virStoragePoolDefFormat(virStoragePoolDefPtr def);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
/* do not require volume capacity at all */
|
||||||
|
VIR_VOL_XML_PARSE_NO_CAPACITY = 1 << 0,
|
||||||
|
} virStorageVolDefParseFlags;
|
||||||
virStorageVolDefPtr
|
virStorageVolDefPtr
|
||||||
virStorageVolDefParseString(virStoragePoolDefPtr pool,
|
virStorageVolDefParseString(virStoragePoolDefPtr pool,
|
||||||
const char *xml,
|
const char *xml,
|
||||||
|
Loading…
Reference in New Issue
Block a user