提交 88ae8b8b 编写于 作者: E Eric Blake

snapshot: Add internal option to validate XML against schema

Similar to VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; the next patch will
put it to use with a counterpart public API flag.

No need to change qemudomainsnapshotxml2xmltest to use the flag, since
the testsuite already has a separate virschematest that does the same.
Signed-off-by: NEric Blake <eblake@redhat.com>
Acked-by: NPeter Krempa <pkrempa@redhat.com>
上级 4cc5679e
......@@ -25,6 +25,7 @@
#include <sys/stat.h>
#include <unistd.h>
#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();
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册