Philippe Mathieu-Daudé <phi...@linaro.org> writes: > On 30/4/25 12:41, Markus Armbruster wrote:
[...] >> Pierrick's stated goal is to have no noticable differences between the >> single binary and the qemu-system-<target> it covers. >> >> We have two external interfaces to worry about: QMP and the command >> line. Let's ignore the latter for now. >> >> Target-specific differences in *syntax* come from QAPI schema >> conditionals with target-specific conditions. Example: >> >> { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], >> 'if': { 'any': [ 'TARGET_PPC', >> 'TARGET_ARM', >> 'TARGET_I386', >> 'TARGET_S390X', >> 'TARGET_MIPS', >> 'TARGET_LOONGARCH64', >> 'TARGET_RISCV' ] } } >> >> This command is only defined for some targets. >> >> The value of query-qmp-schema reflects this: it has >> query-cpu-definitions exactly when the condition is satisfied. The >> condition is evaluated at compile-time, because that's how QAPI schema >> 'if' works. >> >> Say we drop the condition and instead add an equivalent run-time >> condition to command registration. This preserves behavior of command >> execution. But query-qmp-schema now has query-cpu-definitions *always*. >> This is a noticable difference. It may break management applications >> that use query-qmp-schema to probe for the command. >> >> Moreover, conditionals aren't limited to commands. Example: >> >> { 'struct': 'CpuModelExpansionInfo', >> 'data': { 'model': 'CpuModelInfo', >> 'deprecated-props' : { 'type': ['str'], >> ---> 'if': 'TARGET_S390X' } }, >> 'if': { 'any': [ 'TARGET_S390X', >> 'TARGET_I386', >> 'TARGET_ARM', >> 'TARGET_LOONGARCH64', >> 'TARGET_RISCV' ] } } >> >> Here we have a conditional member. [...] > IMHO conditionals should only depend on host / static configuration > features, not features modifiable from the command line. This is how the QAPI schema works now. > (I'm always > confused by KVM features published in the schema, but then you start > your binary with -accel=tcg and still can run KVM specific commands > via QMP, returning errors). Not exactly a ringing endorsement for keeping the QAPI schema work the way it does now, isn't it? ;) The problem at hand is QAPI-generated files in a single binary. Pierrick posted "[RFC PATCH 0/3] single-binary: make QAPI generated files common". The patches are flawed, but that's alright for RFC. In review, I pointed out three possible solutions, and discussed their pros and cons: (1) Drop target-specific conditionals. (2) Replace them by run-time checks. (3) Have target-specific QAPI-generated code for multiple targets coexist in the single binary. Both (1) and (3) keep the QAPI schema work as it does now. Pierrick's patches are an incomplete attempt at (2). Daniel made a case for (1). You and I actually discussed (1) before, and I encouraged you to explore it. We can certainly discuss this some more, but I'd prefer to review a working solution instead.