[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 8/9] s390/virtio-ccw: Add hotplug handler and pre
From: |
Matthew Rosato |
Subject: |
[Qemu-devel] [PATCH v2 8/9] s390/virtio-ccw: Add hotplug handler and prepare for unplug |
Date: |
Thu, 19 Nov 2015 10:10:13 -0500 |
Prepare for hotplug and unplug of s390-cpu. In the case
of unplug, s390 does not have a safe way of communicating
the loss of CPU to a guest, so a full system reset will
be performed on the guest.
Signed-off-by: Matthew Rosato <address@hidden>
---
hw/s390x/s390-virtio-ccw.c | 28 ++++++++++++++++++++++++++++
target-s390x/cpu.c | 32 +++++++++++++++++++++++++++++++-
target-s390x/cpu.h | 2 ++
3 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 4f6ed57..ba0a90d 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -155,10 +155,34 @@ static void ccw_init(MachineState *machine)
gtod_save, gtod_load, kvm_state);
}
+static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
+{
+
+}
+
+static void s390_machine_device_unplug(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
+{
+ if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+ s390_cpu_unplug(hotplug_dev, dev, errp);
+ }
+}
+
+static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
+ DeviceState *dev)
+{
+ if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+ return HOTPLUG_HANDLER(machine);
+ }
+ return NULL;
+}
+
static void ccw_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
NMIClass *nc = NMI_CLASS(oc);
+ HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
mc->init = ccw_init;
mc->reset = s390_machine_reset;
@@ -170,6 +194,9 @@ static void ccw_machine_class_init(ObjectClass *oc, void
*data)
mc->no_sdcard = 1;
mc->use_sclp = 1;
mc->max_cpus = 255;
+ mc->get_hotplug_handler = s390_get_hotplug_handler;
+ hc->plug = s390_machine_device_plug;
+ hc->unplug = s390_machine_device_unplug;
nc->nmi_monitor_handler = s390_nmi;
}
@@ -231,6 +258,7 @@ static const TypeInfo ccw_machine_info = {
.class_init = ccw_machine_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_NMI },
+ { TYPE_HOTPLUG_HANDLER},
{ }
},
};
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 060a3cc..4b83a09 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -236,7 +236,6 @@ static void s390_cpu_initfn(Object *obj)
#if !defined(CONFIG_USER_ONLY)
struct tm tm;
#endif
-
cs->env_ptr = env;
cs->halted = 1;
cs->exception_index = EXCP_HLT;
@@ -282,6 +281,37 @@ static void s390_cpu_finalize(Object *obj)
}
#if !defined(CONFIG_USER_ONLY)
+static void s390_cpu_destroy(S390CPU *cpu)
+{
+ CPUS390XState *env = &cpu->env;
+ s390_unregister_cpustate(env->cpu_num);
+}
+
+static void s390_cpu_release(DeviceState *dev, void *opaque)
+{
+ CPUState *cs = CPU(dev);
+
+ s390_cpu_destroy(S390_CPU(cs));
+ cpu_remove(cs);
+}
+
+int s390_cpu_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp)
+{
+ S390CPU *cpu = S390_CPU(dev);
+ CPUS390XState *env = &cpu->env;
+
+ if (next_cpu_id > env->cpu_num) {
+ next_cpu_id = env->cpu_num;
+ }
+ s390_cpu_release(dev, NULL);
+
+ /* Perform a full system reset */
+ qemu_system_reset_request();
+
+ return 0;
+}
+
static bool disabled_wait(CPUState *cpu)
{
return cpu->halted && !(S390_CPU(cpu)->env.psw.mask &
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 524a7e4..81554b5 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -543,6 +543,8 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu)
void gtod_save(QEMUFile *f, void *opaque);
int gtod_load(QEMUFile *f, void *opaque, int version_id);
+int s390_cpu_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp);
/* service interrupts are floating therefore we must not pass an cpustate */
void s390_sclp_extint(uint32_t parm);
--
1.9.1
- Re: [Qemu-devel] [PATCH v2 1/9] cpus: Reclaim vCPU objects, (continued)
- [Qemu-devel] [PATCH v2 6/9] s390x/cpu: Add functions to (un)register CPU state, Matthew Rosato, 2015/11/19
- [Qemu-devel] [PATCH v2 4/9] s390x/cpu: Set initial CPU state in common routine, Matthew Rosato, 2015/11/19
- [Qemu-devel] [PATCH v2 5/9] s390x/cpu: Move some CPU initialization into realize, Matthew Rosato, 2015/11/19
- [Qemu-devel] [PATCH v2 3/9] s390x/cpu: Cleanup init in preparation for hotplug, Matthew Rosato, 2015/11/19
- [Qemu-devel] [PATCH v2 2/9] cpus: Add a sync version of cpu_remove(), Matthew Rosato, 2015/11/19
- [Qemu-devel] [PATCH v2 7/9] s390x/cpu: Extra cleanup during CPU finalize, Matthew Rosato, 2015/11/19
- [Qemu-devel] [PATCH v2 9/9] s390x/cpu: Allow hot plug/unplug of CPUs, Matthew Rosato, 2015/11/19
- [Qemu-devel] [PATCH v2 8/9] s390/virtio-ccw: Add hotplug handler and prepare for unplug,
Matthew Rosato <=