summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* target/arm: Add sve-max-vq cpu property to -cpu maxRichard Henderson2018-08-165-11/+53
| | | | | | | | | | | | | This allows the default (and maximum) vector length to be set from the command-line. Which is extraordinarily helpful in debugging problems depending on vector length without having to bake knowledge of PR_SET_SVE_VL into every guest binary. Cc: qemu-stable@nongnu.org (3.0.1) Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* target/arm: Dump SVE state if enabledRichard Henderson2018-08-161-11/+82
| | | | | | | | | | | Also fold the FPCR/FPSR state onto the same line as PSTATE, and mention but do not dump disabled FPU state. Cc: qemu-stable@nongnu.org (3.0.1) Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* target/arm: Reformat integer register dumpRichard Henderson2018-08-161-7/+6Star
| | | | | | | | | | With PC, there are 33 registers. Three per line lines up nicely without overflowing 80 columns. Cc: qemu-stable@nongnu.org (3.0.1) Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* target/arm: Fix offset scaling for LD_zprr and ST_zprrRichard Henderson2018-08-161-3/+2Star
| | | | | | | | | | | | The scaling should be solely on the memory operation size; the number of registers being loaded does not come in to the initial computation. Cc: qemu-stable@nongnu.org (3.0.1) Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* target/arm: Fix offset for LD1R instructionsRichard Henderson2018-08-161-1/+2
| | | | | | | | | | | | The immediate should be scaled by the size of the memory reference, not the size of the elements into which it is loaded. Cc: qemu-stable@nongnu.org (3.0.1) Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* target/arm: Fix sign-extension in sve do_ldr/do_strRichard Henderson2018-08-161-10/+8Star
| | | | | | | | | | | | | The expression (int) imm + (uint32_t) len_align turns into uint32_t and thus with negative imm produces a memory operation at the wrong offset. None of the numbers involved are particularly large, so change everything to use int. Cc: qemu-stable@nongnu.org (3.0.1) Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* target/arm: Fix typo in helper_sve_ld1hss_rRichard Henderson2018-08-161-1/+1
| | | | | | | Cc: qemu-stable@nongnu.org (3.0.1) Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* Merge remote-tracking branch 'remotes/armbru/tags/pull-tests-2018-08-16' ↵Peter Maydell2018-08-1651-557/+575
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into staging Testing patches for 2018-08-16 # gpg: Signature made Thu 16 Aug 2018 09:34:43 BST # gpg: using RSA key 3870B400EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-tests-2018-08-16: (25 commits) libqtest: Improve error reporting for bad read from QEMU tests/libqtest: Improve kill_qemu() libqtest: Rename qtest_FOOv() to qtest_vFOO() for consistency libqtest: Replace qtest_startf() by qtest_initf() libqtest: Enable compile-time format string checking migration-test: Clean up string interpolation into QMP, part 3 migration-test: Clean up string interpolation into QMP, part 2 migration-test: Clean up string interpolation into QMP, part 1 migration-test: Make wait_command() cope with '%' tests: New helper qtest_qmp_receive_success() migration-test: Make wait_command() return the "return" member tests: Clean up string interpolation around qtest_qmp_device_add() cpu-plug-test: Don't pass integers as strings to device_add tests: Clean up string interpolation into QMP input (simple cases) tests: Pass literal format strings directly to qmp_FOO() qobject: qobject_from_jsonv() is dangerous, hide it away test-qobject-input-visitor: Avoid format string ambiguity libqtest: Simplify qmp_fd_vsend() a bit qobject: New qobject_from_vjsonf_nofail(), qdict_from_vjsonf_nofail() qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail() ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * libqtest: Improve error reporting for bad read from QEMUMarkus Armbruster2018-08-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When read() from the qtest socket or the QMP socket fails or EOFs, we report "Broken pipe" and exit(1). This commonly happens when QEMU crashes. It also happens when QEMU refuses to run because the test passed it bad arguments. Sadly, we neglect to report either. Improve this by calling abort() instead of exit(1), so kill_qemu() runs, and reports how QEMU died. This improves error reporting to something like /x86_64/device/introspect/list: Broken pipe tests/libqtest.c:129: kill_qemu() detected QEMU death from signal 6 (Aborted) (dumped core) Three exit() remain in libqtest.c: * In qmp_response(), when we can't parse a QMP reply read from the QMP socket. Change to abort() for consistency. * In qtest_qemu_binary(), when QTEST_QEMU_BINARY isn't in the environment. This can only happen before we start QEMU. Leave alone. * In qtest_init_without_qmp_handshake(), when the fork()ed child fails to execlp(). Leave alone. exit() elsewhere are unlikely due to QEMU dying on us. If that should turn out to be wrong, we can move kill_qemu() from @abrt_hooks to atexit() or something. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20180815141945.10457-2-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> [Commit message tweaked slightly]
| * tests/libqtest: Improve kill_qemu()Eric Blake2018-08-161-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In kill_qemu() we have an assert that checks that the QEMU process didn't dump core: assert(!WCOREDUMP(wstatus)); Unfortunately the WCOREDUMP macro here means the resulting message is not very easy to comprehend on at least some systems: ahci-test: tests/libqtest.c:113: kill_qemu: Assertion `!(((__extension__ (((union { __typeof(wstatus) __in; int __i; }) { .__in = (wstatus) }).__i))) & 0x80)' failed. and it doesn't identify what signal the process took. What's more, WCOREDUMP is not reliable - in some cases, setrlimit() coupled with kernel dump settings can result in the flag not being set. It's better to log ALL death by signal, instead of caring whether a core dump was attempted (although once we know a signal happened, also mentioning if a core dump is present can be helpful). Furthermore, we are NOT detecting EINTR (while EINTR shouldn't be happening if we didn't install signal handlers, it's still better to always be robust). Finally, even non-signal death with a non-zero status is suspicious, since qemu's SIGINT handler is supposed to result in exit(0). Instead of using a raw assert, print the information in an easier to understand way: /i386/ahci/sanity: tests/libqtest.c:129: kill_qemu() detected QEMU death from signal 11 (Segmentation fault) (core dumped) (Of course, the really useful information would be why the QEMU process dumped core in the first place, but we don't have that by the time the test program has picked up the exit status.) Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <20180810132800.38549-1-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Core dump reporting and commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
| * libqtest: Rename qtest_FOOv() to qtest_vFOO() for consistencyMarkus Armbruster2018-08-162-8/+8
| | | | | | | | | | | | | | | | | | | | | | 13 of 13 C99 library function pairs taking ... or a va_list parameter are called FOO() and vFOO(). In QEMU, we sometimes call the one taking a va_list FOOv() instead. Bad taste. libqtest.h uses both spellings. Normalize it to the standard spelling. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-24-armbru@redhat.com>
| * libqtest: Replace qtest_startf() by qtest_initf()Markus Armbruster2018-08-1623-82/+80Star
| | | | | | | | | | | | | | | | | | | | | | | | qtest_init() creates a new QTestState, and leaves @global_qtest alone. qtest_start() additionally assigns it to @global_qtest, but qtest_startf() additionally assigns NULL to @global_qtest. This makes no sense. Replace it by qtest_initf() that works like qtest_init(), i.e. leaves @global_qtest alone. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-23-armbru@redhat.com>
| * libqtest: Enable compile-time format string checkingMarkus Armbruster2018-08-161-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | qtest_qmp() & friends pass their format string and variable arguments to qobject_from_vjsonf_nofail(). Unlike qobject_from_jsonv(), they aren't decorated with GCC_FMT_ATTR(). Fix that to get compile-time format string checking. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-22-armbru@redhat.com>
| * migration-test: Clean up string interpolation into QMP, part 3Markus Armbruster2018-08-161-46/+30Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Leaving interpolation into JSON to qmp() is more robust than building QMP input manually, as explained in the recent commit "tests: Clean up string interpolation into QMP input (simple cases)". migration-test.c interpolates strings into JSON in a few places: * migrate_set_parameter() interpolates string parameter @value as a JSON number. Change it to long long. This requires changing migrate_check_parameter() similarly. * migrate_set_capability() interpolates string parameter @value as a JSON boolean. Change it to bool. * deprecated_set_speed() interpolates string parameter @value as a JSON number. Change it to long long. Bonus: gets rid of non-literal format strings. A step towards compile-time format string checking without triggering -Wformat-nonliteral. Cc: Juan Quintela <quintela@redhat.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-21-armbru@redhat.com>
| * migration-test: Clean up string interpolation into QMP, part 2Markus Armbruster2018-08-161-12/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Leaving interpolation into JSON to qmp() is more robust than building QMP input manually, as explained in the recent commit "tests: Clean up string interpolation into QMP input (simple cases)". migrate() interpolates members into a JSON object. Change it to take its extra QMP arguments as arguments for qdict_from_jsonf_nofail() instead of a string containing JSON members. Bonus: gets rid of a non-literal format string. A step towards compile-time format string checking without triggering -Wformat-nonliteral. Cc: Juan Quintela <quintela@redhat.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-20-armbru@redhat.com>
| * migration-test: Clean up string interpolation into QMP, part 1Markus Armbruster2018-08-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Leaving interpolation into JSON to qmp() is more robust than building QMP input manually, as explained in the recent commit "tests: Clean up string interpolation into QMP input (simple cases)". migrate_recover() builds QMP input manually because wait_command() can't interpolate. Well, it can since the previous commit. Simplify accordingly. Bonus: gets rid of a non-literal format string. A step towards compile-time format string checking without triggering -Wformat-nonliteral. Cc: Juan Quintela <quintela@redhat.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-19-armbru@redhat.com>
| * migration-test: Make wait_command() cope with '%'Markus Armbruster2018-08-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wait_command() passes its argument @command to qtest_qmp_send(). Falls apart if @command contain '%'. Two ways to disarm this trap: suppress interpretation of '%' by passing @command as argument to format string "%s", or fix it by having wait_command() take the variable arguments to go with @command. Do the latter. This is another step towards compile-time format string checking without triggering -Wformat-nonliteral. Cc: Juan Quintela <quintela@redhat.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-18-armbru@redhat.com>
| * tests: New helper qtest_qmp_receive_success()Markus Armbruster2018-08-164-67/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit b21373d0713 copied wait_command() from tests/migration-test.c to tests/tpm-util.c. Replace both copies by new libqtest helper qtest_qmp_receive_success(). Also use it to simplify qtest_qmp_device_del(). Bonus: gets rid of a non-literal format string. A step towards compile-time format string checking without triggering -Wformat-nonliteral. Cc: Thomas Huth <thuth@redhat.com> Cc: Juan Quintela <quintela@redhat.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Cc: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-17-armbru@redhat.com>
| * migration-test: Make wait_command() return the "return" memberMarkus Armbruster2018-08-161-23/+15Star
| | | | | | | | | | | | | | | | | | | | | | | | All callers of wait_command() are only interested in the success response's "return" member. Lift its extraction into wait_command(). Cc: Juan Quintela <quintela@redhat.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-16-armbru@redhat.com>
| * tests: Clean up string interpolation around qtest_qmp_device_add()Markus Armbruster2018-08-1618-58/+48Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Leaving interpolation into JSON to qmp() is more robust than building QMP input manually, as explained in the commit before previous. qtest_qmp_device_add() and its wrappers interpolate into JSON as follows: * qtest_qmp_device_add() interpolates members into a JSON object. * So do its wrappers qpci_plug_device_test() and usb_test_hotplug(). * usb_test_hotplug() additionally interpolates strings and numbers into JSON strings. Clean them up: * Have qtest_qmp_device_add() take its extra device properties as arguments for qdict_from_jsonf_nofail() instead of a string containing JSON members. * Drop qpci_plug_device_test(), use qtest_qmp_device_add() directly. * Change usb_test_hotplug() parameter @port to string, to avoid interpolation. Interpolate @hcd_id separately. Bonus: gets rid of a non-literal format string. A step towards compile-time format string checking without triggering -Wformat-nonliteral. Cc: Thomas Huth <thuth@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-15-armbru@redhat.com>
| * cpu-plug-test: Don't pass integers as strings to device_addMarkus Armbruster2018-08-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_plug_with_device_add_x86() plugs Haswell-i386-cpu and Haswell-x86_64-cpu with device_add. It passes socket-id, core-id, thread-id as JSON strings. The properties are actually integers. test_plug_with_device_add_coreid() plugs power8_v2.0-spapr-cpu-core and qemu-s390x-cpu with device_add. It passes core-id as JSON string. The properties are actually integers. Passing JSON string values to integer properties works only due to device_add implementation accidents. Fix the test to pass JSON numbers. While there, use %u rather than %i with unsigned int. Cc: Thomas Huth <thuth@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-14-armbru@redhat.com>
| * tests: Clean up string interpolation into QMP input (simple cases)Markus Armbruster2018-08-166-113/+78Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you build QMP input manually like this cmd = g_strdup_printf("{ 'execute': 'migrate'," "'arguments': { 'uri': '%s' } }", uri); rsp = qmp(cmd); g_free(cmd); you're responsible for escaping the interpolated values for JSON. Not done here, and therefore works only for sufficiently nice @uri. For instance, if @uri contained a single "'", qobject_from_vjsonf_nofail() would abort. A sufficiently nasty @uri could even inject unwanted members into the arguments object. Leaving interpolation into JSON to qmp() is more robust: rsp = qmp("{ 'execute': 'migrate', 'arguments': { 'uri': %s } }", uri); It's also more concise. Clean up the simple cases where we interpolate exactly a JSON value. Bonus: gets rid of non-literal format strings. A step towards compile-time format string checking without triggering -Wformat-nonliteral. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-13-armbru@redhat.com>
| * tests: Pass literal format strings directly to qmp_FOO()Markus Armbruster2018-08-162-6/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The qmp_FOO() take a printf-like format string. In a few places, we assign a string literal to a variable and pass that instead of simply passing the literal. Clean that up. Bonus: gets rid of non-literal format strings. A step towards compile-time format string checking without triggering -Wformat-nonliteral. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-12-armbru@redhat.com>
| * qobject: qobject_from_jsonv() is dangerous, hide it awayMarkus Armbruster2018-08-162-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | qobject_from_jsonv() takes ownership of %p arguments. On failure, we can't generally know whether we failed before or after %p, so ownership becomes indeterminate. To avoid leaks, callers passing %p must terminate on error, e.g. by passing &error_abort. Trap for the unwary; document and give the function internal linkage. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-11-armbru@redhat.com>
| * test-qobject-input-visitor: Avoid format string ambiguityMarkus Armbruster2018-08-161-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When visitor_input_test_init_internal()'s argument @ap is null, then @json_string is interpreted literally, else it's gets %-escapes interpolated. This is awkward. One caller always passes null @ap, and the others never do. Lift the building of the QObject into the callers, where it can be done without such ambiguity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-10-armbru@redhat.com>
| * libqtest: Simplify qmp_fd_vsend() a bitMarkus Armbruster2018-08-161-11/+7Star
| | | | | | | | | | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-9-armbru@redhat.com>
| * qobject: New qobject_from_vjsonf_nofail(), qdict_from_vjsonf_nofail()Markus Armbruster2018-08-162-7/+41
| | | | | | | | | | | | | | | | | | | | | | | | Every printf()-like function sooner or later needs its vprintf()-like buddy. The next commit will need qobject_from_jsonf_nofail()'s buddy, and qdict_from_jsonf_nofail()'s buddy will be used later in this series. Add both. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-8-armbru@redhat.com>
| * qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail()Markus Armbruster2018-08-164-22/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit ab45015a968 "qobject: Let qobject_from_jsonf() fail instead of abort" fails to accomplish its stated aim: the function can still abort due to its use of &error_abort. Its rationale for letting it fail is that all remaining users cope fine with failure. Well, they're just fine with aborting, too; it's what they do on failure. Simply reverting the broken commit would bring back the unfortunate asymmetry between qobject_from_jsonf() and qobject_from_jsonv(): one aborts, the other returns null. So also rename it to qobject_from_jsonf_nofail(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-7-armbru@redhat.com>
| * libqtest: Document calling conventionsEric Blake2018-08-161-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have two flavors of vararg usage in qtest: qtest_hmp() etc. work like sprintf(), and qtest_qmp() etc. work like qobject_from_jsonf(). Spell that out in the comments. Also add GCC_FMT_ATTR() to qtest_hmp() etc. so that the compiler can flag incorrect use. We have some cleanup work to do before we can do the same for qtest_qmp() etc. This would get us the same better-than-nothing checking we already have for qobject_from_jsonf(): common incorrect uses of supported conversion specifications will be flagged (e.g. passing a double for %d), but use of unsupported ones won't. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Rebased, comment wording tweaked, commit message rewritten] Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20180806065344.7103-6-armbru@redhat.com>
| * libqtest: Remove qtest_qmp_discard_response() & friendsMarkus Armbruster2018-08-1611-55/+34Star
| | | | | | | | | | | | | | | | | | | | | | | | | | qtest_qmp_discard_response(...) is shorthand for qobject_unref(qtest_qmp(...), except it's not actually shorter. Moreover, the presence of these functions encourage sloppy testing. Remove them from libqtest. Add them as macros to the tests that use them, with a TODO comment asking for cleanup. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-5-armbru@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com>
| * libqtest: Clean up how we read the QMP greetingMarkus Armbruster2018-08-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qtest_init() still uses the qtest_qmp_discard_response(s, "") hack to receive the greeting, even though we have qtest_qmp_receive() since commit 66e0c7b187e. Put it to use. Bonus: gets rid of an empty format string. A step towards compile-time format string checking without triggering -Wformat-zero-length. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-4-armbru@redhat.com>
| * libqtest: Clean up how we read device_del messagesMarkus Armbruster2018-08-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qtest_qmp_device_del() still uses the qmp("") hack to receive a message, even though we have qmp_receive() since commit 66e0c7b187e. Put it to use. Bonus: gets rid of empty format strings. A step towards compile-time format string checking without triggering -Wformat-zero-length. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-3-armbru@redhat.com>
| * libqtest: Rename functions to send QMP messagesMarkus Armbruster2018-08-165-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The functions to receive messages are called qtest_qmp_receive() and qmp_receive(), qmp_fd_receive(). The ones to send messages are called qtest_async_qmp(), qtest_async_qmpv(), qmp_async(), qmp_fd_send(), qmp_fd_sendv(). Inconsistent. Rename the *_async* ones to qmp_send(), qtest_qmp_send(), qtest_qmp_vsend(). Rename qmp_fd_sendv() to qmp_fd_vsend(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180806065344.7103-2-armbru@redhat.com>
* | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into stagingPeter Maydell2018-08-1535-302/+185Star
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Block layer patches: - Remove deprecated -drive options for geometry/serial/addr - luks: Allow shared writers if the parents allow them (share-rw=on) - qemu-img: Fix error when trying to convert to encrypted target image - mirror: Fail gracefully for source == target - I/O throttling: Fix behaviour during drain (always ignore the limits) - bdrv_reopen() related fixes for bs->options/explicit_options content - Documentation improvements # gpg: Signature made Wed 15 Aug 2018 12:11:43 BST # gpg: using RSA key 7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (21 commits) qapi: block: Remove mentions of error types which were removed block: Simplify append_open_options() block: Update bs->options if bdrv_reopen() succeeds block: Simplify bdrv_reopen_abort() block: Remove children options from bs->{options,explicit_options} qdict: Make qdict_extract_subqdict() accept dst = NULL block: drop empty .bdrv_close handlers block: make .bdrv_close optional qemu-img: fix regression copying secrets during convert mirror: Fail gracefully for source == target qapi/block: Document restrictions for node names block: Remove dead deprecation warning code block: Remove deprecated -drive option serial block: Remove deprecated -drive option addr block: Remove deprecated -drive geometry options luks: Allow share-rw=on throttle-groups: Don't allow timers without throttled requests qemu-iotests: Update 093 to improve the draining test throttle-groups: Skip the round-robin if a member is being drained qemu-iotests: Test removing a throttle group member with a pending timer ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * qapi: block: Remove mentions of error types which were removedPeter Krempa2018-08-151-4/+1Star
| | | | | | | | | | | | | | | | Most of the various error classes were removed prior to the 1.2 release. Remove mentions of the error classes which did not make it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: Simplify append_open_options()Alberto Garcia2018-08-151-5/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | This function returns a BDS's driver-specific options, excluding also those from its children. Since we have just removed all children options from bs->options there's no need to do this last step. We allow references to children, though ("backing": "node0"), so those we still have to remove. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: Update bs->options if bdrv_reopen() succeedsAlberto Garcia2018-08-151-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If bdrv_reopen() succeeds then bs->explicit_options is updated with the new values, but bs->options never changes. Here's an example: { "execute": "blockdev-add", "arguments": { "driver": "qcow2", "node-name": "hd0", "overlap-check": "all", "file": { "driver": "file", "filename": "hd0.qcow2" } } } After this, both bs->options and bs->explicit_options contain "overlap-check": "all". Now let's change that using qemu-io's reopen command: (qemu) qemu-io hd0 "reopen -o overlap-check=none" After this, bs->explicit_options contains the new value but bs->options still keeps the old one. This patch updates bs->options after a BDS has been successfully reopened. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: Simplify bdrv_reopen_abort()Alberto Garcia2018-08-151-5/+4Star
| | | | | | | | | | | | | | | | | | | | | | | | If a bdrv_reopen_multiple() call fails, then the explicit_options QDict has to be deleted for every entry in the reopen queue. This must happen regardless of whether that entry's bdrv_reopen_prepare() call succeeded or not. This patch simplifies the cleanup code a bit. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: Remove children options from bs->{options,explicit_options}Alberto Garcia2018-08-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When bdrv_open_inherit() opens a BlockDriverState the options QDict can contain options for some of its children, passed in the form of child-name.option=value So while each child is opened with that subset of options, those same options remain stored in the parent BDS, leaving (at least) two copies of each one of them ("child-name.option=value" in the parent and "option=value" in the child). Having the children options stored in the parent is unnecessary and it can easily lead to an inconsistent state: $ qemu-img create -f qcow2 hd0.qcow2 10M $ qemu-img create -f qcow2 -b hd0.qcow2 hd1.qcow2 $ qemu-img create -f qcow2 -b hd1.qcow2 hd2.qcow2 $ $QEMU -drive file=hd2.qcow2,node-name=hd2,backing.node-name=hd1 This opens a chain of images hd0 <- hd1 <- hd2. Now let's remove hd1 using block_stream: (qemu) block_stream hd2 0 hd0.qcow2 After this hd2 contains backing.node-name=hd1, which is no longer correct because hd1 doesn't exist anymore. This patch removes all children options from the parent dictionaries at the end of bdrv_open_inherit() and bdrv_reopen_queue_child(). Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qdict: Make qdict_extract_subqdict() accept dst = NULLAlberto Garcia2018-08-151-3/+8
| | | | | | | | | | | | | | | | | | | | | | This function extracts all options from a QDict starting with a certain prefix and puts them in a new QDict. We'll have a couple of cases where we simply want to discard those options instead of copying them, and that's what this patch does. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: drop empty .bdrv_close handlersVladimir Sementsov-Ogievskiy2018-08-156-32/+0Star
| | | | | | | | | | | | | | | | .bdrv_close handler is optional after previous commit, no needs to keep empty functions more. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: make .bdrv_close optionalVladimir Sementsov-Ogievskiy2018-08-152-2/+6
| | | | | | | | | | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qemu-img: fix regression copying secrets during convertDaniel P. Berrangé2018-08-151-17/+15Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the convert command is creating an output file that needs secrets, we need to ensure those secrets are passed to both the blk_new_open and bdrv_create API calls. This is done by qemu-img extracting all opts matching the name suffix "key-secret". Unfortunately the code doing this was run after the call to bdrv_create(), which meant the QemuOpts it was extracting secrets from was now empty. Previously this worked by luks as a bug meant the "key-secret" parameters were not purged from the QemuOpts. This bug was fixed in commit b76b4f604521e59f857d6177bc55f6f2e41fd392 Author: Kevin Wolf <kwolf@redhat.com> Date: Thu Jan 11 16:18:08 2018 +0100 qcow2: Use visitor for options in qcow2_create() Exposing the latent bug in qemu-img. This fix simply moves the copying of secrets to before the bdrv_create() call. Cc: qemu-stable@nongnu.org Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * mirror: Fail gracefully for source == targetKevin Wolf2018-08-153-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | blockdev-mirror with the same node for source and target segfaults today: A node is in its own backing chain, so mirror_start_job() decides that this is an active commit. When adding the intermediate nodes with block_job_add_bdrv(), it starts the iteration through the subchain with the backing file of source, though, so it never reaches target and instead runs into NULL at the base. While we could fix that by starting with source itself, there is no point in allowing mirroring a node into itself and I wouldn't be surprised if this caused more problems later. So just check for this scenario and error out. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
| * qapi/block: Document restrictions for node namesKevin Wolf2018-08-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | blockdev-add fails if an invalid node name is given, so we should document what a valid node name even is. Reported-by: Cong Li <coli@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Cong Li <coli@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com>
| * block: Remove dead deprecation warning codeKevin Wolf2018-08-151-12/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | This reinstates commit 6266e900b8083945cb766b45c124fb3c42932cb3, which was temporarily reverted for the 3.0 release so that libvirt gets some extra time to update their command lines. We removed all options from the 'deprecated' array, so the code is dead and can be removed as well. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
| * block: Remove deprecated -drive option serialKevin Wolf2018-08-1514-48/+8Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reinstates commit b0083267444a5e0f28391f6c2831a539f878d424, which was temporarily reverted for the 3.0 release so that libvirt gets some extra time to update their command lines. The -drive option serial was deprecated in QEMU 2.10. It's time to remove it. Tests need to be updated to set the serial number with -global instead of using the -drive option. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com>
| * block: Remove deprecated -drive option addrKevin Wolf2018-08-155-30/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | | | This reinstates commit eae3bd1eb7c6b105d30ec06008b3bc3dfc5f45bb, which was temporarily reverted for the 3.0 release so that libvirt gets some extra time to update their command lines. The -drive option addr was deprecated in QEMU 2.10. It's time to remove it. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com>
| * block: Remove deprecated -drive geometry optionsKevin Wolf2018-08-157-131/+9Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reinstates commit a7aff6dd10b16b67e8b142d0c94c5d92c3fe88f6, which was temporarily reverted for the 3.0 release so that libvirt gets some extra time to update their command lines. The -drive options cyls, heads, secs and trans were deprecated in QEMU 2.10. It's time to remove them. hd-geo-test tested both the old version with geometry options in -drive and the new one with -device. Therefore the code using -drive doesn't have to be replaced there, we just need to remove the -drive test cases. This in turn allows some simplification of the code. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
| * luks: Allow share-rw=onFam Zheng2018-08-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Format drivers such as qcow2 don't allow sharing the same image between two QEMU instances in order to prevent image corruptions, because of metadata cache. LUKS driver don't modify metadata except for when creating image, so it is safe to relax the permission. This makes share-rw=on property work on virtual devices. Suggested-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>