summaryrefslogtreecommitdiff
path: root/include/qapi
AgeCommit message (Collapse)AuthorFilesLines
2014-09-26qemu-socket: Eliminate silly QERR_ macrosMarkus Armbruster1-12/+0
The QERR_ macros are leftovers from the days of "rich" error objects. They're used with error_set() and qerror_report(), and expand into the first *two* arguments. This trickiness has become pointless. Clean up. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-09-26qemu-socket: Polish errors for connect() and listen() failureMarkus Armbruster1-2/+2
connect() doesn't "connect to socket", it connects a socket to an address and, if it's of type SOCK_STREAM, initiates a connection. Scratch "to". listen() does "set socket to listening mode", but it sounds awkward. Change to "listen on socket". Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-09-26qapi: add visit_start_union and visit_end_unionMichael Roth2-0/+4
In some cases an input visitor might bail out on filling out a struct for various reasons, such as missing fields when running in strict mode. In the case of a QAPI Union type, this may lead to cases where the .kind field which encodes the union type is uninitialized. Subsequently, other visitors, such as the dealloc visitor, may use this .kind value as if it were initialized, leading to assumptions about the union type which in this case may lead to segfaults. For example, freeing an integer value. However, we can generally rely on the fact that the always-present .data void * field that we generate for these union types will always be NULL in cases where .kind is uninitialized (at least, there shouldn't be a reason where we'd do this purposefully). So pass this information on to Visitor implementation via these optional start_union/end_union interfaces so this information can be used to guard against the situation above. We will make use of this information in a subsequent patch for the dealloc visitor. Cc: qemu-stable@nongnu.org Reported-by: Fam Zheng <famz@redhat.com> Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-09-08rename parse_enum_option to qapi_enum_parse and make it publicPeter Lieven1-0/+17
relaxing the license to LGPLv2+ is intentional. Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Benoit Canet <benoit.canet@nodalink.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-06-23qapi: add event helper functionsWenchao Xia1-0/+27
This file holds some functions that do not need to be generated. Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-22Merge remote-tracking branch 'remotes/kraxel/tags/pull-chardev-2' into stagingPeter Maydell1-6/+0
purge error_is_set() # gpg: Signature made Wed 21 May 2014 11:43:44 BST using RSA key ID D3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" * remotes/kraxel/tags/pull-chardev-2: error: error_is_set() is finally unused; remove char: Explain qmp_chardev_add()'s unusual error handling char: Clean up fragile use of error_is_set() char: Use return values instead of error_is_set(errp) qemu-socket: Clean up inet_connect_opts() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-21error: error_is_set() is finally unused; removeMarkus Armbruster1-6/+0
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-20Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into stagingPeter Maydell1-0/+3
Block patches # gpg: Signature made Mon 19 May 2014 15:21:14 BST using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (22 commits) block: optimize zero writes with bdrv_write_zeroes blockdev: add a function to parse enum ids from strings util: add qemu_iovec_is_zero qcow1: Stricter backing file length check qcow1: Validate image size (CVE-2014-0223) qcow1: Validate L2 table size (CVE-2014-0222) qcow1: Check maximum cluster size qcow1: Make padding in the header explicit curl: Add usage documentation curl: Add sslverify option curl: Remove broken parsing of options from url curl: Fix build when curl_multi_socket_action isn't available qemu-iotests: Fix blkdebug in VM drive in 030 qemu-iotests: Fix core dump suppression in test 039 iotests: Add test for the JSON protocol block: Allow JSON filenames check-qdict: Add test for qdict_join() qdict: Add qdict_join() block: add test for vhdx image created by Disk2VHD block: vhdx - account for identical header sections ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-05-19qdict: Add qdict_join()Max Reitz1-0/+3
This function joins two QDicts by absorbing one into the other. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-05-15qapi: Replace start_optional()/end_optional() by optional()Markus Armbruster2-6/+4
Semantics of end_optional() differ subtly from the other end_FOO() callbacks: when start_FOO() succeeds, the matching end_FOO() gets called regardless of what happens in between. end_optional() gets called only when everything in between succeeds as well. Entirely undocumented, like all of the visitor API. The only user of Visitor Callback end_optional() never did anything, and was removed in commit 9f9ab46. I'm about to clean up error handling in the generated visitor code, and end_optional() is in my way. No users mean no test cases, and making non-trivial cleanup transformations without test cases doesn't strike me as a good idea. Drop end_optional(), and rename start_optional() to optional(). We can always go back to a pair of callbacks when we have an actual need. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-15qapi: Remove unused Visitor callbacks start_handle(), end_handle()Markus Armbruster1-3/+0
These have never been called or implemented by anything, and their intended use is undocumented, like all of the visitor API. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09error: Consistently name Error ** objects errp, and not errMarkus Armbruster1-11/+16
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08qmp hmp: Consistently name Error * objects err, and not errpMarkus Armbruster1-1/+1
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25error: Remove some unused headersCole Robinson1-1/+0
Makes it a bit clear how the interdependencies work. Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25qerror.h: Replace QERR_NOT_SUPPORTED with QERR_UNSUPPORTEDCole Robinson1-3/+0
The former is only used twice, the latter is used over 30 times, and has a nicer error message. Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25qerror.h: Remove QERR defines that are only used onceCole Robinson1-66/+0
Just hardcode them in the callers Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-04-25qerror.h: Remove unused error classesCole Robinson1-9/+0
Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-03-11qapi script: do not add "_" for every capitalized char in enumWenchao Xia1-1/+1
Now "enum AIOContext" will generate AIO_CONTEXT instead of A_I_O_CONTEXT, "X86CPU" will generate X86_CPU instead of X86_C_P_U. Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-03-04Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-03-04' ↵Peter Maydell1-1/+1
into staging trivial patches for 2014-03-04 # gpg: Signature made Tue 04 Mar 2014 06:13:56 GMT using RSA key ID 74F0C838 # gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>" # gpg: aka "Michael Tokarev <mjt@corpit.ru>" # gpg: aka "Michael Tokarev <mjt@debian.org>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5 # Subkey fingerprint: E190 8639 3B10 B51B AC2C 8B73 5253 C5AD 74F0 C838 * remotes/mjt/tags/trivial-patches-2014-03-04: vl: Remove unneeded include file qga: Remove unneeded include file qemu-img: Remove unneeded include files exec: Remove unneeded include files util/iov: Use qemu/sockets.h instead of conditional code qjson.h: Remove spurious GCC_FMT_ATTR markup from qobject_from_json() declaration tests/test-int128: Don't use __noclone__ attribute on clang stubs: Optimize dependencies for gdbstub.c tcg: Fix typo in comment (dependancies -> dependencies) bswap: Modify prototypes of st[wl]_{le, be}_p (avoid type conversions) bswap: Modify prototype of stb_p (avoid type conversions) object: Report type in error when not user creatable. include/qemu/host-utils.h: Trivial typo: ctz->cto Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-03-03qjson.h: Remove spurious GCC_FMT_ATTR markup from qobject_from_json() ↵Peter Maydell1-1/+1
declaration The function qobject_from_json() doesn't actually allow its argument to be a format string -- it passes a NULL va_list* to qobject_from_jsonv(), and the parser code will then never actually interpret %-escape sequences (it tests whether the va_list pointer is NULL and will stop with a parse error). The spurious attribute markup causes clang warnings in some of the test cases where we programmatically construct JSON to feed to qobject_from_json(): tests/test-qmp-input-visitor.c:76:35: warning: format string is not a string literal (potentially insecure) [-Wformat-security] data->obj = qobject_from_json(json_string); ^~~~~~~~~~~ Remove the incorrect attribute. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-02-28qerror: Improve QERR_DEVICE_NOT_ACTIVE messageHani Benhabiles1-1/+1
The error message as currently used is confusing as there are no "balloon" or "spice" devices. (qemu) balloon 1024 balloon: Device 'balloon' has not been activated With this patch: (qemu) balloon 1024 balloon: No balloon device has been activated Signed-off-by: Hani Benhabiles <hani@linux.com> Suggested-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-14qapi: Add human mode to StringOutputVisitorPaolo Bonzini1-1/+1
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-01-22qdict: Add qdict_array_split()Max Reitz1-0/+1
This function splits a QDict consisting of entries prefixed by incrementally enumerated indices into a QList of QDicts. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-01-06qerror: Remove assert_no_error()Peter Crosthwaite1-1/+0
This is no longer needed, and is obsoleted by error_abort. Remove. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-01-06error: Add error_abortPeter Crosthwaite1-0/+6
Add a special Error * that can be passed to error handling APIs to signal that any errors are fatal and should abort QEMU. There are two advantages to this: - allows for brevity when wishing to assert success of Error ** accepting APIs. No need for this pattern: Error * local_err = NULL; api_call(foo, bar, &local_err); assert_no_error(local_err); This also removes the need for _nofail variants of APIs with asserting call sites now reduced to 1LOC. - SIGABRT happens from within the offending API. When a fatal error occurs in an API call (when the caller is asserting sucess) failure often means the API itself is broken. With the abort happening in the API call now, the stack frames into the call are available at debug time. In the assert_no_error scheme the abort happens after the fact. The exact semantic is that when an error is raised, if the argument Error ** matches &error_abort, then the abort occurs immediately. The error messaged is reported. For error_propagate, if the destination error is &error_abort, then the abort happens at propagation time. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-01-06monitor: add object-add (QMP) and object_add (HMP) commandPaolo Bonzini1-2/+1
Add two commands that are the monitor counterparts of -object. The commands have the same Visitor-based implementation, but use different kinds of visitors so that the HMP command has a DWIM string-based syntax, while the QMP variant accepts a stricter JSON-based properties dictionary. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-10-10qemu-ga: Extend 'guest-info' command to expose flag 'success-response'Mark Wu1-0/+1
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>
2013-10-10qemu-ga: Add interface to traverse the qmp command list by QmpCommandMark Wu1-2/+4
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>
2013-09-25qdict: Extract qdict_extract_subqdictBenoît Canet1-0/+2
Signed-off-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-09error: Add error_set_win32 and error_setg_win32Tomoki Sekiyama1-0/+13
These functions help maintaining homogeneous formatting of error messages with Windows error code and description (generated by g_win32_error_message()). Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2013-08-20OptsVisitor: don't try to flatten overlong integer rangesLaszlo Ersek1-0/+6
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>
2013-07-26Implement qdict_flatten()Kevin Wolf1-0/+1
qdict_flatten(): For each nested QDict with key x, all fields with key y are moved to this QDict and their key is renamed to "x.y". This operation is applied recursively for nested QDicts. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2013-07-26qapi: Anonymous unionsKevin Wolf3-0/+6
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>
2013-07-26qapi: Add visitor for implicit structsKevin Wolf2-0/+7
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>
2013-06-17qerror: drop QERR_OPEN_FILE_FAILED macroLuiz Capitulino1-3/+0
Not used since the last commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
2013-06-17error: add error_setg_file_open() helperLuiz Capitulino1-0/+5
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
2013-05-30qapi: pad GenericList value fields to 64 bitsMichael Roth1-1/+4
With the introduction of native list types, we now have types such as int64List where the 'value' field is not a pointer, but the actual 64-bit value. On 32-bit architectures, this can lead to situations where 'next' field offset in GenericList does not correspond to the 'next' field in the types that we cast to GenericList when using the visit_next_list() interface, causing issues when we attempt to traverse linked list structures of these types. To fix this, pad the 'value' field of GenericList and other schema-defined/native *List types out to 64-bits. This is less memory-efficient for 32-bit architectures, but allows us to continue to rely on list-handling interfaces that target GenericList to simply visitor implementations. In the future we can improve efficiency by defaulting to using native C array backends to handle list of non-pointer types, which would be more memory efficient in itself and allow us to roll back this change. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-05-18remove some double-includesMichael Tokarev1-1/+0
Some source files #include the same header more than once for no good reason. Remove second #includes in such cases. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-04-05qstring: add qstring_get_length()Luiz Capitulino1-0/+1
Long overdue. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
2013-03-15Add qdict_clone_shallow()Kevin Wolf1-0/+2
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini6-7/+7
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19qapi: move include files to include/qobject/Paolo Bonzini23-0/+1203
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>