[PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication

Pierrick Bouvier posted 8 patches 1 month, 1 week ago
Failed in applying to current master (apply log)
hw/core/machine-qmp-cmds.c            | 32 +++++++++++++++++++++++++++
include/system/qmp-cpu.h              | 20 +++++++++++++++++
stubs/meson.build                     |  6 +++++
stubs/qmp-cpu-arm.c                   |  9 ++++++++
stubs/qmp-cpu-i386.c                  |  9 ++++++++
stubs/qmp-cpu-loongarch.c             |  9 ++++++++
stubs/qmp-cpu-mips.c                  |  9 ++++++++
stubs/qmp-cpu-ppc.c                   |  9 ++++++++
stubs/qmp-cpu-riscv.c                 |  9 ++++++++
stubs/qmp-cpu-s390x.c                 |  6 +++++
stubs/qmp-cpu.c                       |  7 ------
target/arm/arm-qmp-cmds.c             |  3 ++-
target/i386/cpu.c                     |  3 ++-
target/loongarch/loongarch-qmp-cmds.c |  3 ++-
target/mips/system/mips-qmp-cmds.c    |  3 ++-
target/ppc/ppc-qmp-cmds.c             |  3 ++-
target/riscv/riscv-qmp-cmds.c         |  3 ++-
target/s390x/cpu_models_system.c      |  3 ++-
18 files changed, 132 insertions(+), 14 deletions(-)
create mode 100644 include/system/qmp-cpu.h
create mode 100644 stubs/qmp-cpu-arm.c
create mode 100644 stubs/qmp-cpu-i386.c
create mode 100644 stubs/qmp-cpu-loongarch.c
create mode 100644 stubs/qmp-cpu-mips.c
create mode 100644 stubs/qmp-cpu-ppc.c
create mode 100644 stubs/qmp-cpu-riscv.c
[PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Pierrick Bouvier 1 month, 1 week ago
This series allows to link multiple targets that define
qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
target-specific ones and a single dispatcher. We didn't use yet the dispatcher
pattern, and it's the first situation where it appears to be a good fit.

A possible alternative would be to introduce this callback directly at
target-info level, which I think is a less desirable solution, since it would
ties this API to monitor.

If the approach here is accepted, I'll extend this series with
qmp_query_cpu_model_expansion which follows the same pattern.
With this, we'll be free to link together almost all the base architectures.

Pierrick Bouvier (8):
  target/arm: rename qmp_query_cpu_definitions to
    qmp_query_arm_cpu_definitions
  target/i386: rename qmp_query_cpu_definitions to
    qmp_query_i386_cpu_definitions
  target/loongarch: rename to qmp_query_loongarch_cpu_definitions
  target/mips: rename qmp_query_cpu_definitions to
    qmp_query_mips_cpu_definitions
  target/ppc: rename qmp_query_cpu_definitions to
    qmp_query_ppc_cpu_definitions
  target/riscv: rename to qmp_query_cpu_definitions to
    qmp_query_riscv_cpu_definitions
  target/s390x: rename qmp_query_cpu_definitions to
    qmp_query_s390x_cpu_definitions
  qmp: reimplement qmp_query_cpu_definitions as a dispatcher function

 hw/core/machine-qmp-cmds.c            | 32 +++++++++++++++++++++++++++
 include/system/qmp-cpu.h              | 20 +++++++++++++++++
 stubs/meson.build                     |  6 +++++
 stubs/qmp-cpu-arm.c                   |  9 ++++++++
 stubs/qmp-cpu-i386.c                  |  9 ++++++++
 stubs/qmp-cpu-loongarch.c             |  9 ++++++++
 stubs/qmp-cpu-mips.c                  |  9 ++++++++
 stubs/qmp-cpu-ppc.c                   |  9 ++++++++
 stubs/qmp-cpu-riscv.c                 |  9 ++++++++
 stubs/qmp-cpu-s390x.c                 |  6 +++++
 stubs/qmp-cpu.c                       |  7 ------
 target/arm/arm-qmp-cmds.c             |  3 ++-
 target/i386/cpu.c                     |  3 ++-
 target/loongarch/loongarch-qmp-cmds.c |  3 ++-
 target/mips/system/mips-qmp-cmds.c    |  3 ++-
 target/ppc/ppc-qmp-cmds.c             |  3 ++-
 target/riscv/riscv-qmp-cmds.c         |  3 ++-
 target/s390x/cpu_models_system.c      |  3 ++-
 18 files changed, 132 insertions(+), 14 deletions(-)
 create mode 100644 include/system/qmp-cpu.h
 create mode 100644 stubs/qmp-cpu-arm.c
 create mode 100644 stubs/qmp-cpu-i386.c
 create mode 100644 stubs/qmp-cpu-loongarch.c
 create mode 100644 stubs/qmp-cpu-mips.c
 create mode 100644 stubs/qmp-cpu-ppc.c
 create mode 100644 stubs/qmp-cpu-riscv.c

-- 
2.43.0
Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Pierrick Bouvier 1 month, 1 week ago
On 10/14/2026 5:53 PM, Pierrick Bouvier wrote:
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
> 
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
> 
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
> 
> Pierrick Bouvier (8):
>   target/arm: rename qmp_query_cpu_definitions to
>     qmp_query_arm_cpu_definitions
>   target/i386: rename qmp_query_cpu_definitions to
>     qmp_query_i386_cpu_definitions
>   target/loongarch: rename to qmp_query_loongarch_cpu_definitions
>   target/mips: rename qmp_query_cpu_definitions to
>     qmp_query_mips_cpu_definitions
>   target/ppc: rename qmp_query_cpu_definitions to
>     qmp_query_ppc_cpu_definitions
>   target/riscv: rename to qmp_query_cpu_definitions to
>     qmp_query_riscv_cpu_definitions
>   target/s390x: rename qmp_query_cpu_definitions to
>     qmp_query_s390x_cpu_definitions
>   qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
> 
>  hw/core/machine-qmp-cmds.c            | 32 +++++++++++++++++++++++++++
>  include/system/qmp-cpu.h              | 20 +++++++++++++++++
>  stubs/meson.build                     |  6 +++++
>  stubs/qmp-cpu-arm.c                   |  9 ++++++++
>  stubs/qmp-cpu-i386.c                  |  9 ++++++++
>  stubs/qmp-cpu-loongarch.c             |  9 ++++++++
>  stubs/qmp-cpu-mips.c                  |  9 ++++++++
>  stubs/qmp-cpu-ppc.c                   |  9 ++++++++
>  stubs/qmp-cpu-riscv.c                 |  9 ++++++++
>  stubs/qmp-cpu-s390x.c                 |  6 +++++
>  stubs/qmp-cpu.c                       |  7 ------
>  target/arm/arm-qmp-cmds.c             |  3 ++-
>  target/i386/cpu.c                     |  3 ++-
>  target/loongarch/loongarch-qmp-cmds.c |  3 ++-
>  target/mips/system/mips-qmp-cmds.c    |  3 ++-
>  target/ppc/ppc-qmp-cmds.c             |  3 ++-
>  target/riscv/riscv-qmp-cmds.c         |  3 ++-
>  target/s390x/cpu_models_system.c      |  3 ++-
>  18 files changed, 132 insertions(+), 14 deletions(-)
>  create mode 100644 include/system/qmp-cpu.h
>  create mode 100644 stubs/qmp-cpu-arm.c
>  create mode 100644 stubs/qmp-cpu-i386.c
>  create mode 100644 stubs/qmp-cpu-loongarch.c
>  create mode 100644 stubs/qmp-cpu-mips.c
>  create mode 100644 stubs/qmp-cpu-ppc.c
>  create mode 100644 stubs/qmp-cpu-riscv.c
>

This was merged into master (2cab0c10632960c01972727608196984d52c93bf).

Regards,
Pierrick
Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Daniel P. Berrangé 1 month, 1 week ago
On Thu, Oct 15, 2026 at 12:53:47AM +0000, Pierrick Bouvier wrote:
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
> 
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
> 
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
> 
> Pierrick Bouvier (8):
>   target/arm: rename qmp_query_cpu_definitions to
>     qmp_query_arm_cpu_definitions
>   target/i386: rename qmp_query_cpu_definitions to
>     qmp_query_i386_cpu_definitions
>   target/loongarch: rename to qmp_query_loongarch_cpu_definitions
>   target/mips: rename qmp_query_cpu_definitions to
>     qmp_query_mips_cpu_definitions
>   target/ppc: rename qmp_query_cpu_definitions to
>     qmp_query_ppc_cpu_definitions
>   target/riscv: rename to qmp_query_cpu_definitions to
>     qmp_query_riscv_cpu_definitions
>   target/s390x: rename qmp_query_cpu_definitions to
>     qmp_query_s390x_cpu_definitions
>   qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
> 
>  hw/core/machine-qmp-cmds.c            | 32 +++++++++++++++++++++++++++
>  include/system/qmp-cpu.h              | 20 +++++++++++++++++
>  stubs/meson.build                     |  6 +++++
>  stubs/qmp-cpu-arm.c                   |  9 ++++++++
>  stubs/qmp-cpu-i386.c                  |  9 ++++++++
>  stubs/qmp-cpu-loongarch.c             |  9 ++++++++
>  stubs/qmp-cpu-mips.c                  |  9 ++++++++
>  stubs/qmp-cpu-ppc.c                   |  9 ++++++++
>  stubs/qmp-cpu-riscv.c                 |  9 ++++++++
>  stubs/qmp-cpu-s390x.c                 |  6 +++++
>  stubs/qmp-cpu.c                       |  7 ------
>  target/arm/arm-qmp-cmds.c             |  3 ++-
>  target/i386/cpu.c                     |  3 ++-
>  target/loongarch/loongarch-qmp-cmds.c |  3 ++-
>  target/mips/system/mips-qmp-cmds.c    |  3 ++-
>  target/ppc/ppc-qmp-cmds.c             |  3 ++-
>  target/riscv/riscv-qmp-cmds.c         |  3 ++-
>  target/s390x/cpu_models_system.c      |  3 ++-
>  18 files changed, 132 insertions(+), 14 deletions(-)
>  create mode 100644 include/system/qmp-cpu.h
>  create mode 100644 stubs/qmp-cpu-arm.c
>  create mode 100644 stubs/qmp-cpu-i386.c
>  create mode 100644 stubs/qmp-cpu-loongarch.c
>  create mode 100644 stubs/qmp-cpu-mips.c
>  create mode 100644 stubs/qmp-cpu-ppc.c
>  create mode 100644 stubs/qmp-cpu-riscv.c

For series:

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Markus Armbruster 1 month, 1 week ago
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:

> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
>
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.

I'm curious... why would such a tie be undesirable?

> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.

Series
Acked-by: Markus Armbruster <armbru@redhat.com>
Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Daniel P. Berrangé 1 month, 1 week ago
On Thu, Oct 15, 2026 at 07:58:29AM +0200, Markus Armbruster wrote:
> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> 
> > This series allows to link multiple targets that define
> > qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> > target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> > pattern, and it's the first situation where it appears to be a good fit.
> >
> > A possible alternative would be to introduce this callback directly at
> > target-info level, which I think is a less desirable solution, since it would
> > ties this API to monitor.
> 
> I'm curious... why would such a tie be undesirable?

I don't think target-info should be involved at all, it is a problem
to solve in the CPU type system. The CPU definitions are introspecting
sub-classes of TYPE_CPU.

IMHO the right way to solve this is for CPUClass to gain a callback for
introspection, and for each target to provide an impl of that callback.

There should only be a single qmp_query_cpu_definitions method that
introspects all registered TYPE_CPU subclasses. That way in a
multi-target binary, the introspection will return info for all
CPUs for all compiled in targets.

That would need refactoring of the current qmp_query_cpu_definitions
methods which is a bigger job. This series as is, is a reasonable
small initial stepping stone to make it possible to link the binaries,
before a later followup patch to do the full refactoring to get the
desirable API semantics.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Pierrick Bouvier 1 month, 1 week ago
On 10/15/2026 12:57 AM, Daniel P. Berrangé wrote:
> On Thu, Oct 15, 2026 at 07:58:29AM +0200, Markus Armbruster wrote:
>> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
>>
>>> This series allows to link multiple targets that define
>>> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
>>> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
>>> pattern, and it's the first situation where it appears to be a good fit.
>>>
>>> A possible alternative would be to introduce this callback directly at
>>> target-info level, which I think is a less desirable solution, since it would
>>> ties this API to monitor.
>>
>> I'm curious... why would such a tie be undesirable?
> 
> I don't think target-info should be involved at all, it is a problem
> to solve in the CPU type system. The CPU definitions are introspecting
> sub-classes of TYPE_CPU.
> 
> IMHO the right way to solve this is for CPUClass to gain a callback for
> introspection, and for each target to provide an impl of that callback.
> 
> There should only be a single qmp_query_cpu_definitions method that
> introspects all registered TYPE_CPU subclasses. That way in a
> multi-target binary, the introspection will return info for all
> CPUs for all compiled in targets.
>

I was wondering if what we would like to expose is all targets, or only
the ones that have a cpu active.

> That would need refactoring of the current qmp_query_cpu_definitions
> methods which is a bigger job. This series as is, is a reasonable
> small initial stepping stone to make it possible to link the binaries,
> before a later followup patch to do the full refactoring to get the
> desirable API semantics.
>

That was the goal 👍.

> With regards,
> Daniel

Regards,
Pierrick

Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Daniel P. Berrangé 1 month, 1 week ago
On Thu, Oct 15, 2026 at 10:57:50AM -0700, Pierrick Bouvier wrote:
> On 10/15/2026 12:57 AM, Daniel P. Berrangé wrote:
> > On Thu, Oct 15, 2026 at 07:58:29AM +0200, Markus Armbruster wrote:
> >> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> >>
> >>> This series allows to link multiple targets that define
> >>> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> >>> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> >>> pattern, and it's the first situation where it appears to be a good fit.
> >>>
> >>> A possible alternative would be to introduce this callback directly at
> >>> target-info level, which I think is a less desirable solution, since it would
> >>> ties this API to monitor.
> >>
> >> I'm curious... why would such a tie be undesirable?
> > 
> > I don't think target-info should be involved at all, it is a problem
> > to solve in the CPU type system. The CPU definitions are introspecting
> > sub-classes of TYPE_CPU.
> > 
> > IMHO the right way to solve this is for CPUClass to gain a callback for
> > introspection, and for each target to provide an impl of that callback.
> > 
> > There should only be a single qmp_query_cpu_definitions method that
> > introspects all registered TYPE_CPU subclasses. That way in a
> > multi-target binary, the introspection will return info for all
> > CPUs for all compiled in targets.
> >
> 
> I was wondering if what we would like to expose is all targets, or only
> the ones that have a cpu active.

Introspection commands such as this one generally should report on
everything that is built-in to the binary.

> > That would need refactoring of the current qmp_query_cpu_definitions
> > methods which is a bigger job. This series as is, is a reasonable
> > small initial stepping stone to make it possible to link the binaries,
> > before a later followup patch to do the full refactoring to get the
> > desirable API semantics.
> >
> 
> That was the goal 👍.
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Pierrick Bouvier 1 month, 1 week ago
On 10/14/26 10:58 PM, Markus Armbruster wrote:
> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> 
>> This series allows to link multiple targets that define
>> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
>> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
>> pattern, and it's the first situation where it appears to be a good fit.
>>
>> A possible alternative would be to introduce this callback directly at
>> target-info level, which I think is a less desirable solution, since it would
>> ties this API to monitor.
> 
> I'm curious... why would such a tie be undesirable?
>

We have a unique definition of target-info for all targets 
(https://gitlab.com/qemu-project/qemu/-/blob/master/target-info-def.c), 
which is simple and nice.

We could consider adding callbacks in this "generic" file only if they 
are implemented for all targets, but as we can see in this series, only 
a few targets implement this. It would be more boilerplate for the same 
result.

IMHO the two concerned functions (qmp_query_cpu*) look more like an 
exception than a proper rule. dump functions (posted in another series) 
are more related to cpu, and not to target themselves.

I would happy to revisit this if community prefers to go in a different 
direction though.

>> If the approach here is accepted, I'll extend this series with
>> qmp_query_cpu_model_expansion which follows the same pattern.
>> With this, we'll be free to link together almost all the base architectures.
> 
> Series
> Acked-by: Markus Armbruster <armbru@redhat.com>
> 

Regards,
Pierrick
Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Yonggang Luo 1 month, 1 week ago
On Thu, Oct 15, 2026 at 2:14 PM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/14/26 10:58 PM, Markus Armbruster wrote:
> > Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> >
> >> This series allows to link multiple targets that define
> >> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> >> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> >> pattern, and it's the first situation where it appears to be a good fit.
> >>
> >> A possible alternative would be to introduce this callback directly at
> >> target-info level, which I think is a less desirable solution, since it would
> >> ties this API to monitor.
> >
> > I'm curious... why would such a tie be undesirable?
> >
>
> We have a unique definition of target-info for all targets
> (https://gitlab.com/qemu-project/qemu/-/blob/master/target-info-def.c),
> which is simple and nice.
>
> We could consider adding callbacks in this "generic" file only if they
> are implemented for all targets, but as we can see in this series, only
> a few targets implement this. It would be more boilerplate for the same
> result.

I personally think we can call it "generic" if three or more targets
are implemented, otherwise it's too restricted. And also get it hard if
new targets want to leverage/implement it.


Anyway, this series is still fine, I have no objection, just some points.

>
> IMHO the two concerned functions (qmp_query_cpu*) look more like an
> exception than a proper rule. dump functions (posted in another series)
> are more related to cpu, and not to target themselves.
>
> I would happy to revisit this if community prefers to go in a different
> direction though.
>
> >> If the approach here is accepted, I'll extend this series with
> >> qmp_query_cpu_model_expansion which follows the same pattern.
> >> With this, we'll be free to link together almost all the base architectures.
> >
> > Series
> > Acked-by: Markus Armbruster <armbru@redhat.com>
> >
>
> Regards,
> Pierrick
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Yonggang Luo 1 month, 1 week ago
On Thu, Oct 15, 2026 at 8:55 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
>
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
Here is my DRAFT patch, you can take a look about this direction, and
change far less code.

https://lore.kernel.org/qemu-devel/20261015044104.879-1-luoyonggang@gmail.com/


>
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
>
> Pierrick Bouvier (8):
>   target/arm: rename qmp_query_cpu_definitions to
>     qmp_query_arm_cpu_definitions
>   target/i386: rename qmp_query_cpu_definitions to
>     qmp_query_i386_cpu_definitions
>   target/loongarch: rename to qmp_query_loongarch_cpu_definitions
>   target/mips: rename qmp_query_cpu_definitions to
>     qmp_query_mips_cpu_definitions
>   target/ppc: rename qmp_query_cpu_definitions to
>     qmp_query_ppc_cpu_definitions
>   target/riscv: rename to qmp_query_cpu_definitions to
>     qmp_query_riscv_cpu_definitions
>   target/s390x: rename qmp_query_cpu_definitions to
>     qmp_query_s390x_cpu_definitions
>   qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
>
>  hw/core/machine-qmp-cmds.c            | 32 +++++++++++++++++++++++++++
>  include/system/qmp-cpu.h              | 20 +++++++++++++++++
>  stubs/meson.build                     |  6 +++++
>  stubs/qmp-cpu-arm.c                   |  9 ++++++++
>  stubs/qmp-cpu-i386.c                  |  9 ++++++++
>  stubs/qmp-cpu-loongarch.c             |  9 ++++++++
>  stubs/qmp-cpu-mips.c                  |  9 ++++++++
>  stubs/qmp-cpu-ppc.c                   |  9 ++++++++
>  stubs/qmp-cpu-riscv.c                 |  9 ++++++++
>  stubs/qmp-cpu-s390x.c                 |  6 +++++
>  stubs/qmp-cpu.c                       |  7 ------
>  target/arm/arm-qmp-cmds.c             |  3 ++-
>  target/i386/cpu.c                     |  3 ++-
>  target/loongarch/loongarch-qmp-cmds.c |  3 ++-
>  target/mips/system/mips-qmp-cmds.c    |  3 ++-
>  target/ppc/ppc-qmp-cmds.c             |  3 ++-
>  target/riscv/riscv-qmp-cmds.c         |  3 ++-
>  target/s390x/cpu_models_system.c      |  3 ++-
>  18 files changed, 132 insertions(+), 14 deletions(-)
>  create mode 100644 include/system/qmp-cpu.h
>  create mode 100644 stubs/qmp-cpu-arm.c
>  create mode 100644 stubs/qmp-cpu-i386.c
>  create mode 100644 stubs/qmp-cpu-loongarch.c
>  create mode 100644 stubs/qmp-cpu-mips.c
>  create mode 100644 stubs/qmp-cpu-ppc.c
>  create mode 100644 stubs/qmp-cpu-riscv.c
>
> --
> 2.43.0
>
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/8] multi-target: remove qmp_query_cpu_definitions duplication
Posted by Yonggang Luo 1 month, 1 week ago
On Thu, Oct 15, 2026 at 8:55 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> This series allows to link multiple targets that define
> qmp_query_cpu_definitions. It simply replaces the duplicated definitions with
> target-specific ones and a single dispatcher. We didn't use yet the dispatcher
> pattern, and it's the first situation where it appears to be a good fit.
>
> A possible alternative would be to introduce this callback directly at
> target-info level, which I think is a less desirable solution, since it would
> ties this API to monitor.
I tried this way and it is much better I think.

>
> If the approach here is accepted, I'll extend this series with
> qmp_query_cpu_model_expansion which follows the same pattern.
> With this, we'll be free to link together almost all the base architectures.
>
> Pierrick Bouvier (8):
>   target/arm: rename qmp_query_cpu_definitions to
>     qmp_query_arm_cpu_definitions
>   target/i386: rename qmp_query_cpu_definitions to
>     qmp_query_i386_cpu_definitions
>   target/loongarch: rename to qmp_query_loongarch_cpu_definitions
>   target/mips: rename qmp_query_cpu_definitions to
>     qmp_query_mips_cpu_definitions
>   target/ppc: rename qmp_query_cpu_definitions to
>     qmp_query_ppc_cpu_definitions
>   target/riscv: rename to qmp_query_cpu_definitions to
>     qmp_query_riscv_cpu_definitions
>   target/s390x: rename qmp_query_cpu_definitions to
>     qmp_query_s390x_cpu_definitions
>   qmp: reimplement qmp_query_cpu_definitions as a dispatcher function
>
>  hw/core/machine-qmp-cmds.c            | 32 +++++++++++++++++++++++++++
>  include/system/qmp-cpu.h              | 20 +++++++++++++++++
>  stubs/meson.build                     |  6 +++++
>  stubs/qmp-cpu-arm.c                   |  9 ++++++++
>  stubs/qmp-cpu-i386.c                  |  9 ++++++++
>  stubs/qmp-cpu-loongarch.c             |  9 ++++++++
>  stubs/qmp-cpu-mips.c                  |  9 ++++++++
>  stubs/qmp-cpu-ppc.c                   |  9 ++++++++
>  stubs/qmp-cpu-riscv.c                 |  9 ++++++++
>  stubs/qmp-cpu-s390x.c                 |  6 +++++
>  stubs/qmp-cpu.c                       |  7 ------
Introduce this callback directly at target-info level wil avoid these
stubs/qmp-*, basically we indeed can remove more stubs. maybe
qmp-cpu.c be removed.

>  target/arm/arm-qmp-cmds.c             |  3 ++-
>  target/i386/cpu.c                     |  3 ++-
>  target/loongarch/loongarch-qmp-cmds.c |  3 ++-
>  target/mips/system/mips-qmp-cmds.c    |  3 ++-
>  target/ppc/ppc-qmp-cmds.c             |  3 ++-
>  target/riscv/riscv-qmp-cmds.c         |  3 ++-
>  target/s390x/cpu_models_system.c      |  3 ++-
>  18 files changed, 132 insertions(+), 14 deletions(-)
>  create mode 100644 include/system/qmp-cpu.h
>  create mode 100644 stubs/qmp-cpu-arm.c
>  create mode 100644 stubs/qmp-cpu-i386.c
>  create mode 100644 stubs/qmp-cpu-loongarch.c
>  create mode 100644 stubs/qmp-cpu-mips.c
>  create mode 100644 stubs/qmp-cpu-ppc.c
>  create mode 100644 stubs/qmp-cpu-riscv.c
>
> --
> 2.43.0
>
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo