Statistics
| Branch: | Revision:

root / qapi @ e36c8766

# Date Author Comment
e36c8766 08/20/2012 05:05 pm Stefan Weil

qapi: Fix memory leak

valgrind report:

24534 232 bytes in 2 blocks are definitely lost in loss record 1,245 of 1,601
24534 at 0x4824F20: malloc (vg_replace_malloc.c:236)
24534 by 0x293C88: malloc_and_trace (vl.c:2281)
24534 by 0x489AD99: ??? (in /lib/libglib-2.0.so.0.2400.1)...
93b91c59 08/13/2012 08:17 pm Luiz Capitulino

qemu-ga: switch to the new error format on the wire

IMPORTANT: this BREAKS qemu-ga compatibility for the error response.

Instead of returning something like:

{ "error": { "class": "InvalidParameterValue",
"data": {"name": "mode", "expected": "halt|powerdown|reboot" } } }...

7795b166 08/13/2012 08:17 pm Luiz Capitulino

error: drop error_get_qobject()/error_set_qobject()

error_get_qobject() is unused since last commit, error_set_qobject()
has never been used. Also drops error_int.h.

Signed-off-by: Luiz Capitulino <>
Reviewed-by: Markus Armbruster <>

d195325b 07/23/2012 01:55 pm Paolo Bonzini

qapi: fix error propagation

Don't overwrite / leak previously set errors.
Make traversal cope with missing mandatory sub-structs.
Don't try to end a container that could not be started.

v1->v2:
- unchanged

v2->v3:
- instead of examining, assert that we never overwrite errors with...

092705d4 07/23/2012 01:55 pm Laszlo Ersek

qapi: introduce "size" type

v1->v2:
- fall back to uint64 rather than int

Signed-off-by: Laszlo Ersek <>
Signed-off-by: Stefan Hajnoczi <>

eb7ee2cb 07/23/2012 01:55 pm Laszlo Ersek

qapi: introduce OptsVisitor

This visitor supports parsing

-option [type=]discriminator[,optarg1=val1][,optarg2=val2][,...]

style QemuOpts objects into "native" C structures. After defining the type
tree in the qapi schema (see below), a root type traversal with this...

94c3db85 07/13/2012 07:46 pm Luiz Capitulino

qapi: input_type_enum(): fix error message

The enum string is pointed to by 'enum_str' not 'name'. This bug
causes the error message to be:

{ "error": { "class": "InvalidParameter",
"desc": "Invalid parameter 'null'",
"data": { "name": "null" } } }...

ad608da5 06/15/2012 04:41 pm Paolo Bonzini

qmp: do not include monitor.h from qapi-types-core.h

The comment is stale, monitor.h is not needed anymore (only qerror.h
is, because it contains the schema for errors).

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Luiz Capitulino <>

4e27e819 06/08/2012 05:11 pm Michael Roth

qapi: Add Visitor interfaces for uint*_t and int*_t

This adds visitor interfaces for fixed-width integers types.
Implementing these in visitors is optional, otherwise we fall back to
visit_type_int() (int64_t) with some additional bounds checking to avoid...

173bbb75 06/08/2012 05:11 pm Michael Roth

qapi: String visitor, use %f representation for floats

Currently string-output-visitor formats floats as %g, which is nice in
that trailing 0's are automatically truncated, but otherwise this causes
some issues:

- it uses 6 significant figures instead of 6 decimal places, which...
dd5614d6 06/07/2012 10:21 am Paolo Bonzini

build: move qapi/ objects to nested Makefile.objs

Signed-off-by: Paolo Bonzini <>

d34b867d 05/15/2012 05:15 pm Luiz Capitulino

qapi: add support for command options

Options allow for changes in commands behavior. This commit introduces
the QCO_NO_SUCCESS_RESP option, which causes a command to not emit a
success response.

This is needed by commands such as qemu-ga's guest-shutdown, which...

1ee51876 05/14/2012 04:08 pm Michael Roth

qapi: QMP input visitor, handle floats parsed as ints

JSON numbers can be interpreted as either integers or floating point
values depending on their representation. As a result, QMP input visitor
might visit a QInt when it was expecting a QFloat, so add handling to...

f22d85e9 04/30/2012 04:42 pm Michael Roth

qemu-ga: add a whitelist for fsfreeze-safe commands

Currently we rely on fsfreeze/thaw commands disabling/enabling logging
then having other commands check whether logging is disabled to avoid
executing if they aren't safe for running while a filesystem is frozen....

57a33d89 04/23/2012 07:03 pm NODA, Kai

qapi: g_hash_table_find() instead of GHashTableIter.

GHashTableIter was first introduced in glib 2.16.
This patch removes it in favor of older g_hash_table_find()
for better compatibility with RHEL5.

Signed-off-by: NODA, Kai <>
Signed-off-by: Luiz Capitulino <>

e38ac962 03/27/2012 03:15 pm Paolo Bonzini

qapi: add strict mode to input visitor

While QMP in general is designed so that it is possible to ignore
unknown arguments, in the case of the QMP server it is better to
reject them to detect bad clients. In fact, we're already doing
this at the top level in the argument checker. To extend this to...

4faaec6a 03/27/2012 03:15 pm Paolo Bonzini

qapi: place outermost object on qiv stack

This is a slight change in the implementation of QMPInputVisitor
that helps when adding strict mode.

Const QObjects cannot be inc/decref-ed, and that's why QMPInputVisitor
relies heavily on weak references to inner objects. I'm not removing...

3a86a0fa 03/27/2012 03:14 pm Paolo Bonzini

qapi: untangle next_list

Right now, the semantics of next_list are complicated. The caller must:

  • call start_list
  • call next_list for each element including the first
  • on the first call to next_list, the second argument should point to
    NULL and the result is the head of the list. On subsequent calls,...
8b714d37 03/27/2012 03:13 pm Paolo Bonzini

qapi: fix memory leak on error

QmpInputVisitor would leak the malloced struct if the stack was
overflowed. This can be easily fixed using error_propagate.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Anthony Liguori <>...

2c7ff933 03/27/2012 03:13 pm Paolo Bonzini

qapi: fail hard on stack imbalance

QmpOutputVisitor will segfault if an imbalanced end function is
called. So we can abort in QmpInputVisitor too.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Anthony Liguori <>
Signed-off-by: Luiz Capitulino <>

f24582d6 03/27/2012 03:11 pm Laszlo Ersek

qapi: fix double free in qmp_output_visitor_cleanup()

Stack entries in QmpOutputVisitor are navigation links (weak references),
except the bottom (ie. least recently added) entry, which owns the root
QObject [1]. Make qmp_output_visitor_cleanup() drop the stack entries,...

0f71a1e0 02/21/2012 11:21 am Paolo Bonzini

qapi: allow sharing enum implementation across visitors

Most visitors will use the same code for enum parsing. Move it to
the core.

Signed-off-by: Paolo Bonzini <>

9f9ab465 02/21/2012 11:21 am Paolo Bonzini

qapi: drop qmp_input_end_optional

This method is optional, do not implement it if it is empty.

Signed-off-by: Paolo Bonzini <>

a020f980 02/21/2012 11:21 am Paolo Bonzini

qapi: add string-based visitors

String based visitors provide a consistent interface for parsing
strings to C values, as well as consuming C values as strings.
They will be used to parse command-line options.

Signed-off-by: Paolo Bonzini <>

47c6d3ec 12/19/2011 06:27 pm Paolo Bonzini

qapi: protect against NULL QObject in qmp_input_get_object

A NULL qobj can occur when a parameter is fetched via qdict_get, but
the parameter is not in the command. By returning NULL, the caller can
choose whether to raise a missing parameter error, an invalid parameter...

abd6cf6d 12/13/2011 01:06 am Michael Roth

guest agent: add RPC blacklist command-line option

This adds a command-line option, -b/--blacklist, that accepts a
comma-seperated list of RPCs to disable, or prints a list of
available RPCs if passed "?".

In consequence this also adds general blacklisting and RPC listing...

bf95c0d5 12/13/2011 01:06 am Michael Roth

guest agent: add supported command list to guest-info RPC

Not that there is blacklisting functionality we can no longer infer
the agent's capabilities via version. This patch extends the current
guest-info RPC to also return a list of dictionaries containing the name...

54d50be6 11/17/2011 07:15 pm Luiz Capitulino

qapi: Check for negative enum values

We don't currently check for negative enum values in qmp_output_type_enum(),
this will very likely generate a segfault when triggered.

However, it seems that no code in tree can trigger this today.

Acked-by: Michael Roth <>...

776574d6 10/04/2011 05:00 pm Anthony Liguori

qapi: add code generation support for middle mode

To get the ball rolling merging QAPI, this patch introduces a "middle mode" to
the code generator. In middle mode, the code generator generates marshalling
functions that are compatible with the current QMP server. We absolutely need...

5666dd19 10/04/2011 05:00 pm Michael Roth

qapi: dealloc visitor, fix premature free and iteration logic

Currently we do 3 things wrong:

1) The list iterator, in practice, is used in a manner where the pointer
we pass in is the same as the pointer we assign the output to from
visit_next_list(). This causes an infinite loop where we keep freeing...

0b9d8542 10/04/2011 05:00 pm Michael Roth

qapi: dealloc visitor, support freeing of nested lists

Previously our logic for keeping track of when we're visiting the head
of a list was done via a global bool. This can be overwritten if dealing
with nested lists, so use stack entries to track this instead....

e1bc2f7b 10/04/2011 05:00 pm Michael Roth

qapi: modify visitor code generation for list iteration

Modify logic such that we never assign values to the list head argument
to progress through the list on subsequent iterations, instead rely only
on having our return value passed back in as an argument on the next...

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

43c20a43 07/21/2011 10:48 pm Michael Roth

qapi: add QMP command registration/lookup functions

Registration/lookup functions for that provide a lookup table for
dispatching QMP commands.

Signed-off-by: Michael Roth <>
Signed-off-by: Luiz Capitulino <>

ab02ab2a 07/21/2011 10:48 pm Michael Roth

qapi: add QMP dispatch functions

Given an object recieved via QMP, this code uses the dispatch table
provided by qmp_registry.c to call the corresponding marshalling/dispatch
function and format return values/errors for delivery to the QMP.
Currently only synchronous QMP functions are supported, but this will...

2345c77c 07/21/2011 10:48 pm Michael Roth

qapi: add QAPI visitor core

Base definitions/includes for Visiter interface used by generated
visiter/marshalling code.

Includes a GenericList type. Our lists require an embedded element.
Since these types are generated, if you want to use them in a different...

c40cc0a0 07/21/2011 10:48 pm Michael Roth

qapi: add QMP input visitor

A type of Visiter class that is used to walk a qobject's
structure and assign each entry to the corresponding native C type.
Command marshaling function will use this to pull out QMP command
parameters recieved over the wire and pass them as native arguments...

e4e6aa14 07/21/2011 10:48 pm Michael Roth

qapi: add QMP output visitor

Type of Visiter class that serves as the inverse of the input visitor:
it takes a series of native C types and uses their values to construct a
corresponding QObject. The command marshaling/dispatcher functions will
use this to convert the output of QMP functions into a QObject that can...

d5f3c29c 07/21/2011 10:48 pm Michael Roth

qapi: add QAPI dealloc visitor

Type of Visitor class that can be passed into a qapi-generated C
type's visitor function to free() any heap-allocated data types.

Signed-off-by: Michael Roth <>
Signed-off-by: Luiz Capitulino <>