Skip to content

Commit b152b05

Browse files
ehabkostbonzini
authored andcommitted
accel: Move Xen registration code to xen-common.c
Note that this has an user-visible side-effect: instead of reporting "Xen is not supported for this target", QEMU binaries not supporting Xen will report "xen accelerator does not exist". As xen_available() always return 1 when CONFIG_XEN is enabled, we don't need to set AccelClass.available anymore. xen_enabled() is not being removed yet, but only because vl.c is still using it. This also allows us to make xen_init() static. Reviewed-by: Paolo Bonzini <[email protected]> Signed-off-by: Eduardo Habkost <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 782c3f2 commit b152b05

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

accel.c

-18
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,6 @@ static const TypeInfo tcg_accel_type = {
132132
.class_init = tcg_accel_class_init,
133133
};
134134

135-
static void xen_accel_class_init(ObjectClass *oc, void *data)
136-
{
137-
AccelClass *ac = ACCEL_CLASS(oc);
138-
ac->name = "Xen";
139-
ac->available = xen_available;
140-
ac->init = xen_init;
141-
ac->allowed = &xen_allowed;
142-
}
143-
144-
#define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
145-
146-
static const TypeInfo xen_accel_type = {
147-
.name = TYPE_XEN_ACCEL,
148-
.parent = TYPE_ACCEL,
149-
.class_init = xen_accel_class_init,
150-
};
151-
152135
static void qtest_accel_class_init(ObjectClass *oc, void *data)
153136
{
154137
AccelClass *ac = ACCEL_CLASS(oc);
@@ -170,7 +153,6 @@ static void register_accel_types(void)
170153
{
171154
type_register_static(&accel_type);
172155
type_register_static(&tcg_accel_type);
173-
type_register_static(&xen_accel_type);
174156
type_register_static(&qtest_accel_type);
175157
}
176158

include/hw/xen/xen.h

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
3636

3737
qemu_irq *xen_interrupt_controller_init(void);
3838

39-
int xen_init(MachineClass *mc);
4039
void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
4140

4241
#if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)

xen-common-stub.c

-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,3 @@
1111
void xenstore_store_pv_console_info(int i, CharDriverState *chr)
1212
{
1313
}
14-
15-
int xen_init(MachineClass *mc)
16-
{
17-
return -ENOSYS;
18-
}
19-

xen-common.c

+24-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "hw/xen/xen_backend.h"
1212
#include "qmp-commands.h"
1313
#include "sysemu/char.h"
14+
#include "sysemu/accel.h"
1415

1516
//#define DEBUG_XEN
1617

@@ -109,7 +110,7 @@ static void xen_change_state_handler(void *opaque, int running,
109110
}
110111
}
111112

112-
int xen_init(MachineClass *mc)
113+
static int xen_init(MachineClass *mc)
113114
{
114115
xen_xc = xen_xc_interface_open(0, 0, 0);
115116
if (xen_xc == XC_HANDLER_INITIAL_VALUE) {
@@ -121,3 +122,25 @@ int xen_init(MachineClass *mc)
121122
return 0;
122123
}
123124

125+
static void xen_accel_class_init(ObjectClass *oc, void *data)
126+
{
127+
AccelClass *ac = ACCEL_CLASS(oc);
128+
ac->name = "Xen";
129+
ac->init = xen_init;
130+
ac->allowed = &xen_allowed;
131+
}
132+
133+
#define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
134+
135+
static const TypeInfo xen_accel_type = {
136+
.name = TYPE_XEN_ACCEL,
137+
.parent = TYPE_ACCEL,
138+
.class_init = xen_accel_class_init,
139+
};
140+
141+
static void xen_type_init(void)
142+
{
143+
type_register_static(&xen_accel_type);
144+
}
145+
146+
type_init(xen_type_init);

0 commit comments

Comments
 (0)