Received: from eggs.gnu.org ([2001:4830:134:3::10]:58714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zyv-0007RN-Aq for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4zyn-0008Fy-10 for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:04:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zym-0008Fe-NP for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:04:44 -0400 From: Eduardo Habkost Date: Wed, 9 Jul 2014 19:03:57 -0300 Message-Id: <1404943462-711-1-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC 00/25] QOMify accelerator code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Mueller , Marcel Apfelbaum , Alexander Graf , Christian Borntraeger , "Jason J. Herne" , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= Git tree: https://github.com/ehabkost/qemu-hacks/tree/accel-qom.v1 This is an attempt to convert the accel initialization and registration c= ode to be QOM-based. I see two use cases for this: * KVM-specific CPU compat bits; * Probing for accelerator-specific CPU model "runnable" information. =3D KVM-specific compat bits =3D Currently, the PC compat code that deals with KVM-specific CPUID compat b= its can't use compat_props to control compatibility, because it needs to affe= ct the X86CPU CPUID initialization behavior only when KVM is enabled. The soluti= on I propose is to have a "x86-kvm-accel" class which would be responsible for= the KVM-specific CPU initialization behavior. Any compatibility properties fo= r that behavior could then be tuned using "x86-kvm-accel" compat properties. To be able to implement x86-specific accelerator methods, a TYPE_X86_ACCE= L interface was introduced. Patches 19-24 implements this (except for the actual compat properties). =3D Accel-specific runnable information =3D There are plans to eventually make the "query-cpu-definitions" QMP comman= d return "runnable" information, which is accelerator-specific (e.g. some C= PU models may be runnable when using KVM, but not when using TCG). The exist= ing accelerator code maintains lots of global state, and the QOM-based approa= ch will allow us to eventually make query-cpu-definitions instantiate short-lived accelerator objects (without affecting any machine and/or global state) t= o query for accelerator-specific information. Cc: Michael Mueller Cc: Christian Borntraeger Cc: Alexander Graf Cc: "Jason J. Herne" Cc: Paolo Bonzini Cc: Andreas F=C3=A4rber Cc: Marcel Apfelbaum 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 --=20 1.9.3