aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-11-02watchdog: remove select_watchdog_actionPaolo Bonzini4-23/+17
Instead of invoking select_watchdog_action from both HMP and command line, go directly from HMP to QMP and use QemuOpts as the intermediary for the command line. This makes -watchdog-action explicitly a shortcut for "-action watchdog", so that "-watchdog-action" and "-action watchdog" override each other based on the position on the command line; previously, "-action watchdog" always won. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02vl: deprecate -watchdogPaolo Bonzini2-0/+6
-watchdog is the same as -device except that it is case insensitive (and it allows only watchdog devices of course). Now that "-device help" can list as such the available watchdog devices, we can deprecate it. Note that even though -watchdog tries to be case insensitive, it fails at that: "-watchdog i6300xyz" fails with "Unknown -watchdog device", but "-watchdog i6300ESB" also fails (when the generated -device option is processed) with an error "'i6300ESB' is not a valid device model name". For this reason, the documentation update does not mention the case insensitivity of -watchdog. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02watchdog: add information from -watchdog help to -device helpPaolo Bonzini8-7/+14
List all watchdog devices in a separate category, and populate their descriptions. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02hw/i386: Rename default_bus_bypass_iommuJean-Philippe Brucker1-1/+1
Since commit d8fb7d0969d5 ("vl: switch -M parsing to keyval"), machine parameter definitions cannot use underscores, because keyval_dashify() transforms them to dashes and the parser doesn't find the parameter. This affects option default_bus_bypass_iommu which was introduced in the same release: $ qemu-system-x86_64 -M q35,default_bus_bypass_iommu=on qemu-system-x86_64: Property 'pc-q35-6.1-machine.default-bus-bypass-iommu' not found Rename the parameter to "default-bus-bypass-iommu". Passing "default_bus_bypass_iommu" is still valid since the underscore are transformed automatically. Fixes: c9e96b04fc19 ("hw/i386: Add a default_bus_bypass_iommu pc machine option") Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Message-Id: <20211025104737.1560274-1-jean-philippe@linaro.org> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02hvf: Avoid mapping regions < PAGE_SIZE as ramAlexander Graf1-0/+7
HVF has generic memory listener code that adds all RAM regions as HVF RAM regions. However, HVF can only handle page aligned, page granule regions. So let's ignore regions that are not page aligned and sized. They will be trapped as MMIO instead. Signed-off-by: Alexander Graf <agraf@csgraf.de> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20211025132147.28308-1-agraf@csgraf.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02configure: do not duplicate CPU_CFLAGS into QEMU_LDFLAGSPaolo Bonzini1-39/+14
Since commit 4dba2789084 ("configure, meson: move CPU_CFLAGS out of QEMU_CFLAGS"), CPU_CFLAGS is included in the link commands both during configure and (via config-meson.cross) during meson. It need not be added separately to QEMU_LDFLAGS. Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02configure: remove useless NPTL probePaolo Bonzini1-19/+0
Using a linuxthreads system with a recent QEMU will have bigger problems than just not having NPTL. Remove the unnecessary check. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02target/i386: use DMA-enabled multiboot ROM for new-enough QEMU machine typesPaolo Bonzini4-5/+14
As long as fw_cfg supports DMA, the new ROM can be used also on older machine types because it has the same size as the existing one. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02optionrom: add a DMA-enabled multiboot ROMMarcus Hähnel6-5/+72
Add a new option rom for the multiboot loader, using DMA transfers to copy data instead of "rep insb". This significantly lowers QEMU's startup latency by a factor of about 40, for example, going from 30sec to 0.8sec when loading modules of 120MB in size. Signed-off-by: Marcus Hähnel <marcus.haehnel@kernkonzept.com> Signed-off-by: Adam Lackorzynski <adam@l4re.org> [Modified to keep the non-DMA code depending on #ifdef USE_FW_CFG_DMA; do not write below stack. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02target/i386: move linuxboot_dma_enabled to X86MachineStatePaolo Bonzini7-13/+16
This removes a parameter from x86_load_linux, and will avoid code duplication between the linux and multiboot cases once multiboot starts to support DMA. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02MAINTAINERS: update location of microvm docsAlex Bennée1-1/+1
Fixes: e8eee8d3d9 ("docs: Move microvm.rst into the system manual") Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20211012151447.4147923-1-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02util: Make some iova_tree parameters constEugenio Pérez3-11/+11
As qemu guidelines: Unless a pointer is used to modify the pointed-to storage, give it the "const" attribute. In the particular case of iova_tree_find it allows to enforce what is requested by its comment, since the compiler would shout in case of modifying or freeing the const-qualified returned pointer. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Acked-by: Peter Xu <peterx@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20211013182713.888753-2-eperezma@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02configure/optionrom: Fix MSYS2 multiboot.bin issueHelge Konetzka2-3/+6
This patch enables native builds on MSYS2 with symlinks disabled. Signed-off-by: Helge Konetzka <hk@zapateado.de> Message-Id: <2b5ab039-8495-b55f-03f1-ecfd996907a9@zapateado.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02Partially revert "build: -no-pie is no functional linker flag"Jessica Clarke1-1/+4
This partially reverts commit bbd2d5a8120771ec59b86a80a1f51884e0a26e53. This commit was misguided and broke using --disable-pie on any distro that enables PIE by default in their compiler driver, including Debian and its derivatives. Whilst -no-pie is not a linker flag, it is a compiler driver flag that ensures -pie is not automatically passed by it to the linker. Without it, all compile_prog checks will fail as any code built with the explicit -fno-pie will fail to link with the implicit default -pie due to trying to use position-dependent relocations. The only bug that needed fixing was LDFLAGS_NOPIE being used as a flag for the linker itself in pc-bios/optionrom/Makefile. Note this does not reinstate exporting LDFLAGS_NOPIE, as it is unused, since the only previous use was the one that should not have existed. I have also updated the comment for the -fno-pie and -no-pie checks to reflect what they're actually needed for. Fixes: bbd2d5a8120771ec59b86a80a1f51884e0a26e53 Cc: Christian Ehrhardt <christian.ehrhardt@canonical.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> Message-Id: <20210805192545.38279-1-jrtc27@jrtc27.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02Makefile: Fix cscope issues on MacOS and soft linksPeter Xu1-1/+2
This patch fixes actually two issues with 'make cscope'. Firstly, it fixes the command for MacOS "find" command as MacOS will append the full path of "$(SRC_PATH)/" before each found entry, then after the final "./" replacement trick it'll look like (e.g., "qapi/qmp-dispatch.c"): /qapi/qmp-dispatch.c Which will point to the root directory instead. Fix it by simply remove the "/" in "$(SRC_PATH)/" of "find-src-path", then it'll work for at least both Linux and MacOS. The other OS-independent issue is to start proactively ignoring soft links when generating tags, otherwise by default on master branch we'll see this error when "make cscope": cscope: cannot find file subprojects/libvhost-user/include/atomic.h This patch should fix the two issues altogether. Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20210804132328.41353-3-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02Makefile: Fix gtags generationPeter Xu1-1/+1
We should use "-print" or otherwise all "-prone" is ignored. Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20210804132328.41353-2-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-02Merge remote-tracking branch 'remotes/mcayland/tags/qemu-openbios-20211101' ↵Richard Henderson4-0/+0
into staging qemu-openbios queue # gpg: Signature made Mon 01 Nov 2021 05:51:08 PM EDT # gpg: using RSA key CC621AB98E82200D915CC9C45BC2C56FAE0F321F # gpg: issuer "mark.cave-ayland@ilande.co.uk" # gpg: Good signature from "Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>" [full] * remotes/mcayland/tags/qemu-openbios-20211101: roms/openbios: update OpenBIOS images to b9062dea built from submodule Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-11-02Merge remote-tracking branch ↵Richard Henderson2-1/+25
'remotes/alex.williamson/tags/vfio-update-20211101.0' into staging VFIO update 2021-11-01 * Re-enable expanded sub-page BAR mappings after migration (Kunkun Jiang) * Trace dropped listener sections due to page alignment (Kunkun Jiang) # gpg: Signature made Mon 01 Nov 2021 03:48:28 PM EDT # gpg: using RSA key 42F6C04E540BD1A99E7B8A90239B9B6E3BB08B22 # gpg: issuer "alex.williamson@redhat.com" # gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>" [full] # gpg: aka "Alex Williamson <alex@shazbot.org>" [full] # gpg: aka "Alex Williamson <alwillia@redhat.com>" [full] # gpg: aka "Alex Williamson <alex.l.williamson@gmail.com>" [full] * remotes/alex.williamson/tags/vfio-update-20211101.0: vfio/common: Add a trace point when a MMIO RAM section cannot be mapped vfio/pci: Add support for mmapping sub-page MMIO BARs after live migration Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-11-02Merge remote-tracking branch 'remotes/philmd/tags/machine-20211101' into stagingRichard Henderson13-437/+1145
Machine core patches - Move GPIO code out of qdev.c - Move hotplug code out of qdev.c - Restrict various files to sysemu - Move SMP code out of machine.c - Add SMP parsing unit tests - Move dynamic sysbus device check earlier # gpg: Signature made Mon 01 Nov 2021 02:44:32 PM EDT # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full] * remotes/philmd/tags/machine-20211101: machine: remove the done notifier for dynamic sysbus device type check qdev-monitor: Check sysbus device type before creating it machine: add device_type_is_dynamic_sysbus function tests/unit: Add an unit test for smp parsing hw/core/machine: Split out the smp parsing code hw/core: Restrict hotplug to system emulation hw/core: Extract hotplug-related functions to qdev-hotplug.c hw/core: Declare meson source set hw/core: Restrict sysemu specific files machine: Move gpio code to hw/core/gpio.c Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-11-01roms/openbios: update OpenBIOS images to b9062dea built from submoduleMark Cave-Ayland4-0/+0
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-11-01machine: remove the done notifier for dynamic sysbus device type checkDamien Hedde2-28/+0
Now that we check sysbus device types during device creation, we can remove the check in the machine init done notifier. This was the only thing done by this notifier, so we remove the whole sysbus_notifier structure of the MachineState. Note: This notifier was checking all /peripheral and /peripheral-anon sysbus devices. Now we only check those added by -device cli option or device_add qmp command when handling the command/option. So if there are some devices added in one of these containers manually (eg in machine C code), these will not be checked anymore. This use case does not seem to appear apart from hw/xen/xen-legacy-backend.c (it uses qdev_set_id() and in this case, not for a sysbus device, so it's ok). Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> Acked-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211029142258.484907-4-damien.hedde@greensocs.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2021-11-01qdev-monitor: Check sysbus device type before creating itDamien Hedde1-0/+11
Add an early check to test if the requested sysbus device type is allowed by the current machine before creating the device. This impacts both -device cli option and device_add qmp command. Before this patch, the check was done well after the device has been created (in a machine init done notifier). We can now report the error right away. Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211029142258.484907-3-damien.hedde@greensocs.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2021-11-01machine: add device_type_is_dynamic_sysbus functionDamien Hedde2-3/+25
Right now the allowance check for adding a sysbus device using -device cli option (or device_add qmp command) is done well after the device has been created. It is done during the machine init done notifier: machine_init_notify() in hw/core/machine.c This new function will allow us to do the check at the right time and issue an error if it fails. Also make device_is_dynamic_sysbus() use the new function. Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211029142258.484907-2-damien.hedde@greensocs.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2021-11-01tests/unit: Add an unit test for smp parsingYanan Wang3-0/+596
Now that we have a generic parser smp_parse(), let's add an unit test for the code. All possible valid/invalid SMP configurations that the user can specify are covered. Signed-off-by: Yanan Wang <wangyanan55@huawei.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20211026034659.22040-3-wangyanan55@huawei.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <bfed7144-af86-7098-e7a6-731ff13c2cf7@huawei.com> [PMD: Squashed format string fixup from Yanan Wang] Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2021-11-01hw/core/machine: Split out the smp parsing codeYanan Wang5-159/+184
We are going to introduce an unit test for the parser smp_parse() in hw/core/machine.c, but now machine.c is only built in softmmu. In order to solve the build dependency on the smp parsing code and avoid building unrelated stuff for the unit tests, move the tested code from machine.c into a separate file, i.e., machine-smp.c and build it in common field. Signed-off-by: Yanan Wang <wangyanan55@huawei.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20211026034659.22040-2-wangyanan55@huawei.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2021-11-01hw/core: Restrict hotplug to system emulationPhilippe Mathieu-Daudé2-2/+44
Restrict hotplug to system emulation, add stubs for the other uses. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Yanan Wang <wangyanan55@huawei.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211028150521.1973821-5-philmd@redhat.com>
2021-11-01hw/core: Extract hotplug-related functions to qdev-hotplug.cPhilippe Mathieu-Daudé3-60/+74
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Yanan Wang <wangyanan55@huawei.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211028150521.1973821-4-philmd@redhat.com>
2021-11-01hw/core: Declare meson source setPhilippe Mathieu-Daudé2-3/+5
As we want to be able to conditionally add files to the hw/core file list, use a source set. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Yanan Wang <wangyanan55@huawei.com> Tested-by: Yanan Wang <wangyanan55@huawei.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211028150521.1973821-3-philmd@redhat.com>
2021-11-01hw/core: Restrict sysemu specific filesPhilippe Mathieu-Daudé1-9/+9
All these files don't make sense for tools and user emulation, restrict them to system emulation. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Yanan Wang <wangyanan55@huawei.com> Tested-by: Yanan Wang <wangyanan55@huawei.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20211028150521.1973821-2-philmd@redhat.com>
2021-11-01machine: Move gpio code to hw/core/gpio.cEduardo Habkost3-174/+198
Only softmmu code uses gpio, so move gpio code from qdev.c to gpio.c and compile it only on softmmu mode. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20190425200051.19906-2-ehabkost@redhat.com> [PMD: Rebased] Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2021-11-01Merge remote-tracking branch 'remotes/jsnow/tags/python-pull-request' into ↵Richard Henderson16-122/+427
staging Pull request # gpg: Signature made Mon 01 Nov 2021 01:29:49 PM EDT # gpg: using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full] * remotes/jsnow/tags/python-pull-request: (22 commits) python, iotests: replace qmp with aqmp python/aqmp: Create sync QMP wrapper for iotests iotests/300: avoid abnormal shutdown race condition iotests: Conditionally silence certain AQMP errors iotests: Accommodate async QMP Exception classes python/aqmp: Remove scary message python/machine: Handle QMP errors on close more meticulously python/machine: remove has_quit argument python: Add iotest linters to test suite iotests/linters: Add workaround for mypy bug #9852 iotests/linters: Add entry point for linting via Python CI iotests: split linters.py out from 297 iotests/297: split test into sub-cases iotests/297: update tool availability checks iotests/297: Change run_linter() to raise an exception on failure iotests/297: refactor run_[mypy|pylint] as generic execution shim iotests/297: Split run_linters apart into run_pylint and run_mypy iotests/297: Don't rely on distro-specific linter binaries iotests/297: Create main() function iotests/297: Add get_files() function ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-11-01vfio/common: Add a trace point when a MMIO RAM section cannot be mappedKunkun Jiang1-0/+7
The MSI-X structures of some devices and other non-MSI-X structures may be in the same BAR. They may share one host page, especially in the case of large page granularity, such as 64K. For example, MSIX-Table size of 82599 NIC is 0x30 and the offset in Bar 3(size 64KB) is 0x0. vfio_listener_region_add() will be called to map the remaining range (0x30-0xffff). If host page size is 64KB, it will return early at 'int128_ge((int128_make64(iova), llend))' without any message. Let's add a trace point to inform users like commit 5c08600547c0 ("vfio: Use a trace point when a RAM section cannot be DMA mapped") did. Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com> Link: https://lore.kernel.org/r/20211027090406.761-3-jiangkunkun@huawei.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-11-01vfio/pci: Add support for mmapping sub-page MMIO BARs after live migrationKunkun Jiang1-1/+18
We can expand MemoryRegions of sub-page MMIO BARs in vfio_pci_write_config() to improve IO performance for some devices. However, the MemoryRegions of destination VM are not expanded any more after live migration. Because their addresses have been updated in vmstate_load_state() (vfio_pci_load_config) and vfio_sub_page_bar_update_mapping() will not be called. This may result in poor performance after live migration. So iterate BARs in vfio_pci_load_config() and try to update sub-page BARs. Reported-by: Nianyao Tang <tangnianyao@huawei.com> Reported-by: Qixin Gan <ganqixin@huawei.com> Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com> Link: https://lore.kernel.org/r/20211027090406.761-2-jiangkunkun@huawei.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-11-01python, iotests: replace qmp with aqmpJohn Snow1-1/+6
Swap out the synchronous QEMUMonitorProtocol from qemu.qmp with the sync wrapper from qemu.aqmp instead. Add an escape hatch in the form of the environment variable QEMU_PYTHON_LEGACY_QMP which allows you to cajole QEMUMachine into using the old implementation, proving that both implementations work concurrently. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211026175612.4127598-9-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01python/aqmp: Create sync QMP wrapper for iotestsJohn Snow1-0/+138
This is a wrapper around the async QMPClient that mimics the old, synchronous QEMUMonitorProtocol class. It is designed to be interchangeable with the old implementation. It does not, however, attempt to mimic Exception compatibility. Signed-off-by: John Snow <jsnow@redhat.com> Acked-by: Hanna Reitz <hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211026175612.4127598-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/300: avoid abnormal shutdown race conditionJohn Snow1-8/+5
Wait for the destination VM to close itself instead of racing to shut it down first, which produces different error log messages from AQMP depending on precisely when we tried to shut it down. (For example: We may try to issue 'quit' immediately prior to the target VM closing its QMP socket, which will cause an ECONNRESET error to be logged. Waiting for the VM to exit itself avoids the race on shutdown behavior.) Reported-by: Hanna Reitz <hreitz@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211026175612.4127598-7-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests: Conditionally silence certain AQMP errorsJohn Snow2-5/+27
AQMP likes to be very chatty about errors it encounters. In general, this is good because it allows us to get good diagnostic information for otherwise complex async failures. For example, during a failed QMP connection attempt, we might see: +ERROR:qemu.aqmp.qmp_client.qemub-2536319:Negotiation failed: EOFError +ERROR:qemu.aqmp.qmp_client.qemub-2536319:Failed to establish session: EOFError This might be nice in iotests output, because failure scenarios involving the new QMP library will be spelled out plainly in the output diffs. For tests that are intentionally causing this scenario though, filtering that log output could be a hassle. For now, add a context manager that simply lets us toggle this output off during a critical region. (Additionally, a forthcoming patch allows the use of either legacy or async QMP to be toggled with an environment variable. In this circumstance, we can't amend the iotest output to just always expect the error message, either. Just suppress it for now. More rigorous log filtering can be investigated later if/when it is deemed safe to permanently replace the legacy QMP library.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20211026175612.4127598-6-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests: Accommodate async QMP Exception classesJohn Snow2-3/+5
(But continue to support the old ones for now, too.) There are very few cases of any user of QEMUMachine or a subclass thereof relying on a QMP Exception type. If you'd like to check for yourself, you want to grep for all of the derivatives of QMPError, excluding 'AQMPError' and its derivatives. That'd be these: - QMPError - QMPConnectError - QMPCapabilitiesError - QMPTimeoutError - QMPProtocolError - QMPResponseError - QMPBadPortError Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20211026175612.4127598-5-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01python/aqmp: Remove scary messageJohn Snow1-12/+0
The scary message interferes with the iotests output. Coincidentally, if iotests works by removing this, then it's good evidence that we don't really need to scare people away from using it. Signed-off-by: John Snow <jsnow@redhat.com> Acked-by: Hanna Reitz <hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211026175612.4127598-4-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01python/machine: Handle QMP errors on close more meticulouslyJohn Snow1-6/+42
To use the AQMP backend, Machine just needs to be a little more diligent about what happens when closing a QMP connection. The operation is no longer a freebie in the async world; it may return errors encountered in the async bottom half on incoming message receipt, etc. (AQMP's disconnect, ultimately, serves as the quiescence point where all async contexts are gathered together, and any final errors reported at that point.) Because async QMP continues to check for messages asynchronously, it's almost certainly likely that the loop will have exited due to EOF after issuing the last 'quit' command. That error will ultimately be bubbled up when attempting to close the QMP connection. The manager class here then is free to discard it -- if it was expected. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20211026175612.4127598-3-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01python/machine: remove has_quit argumentJohn Snow4-23/+22
If we spy on the QMP commands instead, we don't need callers to remember to pass it. Seems like a fair trade-off. The one slightly weird bit is overloading this instance variable for wait(), where we use it to mean "don't issue the qmp 'quit' command". This means that wait() will "fail" if the QEMU process does not terminate of its own accord. In most cases, we probably did already actually issue quit -- some iotests do this -- but in some others, we may be waiting for QEMU to terminate for some other reason, such as a test wherein we tell the guest (directly) to shut down. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20211026175612.4127598-2-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01python: Add iotest linters to test suiteJohn Snow2-0/+8
Run mypy and pylint on the iotests files directly from the Python CI test infrastructure. This ensures that any accidental breakages to the qemu.[qmp|aqmp|machine|utils] packages will be caught by that test suite. It also ensures that these linters are run with well-known versions and test against a wide variety of python versions, which helps to find accidental cross-version python compatibility issues. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-15-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/linters: Add workaround for mypy bug #9852John Snow1-1/+3
This one is insidious: if you write an import as "from {namespace} import {subpackage}" as mirror-top-perms (now) does, mypy will fail on every-other invocation *if* the package being imported is a typed, installed, namespace-scoped package. Upsettingly, that's exactly what 'qemu.[aqmp|qmp|machine]' et al are in the context of Python CI tests. Now, I could just edit mirror-top-perms to avoid this invocation, but since I tripped on a landmine, I might as well head it off at the pass and make sure nobody else trips on that same landmine. It seems to have something to do with the order in which files are checked as well, meaning the random order in which set(os.listdir()) produces the list of files to test will cause problems intermittently and not just strictly "every other run". This will be fixed in mypy >= 0.920, which is not released yet. The workaround for now is to disable incremental checking, which avoids the issue. Note: This workaround is not applied when running iotest 297 directly, because the bug does not surface there! Given the nature of CI jobs not starting with any stale cache to begin with, this really only has a half-second impact on manual runs of the Python test suite when executed directly by a developer on their local machine. The workaround may be removed when the Python package requirements can stipulate mypy 0.920 or higher, which can happen as soon as it is released. (Barring any unforseen compatibility issues that 0.920 may bring with it.) See also: https://github.com/python/mypy/issues/11010 https://github.com/python/mypy/issues/9852 Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-14-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/linters: Add entry point for linting via Python CIJohn Snow1-0/+27
We need at least a tiny little shim here to join test file discovery with test invocation. This logic could conceivably be hosted somewhere in python/, but I felt it was strictly the least-rude thing to keep the test logic here in iotests/, even if this small function isn't itself an iotest. Note that we don't actually even need the executable bit here, we'll be relying on the ability to run this module as a script using Python CLI arguments. No chance it gets misunderstood as an actual iotest that way. (It's named, not in tests/, doesn't have the execute bit, and doesn't have an execution shebang.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-13-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests: split linters.py out from 297John Snow2-61/+87
Now, 297 is just the iotests-specific incantations and linters.py is as minimal as I can think to make it. The only remaining element in here that ought to be configuration and not code is the list of skip files, but they're still numerous enough that repeating them for mypy and pylint configurations both would be ... a hassle. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-12-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/297: split test into sub-casesJohn Snow1-23/+38
Take iotest 297's main() test function and split it into two sub-cases that can be skipped individually. We can also drop custom environment setup from the pylint test as it isn't needed. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-11-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/297: update tool availability checksJohn Snow1-4/+5
As mentioned in 'iotests/297: Don't rely on distro-specific linter binaries', these checks are overly strict. Update them to be in-line with how we actually invoke the linters themselves. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-10-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/297: Change run_linter() to raise an exception on failureJohn Snow1-10/+14
Instead of using a process return code as the python function return value (or just not returning anything at all), allow run_linter() to raise an exception instead. The responsibility for printing output on error shifts from the function itself to the caller, who will know best how to present/format that information. (Also, "suppress_output" is now a lot more accurate of a parameter name.) Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-9-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/297: refactor run_[mypy|pylint] as generic execution shimJohn Snow1-22/+24
There's virtually nothing special here anymore; we can combine these into a single, rather generic function. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-11-01iotests/297: Split run_linters apart into run_pylint and run_mypyJohn Snow1-14/+24
Move environment setup into main(), and split the actual linter execution into run_pylint and run_mypy, respectively. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-id: 20211019144918.3159078-7-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>