@samitouri / QOSamiQemu / commits / 0a03675429

target/i386/mshv: set cpu model name on -cpu host

By registering a cpu_accel_class for mshv, we can report an accurate model name on -cpu host. Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com> Acked-by: Wei Liu <wei.liu@kernel.org> Reviewed-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com> Link: https://lore.kernel.org/r/20260416121116.527927-6-magnuskulke@linux.microsoft.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Magnus Kulke committed Apr 16, 2026 at 14:11 UTC 0a036754292933b7a3d20eff16815d52490e8086
1 file changed +31
target/i386/mshv/mshv-cpu.c
+31
@@ -24,10 +24,13 @@
24 #include "hw/i386/apic_internal.h"
25
26 #include "cpu.h"
27 +#include "host-cpu.h"
28 #include "emulate/x86_decode.h"
29 #include "emulate/x86_emu.h"
30 #include "emulate/x86_flags.h"
31
32 +#include "accel/accel-cpu-target.h"
33 +
34 #include "trace-accel_mshv.h"
35 #include "trace.h"
36
@@ -1700,3 +1703,31 @@ int mshv_arch_post_init_vm(int vm_fd)
1703
1704 return ret;
1705 }
1706 +
1707 +static void mshv_cpu_instance_init(CPUState *cs)
1708 +{
1709 + X86CPU *cpu = X86_CPU(cs);
1710 +
1711 + host_cpu_instance_init(cpu);
1712 +}
1713 +
1714 +static void mshv_cpu_accel_class_init(ObjectClass *oc, const void *data)
1715 +{
1716 + AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
1717 +
1718 + acc->cpu_instance_init = mshv_cpu_instance_init;
1719 +}
1720 +
1721 +static const TypeInfo mshv_cpu_accel_type_info = {
1722 + .name = ACCEL_CPU_NAME("mshv"),
1723 + .parent = TYPE_ACCEL_CPU,
1724 + .class_init = mshv_cpu_accel_class_init,
1725 + .abstract = true,
1726 +};
1727 +
1728 +static void mshv_cpu_accel_register_types(void)
1729 +{
1730 + type_register_static(&mshv_cpu_accel_type_info);
1731 +}
1732 +
1733 +type_init(mshv_cpu_accel_register_types);