[PATCH 0/2] tests: Add support for the 'unstable' qemu QMP schema feature flag

See 2/2 Peter Krempa (2): testutilsqemuschema: Rename and document 'testQEMUSchemaValidateDeprecated' testutilsqemuschema: Support 'unstable' feature in QMP schema validator tests/testutilsqemuschema.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) -- 2.46.0

Upcoming patch will add more features we care to check. Rename the function to 'testQEMUSchemaValidateFeatures'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/testutilsqemuschema.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index f7b2e122bd..bb3d6b3141 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -29,8 +29,12 @@ struct testQEMUSchemaValidateCtxt { }; +/** + * Validate that the schema member doesn't have some significant features: + * - 'deprecated' - schema member is deprecated + */ static int -testQEMUSchemaValidateDeprecated(virJSONValue *root, +testQEMUSchemaValidateFeatures(virJSONValue *root, const char *name, struct testQEMUSchemaValidateCtxt *ctxt) { @@ -187,8 +191,8 @@ testQEMUSchemaValidateObjectMember(const char *key, return -1; } - /* validate that the member is not deprecated */ - if ((rc = testQEMUSchemaValidateDeprecated(keymember, key, data->ctxt)) < 0) + /* validate that the member doesn't have some of the significant features */ + if ((rc = testQEMUSchemaValidateFeatures(keymember, key, data->ctxt)) < 0) return rc; /* lookup schema entry for keytype */ @@ -387,8 +391,8 @@ testQEMUSchemaValidateEnum(virJSONValue *obj, if (STREQ_NULLABLE(objstr, virJSONValueObjectGetString(member, "name"))) { int rc; - /* the new 'members' array allows us to check deprecations */ - if ((rc = testQEMUSchemaValidateDeprecated(member, objstr, ctxt)) < 0) + /* the new 'members' array allows us to check features */ + if ((rc = testQEMUSchemaValidateFeatures(member, objstr, ctxt)) < 0) return rc; virBufferAsprintf(ctxt->debug, "'%s' OK", NULLSTR(objstr)); @@ -526,7 +530,7 @@ testQEMUSchemaValidateRecurse(virJSONValue *obj, const char *t = virJSONValueObjectGetString(root, "meta-type"); int rc; - if ((rc = testQEMUSchemaValidateDeprecated(root, n, ctxt)) < 0) + if ((rc = testQEMUSchemaValidateFeatures(root, n, ctxt)) < 0) return rc; if (STREQ_NULLABLE(t, "builtin")) { @@ -626,7 +630,7 @@ testQEMUSchemaValidateCommand(const char *command, return -1; } - if ((rc = testQEMUSchemaValidateDeprecated(schemarootcommand, command, &ctxt)) < 0) + if ((rc = testQEMUSchemaValidateFeatures(schemarootcommand, command, &ctxt)) < 0) return rc; if (!arguments) -- 2.46.0

The 'unstable' feature is present on any schema member which was not yet finalized in qemu. Use it to refuse such fields/commands in qemu as they are possibly subject to change. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/testutilsqemuschema.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index bb3d6b3141..6ee83c3ba7 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -32,6 +32,7 @@ struct testQEMUSchemaValidateCtxt { /** * Validate that the schema member doesn't have some significant features: * - 'deprecated' - schema member is deprecated + * - 'unstable' - schema member is considered unstable */ static int testQEMUSchemaValidateFeatures(virJSONValue *root, @@ -57,6 +58,11 @@ testQEMUSchemaValidateFeatures(virJSONValue *root, return -2; } + if (STREQ(curstr, "unstable")) { + virBufferAsprintf(ctxt->debug, "ERROR: '%s' is unstable", name); + return -1; + } + if (STREQ(curstr, "deprecated")) { if (ctxt->allowDeprecated) { virBufferAsprintf(ctxt->debug, "WARNING: '%s' is deprecated", name); -- 2.46.0

On Tue, Sep 24, 2024 at 03:41:12PM +0200, Peter Krempa wrote:
See 2/2
Peter Krempa (2): testutilsqemuschema: Rename and document 'testQEMUSchemaValidateDeprecated' testutilsqemuschema: Support 'unstable' feature in QMP schema validator
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
participants (2)
-
Pavel Hrdina
-
Peter Krempa