qemu: qapi: Allow selecting specifically optional schema entries in virQEMUQAPISchemaTraverse
Add a new modifier character '*' which will select given schema entry only when it is optional (denoted by the presence of the 'default' key). Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
c59734e3f6
commit
139ee1f192
@ -107,6 +107,7 @@ virQEMUQAPISchemaTraverse(const char *baseName,
|
|||||||
virHashTablePtr schema)
|
virHashTablePtr schema)
|
||||||
{
|
{
|
||||||
virJSONValuePtr base;
|
virJSONValuePtr base;
|
||||||
|
virJSONValuePtr obj;
|
||||||
const char *metatype;
|
const char *metatype;
|
||||||
const char *querystr;
|
const char *querystr;
|
||||||
char modifier;
|
char modifier;
|
||||||
@ -134,14 +135,20 @@ virQEMUQAPISchemaTraverse(const char *baseName,
|
|||||||
if (!c_isalpha(modifier))
|
if (!c_isalpha(modifier))
|
||||||
querystr++;
|
querystr++;
|
||||||
|
|
||||||
if (modifier == '+')
|
if (modifier == '+') {
|
||||||
baseName = virQEMUQAPISchemaObjectGetType("variants",
|
baseName = virQEMUQAPISchemaObjectGetType("variants",
|
||||||
querystr,
|
querystr,
|
||||||
"case", base);
|
"case", base);
|
||||||
else
|
} else {
|
||||||
baseName = virQEMUQAPISchemaObjectGetType("members",
|
obj = virQEMUQAPISchemaObjectGet("members", querystr,
|
||||||
querystr,
|
"name", base);
|
||||||
"name", base);
|
|
||||||
|
if (modifier == '*' &&
|
||||||
|
!virJSONValueObjectHasKey(obj, "default"))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
baseName = virQEMUQAPISchemaTypeFromObject(obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (!baseName)
|
if (!baseName)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -177,6 +184,8 @@ virQEMUQAPISchemaTraverse(const char *baseName,
|
|||||||
* attribute: selects whether arguments or return type should be introspected
|
* attribute: selects whether arguments or return type should be introspected
|
||||||
* ("arg-type" or "ret-type" for commands, "arg-type" for events)
|
* ("arg-type" or "ret-type" for commands, "arg-type" for events)
|
||||||
* subattribute: specifies member name of object types
|
* subattribute: specifies member name of object types
|
||||||
|
* *subattribute: same as above but must be optional (has a property named
|
||||||
|
* 'default' field in the schema)
|
||||||
* +variant_discriminator: In the case of unionized objects, select a
|
* +variant_discriminator: In the case of unionized objects, select a
|
||||||
* specific case to introspect.
|
* specific case to introspect.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user