Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / hw / s390x / vhost-vsock-ccw.c
blob07845a9a006f5c02595b89d41f7d3ff54b709464
1 /*
2 * vhost vsock ccw implementation
4 * This work is licensed under the terms of the GNU GPL, version 2 or (at
5 * your option) any later version. See the COPYING file in the top-level
6 * directory.
7 */
9 #include "qemu/osdep.h"
10 #include "hw/qdev-properties.h"
11 #include "hw/virtio/virtio.h"
12 #include "qapi/error.h"
13 #include "qemu/module.h"
14 #include "virtio-ccw.h"
15 #include "hw/virtio/vhost-vsock.h"
17 #define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw"
18 OBJECT_DECLARE_SIMPLE_TYPE(VHostVSockCCWState, VHOST_VSOCK_CCW)
20 struct VHostVSockCCWState {
21 VirtioCcwDevice parent_obj;
22 VHostVSock vdev;
25 static Property vhost_vsock_ccw_properties[] = {
26 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
27 VIRTIO_CCW_MAX_REV),
28 DEFINE_PROP_END_OF_LIST(),
31 static void vhost_vsock_ccw_realize(VirtioCcwDevice *ccw_dev, Error **errp)
33 VHostVSockCCWState *dev = VHOST_VSOCK_CCW(ccw_dev);
34 DeviceState *vdev = DEVICE(&dev->vdev);
36 qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
39 static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data)
41 DeviceClass *dc = DEVICE_CLASS(klass);
42 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
44 k->realize = vhost_vsock_ccw_realize;
45 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
46 device_class_set_props(dc, vhost_vsock_ccw_properties);
49 static void vhost_vsock_ccw_instance_init(Object *obj)
51 VHostVSockCCWState *dev = VHOST_VSOCK_CCW(obj);
52 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
53 VirtIODevice *virtio_dev;
55 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
56 TYPE_VHOST_VSOCK);
58 virtio_dev = VIRTIO_DEVICE(&dev->vdev);
61 * To avoid migration issues, we force virtio version 1 only when
62 * legacy check is enabled in the new machine types (>= 5.1).
64 if (!virtio_legacy_check_disabled(virtio_dev)) {
65 ccw_dev->force_revision_1 = true;
69 static const TypeInfo vhost_vsock_ccw_info = {
70 .name = TYPE_VHOST_VSOCK_CCW,
71 .parent = TYPE_VIRTIO_CCW_DEVICE,
72 .instance_size = sizeof(VHostVSockCCWState),
73 .instance_init = vhost_vsock_ccw_instance_init,
74 .class_init = vhost_vsock_ccw_class_init,
77 static void vhost_vsock_ccw_register(void)
79 type_register_static(&vhost_vsock_ccw_info);
82 type_init(vhost_vsock_ccw_register)