mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
virDomainBackupDiskDefParseXML: Use virDomainStorageSourceParseBase
Don't duplicate code to parse the virStorageSource basics. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d46512fc95
commit
047b45f359
@ -104,7 +104,7 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
|
|||||||
{
|
{
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
g_autofree char *type = NULL;
|
g_autofree char *type = NULL;
|
||||||
g_autofree char *driver = NULL;
|
g_autofree char *format = NULL;
|
||||||
g_autofree char *backup = NULL;
|
g_autofree char *backup = NULL;
|
||||||
g_autofree char *state = NULL;
|
g_autofree char *state = NULL;
|
||||||
g_autofree char *backupmode = NULL;
|
g_autofree char *backupmode = NULL;
|
||||||
@ -169,23 +169,17 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
|
|||||||
def->state = tmp;
|
def->state = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->store = virStorageSourceNew();
|
type = virXMLPropString(node, "type");
|
||||||
|
format = virXPathString("string(./driver/@type)", ctxt);
|
||||||
|
|
||||||
if ((type = virXMLPropString(node, "type"))) {
|
if (!(def->store = virDomainStorageSourceParseBase(type, format, NULL)))
|
||||||
if ((def->store->type = virStorageTypeFromString(type)) <= 0) {
|
return -1;
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("unknown disk backup type '%s'"), type);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (def->store->type != VIR_STORAGE_TYPE_FILE &&
|
if (def->store->type != VIR_STORAGE_TYPE_FILE &&
|
||||||
def->store->type != VIR_STORAGE_TYPE_BLOCK) {
|
def->store->type != VIR_STORAGE_TYPE_BLOCK) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unsupported disk backup type '%s'"), type);
|
_("unsupported disk backup type '%s'"), type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
def->store->type = VIR_STORAGE_TYPE_FILE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (push)
|
if (push)
|
||||||
@ -198,15 +192,6 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node,
|
|||||||
storageSourceParseFlags, xmlopt) < 0)
|
storageSourceParseFlags, xmlopt) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((driver = virXPathString("string(./driver/@type)", ctxt))) {
|
|
||||||
def->store->format = virStorageFileFormatTypeFromString(driver);
|
|
||||||
if (def->store->format <= 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("unknown disk backup driver '%s'"), driver);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user