Skip to content

Commit

Permalink
spapr/xive: Deduce the SpaprXive pointer from XiveTCTX::xptr
Browse files Browse the repository at this point in the history
And use it instead of reaching out to the machine. This allows to get rid
of a call to qdev_get_machine() and to reduce the scope of another one so
that it is only used within the argument list of error_append_hint(). This
is an acceptable tradeoff compared to all it would require to know about
the maximum number of CPUs here without calling qdev_get_machine().

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20200106145645.4539-10-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
gkurz authored and dgibson committed Jan 8, 2020
1 parent 4795094 commit 74e51a3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions hw/intc/spapr_xive_kvm.c
Expand Up @@ -75,7 +75,7 @@ static void kvm_cpu_disable_all(void)

void kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp)
{
SpaprXive *xive = SPAPR_MACHINE(qdev_get_machine())->xive;
SpaprXive *xive = SPAPR_XIVE(tctx->xptr);
uint64_t state[2];
int ret;

Expand All @@ -97,7 +97,7 @@ void kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp)

void kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp)
{
SpaprXive *xive = SPAPR_MACHINE(qdev_get_machine())->xive;
SpaprXive *xive = SPAPR_XIVE(tctx->xptr);
uint64_t state[2] = { 0 };
int ret;

Expand Down Expand Up @@ -152,8 +152,7 @@ void kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, Error **errp)

void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp)
{
MachineState *ms = MACHINE(qdev_get_machine());
SpaprXive *xive = SPAPR_MACHINE(ms)->xive;
SpaprXive *xive = SPAPR_XIVE(tctx->xptr);
unsigned long vcpu_id;
int ret;

Expand All @@ -179,7 +178,7 @@ void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp)
vcpu_id, strerror(errno));
if (errno == ENOSPC) {
error_append_hint(&local_err, "Try -smp maxcpus=N with N < %u\n",
ms->smp.max_cpus);
MACHINE(qdev_get_machine())->smp.max_cpus);
}
error_propagate(errp, local_err);
return;
Expand Down

0 comments on commit 74e51a3

Please sign in to comment.