mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
domain_conf: extract disk driver source bits to its own function
Attribute `type` and sub-element `metadata_cache` are internally stored in the `virStorageSource` structure. Sometimes we only care about the disk source bits so we need a dedicated helper for that. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
b1774e4e0f
commit
fe6ed00ef7
@ -8849,7 +8849,6 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def,
|
||||
xmlNodePtr cur,
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
g_autofree char *tmp = NULL;
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
|
||||
ctxt->node = cur;
|
||||
@ -8900,19 +8899,6 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def,
|
||||
if (virXMLPropUInt(cur, "iothread", 10, VIR_XML_PROP_NONZERO, &def->iothread) < 0)
|
||||
return -1;
|
||||
|
||||
if ((tmp = virXMLPropString(cur, "type"))) {
|
||||
if (STREQ(tmp, "aio")) {
|
||||
/* Xen back-compat */
|
||||
def->src->format = VIR_STORAGE_FILE_RAW;
|
||||
} else {
|
||||
if ((def->src->format = virStorageFileFormatTypeFromString(tmp)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown driver format value '%s'"), tmp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (virXMLPropEnum(cur, "detect_zeroes",
|
||||
virDomainDiskDetectZeroesTypeFromString,
|
||||
VIR_XML_PROP_NONZERO, &def->detect_zeroes) < 0)
|
||||
@ -8921,9 +8907,36 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def,
|
||||
if (virXMLPropUInt(cur, "queues", 10, VIR_XML_PROP_NONE, &def->queues) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainDiskDefDriverSourceParseXML(virStorageSource *src,
|
||||
xmlNodePtr cur,
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
g_autofree char *tmp = NULL;
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
|
||||
ctxt->node = cur;
|
||||
|
||||
if ((tmp = virXMLPropString(cur, "type"))) {
|
||||
if (STREQ(tmp, "aio")) {
|
||||
/* Xen back-compat */
|
||||
src->format = VIR_STORAGE_FILE_RAW;
|
||||
} else {
|
||||
if ((src->format = virStorageFileFormatTypeFromString(tmp)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown driver format value '%s'"), tmp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (virParseScaledValue("./metadata_cache/max_size", NULL,
|
||||
ctxt,
|
||||
&def->src->metadataCacheMaxSize,
|
||||
&src->metadataCacheMaxSize,
|
||||
1, ULLONG_MAX, false) < 0)
|
||||
return -1;
|
||||
|
||||
@ -9129,6 +9142,9 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
|
||||
|
||||
if (virDomainDiskDefDriverParseXML(def, driverNode, ctxt) < 0)
|
||||
return NULL;
|
||||
|
||||
if (virDomainDiskDefDriverSourceParseXML(def->src, driverNode, ctxt) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((mirrorNode = virXPathNode("./mirror", ctxt))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user