Skip to content

Commit

Permalink
accel: Rename 'init' method to 'init_machine'
Browse files Browse the repository at this point in the history
Today, all accelerator init functions affect some global state:
* tcg_init() calls tcg_exec_init() and affects globals such as tcg_tcx,
  page size globals, and possibly others;
* kvm_init() changes the kvm_state global, cpu_interrupt_handler, and possibly
  others;
* xen_init() changes the xen_xc global, and registers a change state handler.

With the new accelerator QOM classes, initialization may now be split in two
steps:
* instance_init() will do basic initialization that doesn't affect any global
  state and don't need MachineState or MachineClass data. This will allow
  probing code to safely create multiple accelerator objects on the fly just
  for reporting host/accelerator capabilities, for example.
* accel_init_machine()/init_machine() will save the accelerator object in
  MachineState, and do initialization steps which still affect global state,
  machine state, or that need data from MachineClass or MachineState.

To clarify the difference between those two steps, rename init() to
init_machine().

Signed-off-by: Eduardo Habkost <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
ehabkost authored and bonzini committed Oct 4, 2014
1 parent d95c852 commit 0d15da8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ static AccelClass *accel_find(const char *opt_name)
return ac;
}

static int accel_init(AccelClass *acc, MachineClass *mc)
static int accel_init_machine(AccelClass *acc, MachineClass *mc)
{
int ret;
*(acc->allowed) = true;
ret = acc->init(mc);
ret = acc->init_machine(mc);
if (ret < 0) {
*(acc->allowed) = false;
}
Expand Down Expand Up @@ -98,7 +98,7 @@ int configure_accelerator(MachineClass *mc)
acc->name);
continue;
}
ret = accel_init(acc, mc);
ret = accel_init_machine(acc, mc);
if (ret < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
Expand Down Expand Up @@ -128,7 +128,7 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "tcg";
ac->init = tcg_init;
ac->init_machine = tcg_init;
ac->allowed = &tcg_allowed;
}

Expand Down
2 changes: 1 addition & 1 deletion include/sysemu/accel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef struct AccelClass {
const char *opt_name;
const char *name;
int (*available)(void);
int (*init)(MachineClass *mc);
int (*init_machine)(MachineClass *mc);
bool *allowed;
} AccelClass;

Expand Down
2 changes: 1 addition & 1 deletion kvm-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -2233,7 +2233,7 @@ static void kvm_accel_class_init(ObjectClass *oc, void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "KVM";
ac->init = kvm_init;
ac->init_machine = kvm_init;
ac->allowed = &kvm_allowed;
}

Expand Down
2 changes: 1 addition & 1 deletion qtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static void qtest_accel_class_init(ObjectClass *oc, void *data)
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "QTest";
ac->available = qtest_available;
ac->init = qtest_init_accel;
ac->init_machine = qtest_init_accel;
ac->allowed = &qtest_allowed;
}

Expand Down
2 changes: 1 addition & 1 deletion xen-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void xen_accel_class_init(ObjectClass *oc, void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "Xen";
ac->init = xen_init;
ac->init_machine = xen_init;
ac->allowed = &xen_allowed;
}

Expand Down

0 comments on commit 0d15da8

Please sign in to comment.