Git tree: https://github.com/ehabkost/qemu-hacks/tree/accel-qom.v1
This is an attempt to convert the accel initialization and registration code to be QOM-based. I see two use cases for this: * KVM-specific CPU compat bits; * Probing for accelerator-specific CPU model "runnable" information. = KVM-specific compat bits = Currently, the PC compat code that deals with KVM-specific CPUID compat bits can't use compat_props to control compatibility, because it needs to affect the X86CPU CPUID initialization behavior only when KVM is enabled. The solution I propose is to have a "x86-kvm-accel" class which would be responsible for the KVM-specific CPU initialization behavior. Any compatibility properties for that behavior could then be tuned using "x86-kvm-accel" compat properties. To be able to implement x86-specific accelerator methods, a TYPE_X86_ACCEL interface was introduced. Patches 19-24 implements this (except for the actual compat properties). = Accel-specific runnable information = There are plans to eventually make the "query-cpu-definitions" QMP command return "runnable" information, which is accelerator-specific (e.g. some CPU models may be runnable when using KVM, but not when using TCG). The existing accelerator code maintains lots of global state, and the QOM-based approach will allow us to eventually make query-cpu-definitions instantiate short-lived accelerator objects (without affecting any machine and/or global state) to query for accelerator-specific information. Cc: Michael Mueller <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Alexander Graf <[email protected]> Cc: "Jason J. Herne" <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Andreas Färber <[email protected]> Cc: Marcel Apfelbaum <[email protected]> Eduardo Habkost (25): vl.c: Small coding style fix accel: Move accel code to accel.c accel: Create struct AccelType accel: Simplify configure_accelerator() using AccelType *acc variable accel: Move accel name lookup to separate function accel: Use QOM classes for accel types accel: Make AccelClass.available() optional accel: Move KVM accel registration to kvm-all.c accel: Move Xen registration code to xen-common.c accel: Move qtest accel registration to qtest.c accel: Remove tcg_available() function accel: Move accel init/allowed code to separate function accel: Rename 'init' method to 'init_machine' accel: Pass MachineState object to accel init functions accel: Create accel object when initializing machine accel: Save AccelState on MachineState when initializing kvm: Make KVMState be the TYPE_KVM_ACCEL instance struct accel: Get target name as argument when initializing accelerator accel: Use target-specific accel class if available accel: TYPE_X86_ACCEL interface kvm: x86 KVM accelerator subclass target-i386: Add AccelState parameter to cpu_x86_create() target-i386: Move accelerator-specific code outside X86CPU.instance_init target-i386: Accept "host" as value for CPU vendor target-i386: Move KVM CPUID hacking to accelerator cpu_post_init hook arch_init.c | 11 +-- hw/core/Makefile.objs | 1 + hw/core/accel.c | 171 +++++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc.c | 3 +- include/hw/accel.h | 60 ++++++++++++++++ include/hw/boards.h | 1 + include/hw/i386/accel.h | 42 +++++++++++ include/hw/xen/xen.h | 1 - include/qemu/typedefs.h | 5 ++ include/sysemu/arch_init.h | 1 - include/sysemu/kvm.h | 5 +- include/sysemu/qtest.h | 1 - kvm-all.c | 40 +++++++++-- kvm-stub.c | 5 -- qtest.c | 27 ++++++- target-i386/Makefile.objs | 1 + target-i386/accel.c | 38 ++++++++++ target-i386/cpu.c | 101 +++++++++++--------------- target-i386/cpu.h | 2 +- target-i386/kvm.c | 70 +++++++++++++++++++ vl.c | 83 +--------------------- xen-common-stub.c | 6 -- xen-common.c | 25 ++++++- 23 files changed, 528 insertions(+), 172 deletions(-) create mode 100644 hw/core/accel.c create mode 100644 include/hw/accel.h create mode 100644 include/hw/i386/accel.h create mode 100644 target-i386/accel.c -- 1.9.3
