cryptospore / rpms / qemu-kvm

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