mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Split out storage format 'compat' attribute sanity check
For future reuse in the snapshot XML.
This commit is contained in:
parent
b77ce18a28
commit
9b90899915
@ -1374,20 +1374,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret->target.compat = virXPathString("string(./target/compat)", ctxt);
|
ret->target.compat = virXPathString("string(./target/compat)", ctxt);
|
||||||
if (ret->target.compat) {
|
if (virStorageFileCheckCompat(ret->target.compat) < 0)
|
||||||
char **version = virStringSplit(ret->target.compat, ".", 2);
|
goto error;
|
||||||
unsigned int result;
|
|
||||||
|
|
||||||
if (!version || !version[1] ||
|
|
||||||
virStrToLong_ui(version[0], NULL, 10, &result) < 0 ||
|
|
||||||
virStrToLong_ui(version[1], NULL, 10, &result) < 0) {
|
|
||||||
virStringFreeList(version);
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
||||||
_("forbidden characters in 'compat' attribute"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
virStringFreeList(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virXPathNode("./target/nocow", ctxt))
|
if (virXPathNode("./target/nocow", ctxt))
|
||||||
ret->target.nocow = true;
|
ret->target.nocow = true;
|
||||||
|
@ -2873,3 +2873,32 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top,
|
|||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* virStorageFileCheckCompat
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virStorageFileCheckCompat(const char *compat)
|
||||||
|
{
|
||||||
|
char **version;
|
||||||
|
unsigned int result;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (!compat)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
version = virStringSplit(compat, ".", 2);
|
||||||
|
if (!version || !version[1] ||
|
||||||
|
virStrToLong_ui(version[0], NULL, 10, &result) < 0 ||
|
||||||
|
virStrToLong_ui(version[1], NULL, 10, &result) < 0) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("forbidden characters in 'compat' attribute"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virStringFreeList(version);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -384,4 +384,5 @@ int virStorageFileGetRelativeBackingPath(virStorageSourcePtr from,
|
|||||||
char **relpath)
|
char **relpath)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||||
|
|
||||||
|
int virStorageFileCheckCompat(const char *compat);
|
||||||
#endif /* __VIR_STORAGE_FILE_H__ */
|
#endif /* __VIR_STORAGE_FILE_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user