[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 5/5] spapr: Simplify spapr_cpu_core_realize() and spapr_cpu_co
From: |
Greg Kurz |
Subject: |
[PATCH v2 5/5] spapr: Simplify spapr_cpu_core_realize() and spapr_cpu_core_unrealize() |
Date: |
Thu, 15 Oct 2020 23:18:53 +0200 |
User-agent: |
StGit/0.21 |
Now that the error path of spapr_cpu_core_realize() is just to call
idempotent spapr_cpu_core_unrealize() for rollback, no need to create
and realize the vCPUs in two separate loops.
Merge them and do them same in spapr_cpu_core_unrealize() for symmetry.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_cpu_core.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 317fb9934f58..2f7dc3c23ded 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -238,10 +238,6 @@ static void spapr_cpu_core_unrealize(DeviceState *dev)
&error_abort)) {
spapr_unrealize_vcpu(sc->threads[i], sc);
}
- }
- }
- for (i = 0; i < cc->nr_threads; i++) {
- if (sc->threads[i]) {
spapr_delete_vcpu(sc->threads[i]);
}
}
@@ -326,7 +322,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error
**errp)
TYPE_SPAPR_MACHINE);
SpaprCpuCore *sc = SPAPR_CPU_CORE(OBJECT(dev));
CPUCore *cc = CPU_CORE(OBJECT(dev));
- int i, j;
+ int i;
if (!spapr) {
error_setg(errp, TYPE_SPAPR_CPU_CORE " needs a pseries machine");
@@ -337,14 +333,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error
**errp)
sc->threads = g_new0(PowerPCCPU *, cc->nr_threads);
for (i = 0; i < cc->nr_threads; i++) {
sc->threads[i] = spapr_create_vcpu(sc, i, errp);
- if (!sc->threads[i]) {
- spapr_cpu_core_unrealize(dev);
- return;
- }
- }
-
- for (j = 0; j < cc->nr_threads; j++) {
- if (!spapr_realize_vcpu(sc->threads[j], spapr, sc, errp)) {
+ if (!sc->threads[i] ||
+ !spapr_realize_vcpu(sc->threads[i], spapr, sc, errp)) {
spapr_cpu_core_unrealize(dev);
return;
}
- [PATCH v2 0/5] spapr: Fix and cleanups for sPAPR CPU core, Greg Kurz, 2020/10/15
- [PATCH v2 3/5] spapr: Drop spapr_delete_vcpu() unused argument, Greg Kurz, 2020/10/15
- [PATCH v2 4/5] spapr: Make spapr_cpu_core_unrealize() idempotent, Greg Kurz, 2020/10/15
- [PATCH v2 2/5] spapr: Unrealize vCPUs with qdev_unrealize(), Greg Kurz, 2020/10/15
- [PATCH v2 1/5] spapr: Fix leak of CPU machine specific data, Greg Kurz, 2020/10/15
- [PATCH v2 5/5] spapr: Simplify spapr_cpu_core_realize() and spapr_cpu_core_unrealize(),
Greg Kurz <=
- Re: [PATCH v2 0/5] spapr: Fix and cleanups for sPAPR CPU core, David Gibson, 2020/10/22