diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index c7f29360e748d889f1ccf09c04a04185bd73b702..ea04413aec1befe1924674dba7c5bbca30aa7cdb 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -25,6 +25,7 @@ #include #include +#include "configmake.h" #include "internal.h" #include "virbitmap.h" #include "virbuffer.h" @@ -409,6 +410,18 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml, goto cleanup; } + if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE) { + VIR_AUTOFREE(char *) schema = NULL; + + schema = virFileFindResource("domainsnapshot.rng", + abs_top_srcdir "/docs/schemas", + PKGDATADIR "/schemas"); + if (!schema) + goto cleanup; + if (virXMLValidateAgainstSchema(schema, xml) < 0) + goto cleanup; + } + ctxt = xmlXPathNewContext(xml); if (ctxt == NULL) { virReportOOMError(); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 08b2a3b955799523965b7075e2f6f164e8123d23..a0c87e7ade2ea875cefa252da54a5c28b85c0c76 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -92,6 +92,7 @@ typedef enum { VIR_DOMAIN_SNAPSHOT_PARSE_DISKS = 1 << 1, VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL = 1 << 2, VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE = 1 << 3, + VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE = 1 << 4, } virDomainSnapshotParseFlags; typedef enum {