On 04.03.20 12:42, Janosch Frank wrote:
[...]
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index 3dd396e870..69b1cc5dfc 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -37,6 +37,8 @@
> #include "sysemu/hw_accel.h"
> #include "hw/qdev-properties.h"
> #ifndef CONFIG_USER_ONLY
> +#include "hw/s390x/s390-virtio-ccw.h"
> +#include "hw/s390x/pv.h"
> #include "hw/boards.h"
> #include "sysemu/arch_init.h"
> #include "sysemu/sysemu.h"
> @@ -191,6 +193,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error
> **errp)
>
> #if !defined(CONFIG_USER_ONLY)
> MachineState *ms = MACHINE(qdev_get_machine());
> + S390CcwMachineState *ccw = S390_CCW_MACHINE(ms);
> unsigned int max_cpus = ms->smp.max_cpus;
> if (cpu->env.core_id >= max_cpus) {
> error_setg(&err, "Unable to add CPU with core-id: %" PRIu32
I messed this up and this can break for the none machine.
Something like this on top:
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 7840e784f1..1b42b0fa25 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -181,6 +181,18 @@ static void s390_cpu_disas_set_info(CPUState *cpu,
disassemble_info *info)
info->print_insn = print_insn_s390;
}
+static bool machine_is_pv(MachineState *ms)
+{
+ Object *obj;
+
+ /* we have to bail out for the "none" machine */
+ obj = object_dynamic_cast(OBJECT(ms), TYPE_S390_CCW_MACHINE);
+ if (!obj) {
+ return false;
+ }
+ return S390_CCW_MACHINE(obj)->pv;
+}
+
static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cs = CPU(dev);
@@ -198,7 +210,6 @@ static void s390_cpu_realizefn(DeviceState *dev, Error
**errp)
#if !defined(CONFIG_USER_ONLY)
MachineState *ms = MACHINE(qdev_get_machine());
- S390CcwMachineState *ccw = S390_CCW_MACHINE(ms);
unsigned int max_cpus = ms->smp.max_cpus;
if (cpu->env.core_id >= max_cpus) {
error_setg(&err, "Unable to add CPU with core-id: %" PRIu32
@@ -213,7 +224,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error
**errp)
goto out;
}
- cpu->env.pv = ccw->pv;
+ cpu->env.pv = machine_is_pv(ms);
/* sync cs->cpu_index and env->core_id. The latter is needed for TCG. */
cs->cpu_index = cpu->env.core_id;
#endif