Commit Graph

13 Commits

Author SHA1 Message Date
Peter Krempa
8af5d6bd7c qemu: qapi: Separate virQEMUQAPISchemaTraverse into functions by object type
Simplify virQEMUQAPISchemaTraverse by separating out the necessary
operations for given 'meta-type' into separate functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-06 09:46:06 +02:00
Peter Krempa
5ded7590d1 qemu: qapi: Convert virQEMUQAPISchemaTraverse to recursive lookup
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-06 09:46:06 +02:00
Peter Krempa
641c60a17d qemu: qapi: Modify values returned by virQEMUQAPISchemaPathGet
Return 1 if the schema entry was found optionally returning it rather
than depending on the returned object.

Some callers don't care which schema object belongs to the query, but
rather only want to know whether it exists. Additionally this will allow
introducing boolean queries for checking if enum values exist.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-06 09:46:06 +02:00
Peter Krempa
9da894dea7 qemu: qapi: Return schema entry via argument in virQEMUQAPISchemaTraverse
To allow for boolean query string, let's return the queried schema entry
via argument rather than a return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-06 09:46:06 +02:00
Peter Krempa
eed544e131 qemu: qapi: Fix return value of impossible case in virQEMUQAPISchemaTraverse
The return statement after the infinite loop without a break is there to
appease the compiler. Make it return NULL as it would be a failure if
control flow reaches that point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-06 09:46:06 +02:00
Peter Krempa
432452eb0d qemu: qapi: Use automatic memory cleanup
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-05-06 09:46:06 +02:00
Peter Krempa
139ee1f192 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>
2018-08-24 15:58:33 +02:00
Peter Krempa
c59734e3f6 qemu: qapi: Split up virQEMUQAPISchemaObjectGetType
Split it into a function that returns the whole schema entry so that we
can do additional checks and a helper getting the type string from the
schema entry.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-08-24 15:58:33 +02:00
Peter Krempa
cbcee32350 qemu: qapi: Simplify value handling in virQEMUQAPISchemaTraverse
Introduce a few variables so that we can easily access the modifier
character and also don't have to do pointer arithmetic when selecting
the schema entries. This will simplify adding of new modifier
characters.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-08-24 15:58:33 +02:00
Peter Krempa
3283950057 qemu: qapi: Return correct entry in virQEMUQAPISchemaTraverse
virQEMUQAPISchemaTraverse would return previous-to-last queried item on
a query. It would not be a problem if checking if the given path exists
since error reporting works properly but if the caller is interested in
the result, it would be wrong.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
38b3b20c66 qemu: monitor: Move processing of QMP schema to the new file
The JSON array was processed to the hash table used by the query apis in
the monitor code. Move it to a new helper in qemu_qapi.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
ab8c5fe63f qemu: qapi: Fix naming of moved functions
Change the prefix of the functions to 'virQEMUQapi' and rename the two
public APIs so that the verb is put last.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
367697c54c qemu: caps: Move QAPI schema related code into separate file
Extract the code into qemu_qapi.c/h so that we separate it from various
parts of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00