yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
8fced6
From fc5d5887462da813d91a3a0649214313d580d7af Mon Sep 17 00:00:00 2001
8fced6
From: Claudio Imbrenda <cimbrend@redhat.com>
8fced6
Date: Tue, 27 Oct 2020 12:02:16 -0400
8fced6
Subject: [PATCH 03/18] virtio: add vhost-user-fs-ccw device
8fced6
8fced6
RH-Author: Claudio Imbrenda <cimbrend@redhat.com>
8fced6
Message-id: <20201027120217.2997314-3-cimbrend@redhat.com>
8fced6
Patchwork-id: 98720
8fced6
O-Subject: [RHEL8.4 qemu-kvm PATCH 2/3] virtio: add vhost-user-fs-ccw device
8fced6
Bugzilla: 1857733
8fced6
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
RH-Acked-by: Thomas Huth <thuth@redhat.com>
8fced6
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
8fced6
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
8fced6
8fced6
From: Halil Pasic <pasic@linux.ibm.com>
8fced6
8fced6
upstream bd0bbb9aba2afbc2ea24b0475be04f795468b381
8fced6
8fced6
fixed for the backport:
8fced6
* makefile logic instead of meson
8fced6
* old style qdev initialization
8fced6
* old style device class properties
8fced6
8fced6
--
8fced6
8fced6
Wire up the CCW device for vhost-user-fs.
8fced6
8fced6
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
8fced6
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
8fced6
Message-id: 20200901150019.29229-2-mhartmay@linux.ibm.com
8fced6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 hw/s390x/Makefile.objs       |  1 +
8fced6
 hw/s390x/vhost-user-fs-ccw.c | 76 ++++++++++++++++++++++++++++++++++++
8fced6
 2 files changed, 77 insertions(+)
8fced6
 create mode 100644 hw/s390x/vhost-user-fs-ccw.c
8fced6
8fced6
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
8fced6
index a46a1c7894e..c4086ec3171 100644
8fced6
--- a/hw/s390x/Makefile.objs
8fced6
+++ b/hw/s390x/Makefile.objs
8fced6
@@ -20,6 +20,7 @@ obj-$(CONFIG_VIRTIO_NET) += virtio-ccw-net.o
8fced6
 obj-$(CONFIG_VIRTIO_BLK) += virtio-ccw-blk.o
8fced6
 obj-$(call land,$(CONFIG_VIRTIO_9P),$(CONFIG_VIRTFS)) += virtio-ccw-9p.o
8fced6
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-ccw.o
8fced6
+obj-$(CONFIG_VHOST_USER_FS) += vhost-user-fs-ccw.o
8fced6
 endif
8fced6
 obj-y += css-bridge.o
8fced6
 obj-y += ccw-device.o
8fced6
diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c
8fced6
new file mode 100644
8fced6
index 00000000000..e7b165d5f61
8fced6
--- /dev/null
8fced6
+++ b/hw/s390x/vhost-user-fs-ccw.c
8fced6
@@ -0,0 +1,76 @@
8fced6
+/*
8fced6
+ * virtio ccw vhost-user-fs implementation
8fced6
+ *
8fced6
+ * Copyright 2020 IBM Corp.
8fced6
+ *
8fced6
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
8fced6
+ * your option) any later version. See the COPYING file in the top-level
8fced6
+ * directory.
8fced6
+ */
8fced6
+#include "qemu/osdep.h"
8fced6
+#include "hw/qdev-properties.h"
8fced6
+#include "qapi/error.h"
8fced6
+#include "hw/virtio/vhost-user-fs.h"
8fced6
+#include "virtio-ccw.h"
8fced6
+
8fced6
+typedef struct VHostUserFSCcw {
8fced6
+    VirtioCcwDevice parent_obj;
8fced6
+    VHostUserFS vdev;
8fced6
+} VHostUserFSCcw;
8fced6
+
8fced6
+#define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
8fced6
+#define VHOST_USER_FS_CCW(obj) \
8fced6
+        OBJECT_CHECK(VHostUserFSCcw, (obj), TYPE_VHOST_USER_FS_CCW)
8fced6
+
8fced6
+
8fced6
+static Property vhost_user_fs_ccw_properties[] = {
8fced6
+    DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
8fced6
+                    VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
8fced6
+    DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
8fced6
+                       VIRTIO_CCW_MAX_REV),
8fced6
+    DEFINE_PROP_END_OF_LIST(),
8fced6
+};
8fced6
+
8fced6
+static void vhost_user_fs_ccw_realize(VirtioCcwDevice *ccw_dev, Error **errp)
8fced6
+{
8fced6
+    VHostUserFSCcw *dev = VHOST_USER_FS_CCW(ccw_dev);
8fced6
+    DeviceState *vdev = DEVICE(&dev->vdev);
8fced6
+
8fced6
+    qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
8fced6
+    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
8fced6
+}
8fced6
+
8fced6
+static void vhost_user_fs_ccw_instance_init(Object *obj)
8fced6
+{
8fced6
+    VHostUserFSCcw *dev = VHOST_USER_FS_CCW(obj);
8fced6
+    VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
8fced6
+
8fced6
+    ccw_dev->force_revision_1 = true;
8fced6
+    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
8fced6
+                                TYPE_VHOST_USER_FS);
8fced6
+}
8fced6
+
8fced6
+static void vhost_user_fs_ccw_class_init(ObjectClass *klass, void *data)
8fced6
+{
8fced6
+    DeviceClass *dc = DEVICE_CLASS(klass);
8fced6
+    VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
8fced6
+
8fced6
+    k->realize = vhost_user_fs_ccw_realize;
8fced6
+    dc->props = vhost_user_fs_ccw_properties;
8fced6
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
8fced6
+}
8fced6
+
8fced6
+static const TypeInfo vhost_user_fs_ccw = {
8fced6
+    .name          = TYPE_VHOST_USER_FS_CCW,
8fced6
+    .parent        = TYPE_VIRTIO_CCW_DEVICE,
8fced6
+    .instance_size = sizeof(VHostUserFSCcw),
8fced6
+    .instance_init = vhost_user_fs_ccw_instance_init,
8fced6
+    .class_init    = vhost_user_fs_ccw_class_init,
8fced6
+};
8fced6
+
8fced6
+static void vhost_user_fs_ccw_register(void)
8fced6
+{
8fced6
+    type_register_static(&vhost_user_fs_ccw);
8fced6
+}
8fced6
+
8fced6
+type_init(vhost_user_fs_ccw_register)
8fced6
-- 
8fced6
2.27.0
8fced6