@@ -1268,7 +1268,7 @@ void machine_run_board_init(MachineState *machine)
"on", false);
}
- accel_init_interfaces(ACCEL_GET_CLASS(machine->accelerator));
+ accel_init_interfaces(ACCEL_BASE_GET_CLASS(machine->accelerator));
machine_class->init(machine);
phase_advance(PHASE_MACHINE_INITIALIZED);
}
@@ -54,17 +54,17 @@ typedef struct AccelClass {
GPtrArray *compat_props;
} AccelClass;
-#define TYPE_ACCEL "accel"
+#define TYPE_ACCEL_BASE "accel"
-#define ACCEL_CLASS_SUFFIX "-" TYPE_ACCEL
+#define ACCEL_CLASS_SUFFIX "-" TYPE_ACCEL_BASE
#define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX)
-#define ACCEL_CLASS(klass) \
- OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL)
-#define ACCEL(obj) \
- OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL)
-#define ACCEL_GET_CLASS(obj) \
- OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
+#define ACCEL_BASE_CLASS(klass) \
+ OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL_BASE)
+#define ACCEL_BASE(obj) \
+ OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL_BASE)
+#define ACCEL_BASE_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL_BASE)
AccelClass *accel_find(const char *opt_name);
AccelState *current_accel(void);
@@ -34,7 +34,7 @@
#endif /* !CONFIG_USER_ONLY */
static const TypeInfo accel_type = {
- .name = TYPE_ACCEL,
+ .name = TYPE_ACCEL_BASE,
.parent = TYPE_OBJECT,
.class_size = sizeof(AccelClass),
.instance_size = sizeof(AccelState),
@@ -44,7 +44,7 @@ static const TypeInfo accel_type = {
AccelClass *accel_find(const char *opt_name)
{
char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
- AccelClass *ac = ACCEL_CLASS(module_object_class_by_name(class_name));
+ AccelClass *ac = ACCEL_BASE_CLASS(module_object_class_by_name(class_name));
g_free(class_name);
return ac;
}
@@ -32,7 +32,7 @@
int accel_init_machine(AccelState *accel, MachineState *ms)
{
- AccelClass *acc = ACCEL_GET_CLASS(accel);
+ AccelClass *acc = ACCEL_BASE_GET_CLASS(accel);
int ret;
ms->accelerator = accel;
*(acc->allowed) = true;
@@ -55,7 +55,7 @@ AccelState *current_accel(void)
void accel_setup_post(MachineState *ms)
{
AccelState *accel = ms->accelerator;
- AccelClass *acc = ACCEL_GET_CLASS(accel);
+ AccelClass *acc = ACCEL_BASE_GET_CLASS(accel);
if (acc->setup_post) {
acc->setup_post(ms, accel);
}
@@ -18,7 +18,7 @@ AccelState *current_accel(void)
AccelClass *ac = accel_find("tcg");
g_assert(ac != NULL);
- accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
+ accel = ACCEL_BASE(object_new_with_class(OBJECT_CLASS(ac)));
}
return accel;
}
@@ -329,7 +329,7 @@ static int hvf_accel_init(MachineState *ms)
static void hvf_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
ac->name = "HVF";
ac->init_machine = hvf_accel_init;
ac->allowed = &hvf_allowed;
@@ -337,7 +337,7 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data)
static const TypeInfo hvf_accel_type = {
.name = TYPE_HVF_ACCEL,
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.class_init = hvf_accel_class_init,
};
@@ -3618,7 +3618,7 @@ static void kvm_accel_instance_init(Object *obj)
static void kvm_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
ac->name = "KVM";
ac->init_machine = kvm_init;
ac->has_memory = kvm_accel_has_memory;
@@ -3645,7 +3645,7 @@ static void kvm_accel_class_init(ObjectClass *oc, void *data)
static const TypeInfo kvm_accel_type = {
.name = TYPE_KVM_ACCEL,
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.instance_init = kvm_accel_instance_init,
.class_init = kvm_accel_class_init,
.instance_size = sizeof(KVMState),
@@ -32,7 +32,7 @@ static int qtest_init_accel(MachineState *ms)
static void qtest_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
ac->name = "QTest";
ac->init_machine = qtest_init_accel;
ac->allowed = &qtest_allowed;
@@ -42,7 +42,7 @@ static void qtest_accel_class_init(ObjectClass *oc, void *data)
static const TypeInfo qtest_accel_type = {
.name = TYPE_QTEST_ACCEL,
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.class_init = qtest_accel_class_init,
};
module_obj(TYPE_QTEST_ACCEL);
@@ -210,7 +210,7 @@ static void tcg_set_splitwx(Object *obj, bool value, Error **errp)
static void tcg_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
ac->name = "tcg";
ac->init_machine = tcg_init_machine;
ac->allowed = &tcg_allowed;
@@ -233,7 +233,7 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
static const TypeInfo tcg_accel_type = {
.name = TYPE_TCG_ACCEL,
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.instance_init = tcg_accel_instance_init,
.class_init = tcg_accel_class_init,
.instance_size = sizeof(TCGState),
@@ -186,7 +186,7 @@ static int xen_init(MachineState *ms)
static void xen_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
static GlobalProperty compat[] = {
{ "migration", "store-global-state", "off" },
{ "migration", "send-configuration", "off" },
@@ -211,7 +211,7 @@ static void xen_accel_class_init(ObjectClass *oc, void *data)
static const TypeInfo xen_accel_type = {
.name = TYPE_XEN_ACCEL,
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.class_init = xen_accel_class_init,
};
@@ -793,7 +793,7 @@ int main(int argc, char **argv)
cpu_type = parse_cpu_option(cpu_model);
/* init tcg before creating CPUs and to get qemu_host_page_size */
{
- AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+ AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
accel_init_interfaces(ac);
ac->init_machine(NULL);
@@ -723,7 +723,7 @@ int main(int argc, char **argv, char **envp)
/* init tcg before creating CPUs and to get qemu_host_page_size */
{
- AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+ AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
accel_init_interfaces(ac);
ac->init_machine(NULL);
@@ -3261,7 +3261,7 @@ void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
};
GArray *fv_address_spaces;
GHashTable *views = g_hash_table_new(g_direct_hash, g_direct_equal);
- AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+ AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
if (ac->has_memory) {
fvi.ac = ac;
@@ -2305,7 +2305,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
}
return 0;
}
- accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
+ accel = ACCEL_BASE(object_new_with_class(OBJECT_CLASS(ac)));
object_apply_compat_props(OBJECT(accel));
qemu_opt_foreach(opts, accelerator_set_property,
accel,
@@ -2386,7 +2386,7 @@ static void configure_accelerators(const char *progname)
}
if (init_failed && !qtest_chrdev) {
- AccelClass *ac = ACCEL_GET_CLASS(current_accel());
+ AccelClass *ac = ACCEL_BASE_GET_CLASS(current_accel());
error_report("falling back to %s", ac->name);
}
@@ -3315,7 +3315,7 @@ void qemu_init(int argc, char **argv, char **envp)
optarg = qemu_opt_get(accel_opts, "accel");
if (!optarg || is_help_option(optarg)) {
printf("Accelerators supported in QEMU binary:\n");
- GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL,
+ GSList *el, *accel_list = object_class_get_list(TYPE_ACCEL_BASE,
false);
for (el = accel_list; el; el = el->next) {
gchar *typename = g_strdup(object_class_get_name(
@@ -1120,7 +1120,7 @@ void hax_reset_vcpu_state(void *opaque)
static void hax_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
ac->name = "HAX";
ac->init_machine = hax_accel_init;
ac->allowed = &hax_allowed;
@@ -1128,7 +1128,7 @@ static void hax_accel_class_init(ObjectClass *oc, void *data)
static const TypeInfo hax_accel_type = {
.name = ACCEL_CLASS_NAME("hax"),
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.class_init = hax_accel_class_init,
};
@@ -1205,7 +1205,7 @@ nvmm_enabled(void)
static void
nvmm_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
ac->name = "NVMM";
ac->init_machine = nvmm_accel_init;
ac->allowed = &nvmm_allowed;
@@ -1213,7 +1213,7 @@ nvmm_accel_class_init(ObjectClass *oc, void *data)
static const TypeInfo nvmm_accel_type = {
.name = ACCEL_CLASS_NAME("nvmm"),
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.class_init = nvmm_accel_class_init,
};
@@ -1873,7 +1873,7 @@ bool whpx_apic_in_platform(void) {
static void whpx_accel_class_init(ObjectClass *oc, void *data)
{
- AccelClass *ac = ACCEL_CLASS(oc);
+ AccelClass *ac = ACCEL_BASE_CLASS(oc);
ac->name = "WHPX";
ac->init_machine = whpx_accel_init;
ac->allowed = &whpx_allowed;
@@ -1896,7 +1896,7 @@ static void whpx_accel_instance_init(Object *obj)
static const TypeInfo whpx_accel_type = {
.name = ACCEL_CLASS_NAME("whpx"),
- .parent = TYPE_ACCEL,
+ .parent = TYPE_ACCEL_BASE,
.instance_init = whpx_accel_instance_init,
.class_init = whpx_accel_class_init,
};
The ACCEL name conflicts with a Windows API typedef name, and it is difficult to work around this because windows.h needs to be included by osdep.h. This prevents us from replacing the existing ACCEL macro with an inline function generated by OBJECT_DEFINE_TYPE. Work around the conflict by renaming TYPE_ACCEL to TYPE_ACCEL_BASE. Note that the actual QOM type name is still "accel", because QOM type names are user-visible and I don't want to make any user-visible change here. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- Notes about name alternatives: I have considered using the name "CPU_ACCEL" as Daniel suggested, but this would lead to a parent class named CPU_ACCEL, while the subclasses would be still named KVM_ACCEL, HVF_ACCEL, TCG_ACCEL, etc. I that this would be confusing, because it would look like CPU_ACCEL is just another type of accel, not the parent type of all other *_ACCEL types. Renaming KVM_ACCEL/HVF_ACCEL/TCG_ACCEL to KVM_CPU_ACCEL/HVF_CPU_ACCEL/TCG_CPU_ACCEL would be clearer, but I believe it would be too intrusive and the resulting type names would be too long. Renaming the base classe ACCEL_BASE sounds like a reasonable alternative, as there are other examples in QEMU where abstract base classes are called *_BASE: TYPE_VIRTIO_GPU_PCI_BASE, TYPE_VIRTIO_GPU_BASE, TYPE_E1000_BASE, TYPE_RISCV_CPU_BASE, TYPE_MEGASAS_BASE, TYPE_SCSI_DISK_BASE, etc. --- Cc: Richard Henderson <richard.henderson@linaro.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Cameron Esfahani <dirty@apple.com> Cc: Roman Bolshakov <r.bolshakov@yadro.com> Cc: Thomas Huth <thuth@redhat.com> Cc: Laurent Vivier <lvivier@redhat.com> Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Anthony Perard <anthony.perard@citrix.com> Cc: Paul Durrant <paul@xen.org> Cc: Warner Losh <imp@bsdimp.com> Cc: Kyle Evans <kevans@freebsd.org> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Cc: Peter Xu <peterx@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: Wenchao Wang <wenchao.wang@intel.com> Cc: Colin Xu <colin.xu@intel.com> Cc: Kamil Rytarowski <kamil@netbsd.org> Cc: Reinoud Zandijk <reinoud@netbsd.org> Cc: Sunil Muthuswamy <sunilmut@microsoft.com> Cc: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Cc: xen-devel@lists.xenproject.org Cc: haxm-team@intel.com --- hw/core/machine.c | 2 +- include/qemu/accel.h | 16 ++++++++-------- accel/accel-common.c | 4 ++-- accel/accel-softmmu.c | 4 ++-- accel/accel-user.c | 2 +- accel/hvf/hvf-accel-ops.c | 4 ++-- accel/kvm/kvm-all.c | 4 ++-- accel/qtest/qtest.c | 4 ++-- accel/tcg/tcg-all.c | 4 ++-- accel/xen/xen-all.c | 4 ++-- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- softmmu/memory.c | 2 +- softmmu/vl.c | 6 +++--- target/i386/hax/hax-all.c | 4 ++-- target/i386/nvmm/nvmm-all.c | 4 ++-- target/i386/whpx/whpx-all.c | 4 ++-- 17 files changed, 36 insertions(+), 36 deletions(-)