storage: virStorageVolDefParse and storageVolCreateXML flags fix

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>
This commit is contained in:
Kirill Shchetiniuk via Devel authored and Michal Privoznik committed 2025-04-09 14:27:15 +02:00
1 parent 7f07cf5a72
commit b8c3d847a9
2 files changed
+5 -1

No files matched your search

+2
View 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);
}
+3 -1
View 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);