Commit Graph

11 Commits

Author SHA1 Message Date
Peter Maydell cbf2115190 qapi: Clean up includes
Clean up includes so that osdep.h is included first and headers
which it implies are not included manually.

This commit was created with scripts/clean-includes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1454089805-5470-8-git-send-email-peter.maydell@linaro.org
2016-02-04 17:41:30 +00:00
Markus Armbruster cc7a8ea740 Include qapi/qmp/qerror.h exactly where needed
In particular, don't include it into headers.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22 18:20:41 +02:00
Hu Tao 684531ad1f qapi/string-output-visitor: fix human output
"0x1-0x10" looks better than "0x1-10"

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2014-06-23 17:38:00 +03:00
Michael S. Tsirkin 56fdfb6106 qapi/string-output-visitor: fix bugs
in human mode, we are creating the string:

16-31 (16-31)

instead of

16-17 (10-1f)

because we forgot to pass 'true' as the human parameter on one of the
two calls to format_string.
Also, this is a worsening of quality; previously we would produce

16 (0x10)

to make it obvious which number was hex.
Fix these issues.

Reported-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2014-06-19 18:44:22 +03:00
Michael S. Tsirkin 0d156683f6 qapi: fix build on glib < 2.28
The following commits:
    qapi: make string output visitor parse int list
    qapi: make string input visitor parse int list
break with glib < 2.28 since they use the
new g_list_free_full function.

Open-code that to fix build on old systems.

Cc: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-06-19 18:44:21 +03:00
Hu Tao 69e255635d qapi: make string output visitor parse int list
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

MST: split up patch
2014-06-19 18:44:21 +03:00
Paolo Bonzini e41b509d68 qapi: Refine human printing of sizes
This fixes several bugs or shortcomings of the previous pretty-printer.
In particular:

* use PRIu64 instead of casting to long long

* the exact value is included too

* the correct unit of measure (MiB, GiB, etc.) is used.  PiB and EiB
are added too.

* due to an off-by-one error, 512*2^30 was printed as 0.500MiB rather than
512MiB.  floor(log2(val)) is equal to 63 - clz(val), while the code used 64.

* The desired specification is %g rather than %f, which always uses three
decimals in the current code.  However %g would switch to scientific
notation when the integer part is >= 1000 (e.g. 1000*2^30).  To keep the
code simple, switch to the higher power when the integer part is >= 1000;
overflow is avoided by using frexp instead of clz.

Suggested-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-02-14 21:12:05 +01:00
Paolo Bonzini 0b7593e085 qapi: Add human mode to StringOutputVisitor
This will be used by "info qtree".  For numbers it prints both the
decimal and hex values.  For sizes it rounds to the nearest power
of 2^10.  For strings, it puts quotes around the string and separates
NULL and empty string.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-02-14 21:12:03 +01:00
Paolo Bonzini 7b1b5d1913 qapi: move include files to include/qobject/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:31:31 +01:00
Michael Roth 173bbb754f 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
   means something like 155777.5 (which even has an exact floating point
   representation) will be rounded to 155778 when converted to a string.

 - output will be presented in scientific notation when the normalized
   form requires a 10^x multiplier. Not a huge deal, but arguably less
   readable for command-line arguments.

 - due to using scientific notation for numbers requiring more than 6
   significant figures, instead of hard-defined decimal places, it
   fails a lot of the test-visitor-serialization unit tests for floats.

Instead, let's just use %f, which is what the QJSON and the QMP visitors
use.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-08 16:11:14 +02:00
Paolo Bonzini a020f9809c 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 <pbonzini@redhat.com>
2012-02-21 10:21:05 +01:00