On 04/26/2018 01:34 PM, Laszlo Ersek wrote:
> Add a new field @target (of type @SysEmuTarget) to the output of the
> @query-cpus-fast command, which provides more information about the
> emulation target than the field @arch (of type @CpuInfoArch). Make @target
> the new discriminator for the @CpuInfoFast return structure. Keep @arch
> for compatibility.
> 
> Cc: "Daniel P. Berrange" <berra...@redhat.com>
> Cc: Eric Blake <ebl...@redhat.com>
> Cc: Markus Armbruster <arm...@redhat.com>
> Signed-off-by: Laszlo Ersek <ler...@redhat.com>
> ---
> 

> +static CpuInfoArch sysemu_target_to_cpuinfo_arch(SysEmuTarget target)
> +{
> +    /*
> +     * The @SysEmuTarget -> @CpuInfoArch mapping below is based on the
> +     * TARGET_ARCH -> TARGET_BASE_ARCH mapping in the "configure" script.
> +     */
> +    switch (target) {
> +    case SYS_EMU_TARGET_I386:
> +    case SYS_EMU_TARGET_X86_64:
> +        return CPU_INFO_ARCH_X86;

Thankfully, the addition of new targets is infrequent, so hopefully not
too hard to keep this mapping up-to-date.

I also like that this approach is introspectible via 'query-qmp-schema'
- if 'query-cpus-fast' has the "target" member, then you know that it is
fixed (you can ignore "arch" in that case, even though you know it
works); if it lacks "target", you know that "arch":"s390x" is the only
real string to look for and that all other systems report "x86" whether
or not that was accurate.

Reviewed-by: Eric Blake <ebl...@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to