]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: storage: Add support for validating storage vol XML to virStorageVolDefParse
authorPeter Krempa <pkrempa@redhat.com>
Tue, 18 Oct 2022 11:47:31 +0000 (13:47 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 1 Nov 2022 12:07:20 +0000 (13:07 +0100)
Introduce the VIR_VOL_XML_PARSE_VALIDATE parser flag and wire it up into
the validator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
src/conf/storage_conf.c
src/conf/storage_conf.h

index 0f4fe1451ea4d557cc0768319a78e3ac9a80c4a7..72c53872cb268d6e8c7fd802dd87f1848b5a0c8c 100644 (file)
@@ -1407,9 +1407,10 @@ virStorageVolDefParse(virStoragePoolDef *pool,
 {
     g_autoptr(xmlDoc) xml = NULL;
     g_autoptr(xmlXPathContext) ctxt = NULL;
+    bool validate = flags & VIR_VOL_XML_PARSE_VALIDATE;
 
     if (!(xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)"),
-                            "volume", &ctxt, NULL, false)))
+                            "volume", &ctxt, "storagevol.rng", validate)))
         return NULL;
 
     return virStorageVolDefParseXML(pool, ctxt, flags);
index bbfdbc2f2f0fd2de8b40ef7d225e66082f75a30c..fc67957cfe9744dd50e443b2f88a737b7e1a2d2a 100644 (file)
@@ -284,6 +284,8 @@ typedef enum {
     VIR_VOL_XML_PARSE_NO_CAPACITY  = 1 << 0,
     /* do not require volume capacity if the volume has a backing store */
     VIR_VOL_XML_PARSE_OPT_CAPACITY = 1 << 1,
+    /* validate the XML against the RNG schema */
+    VIR_VOL_XML_PARSE_VALIDATE = 1 << 2,
 } virStorageVolDefParseFlags;
 
 virStorageVolDef *