summaryrefslogtreecommitdiffstats
path: root/qapi
Commit message (Collapse)AuthorAgeFilesLines
* qapi: Add missing null check to opts_start_struct()Markus Armbruster2014-03-031-1/+3
| | | | | | | | | Argument is null when visiting an unboxed struct. I can't see such a visit in the current code. Fix it anyway. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: Clean up superfluous null check in qapi_dealloc_type_str()Markus Armbruster2014-03-031-3/+1
| | | | | | | | | Argument can't be null. No other Visitor method type_str() checks for null. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: Refine human printing of sizesPaolo Bonzini2014-02-141-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* qapi: Add human mode to StringOutputVisitorPaolo Bonzini2014-02-141-3/+52
| | | | | | | | | | | | 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>
* qapi: Add size parser to StringInputVisitorPaolo Bonzini2014-02-141-0/+24
| | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qapi: fix memleak by adding implict struct functions in dealloc visitorWenchao Xia2013-11-051-0/+20
| | | | | | | | | | Otherwise member "base" is leaked in a qapi_free_STRUCTURE() call. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1383676551-18806-2-git-send-email-xiawenc@linux.vnet.ibm.com Cc: qemu-stable@nongnu.org Signed-off-by: Anthony Liguori <aliguori@amazon.com>
* qemu-ga: Extend 'guest-info' command to expose flag 'success-response'Mark Wu2013-10-101-0/+5
| | | | | | | | | | | | | Now we have several qemu-ga commands not returning response on success. It has been documented in qga/qapi-schema.json already. This patch exposes the 'success-response' flag by extending 'guest-info' command. With this change, the clients can handle the command response more flexibly. Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> *fixed up commit subject Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: Add interface to traverse the qmp command list by QmpCommandMark Wu2013-10-101-22/+8
| | | | | | | | | | | | | | | | In the original code, qmp_get_command_list is used to construct a list of all commands' name. To get the information of all qga commands, it traverses the name list and search the command info with its name. So it can cause O(n^2) in the number of commands. This patch adds an interface to traverse the qmp command list by QmpCommand to replace qmp_get_command_list. It can decrease the complexity from O(n^2) to O(n). Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> *fix up commit subject Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* OptsVisitor: don't try to flatten overlong integer rangesLaszlo Ersek2013-08-201-2/+5
| | | | | | | | | | | | | Prevent mistyped command line options from incurring high memory and CPU usage at startup. 64K elements in a range should be enough for everyone (TM). The OPTS_VISITOR_RANGE_MAX macro is public so that unit tests can construct corner cases with it. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* OptsVisitor: opts_type_uint64(): recognize intervals when LM_IN_PROGRESSLaszlo Ersek2013-08-201-5/+27
| | | | | | | | | | When a well-formed range value, bounded by unsigned integers, is encountered while processing a repeated option, enter LM_UNSIGNED_INTERVAL and return the low bound. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* OptsVisitor: rebase opts_type_uint64() to parse_uint_full()Laszlo Ersek2013-08-201-18/+5
| | | | | | | | Simplify the code in preparation for the next patch. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* OptsVisitor: opts_type_int(): recognize intervals when LM_IN_PROGRESSLaszlo Ersek2013-08-201-6/+28
| | | | | | | | | | When a well-formed range value, bounded by signed integers, is encountered while processing a repeated option, enter LM_SIGNED_INTERVAL and return the low bound. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* OptsVisitor: introduce list modes for interval flatteningLaszlo Ersek2013-08-201-2/+65
| | | | | | | | | | | | | | | | | | | | | | | | | The new modes are equal-rank, exclusive alternatives of LM_IN_PROGRESS. Teach opts_next_list(), opts_type_int() and opts_type_uint64() to handle them. Also enumerate explicitly what functions are valid to call in what modes: - opts_next_list() is valid to call while flattening a range, - opts_end_list(): ditto, - lookup_scalar() is invalid to call during flattening; generated qapi traversal code must continue asking for the same kind of signed/unsigned list element until the interval is fully flattened, - processed(): ditto. List mode restrictions are always formulated in positive / inclusive sense. The restrictions for lookup_scalar() and processed() are automatically satisfied by current qapi traversals if the schema to build is compatible with OptsVisitor. The new list modes are not entered yet. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* OptsVisitor: introduce basic list modesLaszlo Ersek2013-08-201-10/+35
| | | | | | | | | | | | | | | | | | | | | | We're going to need more state while processing a list of repeated options. This change eliminates "repeated_opts_first" and adds a new state variable: list_mode repeated_opts repeated_opts_first -------------- ------------- ------------------- LM_NONE NULL false LM_STARTED non-NULL true LM_IN_PROGRESS non-NULL false Additionally, it is documented that lookup_scalar() and processed(), both called by opts_type_XXX(), are invalid in LM_STARTED -- generated qapi code calls opts_next_list() to allocate the very first link before trying to parse a scalar into it. List mode restrictions are expressed in positive / inclusive form. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: make visit_type_size fallback to type_intVasilis Liaskovitis2013-07-291-1/+10
| | | | | | | | | | | | | | | Currently visit_type_size checks if the visitor's type_size function pointer is NULL. If not, it calls it, otherwise it calls v->type_uint64(). But neither of these pointers are ever set. Fallback to calling v->type_int() in this third (default) case. Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Message-id: 1375109277-25561-6-git-send-email-imammedo@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qapi: Anonymous unionsKevin Wolf2013-07-262-0/+23
| | | | | | | | | | | | | | | | | | | | | The discriminator for anonymous unions is the data type. This allows to have a union type that allows both of these: { 'file': 'my_existing_block_device_id' } { 'file': { 'filename': '/tmp/mydisk.qcow2', 'read-only': true } } Unions like this are specified in the schema with an empty dict as discriminator. For this example you could take: { 'union': 'BlockRef', 'discriminator': {}, 'data': { 'definition': 'BlockOptions', 'reference': 'str' } } { 'type': 'ExampleObject', 'data: { 'file': 'BlockRef' } } Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Add consume argument to qmp_input_get_object()Kevin Wolf2013-07-261-9/+10
| | | | | | | | This allows to just look at the next element without actually consuming it. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Add visitor for implicit structsKevin Wolf2013-07-262-0/+30
| | | | | | | | | | These can be used when an embedded struct is parsed and members not belonging to the struct may be present in the input (e.g. parsing a flat namespace QMP union, where fields from both the base and one of the alternative types are mixed in the JSON object) Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* qapi: Fix unchecked strdup() by converting to g_strdup()Markus Armbruster2013-01-301-1/+1
| | | | | | | | | Note that we already free with g_free(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* build: move base QAPI files to libqemuutil.aPaolo Bonzini2013-01-121-4/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-194-5/+5
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi: move include files to include/qobject/Paolo Bonzini2012-12-1918-367/+29
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi: make struct Visitor opaquePaolo Bonzini2012-12-192-40/+40
| | | | | Move its definition from qapi-visit-core.h to qapi-visit-impl.h. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi: remove qapi/qapi-types-core.hPaolo Bonzini2012-12-196-22/+5
| | | | | | The file is only including error.h and qerror.h. Prefer explicit inclusion of whatever files are needed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi: move inclusions of qemu-common.h from headers to .c filesPaolo Bonzini2012-12-193-1/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi/qmp-registry.c: Include headers it needsEduardo Habkost2012-12-061-0/+2
| | | | | | | | | | | | | Include: - <glib.h> for g_malloc0() - <string.h> for strcmp() Some of those headers were probably being included by accident because some other headers were including qemu-common.h, but those headers should eventually stop including qemu-common.h. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qapi: fix qapi_dealloc_type_size parameter typeBruce Rogers2012-11-291-1/+1
| | | | | | | | | | | The second parameter to qapi_dealloc_type_size should be a uint64_t *, not a size_t *. This was causing our 32 bit x86 build to fail, since warnings are treated as errors. Signed-off-by: Bruce Rogers <brogers@suse.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: handle visitor->type_size() in QapiDeallocVisitorStefan Hajnoczi2012-11-261-0/+6
| | | | | | | | | | | | | | | | | | visit_type_size() requires either visitor->type_size() or visitor_uint64() to be implemented, otherwise a NULL function pointer is invoked. It is possible to trigger this crash as follows: $ qemu-system-x86_64 -netdev tap,sndbuf=0,id=netdev0 \ -device virtio-blk-pci,netdev=netdev0 The 'sndbuf' option has type "size". Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* build: opts-visitor is not really part of QAPIPaolo Bonzini2012-10-301-1/+3
| | | | | | It is only used by QEMU itself, do not build it into the tests. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi: Fix memory leakStefan Weil2012-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | 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) ==24534== by 0x489B23B: g_malloc0 (in /lib/libglib-2.0.so.0.2400.1) ==24534== by 0x2B4EFC: opts_visitor_new (opts-visitor.c:376) ==24534== by 0x29DEA5: net_client_init (net.c:708) ==24534== by 0x29E6C7: net_init_client (net.c:966) ==24534== by 0x2C2179: qemu_opts_foreach (qemu-option.c:1114) ==24534== by 0x29E85B: net_init_clients (net.c:1008) ==24534== by 0x296F40: main (vl.c:3463) Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* error: drop error_get_qobject()/error_set_qobject()Luiz Capitulino2012-08-131-1/+0
| | | | | | | | 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 <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
* qemu-ga: switch to the new error format on the wireLuiz Capitulino2012-08-132-1/+10
| | | | | | | | | | | | | | | | | | | | 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" } } } qemu-ga now returns: { "error": { "class": "GenericError", "desc": "Parameter 'mode' expects halt|powerdown|reboot" } } Notice that this is also a bug fix, as qemu-ga wasn't returning the human message. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
* qapi: introduce OptsVisitorLaszlo Ersek2012-07-233-1/+459
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 visitor linked to the underlying QemuOpts object will build the "native" C representation of the option. The type tree in the schema, corresponding to an option with a discriminator, must have the following structure: struct scalar member for non-discriminated optarg 1 [*] list for repeating non-discriminated optarg 2 [*] wrapper struct single scalar member union struct for discriminator case 1 scalar member for optarg 3 [*] list for repeating optarg 4 [*] wrapper struct single scalar member scalar member for optarg 5 [*] struct for discriminator case 2 ... The "type" optarg name is fixed for the discriminator role. Its schema representation is "union of structures", and each discriminator value must correspond to a member name in the union. If the option takes no "type" descriminator, then the type subtree rooted at the union must be absent from the schema (including the union itself). Optarg values can be of scalar types str / bool / integers / size. Members marked with [*] may be defined as optional in the schema, describing an optional optarg. Repeating an optarg is supported; its schema representation must be "list of structure with single mandatory scalar member". If an optarg is not described as repeating in the schema (ie. it is defined as a scalar field instead of a list), its last occurrence will take effect. Ordering between differently named optargs is not preserved. A mandatory list (or an optional one which is reported to be available), corresponding to a repeating optarg, has at least one element after successful parsing. v1->v2: - Update opts_type_size() prototype to uint64_t. - Add opts_type_uint64() for options needing the full uint64_t range. (Internals could be extracted to "cutils.c".) - Allow negative values in opts_type_int(). - Rebase to nested Makefiles. v2->v3: - Factor opts_visitor_insert() out of opts_start_struct() and call it separately for opts_root->id if there's any. - Don't require non-negative values in opts_type_int()'s error message. - g_malloc0() may return NULL for zero-sized requests. Support empty structures by requesting 1 byte for them instead. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qapi: introduce "size" typeLaszlo Ersek2012-07-232-0/+10
| | | | | | | | v1->v2: - fall back to uint64 rather than int Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qapi: fix error propagationPaolo Bonzini2012-07-231-6/+4
| | | | | | | | | | | | | | | | | | | | | | 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 error_set() - allow visitors to set a NULL struct pointer successfully, so traversal of incomplete objects can continue - check for a NULL "obj" before accessing "(*obj)->has_XXX" (this is not a typo, "obj != NULL" implies "*obj != NULL" here) - fix start_struct / end_struct balance for unions as well Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qapi: input_type_enum(): fix error messageLuiz Capitulino2012-07-131-1/+1
| | | | | | | | | | | | 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" } } } Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Amos Kong <akong@redhat.com>
* qmp: do not include monitor.h from qapi-types-core.hPaolo Bonzini2012-06-151-3/+1
| | | | | | | | 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 <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: String visitor, use %f representation for floatsMichael Roth2012-06-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* qapi: Add Visitor interfaces for uint*_t and int*_tMichael Roth2012-06-082-0/+155
| | | | | | | | | | | | | | | 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 integer overflows for cases where the value fetched exceeds the bounds of our target C type. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [LE: exclude negative values in uint*_t Visitor interfaces] Signed-off-by: Laszlo Ersek <lersek@redhat.com> [AF: Merged fix by Laszlo] Signed-off-by: Andreas Färber <afaerber@suse.de>
* build: move qapi/ objects to nested Makefile.objsPaolo Bonzini2012-06-071-0/+3
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi: add support for command optionsLuiz Capitulino2012-05-153-4/+18
| | | | | | | | | | | | | 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 may not be able to complete before the VM vanishes. In this case, it's useful and simpler not to bother sending a success response. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qapi: QMP input visitor, handle floats parsed as intsMichael Roth2012-05-141-3/+8
| | | | | | | | | | | 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 account for this. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Acked-by: Andreas Färber <afaerber@suse.de>
* qemu-ga: add a whitelist for fsfreeze-safe commandsMichael Roth2012-04-302-2/+13
| | | | | | | | | | | | 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. Instead, have an explicit whitelist of fsfreeze-safe commands, and consolidate logging and command enablement/disablement into a pair of helper functions: ga_set_frozen()/ga_unset_frozen() Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qapi: g_hash_table_find() instead of GHashTableIter.NODA, Kai2012-04-231-8/+17
| | | | | | | | | 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 <nodakai@gmail.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: add strict mode to input visitorPaolo Bonzini2012-03-272-3/+47
| | | | | | | | | | | | 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 complex structures, add a mode to the input visitor where it checks for unvisited keys and raises an error if it finds one. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: place outermost object on qiv stackPaolo Bonzini2012-03-271-24/+17
| | | | | | | | | | | | | | 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 the weak references now, but since refcount+const is a lost battle in C (C++ has "mutable") I think removing const is fine in this case. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: untangle next_listPaolo Bonzini2012-03-271-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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, the second argument should point to the last node (last result of next_list) and next_list itself tacks the element at the tail of the list. This works for both input and output visitor, but having the visitor write memory when it is only reading the list is ugly. Plus, relying on *list to detect the first call is tricky and undocumented. We can initialize so->entry in next_list instead of start_list, leaving it NULL in start_list. This way next_list sees clearly whether it is on the first call---as a bonus, it discriminates the cases based on internal state of the visitor rather than external state. We can also pull the assignment of the list head from generated code up to next_list. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: fix memory leak on errorPaolo Bonzini2012-03-271-2/+4
| | | | | | | | | QmpInputVisitor would leak the malloced struct if the stack was overflowed. This can be easily fixed using error_propagate. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: fail hard on stack imbalancePaolo Bonzini2012-03-271-4/+1
| | | | | | | | | QmpOutputVisitor will segfault if an imbalanced end function is called. So we can abort in QmpInputVisitor too. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qapi: fix double free in qmp_output_visitor_cleanup()Laszlo Ersek2012-03-271-3/+5
| | | | | | | | | | | | | | | 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, then release the QObject tree by the root. Attempting to serialize an invalid enum inside a dictionary is an example for triggering the double free. [1] http://lists.nongnu.org/archive/html/qemu-devel/2012-03/msg03276.html Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
OpenPOWER on IntegriCloud