On Fri, Nov 6, 2026 at 11:45 PM Daniel P. Berrangé <[email protected]> wrote: > > On Fri, Nov 06, 2026 at 03:03:43AM +0800, Yonggang Luo wrote: > > Return the QEMU_ARCH_* mask of the selected target. System mode > > returns QEMU_ARCH_ALL until a target is selected. User mode returns > > that target's bit. Tools return 0. > > I was wondering if it was better to have system mode return > 0 or QEMU_ARCH_ALL, when no target is selected.
Tools return 0, so only an object whose targets are QEMU_ARCH_ALL is accepted. Any other mask is filtered out, because 0 AND anything is 0. System mode returns QEMU_ARCH_ALL until a target is selected, so every target mask is accepted. User mode always has a target selected, so it returns that target's bitmask. Tools and system mode need different values so the two binaries can be distinguished. 0 is tools. QEMU_ARCH_ALL is system mode before a target is selected. > > I guess QEMU_ARCH_ALL (or a mask of all arches that are > built-in to the bniary) is a better approach, as it expresses That "mask" is a subset of QEMU_ARCH_ALL. A user-mode binary still contains every bit of QEMU_ARCH_ALL, so the subset cannot replace it. TYPE_INTERFACE and TYPE_OBJECT are registered with QEMU_ARCH_ALL. If the "mask" is still a generated macro, registering them with it filters them out for some user target, or object.c has to be compiled twice(user/system), or we need a stub variable for the mask. That is far more complicated. QEMU_ARCH_ALL has no such restriction. > that the system's current state is capable of targetting > any of the include arches, while '0' conceptually represents > the "no arch specific features" scenario for tools. > > > > > Signed-off-by: Yonggang Luo <[email protected]> > > --- > > include/qemu/target-info-init.h | 15 ++++++++++----- > > include/qemu/target-info.h | 9 +++++++++ > > stubs/meson.build | 1 + > > stubs/target-mask-selected.c | 13 +++++++++++++ > > target-info-def.c | 3 +++ > > target-info-qom.c | 10 ++++++++++ > > 6 files changed, 46 insertions(+), 5 deletions(-) > > create mode 100644 stubs/target-mask-selected.c > > Reviewed-by: Daniel P. Berrangé <[email protected]> > > this patch looks applicable independently of this > series. > > > 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 :| > -- 此致 礼 罗勇刚 Yours sincerely, Yonggang Luo
