@@ -18,6 +18,7 @@
#include "trace.h"
#include "hw/qdev.h"
#include "qapi/error.h"
+#include "hw/s390x/s390-virtio-ccw.h"
S390FLICState *s390_get_flic(void)
{
@@ -137,3 +138,50 @@ static void qemu_s390_flic_register_types(void)
}
type_init(qemu_s390_flic_register_types)
+
+static bool adapter_info_so_needed(void *opaque)
+{
+ return css_migration_enabled();
+}
+
+const VMStateDescription vmstate_adapter_info_so = {
+ .name = "s390_adapter_info/summary_offset",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = adapter_info_so_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32(summary_offset, AdapterInfo),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+const VMStateDescription vmstate_adapter_info = {
+ .name = "s390_adapter_info",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT64(ind_offset, AdapterInfo),
+ /*
+ * We do not have to migrate neither the id nor the addresses.
+ * The id is set by css_register_io_adapter and the addresses
+ * are set based on the IndAddr objects after those get mapped.
+ */
+ VMSTATE_END_OF_LIST()
+ },
+ .subsections = (const VMStateDescription * []) {
+ &vmstate_adapter_info_so,
+ NULL
+ }
+};
+
+const VMStateDescription vmstate_adapter_routes = {
+
+ .name = "s390_adapter_routes",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_STRUCT(adapter, AdapterRoutes, 1, vmstate_adapter_info, \
+ AdapterInfo),
+ VMSTATE_END_OF_LIST()
+ }
+};
@@ -34,9 +34,47 @@
#include "virtio-ccw.h"
#include "trace.h"
#include "hw/s390x/css-bridge.h"
+#include "hw/s390x/s390-virtio-ccw.h"
#define NR_CLASSIC_INDICATOR_BITS 64
+static int virtio_ccw_dev_post_load(void *opaque, int version_id)
+{
+ VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(opaque);
+ CcwDevice *ccw_dev = CCW_DEVICE(dev);
+ CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);
+
+ ccw_dev->sch->driver_data = dev;
+ if (CCW_DEVICE(dev)->sch->thinint_active) {
+ dev->routes.adapter.adapter_id = css_get_adapter_id(
+ CSS_IO_ADAPTER_VIRTIO,
+ dev->thinint_isc);
+ }
+ /* Re-fill subch_id after loading the subchannel states.*/
+ if (ck->refill_ids) {
+ ck->refill_ids(ccw_dev);
+ }
+ return 0;
+}
+
+const VMStateDescription vmstate_virtio_ccw_dev = {
+ .name = "s390_virtio_ccw_dev",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .post_load = virtio_ccw_dev_post_load,
+ .fields = (VMStateField[]) {
+ VMSTATE_CCW_DEVICE(parent_obj, VirtioCcwDevice),
+ VMSTATE_PTR_TO_IND_ADDR(indicators, VirtioCcwDevice),
+ VMSTATE_PTR_TO_IND_ADDR(indicators2, VirtioCcwDevice),
+ VMSTATE_PTR_TO_IND_ADDR(summary_indicator, VirtioCcwDevice),
+ VMSTATE_STRUCT(routes, VirtioCcwDevice, 1, vmstate_adapter_routes, \
+ AdapterRoutes),
+ VMSTATE_UINT8(thinint_isc, VirtioCcwDevice),
+ VMSTATE_INT32(revision, VirtioCcwDevice),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
VirtioCcwDevice *dev);
@@ -31,6 +31,11 @@ typedef struct AdapterRoutes {
int gsi[ADAPTER_ROUTES_MAX_GSI];
} AdapterRoutes;
+extern const VMStateDescription vmstate_adapter_routes;
+
+#define VMSTATE_ADAPTER_ROUTES(_f, _s) \
+ VMSTATE_STRUCT(_f, _s, 1, vmstate_adapter_routes, AdapterRoutes)
+
#define TYPE_S390_FLIC_COMMON "s390-flic"
#define S390_FLIC_COMMON(obj) \
OBJECT_CHECK(S390FLICState, (obj), TYPE_S390_FLIC_COMMON)