summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2014-05-09qmp: use valid JSON in transaction exampleEric Blake1-4/+4
Our example should use the correct quotes to match what someone could actually pass over the wire. * qmp-commands.hx: Use correct JSON quotes. Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09qmp: Don't use error_is_set() to suppress additional errorsMarkus Armbruster1-21/+11
Using error_is_set(errp) that way can sweep programming errors under the carpet when we get called incorrectly with an error set. encrypted_bdrv_it() does it, because there's no way to make bdrv_iterate() break its loop. Actually safe, because qmp_cont() clears the error before the loop. Clean it up anyway: replace bdrv_iterate() by bdrv_next(), break the loop on error. Replace both occurrences, for consistency. 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-09dump: Drop pointless error_is_set(), DumpState member errpMarkus Armbruster1-4/+2
In qmp_dump_guest_memory(), the error must be clear on entry, and we always bail out after setting it, directly or via dump_init(). Therefore, both error_is_set() are always false. Drop them. DumpState member errp is now write-only. Drop it, too. 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-09qemu-option: Clean up fragile use of error_is_set()Markus Armbruster1-1/+1
Using error_is_set(ERRP) to find out whether to bail out due to previous error is either wrong, fragile, or unnecessarily opaque. It's wrong when ERRP may be null, because errors go undetected when it is. It's fragile when proving ERRP non-null involves a non-local argument. Else, it's unnecessarily opaque (see commit 84d18f0). The error_is_set(state->errp) in qemu_opts_from_qdict_1() is merely fragile, because the callers never pass state argument with null state->errp. Make the code more robust and more obviously correct: test *state->errp directly. 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-09qga: Drop superfluous error_is_set()Markus Armbruster1-10/+0
acquire_privilege(), execute_async() and check_suspend_mode() do nothing when called with an error set. Callers shouldn't do that, and no caller does. Drop the superfluous tests. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09qga: Clean up fragile use of error_is_set()Markus Armbruster2-20/+40
Using error_is_set(ERRP) to find out whether a function failed is either wrong, fragile, or unnecessarily opaque. It's wrong when ERRP may be null, because errors go undetected when it is. It's fragile when proving ERRP non-null involves a non-local argument. Else, it's unnecessarily opaque (see commit 84d18f0). The error_is_set(errp) in the guest agent command handler functions are merely fragile, because all chall chains (do_qmp_dispatch() via the generated marshalling functions) pass a non-null errp argument. Make the code more robust and more obviously correct: receive the error in a local variable, then propagate it through the parameter. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09qapi: Clean up fragile use of error_is_set()Markus Armbruster1-7/+8
Using error_is_set(ERRP) to find out whether a function failed is either wrong, fragile, or unnecessarily opaque. It's wrong when ERRP may be null, because errors go undetected when it is. It's fragile when proving ERRP non-null involves a non-local argument. Else, it's unnecessarily opaque (see commit 84d18f0). The error_is_set(errp) in do_qmp_dispatch() is merely fragile, because the caller never passes a null errp argument. Make the code more robust and more obviously correct: receive the error in a local variable, then propagate it through the parameter. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09tests/qapi-schema: Drop superfluous error_is_set()Markus Armbruster1-13/+12
visit_type_TestStruct() does nothing when called with an error set. Callers shouldn't do that, and no caller does. Drop the superfluous test. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09qapi: Drop redundant, unclean error_is_set()Markus Armbruster1-2/+1
do_qmp_dispatch()'s test for qmp_dispatch_check_obj() failure examines both the return value and the error object. The latter part is unclean; it works only when do_qmp_dispatch()'s caller passes a non-null errp argument. That's the case, but it's not locally obvious. Unclean. Cleanup would be easy enough, but since the unclean code is also redundant, let's just drop it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09hmp: Guard against misuse of hmp_handle_error()Markus Armbruster1-1/+2
Null errp argument makes no sense. Assert it's not null, to make this explicit, and guard against misuse. All current callers pass non-null errp. 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-09qga: Use return values instead of error_is_set(errp)Markus Armbruster2-3/+4
Using error_is_set(errp) to check whether a function call failed is fragile: it breaks when errp is null. ga_get_fd_handle() and guest_file_handle_add() don't return a useful value when they fail, but that's just stupid. Fix that, and check them instead. As far as I can tell, errp can't be null there, but this is more robust and more obviously correct. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09error: Consistently name Error ** objects errp, and not errMarkus Armbruster2-15/+20
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-09qmp: Consistently name Error ** objects errp, and not errMarkus Armbruster1-8/+8
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-09qga: Consistently name Error ** objects errp, and not errMarkus Armbruster5-155/+161
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-09qemu-iotests: Test converting to streamOptimized from small cluster sizeFam Zheng2-0/+14
Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09vmdk: Implement .bdrv_get_info()Fam Zheng2-0/+22
This will return cluster_size and needs_compressed_writes to caller, if all the extents have the same value (or there's only one extent). Otherwise return -ENOTSUP. cluster_size is only reported for sparse formats. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09vmdk: Implement .bdrv_write_compressedFam Zheng1-0/+14
Add a wrapper function to support "compressed" path in qemu-img convert. Only support streamOptimized subformat case for now (num_extents == 1 and extent compression is true). Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09qemu-img: Convert by cluster size if target is compressedFam Zheng2-0/+5
If target block driver forces compression, qemu-img convert needs to write by cluster size as well as "-c" option. Particularly, this applies for converting to VMDK streamOptimized format. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09block/iscsi: bump year in copyright noticePeter Lieven1-1/+1
Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09block/nfs: Check for NULL server partMax Reitz1-0/+4
After the URL has been parsed make sure the server part is valid in order to avoid a segmentation fault when calling nfs_mount(). Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09qemu-img: sort block formats in help messageMike Day1-3/+25
The help message for qemu-img lists the supported block formats, of which there are 27 as of version 2.0.50. The formats are printed in the order of their driver's position in a linked list, which appears random. This patch prints the formats in sorted order, making it easier to read and to find a specific format in the list. [Added suggestions from Fam Zheng <famz@redhat.com> to declare variables at the top of the scope in help() and to omit explicit cast for void* opaque. --Stefan] Signed-off-by: Mike Day <ncmike@ncultra.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09iotests: Use configured pythonMax Reitz10-43/+70
Currently, QEMU's iotests rely on /usr/bin/env to start the correct Python (that is, at least Python 2.4, but not 3). On systems where Python 3 is the default, the user has no clean way of making the iotests use the correct binary. This commit makes the iotests use the Python selected by configure. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-09qcow2: Fix alloc_clusters_noref() overflow detectionMax Reitz1-1/+3
If the very first allocation has a length of 0, the free_cluster_index is still 0 after the for loop, which means that subtracting one from it will underflow and signal an invalid range of clusters by returning -EFBIG. However, there is no such range, as its length is 0. Fix this by preventing underflows on free_cluster_index during the check. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-08qmp hmp: Consistently name Error * objects err, and not errpMarkus Armbruster9-240/+240
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-08pci-assign: assigned_initfn(): set monitor error in common error handlerLaszlo Ersek1-16/+10
Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate errors from assign_intx()Laszlo Ersek1-11/+28
Among the callers, only assigned_initfn() should set the monitor's stored error. Other callers may run in contexts where the monitor's stored error makes no sense. For example: assigned_dev_pci_write_config() assigned_dev_update_msix() assign_intx() Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate errors from assign_device()Laszlo Ersek1-14/+15
Also, change the return type to "void"; the function is static (with a sole caller) and the negative errno values are not distinguished from each other. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate errors from assigned_dev_register_regions()Laszlo Ersek1-10/+13
Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate errors from assigned_dev_register_msix_mmio()Laszlo Ersek1-5/+7
The return type is also changed from "int" to "void", because it was used in a success vs. failure sense only (the caller didn't distinguish error codes from each other, and even assigned_dev_register_msix_mmio() masked mmap()'s errno values with a common -EFAULT). Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate errors from assigned_device_pci_cap_init()Laszlo Ersek1-26/+19
Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate errors from get_real_device()Laszlo Ersek1-20/+20
Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: assignment should fail if we can't read config spaceLaszlo Ersek1-0/+1
assigned_initfn() get_real_device() read() Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: accept Error from pci_add_capability2()Laszlo Ersek1-7/+28
Propagate any errors while adding PCI capabilities to assigned_device_pci_cap_init(). We'll continue the propagation upwards when assigned_device_pci_cap_init() becomes a leaf itself (when none of its callees will report errors internally any longer when detecting and returning them). Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci: add Error-propagating pci_add_capability2()Laszlo Ersek2-6/+30
... and rebase pci_add_capability() to it. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate Error from check_irqchip_in_kernel()Laszlo Ersek1-8/+17
Rename check_irqchip_in_kernel() to verify_irqchip_in_kernel(), so that the name reflects our expectation better. Rather than returning a bool, make it do nothing or set an Error. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: propagate errors from get_real_id()Laszlo Ersek1-18/+27
get_real_id() has two thin wrappers (and no other callers), get_real_vendor_id() and get_real_device_id(); it's easiest to convert them in one fell swoop. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: make assign_failed_examine() just format the causeLaszlo Ersek1-11/+19
This allows us to report the entire error with one error_report() call, easing future error propagation. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08pci-assign: accept Error from monitor_handle_fd_param2()Laszlo Ersek1-2/+7
Propagate any errors in monitor fd handling up to get_real_device(), and report them there. We'll continue the propagation upwards when get_real_device() becomes a leaf itself (when none of its callees will report errors internally any longer when detecting and returning an error). Signed-off-by: Laszlo Ersek <lersek@redhat.com> eviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08monitor: add Error-propagating monitor_handle_fd_param2()Laszlo Ersek2-5/+23
and rebase monitor_handle_fd_param() to it. (Note that this will slightly change the behavior when the qemu_parse_fd() branch is selected and it fails: we now report (and in case of QMP, set) the error immediately, rather than allowing the caller to set its own error message (if any)). Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08cutils: tighten qemu_parse_fd()Laszlo Ersek1-3/+10
qemu_parse_fd() used to handle at least the following strings incorrectly: o "-2": simply let through o "2147483648": returned as LONG_MAX==INT_MAX on ILP32 (with ERANGE ignored); implementation-defined behavior on LP64 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08qapi: treat all negative return of strtosz_suffix() as errorAmos Kong1-5/+6
strtosz_suffix() might return negative error, this patch fixes the error handling. This patch also changes to handle error in the if statement rather than handle success specially, this will make this use of strtosz_suffix consistent with all other uses. Signed-off-by: Amos Kong <akong@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08qapi: Add a primitive to include other files from a QAPI schema fileLluís Vilanova44-13/+110
The primitive uses JSON syntax, and include paths are relative to the file using the directive: { 'include': 'path/to/file.json' } Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08qapi: Use an explicit input fileLluís Vilanova25-42/+54
Use an explicit input file on the command-line instead of reading from standard input. It also outputs the proper file name when there's an error. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08qapi: [trivial] Do not catch unknown exceptions in "test-qapi.py"Lluís Vilanova1-3/+0
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08qapi: [trivial] Break long command linesLluís Vilanova2-10/+32
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-08build: convert some obj-specific CFLAGS to use new foo.o-cflags syntaxMichael Tokarev6-10/+6
Current Makefile system allows using foo.o-cflags variables to store object-specific CFLAGS. Convert some usages of old syntax (using QEMU_CFLAGS += construct) to the new syntax. Do not touch multifile modules for now, as build system isn't ready for this. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08build: add support for per-object -cflags and -libs to all rulesPaolo Bonzini1-5/+5
This is needed in order to use per-object flags variables. Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08Makefile: use $(INSTALL_LIB) for modules not $(INSTALL_PROG)Michael Tokarev1-1/+1
We have $(INSTALL_LIB) which is the same as $(INSTALL_PROG) but uses correct permissions. Loadable objects (modules) are like shared libraries, not like programs. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Cc: Fam Zheng <famz@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08Makefile.target: use $(INSTALL_PROG) for installing, not $(INSTALL)Michael Tokarev1-1/+1
$(INSTALL_PROG) is evaluated to libtool if using libtool, while $(INSTALL) is not. Use $(INSTALL_PROG) so that libtool is used with target too when necessary. This allows, for example, to link qemu with shared libcacard. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Cc: Fam Zheng <famz@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Alon Levy <alevy@redhat.com> Cc: qemu-trivial@nongnu.org -- This is done on top of previous patch (using $(STRIP)), but it can be used by its own. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-08Makefile: strip tools and modules tooMichael Tokarev2-5/+13
Commit 52ba784d3 replaced $(STRIP_OPT) with $(STRIP) in some places (for example, Makefile.target), but not all of them. There are a few places remain in main Makefile which still uses $(STRIP_OPT). Replace these places with $(STRIP) too. While at it, simplify variable pattern substitution of the surrounding places, change $(patsubst pat,rep,$(var)) into $(var:pat=rep) which is much easier to read (this is probably a good idea to do everywhere). Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Cc: Fam Zheng <famz@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>