Use the new parser instead of virDomainDiskSourceParse.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/snapshot_conf.c | 38 +++++++++++---------------------------
1 file changed, 11 insertions(+), 27 deletions(-)
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index bc4b9c8f11..5dad2c3c51 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -108,16 +108,10 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
{
int ret = -1;
char *snapshot = NULL;
- char *type = NULL;
- char *driver = NULL;
- xmlNodePtr cur;
xmlNodePtr saved = ctxt->node;
ctxt->node = node;
- if (!(def->src = virStorageSourceNew()))
- goto cleanup;
-
def->name = virXMLPropString(node, "name");
if (!def->name) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -136,27 +130,19 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
}
}
- if ((type = virXMLPropString(node, "type"))) {
- if ((def->src->type = virStorageTypeFromString(type)) <= 0 ||
- def->src->type == VIR_STORAGE_TYPE_VOLUME ||
- def->src->type == VIR_STORAGE_TYPE_DIR) {
- virReportError(VIR_ERR_XML_ERROR,
- _("unknown disk snapshot type '%s'"),
type);
- goto cleanup;
- }
- } else {
- def->src->type = VIR_STORAGE_TYPE_FILE;
- }
-
- if ((cur = virXPathNode("./source", ctxt)) &&
- virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
+ if (!(def->src = virDomainStorageSourceParseFull("string(@type)",
+ "string(./driver/@type)",
+ "./source",
+ NULL, true,
+ ctxt, flags, xmlopt)))
goto cleanup;
- if ((driver = virXPathString("string(./driver/@type)", ctxt)) &&
- (def->src->format = virStorageFileFormatTypeFromString(driver)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown disk snapshot driver '%s'"),
driver);
- goto cleanup;
+ if (def->src->type == VIR_STORAGE_TYPE_VOLUME ||
+ def->src->type == VIR_STORAGE_TYPE_DIR) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unsupported disk snapshot type '%s'"),
+ virStorageTypeToString(def->src->type));
+ goto cleanup;
}
/* validate that the passed path is absolute */
@@ -174,9 +160,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
cleanup:
ctxt->node = saved;
- VIR_FREE(driver);
VIR_FREE(snapshot);
- VIR_FREE(type);
if (ret < 0)
virDomainSnapshotDiskDefClear(def);
return ret;
--
2.20.1