]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: virStorageVolDefParse and storageVolCreateXML flags fix
authorKirill Shchetiniuk via Devel <devel@lists.libvirt.org>
Wed, 9 Apr 2025 08:43:15 +0000 (10:43 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 9 Apr 2025 12:27:15 +0000 (14:27 +0200)
When the new storage was created using virsh with --validate option
following errors occurred:

 # virsh vol-create default --file vol-def.xml --validate
error: Failed to create vol from vol-def.xml
error: unsupported flags (0x4) in function virStorageVolDefParseXML

and after virStorageVolDefParse fix:

 # virsh vol-create default --file vol-def.xml --validate
error: Failed to create vol from vol-def.xml
error: unsupported flags (0x4) in function storageBackendCreateQemuImg

Clear the VIR_VOL_XML_PARSE_VALIDATE flag before
virStorageVolDefParseXML() and the VIR_STORAGE_VOL_CREATE_VALIDATE before
backend->buildVol() (traces down to storageBackendCreateQemuImg) calls,
as the XML schema validation is already complete within previous steps
and there is no validation later.

Signed-off-by: Kirill Shchetiniuk <kshcheti@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/storage_conf.c
src/storage/storage_driver.c

index 68842004b71d0762be241abeb4d9fc8a450bd60c..1dc9365bf288037a995ed1fad7df193ac4c37c7f 100644 (file)
@@ -1409,6 +1409,8 @@ virStorageVolDefParse(virStoragePoolDef *pool,
                             "volume", &ctxt, "storagevol.rng", validate)))
         return NULL;
 
+    flags &= ~VIR_VOL_XML_PARSE_VALIDATE;
+
     return virStorageVolDefParseXML(pool, ctxt, flags);
 }
 
index 86c03762d2717216eac29e7458e14fe23e3f590b..e19e0324277f891617db097b69d03454319e793b 100644 (file)
@@ -1939,6 +1939,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
     if (backend->buildVol) {
         int buildret;
         virStorageVolDef *buildvoldef = NULL;
+        unsigned int buildFlags = flags;
 
         buildvoldef = g_new0(virStorageVolDef, 1);
 
@@ -1953,7 +1954,8 @@ storageVolCreateXML(virStoragePoolPtr pool,
         voldef->building = true;
         virObjectUnlock(obj);
 
-        buildret = backend->buildVol(obj, buildvoldef, flags);
+        buildFlags &= ~VIR_STORAGE_VOL_CREATE_VALIDATE;
+        buildret = backend->buildVol(obj, buildvoldef, buildFlags);
 
         VIR_FREE(buildvoldef);