提交 2bd47d9c 编写于 作者: J Ján Tomko

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.
上级 21f58a58
......@@ -1260,7 +1260,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
size_t i;
int n;
virCheckFlags(0, NULL);
virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY, NULL);
options = virStorageVolOptionsForPoolType(pool->type);
if (options == NULL)
......@@ -1322,13 +1322,13 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
capacity = virXPathString("string(./capacity)", ctxt);
unit = virXPathString("string(./capacity/@unit)", ctxt);
if (capacity == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing capacity element"));
goto error;
}
if (capacity) {
if (virStorageSize(unit, capacity, &ret->target.capacity) < 0)
goto error;
} else if (!(flags & VIR_VOL_XML_PARSE_NO_CAPACITY)) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("missing capacity element"));
goto error;
}
VIR_FREE(unit);
allocation = virXPathString("string(./allocation)", ctxt);
......
......@@ -345,6 +345,10 @@ virStoragePoolDefPtr virStoragePoolDefParseNode(xmlDocPtr xml,
xmlNodePtr root);
char *virStoragePoolDefFormat(virStoragePoolDefPtr def);
typedef enum {
/* do not require volume capacity at all */
VIR_VOL_XML_PARSE_NO_CAPACITY = 1 << 0,
} virStorageVolDefParseFlags;
virStorageVolDefPtr
virStorageVolDefParseString(virStoragePoolDefPtr pool,
const char *xml,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册