|
@@ -46,6 +46,8 @@
|
|
#include "qapi/visitor.h"
|
|
#include "qapi/visitor.h"
|
|
#include "hw/s390x/cpu-topology.h"
|
|
#include "hw/s390x/cpu-topology.h"
|
|
#include "kvm/kvm_s390x.h"
|
|
#include "kvm/kvm_s390x.h"
|
|
|
|
+#include "hw/virtio/virtio-md-pci.h"
|
|
|
|
+#include "hw/s390x/virtio-ccw-md.h"
|
|
#include CONFIG_DEVICES
|
|
#include CONFIG_DEVICES
|
|
|
|
|
|
static Error *pv_mig_blocker;
|
|
static Error *pv_mig_blocker;
|
|
@@ -546,11 +548,39 @@ static void s390_machine_reset(MachineState *machine, ResetType type)
|
|
s390_ipl_clear_reset_request();
|
|
s390_ipl_clear_reset_request();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void s390_machine_device_pre_plug(HotplugHandler *hotplug_dev,
|
|
|
|
+ DeviceState *dev, Error **errp)
|
|
|
|
+{
|
|
|
|
+ if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) {
|
|
|
|
+ virtio_ccw_md_pre_plug(VIRTIO_MD_CCW(dev), MACHINE(hotplug_dev), errp);
|
|
|
|
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) {
|
|
|
|
+ error_setg(errp,
|
|
|
|
+ "PCI-attached virtio based memory devices not supported");
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
|
|
static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
|
|
DeviceState *dev, Error **errp)
|
|
DeviceState *dev, Error **errp)
|
|
{
|
|
{
|
|
|
|
+ S390CcwMachineState *s390ms = S390_CCW_MACHINE(hotplug_dev);
|
|
|
|
+
|
|
if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
s390_cpu_plug(hotplug_dev, dev, errp);
|
|
s390_cpu_plug(hotplug_dev, dev, errp);
|
|
|
|
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) {
|
|
|
|
+ /*
|
|
|
|
+ * At this point, the device is realized and set all memdevs mapped, so
|
|
|
|
+ * qemu_maxrampagesize() will pick up the page sizes of these memdevs
|
|
|
|
+ * as well. Before we plug the device and expose any RAM memory regions
|
|
|
|
+ * to the system, make sure we don't exceed the previously set max page
|
|
|
|
+ * size. While only relevant for KVM, there is not really any use case
|
|
|
|
+ * for this with TCG, so we'll unconditionally reject it.
|
|
|
|
+ */
|
|
|
|
+ if (qemu_maxrampagesize() != s390ms->max_pagesize) {
|
|
|
|
+ error_setg(errp, "Memory device uses a bigger page size than"
|
|
|
|
+ " initial memory");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ virtio_ccw_md_plug(VIRTIO_MD_CCW(dev), MACHINE(hotplug_dev), errp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -560,9 +590,20 @@ static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev,
|
|
if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
error_setg(errp, "CPU hot unplug not supported on this machine");
|
|
error_setg(errp, "CPU hot unplug not supported on this machine");
|
|
return;
|
|
return;
|
|
|
|
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) {
|
|
|
|
+ virtio_ccw_md_unplug_request(VIRTIO_MD_CCW(dev), MACHINE(hotplug_dev),
|
|
|
|
+ errp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void s390_machine_device_unplug(HotplugHandler *hotplug_dev,
|
|
|
|
+ DeviceState *dev, Error **errp)
|
|
|
|
+{
|
|
|
|
+ if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) {
|
|
|
|
+ virtio_ccw_md_unplug(VIRTIO_MD_CCW(dev), MACHINE(hotplug_dev), errp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
static CpuInstanceProperties s390_cpu_index_to_props(MachineState *ms,
|
|
static CpuInstanceProperties s390_cpu_index_to_props(MachineState *ms,
|
|
unsigned cpu_index)
|
|
unsigned cpu_index)
|
|
{
|
|
{
|
|
@@ -609,7 +650,9 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms)
|
|
static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
|
|
static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
|
|
DeviceState *dev)
|
|
DeviceState *dev)
|
|
{
|
|
{
|
|
- if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
|
|
|
|
|
+ if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) ||
|
|
|
|
+ object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW) ||
|
|
|
|
+ object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) {
|
|
return HOTPLUG_HANDLER(machine);
|
|
return HOTPLUG_HANDLER(machine);
|
|
}
|
|
}
|
|
return NULL;
|
|
return NULL;
|
|
@@ -769,8 +812,10 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
|
|
mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
|
|
mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
|
|
/* it is overridden with 'host' cpu *in kvm_arch_init* */
|
|
/* it is overridden with 'host' cpu *in kvm_arch_init* */
|
|
mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
|
|
mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
|
|
|
|
+ hc->pre_plug = s390_machine_device_pre_plug;
|
|
hc->plug = s390_machine_device_plug;
|
|
hc->plug = s390_machine_device_plug;
|
|
hc->unplug_request = s390_machine_device_unplug_request;
|
|
hc->unplug_request = s390_machine_device_unplug_request;
|
|
|
|
+ hc->unplug = s390_machine_device_unplug;
|
|
nc->nmi_monitor_handler = s390_nmi;
|
|
nc->nmi_monitor_handler = s390_nmi;
|
|
mc->default_ram_id = "s390.ram";
|
|
mc->default_ram_id = "s390.ram";
|
|
mc->default_nic = "virtio-net-ccw";
|
|
mc->default_nic = "virtio-net-ccw";
|