mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virQEMUQAPISchemaTraverseEnum: Allow query of enume type features
QEMU-6.2 added feature flags for enum types. Add support for querying them into our QMP schema query language. 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
2827c411c2
commit
626b53ba9b
@ -242,6 +242,7 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur,
|
|||||||
struct virQEMUQAPISchemaTraverseContext *ctxt)
|
struct virQEMUQAPISchemaTraverseContext *ctxt)
|
||||||
{
|
{
|
||||||
const char *query = virQEMUQAPISchemaTraverseContextNextQuery(ctxt);
|
const char *query = virQEMUQAPISchemaTraverseContextNextQuery(ctxt);
|
||||||
|
const char *featurequery = NULL;
|
||||||
virJSONValue *values;
|
virJSONValue *values;
|
||||||
virJSONValue *members;
|
virJSONValue *members;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -249,8 +250,16 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur,
|
|||||||
if (query[0] != '^')
|
if (query[0] != '^')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (virQEMUQAPISchemaTraverseContextHasNextQuery(ctxt))
|
if (virQEMUQAPISchemaTraverseContextHasNextQuery(ctxt)) {
|
||||||
return -3;
|
/* we might have a query for a feature flag of an enum value */
|
||||||
|
featurequery = virQEMUQAPISchemaTraverseContextNextQuery(ctxt);
|
||||||
|
|
||||||
|
if (*featurequery != '$' ||
|
||||||
|
virQEMUQAPISchemaTraverseContextHasNextQuery(ctxt))
|
||||||
|
return -3;
|
||||||
|
|
||||||
|
featurequery++;
|
||||||
|
}
|
||||||
|
|
||||||
query++;
|
query++;
|
||||||
|
|
||||||
@ -263,13 +272,21 @@ virQEMUQAPISchemaTraverseEnum(virJSONValue *cur,
|
|||||||
if (!member || !(name = virJSONValueObjectGetString(member, "name")))
|
if (!member || !(name = virJSONValueObjectGetString(member, "name")))
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (STREQ(name, query))
|
if (STREQ(name, query)) {
|
||||||
|
if (featurequery)
|
||||||
|
return virQEMUQAPISchemaTraverseHasObjectFeature(featurequery, member);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* old-style "values" array doesn't have feature flags so any query is necessarily false */
|
||||||
|
if (featurequery)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!(values = virJSONValueObjectGetArray(cur, "values")))
|
if (!(values = virJSONValueObjectGetArray(cur, "values")))
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
@ -439,7 +456,8 @@ virQEMUQAPISchemaTraverse(const char *baseName,
|
|||||||
*
|
*
|
||||||
* The above types can be chained arbitrarily using slashes to construct any
|
* The above types can be chained arbitrarily using slashes to construct any
|
||||||
* path into the schema tree, booleans must be always the last component as they
|
* path into the schema tree, booleans must be always the last component as they
|
||||||
* don't refer to a type.
|
* don't refer to a type. An exception is querying feature of an enum value
|
||||||
|
* (.../^enumval/$featurename) which is allowed.
|
||||||
*
|
*
|
||||||
* Returns 1 if @query was found in @schema filling @entry if non-NULL, 0 if
|
* Returns 1 if @query was found in @schema filling @entry if non-NULL, 0 if
|
||||||
* @query was not found in @schema and -1 on other errors along with an appropriate
|
* @query was not found in @schema and -1 on other errors along with an appropriate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user