thebeanogamer / rpms / qemu-kvm

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