mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
testQEMUSchemaValidateEnum: Use new 'members' for 'enum' meta type
Switch to the new more featured way to report enum members which will also allow us to detect use of deprecated members. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
91453650f3
commit
cf68184e74
@ -324,6 +324,7 @@ testQEMUSchemaValidateEnum(virJSONValue *obj,
|
|||||||
{
|
{
|
||||||
const char *objstr;
|
const char *objstr;
|
||||||
virJSONValue *values = NULL;
|
virJSONValue *values = NULL;
|
||||||
|
virJSONValue *members = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
|
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
|
||||||
@ -333,6 +334,22 @@ testQEMUSchemaValidateEnum(virJSONValue *obj,
|
|||||||
|
|
||||||
objstr = virJSONValueGetString(obj);
|
objstr = virJSONValueGetString(obj);
|
||||||
|
|
||||||
|
/* qemu-6.2 added a "members" array superseding "values" */
|
||||||
|
if ((members = virJSONValueObjectGetArray(root, "members"))) {
|
||||||
|
for (i = 0; i < virJSONValueArraySize(members); i++) {
|
||||||
|
virJSONValue *member = virJSONValueArrayGet(members, i);
|
||||||
|
|
||||||
|
if (STREQ_NULLABLE(objstr, virJSONValueObjectGetString(member, "name"))) {
|
||||||
|
virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(ctxt->debug, "ERROR: enum value '%s' is not in schema",
|
||||||
|
NULLSTR(objstr));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((values = virJSONValueObjectGetArray(root, "values"))) {
|
if ((values = virJSONValueObjectGetArray(root, "values"))) {
|
||||||
for (i = 0; i < virJSONValueArraySize(values); i++) {
|
for (i = 0; i < virJSONValueArraySize(values); i++) {
|
||||||
virJSONValue *value = virJSONValueArrayGet(values, i);
|
virJSONValue *value = virJSONValueArrayGet(values, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user