Re: [QEMU][PATCH v1 5/7] memory: add MemoryRegion map and unmap callbacks

2023-10-11 Thread Juergen Gross
On 10.10.23 02:17, Stefano Stabellini wrote: On Thu, 5 Oct 2023, Vikram Garhwal wrote: From: Juergen Gross In order to support mapping and unmapping guest memory dynamically to and from qemu during address_space_[un]map() operations add the map() and unmap() callbacks to MemoryRegionOps. Thos

[PATCH v9 01/23] target/riscv: Move MISA limits to class

2023-10-11 Thread Akihiko Odaki
MISA limits are common for all instances of a RISC-V CPU class so they are better put into class. Signed-off-by: Akihiko Odaki --- target/riscv/cpu-qom.h | 2 + target/riscv/cpu.h | 2 - hw/riscv/boot.c | 2 +- target/riscv/cpu.c | 212 +++

[PATCH v9 07/23] target/arm: Use GDBFeature for dynamic XML

2023-10-11 Thread Akihiko Odaki
In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Acked-by: Richard Henderson --- target/arm/cpu.h | 21 +++ target/arm/internal

[PATCH v9 11/23] gdbstub: Use GDBFeature for GDBRegisterState

2023-10-11 Thread Akihiko Odaki
Simplify GDBRegisterState by replacing num_regs and xml members with one member that points to GDBFeature. Signed-off-by: Akihiko Odaki --- gdbstub/gdbstub.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 20586e0b6a.

[PATCH v9 13/23] gdbstub: Simplify XML lookup

2023-10-11 Thread Akihiko Odaki
Now we know all instances of GDBFeature that is used in CPU so we can traverse them to find XML. This removes the need for a CPU-specific lookup function for dynamic XMLs. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 2 + gdbstub/gdbstub.c | 85 +++-

[PATCH v9 16/23] gdbstub: Add members to identify registers to GDBFeature

2023-10-11 Thread Akihiko Odaki
These members will be used to help plugins to identify registers. The added members in instances of GDBFeature dynamically generated by CPUs will be filled in later changes. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 3 +++ gdbstub/gdbstub.c | 10 -- target/riscv/g

[PATCH v9 04/23] gdbstub: Add num_regs member to GDBFeature

2023-10-11 Thread Akihiko Odaki
Currently the number of registers exposed to GDB is written as magic numbers in code. Derive the number of registers GDB actually see from XML files to replace the magic numbers in code later. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- include

[PATCH v9 23/23] plugins: Support C++

2023-10-11 Thread Akihiko Odaki
Make qemu-plugin.h consumable for C++ platform. Signed-off-by: Akihiko Odaki --- docs/devel/tcg-plugins.rst | 4 meson.build| 2 +- include/qemu/qemu-plugin.h | 4 tests/plugin/cc.cc | 16 tests/plugin/meson.build | 5 + tests/tcg/Make

[PATCH v9 22/23] contrib/plugins: Allow to log registers

2023-10-11 Thread Akihiko Odaki
This demonstrates how a register can be read from a plugin. Signed-off-by: Akihiko Odaki --- docs/devel/tcg-plugins.rst | 10 +++- contrib/plugins/execlog.c | 120 +++-- 2 files changed, 97 insertions(+), 33 deletions(-) diff --git a/docs/devel/tcg-plugins.rst

[PATCH v9 12/23] gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb

2023-10-11 Thread Akihiko Odaki
Align the parameters of gdb_get_reg_cb and gdb_set_reg_cb with the gdb_read_register and gdb_write_register members of CPUClass to allow to unify the logic to access registers of the core and coprocessors in the future. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 4 +- target

[PATCH v9 19/23] plugins: Remove an extra parameter

2023-10-11 Thread Akihiko Odaki
copy_call() has an unused parameter so remove it. Signed-off-by: Akihiko Odaki --- accel/tcg/plugin-gen.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 39b3c9351f..78b331b251 100644 --- a/accel/tcg/plugin-gen.c

[PATCH v9 17/23] gdbstub: Expose functions to read registers

2023-10-11 Thread Akihiko Odaki
gdb_find_feature() and gdb_find_feature_register() find registers. gdb_read_register() actually reads registers. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 5 + gdbstub/gdbstub.c | 31 ++- 2 files changed, 35 insertions(+), 1 deletion(-) diff

[PATCH v9 21/23] plugins: Allow to read registers

2023-10-11 Thread Akihiko Odaki
It is based on GDB protocol to ensure interface stability. The timing of the vcpu init hook is also changed so that the hook will get called after GDB features are initialized. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1706 Signed-off-by: Akihiko Odaki --- include/qemu/qemu-plugin

[PATCH v9 00/23] plugins: Allow to read registers

2023-10-11 Thread Akihiko Odaki
Based-on: <20231009164104.369749-4-alex.ben...@linaro.org> ("[PATCH 00/25] October maintainer omnibus pre-PR (tests, gdbstub, plugins)") I and other people in the University of Tokyo, where I research processor design, found TCG plugins are very useful for processor design exploration. The featur

[PATCH v9 10/23] gdbstub: Use GDBFeature for gdb_register_coprocessor

2023-10-11 Thread Akihiko Odaki
This is a tree-wide change to introduce GDBFeature parameter to gdb_register_coprocessor(). The new parameter just replaces num_regs and xml parameters for now. GDBFeature will be utilized to simplify XML lookup in a following change. Signed-off-by: Akihiko Odaki Acked-by: Alex Bennée --- inclu

[PATCH v9 09/23] target/riscv: Use GDBFeature for dynamic XML

2023-10-11 Thread Akihiko Odaki
In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki --- target/riscv/cpu.h | 5 +-- target/riscv/cpu.c | 4 +-- target/riscv/gdbstub

[PATCH v9 18/23] cpu: Call plugin hooks only when ready

2023-10-11 Thread Akihiko Odaki
The initialization and exit hooks will not affect the state of vCPU outside TCG context, but they may depend on the state of vCPU. Therefore, it's better to call plugin hooks after the vCPU state is fully initialized and before it gets uninitialized. Signed-off-by: Akihiko Odaki --- cpu-target.c

[PATCH v9 06/23] gdbstub: Introduce GDBFeatureBuilder

2023-10-11 Thread Akihiko Odaki
GDBFeatureBuilder unifies the logic to generate dynamic GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson --- include/exec/gdbstub.h | 20 ++ gdbstub/gdbstub.c | 59 ++ 2 files changed, 79 insertions(+) diff --git a

[PATCH v9 08/23] target/ppc: Use GDBFeature for dynamic XML

2023-10-11 Thread Akihiko Odaki
In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Richard Henderson --- target/ppc/cpu-qom.h | 4 ++-- target/ppc/cpu.h

[PATCH v9 20/23] plugins: Use different helpers when reading registers

2023-10-11 Thread Akihiko Odaki
This avoids optimizations incompatible when reading registers. Signed-off-by: Akihiko Odaki --- accel/tcg/plugin-helpers.h | 3 ++- include/exec/plugin-gen.h | 4 ++-- include/hw/core/cpu.h | 4 ++-- include/qemu/plugin.h | 3 +++ plugins/plugin.h | 5 +++-- accel/tcg/p

[PATCH v9 15/23] hw/core/cpu: Remove gdb_get_dynamic_xml member

2023-10-11 Thread Akihiko Odaki
This function is no longer used. Signed-off-by: Akihiko Odaki --- include/hw/core/cpu.h | 4 target/arm/cpu.h | 6 -- target/ppc/cpu.h | 1 - target/arm/cpu.c | 1 - target/arm/gdbstub.c | 18 -- target/ppc/cpu_init.c | 3 --- target/ppc/gdbstub.c |

[PATCH v9 02/23] target/riscv: Remove misa_mxl validation

2023-10-11 Thread Akihiko Odaki
It is initialized with a simple assignment and there is little room for error. In fact, the validation is even more complex. Signed-off-by: Akihiko Odaki --- target/riscv/cpu.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/c

[PATCH v9 05/23] gdbstub: Introduce gdb_find_static_feature()

2023-10-11 Thread Akihiko Odaki
This function is useful to determine the number of registers exposed to GDB from the XML name. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- include/exec/gdbstub.h | 2 ++ gdbstub/gdbstub.c | 13 +

[PATCH v9 14/23] gdbstub: Infer number of core registers from XML

2023-10-11 Thread Akihiko Odaki
GDBFeature has the num_regs member so use it where applicable to remove magic numbers. Signed-off-by: Akihiko Odaki --- include/hw/core/cpu.h | 3 ++- target/s390x/cpu.h | 2 -- gdbstub/gdbstub.c | 5 - target/arm/cpu.c| 1 - target/arm/cpu64.c | 1 - target/avr/cpu

[PATCH v9 03/23] target/riscv: Validate misa_mxl_max only once

2023-10-11 Thread Akihiko Odaki
misa_mxl_max is now a class member and initialized only once for each class. This also moves the initialization of gdb_core_xml_file which will be referenced before realization in the future. Signed-off-by: Akihiko Odaki --- target/riscv/cpu.c | 7 +++ 1 file changed, 3 insertions(+), 4 dele

Re: [PATCH V4 01/10] accel/kvm: Extract common KVM vCPU {creation,parking} code

2023-10-11 Thread Gavin Shan
Hi Salil, On 10/10/23 06:35, Salil Mehta wrote: KVM vCPU creation is done once during the initialization of the VM when Qemu thread is spawned. This is common to all the architectures. Hot-unplug of vCPU results in destruction of the vCPU object in QOM but the corresponding KVM vCPU object in t

[PATCH v3 0/2] target/s390x/kvm: Simplify the synchronization code

2023-10-11 Thread Thomas Huth
KVM_SYNC_GPRS, KVM_SYNC_ACRS, KVM_SYNC_CRS and KVM_SYNC_PREFIX are available since kernel 3.10. Since we already require at least kernel 3.15 in the s390x KVM code, we can also assume that the KVM_CAP_SYNC_REGS sync code is always possible for these registers, and remove the related checks and fall

[PATCH v3 2/2] target/s390x/kvm: Simplify the GPRs, ACRs, CRs and prefix synchronization code

2023-10-11 Thread Thomas Huth
KVM_SYNC_GPRS, KVM_SYNC_ACRS, KVM_SYNC_CRS and KVM_SYNC_PREFIX are available since kernel 3.10. Since we already require at least kernel 3.15 in the s390x KVM code, we can also assume that the KVM_CAP_SYNC_REGS sync code is always possible for these registers, and remove the related checks and fall

[PATCH v3 1/2] target/s390x/kvm: Turn KVM_CAP_SYNC_REGS into a hard requirement

2023-10-11 Thread Thomas Huth
Since we already require at least kernel 3.15 in the s390x KVM code, we can assume that the KVM_CAP_SYNC_REGS capability is always there. Thus turn this into a hard requirement now. Reviewed-by: Christian Borntraeger Signed-off-by: Thomas Huth --- target/s390x/kvm/kvm.c | 20 ++-

Re: [PULL 50/51] subprojects: add wrap file for libblkio

2023-10-11 Thread Daniel P . Berrangé
On Wed, Oct 11, 2023 at 07:35:24AM +0200, Philippe Mathieu-Daudé wrote: > Hi Paolo, > > On 7/9/23 14:59, Paolo Bonzini wrote: > > This allows building libblkio at the same time as QEMU, if QEMU is > > configured with --enable-blkio --enable-download. > > > > Signed-off-by: Paolo Bonzini > > ---

Re: [PATCH v9 23/23] plugins: Support C++

2023-10-11 Thread Daniel P . Berrangé
On Wed, Oct 11, 2023 at 04:03:09PM +0900, Akihiko Odaki wrote: > Make qemu-plugin.h consumable for C++ platform. > > Signed-off-by: Akihiko Odaki > --- > docs/devel/tcg-plugins.rst | 4 > meson.build| 2 +- > include/qemu/qemu-plugin.h | 4 > tests/plugin/cc.cc

RE: [PATCH v2] migration: refactor migration_completion

2023-10-11 Thread Wang, Wei W
On Friday, August 4, 2023 9:37 PM, Peter Xu wrote: Fri, Aug 04, 2023 at 05:30:53PM +0800, Wei Wang wrote: > > Current migration_completion function is a bit long. Refactor the long > > implementation into different subfunctions: > > - migration_completion_precopy: completion code related to precopy

[PULL 03/65] tests/qtest: migration: Add migrate_incoming_qmp helper

2023-10-11 Thread Juan Quintela
From: Fabiano Rosas file-based migration requires the target to initiate its migration after the source has finished writing out the data in the file. Currently there's no easy way to initiate 'migrate-incoming', allow this by introducing migrate_incoming_qmp helper, similarly to migrate_qmp. Al

[PULL 00/65] Migration 20231011 patches

2023-10-11 Thread Juan Quintela
u.git tags/migration-20231011-pull-request for you to fetch changes up to 5e79a4bf032213fd59aa614781751fe76584f8e8: migration: Add migration_rp_wait|kick() (2023-10-11 11:17:05 +0200) Migration Pull request (20231011 edition) H

[PULL 05/65] migration: Set migration status early in incoming side

2023-10-11 Thread Juan Quintela
From: Fabiano Rosas We are sending a migration event of MIGRATION_STATUS_SETUP at qemu_start_incoming_migration but never actually setting the state. This creates a window between qmp_migrate_incoming and process_incoming_migration_co where the migration status is still MIGRATION_STATUS_NONE. Ca

[PULL 09/65] migration/rdma: Clean up qemu_rdma_data_init()'s return type

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_data_init() return type is void *. It actually returns RDMAContext *, and all its callers assign the value to an RDMAContext *. Unclean. Return RDMAContext * instead. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Revie

[PULL 25/65] migration/rdma: Fix io_writev(), io_readv() methods to obey contract

2023-10-11 Thread Juan Quintela
From: Markus Armbruster QIOChannelClass methods qio_channel_rdma_readv() and qio_channel_rdma_writev() violate their method contract when rdma->error_state is non-zero: 1. They return whatever is in rdma->error_state then. Only -1 will be fine. -2 will be misinterpreted as "would block". A

[PULL 15/65] migration/rdma: Give qio_channel_rdma_source_funcs internal linkage

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-9-arm...@redhat.com> --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletio

[PULL 20/65] migration/rdma: Drop qemu_rdma_search_ram_block() error handling

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_search_ram_block() can't fail. Return void, and drop the unreachable error handling. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-14-arm...@redhat.com> -

[PULL 17/65] migration/rdma: Put @errp parameter last

2023-10-11 Thread Juan Quintela
From: Markus Armbruster include/qapi/error.h demands: * - Functions that use Error to report errors have an Error **errp * parameter. It should be the last parameter, except for functions * taking variable arguments. qemu_rdma_connect() does not conform. Clean it up. Signed-off-by: Ma

[PULL 26/65] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Hiding return statements in macros is a bad idea. Use a function instead, and open code the return part. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928

[PULL 22/65] migration/rdma: Use bool for two RDMAContext flags

2023-10-11 Thread Juan Quintela
From: Markus Armbruster @error_reported and @received_error are flags. The latter is even assigned bool true. Change them from int to bool. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-I

[PULL 33/65] migration/rdma: Dumb down remaining int error values to -1

2023-10-11 Thread Juan Quintela
From: Markus Armbruster This is just to make the error value more obvious. Callers don't mind. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-27-arm...@redhat.com> --- migration/rdma.c | 4

[PULL 64/65] migration: Remember num of ramblocks to sync during recovery

2023-10-11 Thread Juan Quintela
From: Peter Xu Instead of only relying on the count of rp_sem, make the counter be part of RAMState so it can be used in both threads to synchronize on the process. rp_sem will be further reused in follow up patches, as a way to kick the main thread, e.g., on recovery failures. Reviewed-by: Fab

[PULL 37/65] migration/rdma: Plug a memory leak and improve a message

2023-10-11 Thread Juan Quintela
From: Markus Armbruster When migration capability @rdma-pin-all is true, but the server cannot honor it, qemu_rdma_connect() calls macro ERROR(), then returns success. ERROR() sets an error. Since qemu_rdma_connect() returns success, its caller rdma_start_outgoing_migration() duly assumes @errp

Re: [PATCH RFC v4 4/9] target/loongarch: Implement kvm get/set registers

2023-10-11 Thread lixianglai
Hi Philippe Mathieu-Daudé: Hi Li and Zhao, On 9/10/23 11:01, xianglai li wrote: From: Tianrui Zhao Implement kvm_arch_get/set_registers interfaces, many regs can be get/set in the function, such as core regs, csr regs, fpu regs, mp state, etc. Cc: "Michael S. Tsirkin" Cc: Cornelia Huck Cc

[PULL 30/65] migration/rdma: Fix QEMUFileHooks method return values

2023-10-11 Thread Juan Quintela
From: Markus Armbruster The QEMUFileHooks methods don't come with a written contract. Digging through the code calling them, we find: * save_page(): Negative values RAM_SAVE_CONTROL_DELAYED and RAM_SAVE_CONTROL_NOT_SUPP are special. Any other negative value is an unspecified error. q

[PULL 34/65] migration/rdma: Replace int error_state by bool errored

2023-10-11 Thread Juan Quintela
From: Markus Armbruster All we do with the value of RDMAContext member @error_state is test whether it's zero. Change to bool and rename to @errored. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.

[PULL 52/65] migration/rdma: Silence qemu_rdma_resolve_host()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 01/65] migration/qmp: Fix crash on setting tls-authz with null

2023-10-11 Thread Juan Quintela
From: Peter Xu QEMU will crash if anyone tries to set tls-authz (which is a type StrOrNull) with 'null' value. Fix it in the easy way by converting it to qstring just like the other two tls parameters. Cc: qemu-sta...@nongnu.org # v4.0+ Fixes: d2f1d29b95 ("migration: add support for a "tls-auth

[PULL 24/65] migration/rdma: Ditch useless numeric error codes in error messages

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Several error messages include numeric error codes returned by failed functions: * ibv_poll_cq() returns an unspecified negative value. Useless. * rdma_accept and rdma_get_cm_event() return -1. Useless. * qemu_rdma_poll() returns either -1 or an unspecified negative

[PULL 04/65] tests/qtest: migration: Use migrate_incoming_qmp where appropriate

2023-10-11 Thread Juan Quintela
From: Fabiano Rosas Use the new migrate_incoming_qmp helper in the places that currently open-code calling migrate-incoming. Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20230712190742.22294-4-faro...@suse.de> --- te

[PULL 36/65] migration/rdma: Check negative error values the same way everywhere

2023-10-11 Thread Juan Quintela
From: Markus Armbruster When a function returns 0 on success, negative value on error, checking for non-zero suffices, but checking for negative is clearer. So do that. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message

[PULL 38/65] migration/rdma: Delete inappropriate error_report() in macro ERROR()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 65/65] migration: Add migration_rp_wait|kick()

2023-10-11 Thread Juan Quintela
From: Peter Xu It's just a simple wrapper for rp_sem on either wait() or kick(), make it even clearer on how it is used. Prepared to be used even for other things. Reviewed-by: Fabiano Rosas Signed-off-by: Peter Xu Message-ID: <20231004220240.167175-8-pet...@redhat.com> Signed-off-by: Juan Qu

[PULL 14/65] migration/rdma: Clean up two more harmless signed vs. unsigned issues

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_exchange_get_response() compares int parameter @expecting with uint32_t head->type. Actual arguments are non-negative enumeration constants, RDMAControlHeader uint32_t member type, or qemu_rdma_exchange_recv() int parameter expecting. Actual arguments for the l

[PULL 08/65] migration/rdma: Clean up qemu_rdma_poll()'s return type

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_poll()'s return type is uint64_t, even though it returns 0, -1, or @ret, which is int. Its callers assign the return value to int variables, then check whether it's negative. Unclean. Return int instead. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano

[PULL 23/65] migration/rdma: Fix or document problematic uses of errno

2023-10-11 Thread Juan Quintela
From: Markus Armbruster We use errno after calling Libibverbs functions that are not documented to set errno (manual page does not mention errno), or where the documentation is unclear ("returns [...] the value of errno on failure"). While this could be read as "sets errno and returns it", a gla

[PULL 07/65] migration: Allow RECOVER->PAUSED convertion for dest qemu

2023-10-11 Thread Juan Quintela
From: Peter Xu There's a bug on dest that if a double fault triggered on dest qemu (a network issue during postcopy-recover), we won't set PAUSED correctly because we assumed we always came from ACTIVE. Fix that by always overwriting the state to PAUSE. We could also check for these two states,

[PULL 47/65] migration/rdma: Convert qemu_rdma_write_one() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 35/65] migration/rdma: Drop superfluous assignments to @ret

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-29-arm...@redhat.com> --- migration/rdma.c | 35 ++- 1 file changed, 10 insertions(+),

[PULL 43/65] migration/rdma: Convert qemu_rdma_exchange_send() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 29/65] migration/rdma: Drop dead qemu_rdma_data_init() code for !@host_port

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_data_init() neglects to set an Error when it fails because @host_port is null. Fortunately, no caller passes null, so this is merely a latent bug. Drop the flawed code handling null argument. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Review

[PULL 41/65] migration/rdma: Drop "@errp is clear" guards around error_setg()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster These guards are all redundant now. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-35-arm...@redhat.com> --- migration/rdma.c | 164 +++--

[PULL 31/65] migration/rdma: Fix rdma_getaddrinfo() error checking

2023-10-11 Thread Juan Quintela
From: Markus Armbruster rdma_getaddrinfo() returns 0 on success. On error, it returns one of the EAI_ error codes like getaddrinfo() does, or -1 with errno set. This is broken by design: POSIX implicitly specifies the EAI_ error codes to be non-zero, no more. They could clash with -1. Nothing

[PULL 28/65] migration/rdma: Fix qemu_get_cm_event_timeout() to always set error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_get_cm_event_timeout() neglects to set an error when it fails because rdma_get_cm_event() fails. Harmless, as its caller qemu_rdma_connect() substitutes a generic error then. Fix it anyway. qemu_rdma_connect() also sets the generic error when its own call of rdma_g

[PULL 11/65] migration/rdma: Drop fragile wr_id formatting

2023-10-11 Thread Juan Quintela
From: Markus Armbruster wrid_desc[] uses 4001 pointers to map four integer values to strings. print_wrid() accesses wrid_desc[] out of bounds when passed a negative argument. It returns null for values 2..1999 and 2001..3999. qemu_rdma_poll() and qemu_rdma_block_for_wrid() print wrid_desc[wr_i

[PULL 56/65] migration/rdma: Silence qemu_rdma_block_for_wrid()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 62/65] migration: Introduce migrate_has_error()

2023-10-11 Thread Juan Quintela
From: Peter Xu Introduce a helper to detect whether MigrationState.error is set for whatever reason. This is preparation work for any thread (e.g. source return path thread) to setup errors in an unified way to MigrationState, rather than relying on its own way to set errors (mark_source_rp_bad(

[PULL 61/65] migration: Display error in query-migrate irrelevant of status

2023-10-11 Thread Juan Quintela
From: Peter Xu Display it as long as being set, irrelevant of FAILED status. E.g., it may also be applicable to PAUSED stage of postcopy, to provide hint on what has gone wrong. The error_mutex seems to be overlooked when referencing the error, add it to be very safe. This will change QAPI beh

[PULL 42/65] migration/rdma: Convert qemu_rdma_exchange_recv() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 40/65] migration/rdma: Fix error handling around rdma_getaddrinfo()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_resolve_host() and qemu_rdma_dest_init() iterate over addresses to find one that works, holding onto the first Error from qemu_rdma_broken_ipv6_kernel() for use when no address works. Issues: 1. If @errp was &error_abort or &error_fatal, we'd terminate instead

[PULL 10/65] migration/rdma: Clean up rdma_delete_block()'s return type

2023-10-11 Thread Juan Quintela
From: Markus Armbruster rdma_delete_block() always returns 0, which its only caller ignores. Return void instead. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-4

[PULL 21/65] migration/rdma: Make qemu_rdma_buffer_mergeable() return bool

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_buffer_mergeable() is semantically a predicate. It returns int 0 or 1. Return bool instead, and fix the function name's spelling. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by:

[PULL 16/65] migration/rdma: Fix qemu_rdma_accept() to return failure on errors

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_accept() returns 0 in some cases even when it didn't complete its job due to errors. Impact is not obvious. I figure the caller will soon fail again with a misleading error message. Fix it to return -1 on any failure. Signed-off-by: Markus Armbruster Reviewe

[PULL 39/65] migration/rdma: Retire macro ERROR()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster ERROR() has become "error_setg() unless an error has been set already". Hiding the conditional in the macro is in the way of further work. Replace the macro uses by their expansion, and delete the macro. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewe

[PULL 60/65] migration/rdma: Replace flawed device detail dump by tracing

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_dump_id() dumps RDMA device details to stdout. rdma_start_outgoing_migration() calls it via qemu_rdma_source_init() and qemu_rdma_resolve_host() to show source device details. rdma_start_incoming_migration() arranges its call via rdma_accept_incoming_migration()

[PULL 32/65] migration/rdma: Return -1 instead of negative errno code

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Several functions return negative errno codes on failure. Callers check for specific codes exactly never. For some of the functions, callers couldn't check even if they wanted to, because the functions also return negative values that aren't errno codes, leaving readers

[PULL 63/65] qemufile: Always return a verbose error

2023-10-11 Thread Juan Quintela
From: Peter Xu There're a lot of cases where we only have an errno set in last_error but without a detailed error description. When this happens, try to generate an error contains the errno as a descriptive error. This will be helpful in cases where one relies on the Error*. E.g., migration st

[PULL 45/65] migration/rdma: Convert qemu_rdma_reg_whole_ram_blocks() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 44/65] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 27/65] migration/rdma: Fix qemu_rdma_broken_ipv6_kernel() to set error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qemu_rdma_resolve_host() and qemu_rdma_dest_init() try addresses until they find on that works. If none works, they return the first Error set by qemu_rdma_broken_ipv6_kernel(), or else return a generic one. qemu_rdma_broken_ipv6_kernel() neglects to set an Error when ib

[PULL 59/65] migration/rdma: Use error_report() & friends instead of stderr

2023-10-11 Thread Juan Quintela
From: Markus Armbruster error_report() obeys -msg, reports the current error location if any, and reports to the current monitor if any. Reporting to stderr directly with fprintf() or perror() is wrong, because it loses all this. Fix the offenders. Bonus: resolves a FIXME about problematic use

[PULL 49/65] migration/rdma: Convert qemu_rdma_post_send_control() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 18/65] migration/rdma: Eliminate error_propagate()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-b

[PULL 02/65] tests/qtest: migration: Expose migrate_set_capability

2023-10-11 Thread Juan Quintela
From: Fabiano Rosas The following patch will make use of this function from within migrate-helpers.c, so move it there. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <20230712190742.22294-2-far

[PULL 58/65] migration/rdma: Downgrade qemu_rdma_cleanup() errors to warnings

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 53/65] migration/rdma: Silence qemu_rdma_connect()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 46/65] migration/rdma: Convert qemu_rdma_write_flush() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 55/65] migration/rdma: Don't report received completion events as error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster When qemu_rdma_wait_comp_channel() receives an event from the completion channel, it reports an error "receive cm event while wait comp channel,cm event is T", where T is the numeric event type. However, the function fails only when T is a disconnect or device removal. Ev

[PULL 12/65] migration/rdma: Consistently use uint64_t for work request IDs

2023-10-11 Thread Juan Quintela
From: Markus Armbruster We use int instead of uint64_t in a few places. Change them to uint64_t. This cleans up a comparison of signed qemu_rdma_block_for_wrid() parameter @wrid_requested with unsigned @wr_id. Harmless, because the actual arguments are non-negative enumeration constants. Sign

[PULL 19/65] migration/rdma: Drop rdma_add_block() error handling

2023-10-11 Thread Juan Quintela
From: Markus Armbruster rdma_add_block() can't fail. Return void, and drop the unreachable error handling. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-13-arm.

[PULL 06/65] tests/qtest: migration: Add support for negative testing of qmp_migrate

2023-10-11 Thread Juan Quintela
From: Fabiano Rosas There is currently no way to write a test for errors that happened in qmp_migrate before the migration has started. Add a version of qmp_migrate that ensures an error happens. To make use of it a test needs to set MigrateCommon.result as MIG_TEST_QMP_ERROR. Reviewed-by: Pete

[PULL 54/65] migration/rdma: Silence qemu_rdma_reg_control()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 13/65] migration/rdma: Fix unwanted integer truncation

2023-10-11 Thread Juan Quintela
From: Markus Armbruster qio_channel_rdma_readv() assigns the size_t value of qemu_rdma_fill() to an int variable before it adds it to @done / subtracts it from @want, both size_t. Truncation when qemu_rdma_fill() copies more than INT_MAX bytes. Seems vanishingly unlikely, but needs fixing all t

[PULL 48/65] migration/rdma: Convert qemu_rdma_write() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Just for consistency with qemu_rdma_write_one() and qemu_rdma_write_flush(), and for slightly simpler code. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-42-arm...@r

[PULL 57/65] migration/rdma: Silence qemu_rdma_register_and_get_keys()

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

[PULL 50/65] migration/rdma: Convert qemu_rdma_post_recv_control() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Just for symmetry with qemu_rdma_post_send_control(). Error messages lose detail I consider of no use to users. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-44-arm

[PULL 51/65] migration/rdma: Convert qemu_rdma_alloc_pd_cq() to Error

2023-10-11 Thread Juan Quintela
From: Markus Armbruster Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to re

Re: [PATCH 2/3] target/riscv: Support discontinuous PMU counters

2023-10-11 Thread Rob Bradford
On Mon, 2023-10-09 at 11:00 -0700, Atish Kumar Patra wrote: > On Sun, Oct 8, 2023 at 5:58 PM Alistair Francis > wrote: > > > > On Wed, Oct 4, 2023 at 7:36 PM Rob Bradford > > wrote: > > > > > > Hi Atish, > > > > > > On Tue, 2023-10-03 at 13:25 -0700, Atish Kumar Patra wrote: > > > > On Tue, Oc

  1   2   3   4   5   6   >