Skip to contentSkip to conversation

virtio: add input device

PATCH In review Gerd Hoffmann 2 participants 14 messages Mar 18, 2015 – Mar 19, 2015

lore
Share & tools
lore
#0 lore raw

cover virtio: add input device

Hi,

This patch series adds virtio input devices. It's basically sending linux evdev events over virtio. There is support for emulated hid devices (i.e. send usual input to virtio device instead of usb or ps2 device) and for evdev device pass-through.

This depends on mst's virtio-1.0 patches.

Guest driver:
https://www.kraxel.org/cgit/linux/log/?h=virtio-input

Specification:
https://www.kraxel.org/cgit/virtio-spec/log/?h=virtio-input
https://www.kraxel.org/virtio/virtio-v1.0-csprd03-virtio-input.html#x1-2640007

Gerd Hoffmann (4):
pci: add PCI_CLASS_INPUT_*
virtio-input: core code & base class
virtio-input: emulated devices
virtio-input: evdev passthrough

 hw/input/Makefile.objs           |   6 +
 hw/input/virtio-input-hid.c      | 482 +++++++++++++++++++++++++++++++++++++++
 hw/input/virtio-input-host.c     | 172 ++++++++++++++
 hw/input/virtio-input.c          | 284 +++++++++++++++++++++++
 hw/virtio/virtio-pci.c           | 150 ++++++++++++
 hw/virtio/virtio-pci.h           |  37 +++
 include/hw/pci/pci_ids.h         |   7 +
 include/hw/virtio/virtio-input.h | 140 ++++++++++++
 include/hw/virtio/virtio.h       |   1 +
 9 files changed, 1279 insertions(+)
 create mode 100644 hw/input/virtio-input-hid.c
 create mode 100644 hw/input/virtio-input-host.c
 create mode 100644 hw/input/virtio-input.c
 create mode 100644 include/hw/virtio/virtio-input.h
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/4 pci: add PCI_CLASS_INPUT_*

---
 include/hw/pci/pci_ids.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/hw/pci/pci_ids.h +7 -0
index d7be386..dfccefc 100644
@@ -46,6 +46,13 @@
 #define PCI_CLASS_COMMUNICATION_SERIAL   0x0700
 #define PCI_CLASS_COMMUNICATION_OTHER    0x0780
 
+#define PCI_CLASS_INPUT_KEYBOARD         0x0900
+#define PCI_CLASS_INPUT_PEN              0x0901
+#define PCI_CLASS_INPUT_MOUSE            0x0902
+#define PCI_CLASS_INPUT_SCANNER          0x0903
+#define PCI_CLASS_INPUT_GAMEPORT         0x0904
+#define PCI_CLASS_INPUT_OTHER            0x0980
+
 #define PCI_CLASS_PROCESSOR_CO           0x0b40
 #define PCI_CLASS_PROCESSOR_POWERPC      0x0b20
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/4 virtio-input: core code & base class

In reply to Gerd Hoffmann

This patch adds virtio-input support to qemu. It brings a abstract base class providing core support, other classes can build on it to actually implement input devices.

virtio-input basically sends linux input layer events (evdev) over virtio.

---
 hw/input/Makefile.objs           |   4 +
 hw/input/virtio-input.c          | 284 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pci.c           |  36 +++++
 hw/virtio/virtio-pci.h           |  14 ++
 include/hw/virtio/virtio-input.h | 106 +++++++++++++++
 include/hw/virtio/virtio.h       |   1 +
 6 files changed, 445 insertions(+)
 create mode 100644 hw/input/virtio-input.c
 create mode 100644 include/hw/virtio/virtio-input.h
hw/input/Makefile.objs +4 -0
index e8c80b9..ee8bba9 100644
@@ -8,6 +8,10 @@ common-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
 common-obj-$(CONFIG_TSC2005) += tsc2005.o
 common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
 
+ifeq ($(CONFIG_LINUX),y)
+common-obj-$(CONFIG_VIRTIO) += virtio-input.o
+endif
+
 obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
 obj-$(CONFIG_PXA2XX) += pxa2xx_keypad.o
 obj-$(CONFIG_TSC210X) += tsc210x.o
hw/input/virtio-input.c new file +284 -0

284 lines not on this page · raw message

hw/virtio/virtio-pci.c +36 -0
index 4c653fe..4bfd927 100644
@@ -24,6 +24,7 @@
 #include "hw/virtio/virtio-serial.h"
 #include "hw/virtio/virtio-scsi.h"
 #include "hw/virtio/virtio-balloon.h"
+#include "hw/virtio/virtio-input.h"
 #include "hw/pci/pci.h"
 #include "qemu/error-report.h"
 #include "hw/pci/msi.h"
@@ -1888,6 +1889,40 @@ static const TypeInfo virtio_rng_pci_info = {
     .class_init    = virtio_rng_pci_class_init,
 };
 
+/* virtio-input-pci */
+
+static void virtio_input_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+    VirtIOInputPCI *vinput = VIRTIO_INPUT_PCI(vpci_dev);
+    DeviceState *vdev = DEVICE(&vinput->vdev);
+
+    qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
+    /* force virtio-1.0 */
+    vpci_dev->flags &= ~VIRTIO_PCI_FLAG_DISABLE_MODERN;
+    vpci_dev->flags |= VIRTIO_PCI_FLAG_DISABLE_LEGACY;
+    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+}
+
+static void virtio_input_pci_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+    PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+
+    k->realize = virtio_input_pci_realize;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
+
+    pcidev_k->class_id = PCI_CLASS_INPUT_OTHER;
+}
+
+static const TypeInfo virtio_input_pci_info = {
+    .name          = TYPE_VIRTIO_INPUT_PCI,
+    .parent        = TYPE_VIRTIO_PCI,
+    .instance_size = sizeof(VirtIOInputPCI),
+    .class_init    = virtio_input_pci_class_init,
+    .abstract      = true,
+};
+
 /* virtio-pci-bus */
 
 static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
@@ -1929,6 +1964,7 @@ static const TypeInfo virtio_pci_bus_info = {
 static void virtio_pci_register_types(void)
 {
     type_register_static(&virtio_rng_pci_info);
+    type_register_static(&virtio_input_pci_info);
     type_register_static(&virtio_pci_bus_info);
     type_register_static(&virtio_pci_info);
 #ifdef CONFIG_VIRTFS
hw/virtio/virtio-pci.h +14 -0
index b382688..8a744eb 100644
@@ -24,6 +24,7 @@
 #include "hw/virtio/virtio-balloon.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-9p.h"
+#include "hw/virtio/virtio-input.h"
 #ifdef CONFIG_VIRTFS
 #include "hw/9pfs/virtio-9p.h"
 #endif
@@ -39,6 +40,7 @@ typedef struct VirtIOSerialPCI VirtIOSerialPCI;
 typedef struct VirtIONetPCI VirtIONetPCI;
 typedef struct VHostSCSIPCI VHostSCSIPCI;
 typedef struct VirtIORngPCI VirtIORngPCI;
+typedef struct VirtIOInputPCI VirtIOInputPCI;
 
 /* virtio-pci-bus */
 
@@ -225,6 +227,18 @@ struct VirtIORngPCI {
     VirtIORNG vdev;
 };
 
+/*
+ * virtio-input-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci"
+#define VIRTIO_INPUT_PCI(obj) \
+        OBJECT_CHECK(VirtIOInputPCI, (obj), TYPE_VIRTIO_INPUT_PCI)
+
+struct VirtIOInputPCI {
+    VirtIOPCIProxy parent_obj;
+    VirtIOInput vdev;
+};
+
 /* Virtio ABI version, if we increment this, we break the guest driver. */
 #define VIRTIO_PCI_ABI_VERSION          0
 
include/hw/virtio/virtio-input.h new file +106 -0

106 lines not on this page · raw message

include/hw/virtio/virtio.h +1 -0
index a4ade5c..8e33fe4 100644
@@ -201,6 +201,7 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val);
 typedef struct VirtIOBlkConf VirtIOBlkConf;
 struct virtio_net_conf;
 typedef struct virtio_serial_conf virtio_serial_conf;
+typedef struct virtio_input_conf virtio_input_conf;
 typedef struct VirtIOSCSIConf VirtIOSCSIConf;
 typedef struct VirtIORNGConf VirtIORNGConf;
 
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH 4/4 virtio-input: evdev passthrough

In reply to Gerd Hoffmann

This allows to assign host input devices to the guest:

qemu -device virto-input-host-pci,evdev=/dev/input/event<nr>

The guest gets exclusive access to the input device, so be careful with assigning the keyboard if you have only one connected to your machine.

---
 hw/input/Makefile.objs           |   1 +
 hw/input/virtio-input-host.c     | 172 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pci.c           |  30 +++++++
 hw/virtio/virtio-pci.h           |  10 +++
 include/hw/virtio/virtio-input.h |  13 +++
 5 files changed, 226 insertions(+)
 create mode 100644 hw/input/virtio-input-host.c
hw/input/Makefile.objs +1 -0
index 0dae710..624ba7e 100644
@@ -11,6 +11,7 @@ common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
 ifeq ($(CONFIG_LINUX),y)
 common-obj-$(CONFIG_VIRTIO) += virtio-input.o
 common-obj-$(CONFIG_VIRTIO) += virtio-input-hid.o
+common-obj-$(CONFIG_VIRTIO) += virtio-input-host.o
 endif
 
 obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
hw/input/virtio-input-host.c new file +172 -0

172 lines not on this page · raw message

hw/virtio/virtio-pci.c +30 -0
index f7d6b55..d1b02b3 100644
@@ -1897,6 +1897,13 @@ static Property virtio_input_hid_pci_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static Property virtio_input_host_pci_properties[] = {
+    DEFINE_VIRTIO_INPUT_PROPERTIES(VirtIOInputPCI, vdev.input),
+    DEFINE_PROP_STRING("evdev", VirtIOInputHostPCI, vdev.evdev),
+    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void virtio_input_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
 {
     VirtIOInputPCI *vinput = VIRTIO_INPUT_PCI(vpci_dev);
@@ -1943,6 +1950,13 @@ static void virtio_input_hid_mouse_pci_class_init(ObjectClass *klass,
     pcidev_k->class_id = PCI_CLASS_INPUT_MOUSE;
 }
 
+static void virtio_input_host_pci_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->props = virtio_input_host_pci_properties;
+}
+
 static void virtio_keyboard_initfn(Object *obj)
 {
     VirtIOInputHIDPCI *dev = VIRTIO_INPUT_HID_PCI(obj);
@@ -1964,6 +1978,13 @@ static void virtio_tablet_initfn(Object *obj)
     object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
 }
 
+static void virtio_host_initfn(Object *obj)
+{
+    VirtIOInputHostPCI *dev = VIRTIO_INPUT_HOST_PCI(obj);
+    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_INPUT_HOST);
+    object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+}
+
 static const TypeInfo virtio_input_pci_info = {
     .name          = TYPE_VIRTIO_INPUT_PCI,
     .parent        = TYPE_VIRTIO_PCI,
@@ -2003,6 +2024,14 @@ static const TypeInfo virtio_tablet_pci_info = {
     .instance_init = virtio_tablet_initfn,
 };
 
+static const TypeInfo virtio_host_pci_info = {
+    .name          = TYPE_VIRTIO_INPUT_HOST_PCI,
+    .parent        = TYPE_VIRTIO_INPUT_PCI,
+    .instance_size = sizeof(VirtIOInputHostPCI),
+    .instance_init = virtio_host_initfn,
+    .class_init    = virtio_input_host_pci_class_init,
+};
+
 /* virtio-pci-bus */
 
 static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
@@ -2049,6 +2078,7 @@ static void virtio_pci_register_types(void)
     type_register_static(&virtio_keyboard_pci_info);
     type_register_static(&virtio_mouse_pci_info);
     type_register_static(&virtio_tablet_pci_info);
+    type_register_static(&virtio_host_pci_info);
     type_register_static(&virtio_pci_bus_info);
     type_register_static(&virtio_pci_info);
 #ifdef CONFIG_VIRTFS
hw/virtio/virtio-pci.h +10 -0
index dbaca2b..fc58539 100644
@@ -42,6 +42,7 @@ typedef struct VHostSCSIPCI VHostSCSIPCI;
 typedef struct VirtIORngPCI VirtIORngPCI;
 typedef struct VirtIOInputPCI VirtIOInputPCI;
 typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
+typedef struct VirtIOInputHostPCI VirtIOInputHostPCI;
 
 /* virtio-pci-bus */
 
@@ -252,6 +253,15 @@ struct VirtIOInputHIDPCI {
     VirtIOInputHID vdev;
 };
 
+#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci"
+#define VIRTIO_INPUT_HOST_PCI(obj) \
+        OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI)
+
+struct VirtIOInputHostPCI {
+    VirtIOPCIProxy parent_obj;
+    VirtIOInputHost vdev;
+};
+
 /* Virtio ABI version, if we increment this, we break the guest driver. */
 #define VIRTIO_PCI_ABI_VERSION          0
 
include/hw/virtio/virtio-input.h +13 -0
index ca5bcee..eb870bb 100644
@@ -66,6 +66,12 @@ typedef struct virtio_input_event {
 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
         OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
 
+#define TYPE_VIRTIO_INPUT_HOST   "virtio-input-host"
+#define VIRTIO_INPUT_HOST(obj) \
+        OBJECT_CHECK(VirtIOInputHost, (obj), TYPE_VIRTIO_INPUT_HOST)
+#define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
+        OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
+
 #define DEFINE_VIRTIO_INPUT_PROPERTIES(_state, _field)       \
         DEFINE_PROP_STRING("serial", _state, _field.serial)
 
@@ -73,6 +79,7 @@ typedef struct VirtIOInput VirtIOInput;
 typedef struct VirtIOInputClass VirtIOInputClass;
 typedef struct VirtIOInputConfig VirtIOInputConfig;
 typedef struct VirtIOInputHID VirtIOInputHID;
+typedef struct VirtIOInputHost VirtIOInputHost;
 
 struct virtio_input_conf {
     char *serial;
@@ -116,6 +123,12 @@ struct VirtIOInputHID {
     int                               ledstate;
 };
 
+struct VirtIOInputHost {
+    VirtIOInput                       parent_obj;
+    char                              *evdev;
+    int                               fd;
+};
+
 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
 void virtio_input_init_config(VirtIOInput *vinput,
                               virtio_input_config *config);
Signature · 1 line
1.8.3.1
#12 lore raw

PATCH 3/4 virtio-input: emulated devices

In reply to Gerd Hoffmann

This patch adds the virtio-input-hid base class and virtio-{keyboard,mouse,tablet} subclasses building on the base class. They are hooked up to the qemu input core and deliver input events to the guest like all other hid devices (ps/2 kbd, usb tablet, ...).

Using them is as simple as adding "-device virtio-tablet-pci" to your command line. If you want add multiple devices but don't want waste a pci slot for each you can compose a multifunction device this way:

qemu -device virtio-keyboard-pci,addr=0d.0,multifunction=on \
-device virtio-tablet-pci,addr=0d.1,multifunction=on

---
 hw/input/Makefile.objs           |   1 +
 hw/input/virtio-input-hid.c      | 482 +++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pci.c           |  84 +++++++
 hw/virtio/virtio-pci.h           |  13 ++
 include/hw/virtio/virtio-input.h |  21 ++
 5 files changed, 601 insertions(+)
 create mode 100644 hw/input/virtio-input-hid.c
hw/input/Makefile.objs +1 -0
index ee8bba9..0dae710 100644
@@ -10,6 +10,7 @@ common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
 
 ifeq ($(CONFIG_LINUX),y)
 common-obj-$(CONFIG_VIRTIO) += virtio-input.o
+common-obj-$(CONFIG_VIRTIO) += virtio-input-hid.o
 endif
 
 obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
hw/input/virtio-input-hid.c new file +482 -0

482 lines not on this page · raw message

hw/virtio/virtio-pci.c +84 -0

108 lines not on this page · raw message

hw/virtio/virtio-pci.h +13 -0
index 8a744eb..dbaca2b 100644
@@ -41,6 +41,7 @@ typedef struct VirtIONetPCI VirtIONetPCI;
 typedef struct VHostSCSIPCI VHostSCSIPCI;
 typedef struct VirtIORngPCI VirtIORngPCI;
 typedef struct VirtIOInputPCI VirtIOInputPCI;
+typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
 
 /* virtio-pci-bus */
 
@@ -239,6 +240,18 @@ struct VirtIOInputPCI {
     VirtIOInput vdev;
 };
 
+#define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci"
+#define TYPE_VIRTIO_KEYBOARD_PCI  "virtio-keyboard-pci"
+#define TYPE_VIRTIO_MOUSE_PCI     "virtio-mouse-pci"
+#define TYPE_VIRTIO_TABLET_PCI    "virtio-tablet-pci"
+#define VIRTIO_INPUT_HID_PCI(obj) \
+        OBJECT_CHECK(VirtIOInputHIDPCI, (obj), TYPE_VIRTIO_INPUT_HID_PCI)
+
+struct VirtIOInputHIDPCI {
+    VirtIOPCIProxy parent_obj;
+    VirtIOInputHID vdev;
+};
+
 /* Virtio ABI version, if we increment this, we break the guest driver. */
 #define VIRTIO_PCI_ABI_VERSION          0
 
include/hw/virtio/virtio-input.h +21 -0
index 718ebfd..ca5bcee 100644
@@ -56,9 +56,23 @@ typedef struct virtio_input_event {
 #define VIRTIO_INPUT_CLASS(klass) \
         OBJECT_CLASS_CHECK(VirtIOInputClass, klass, TYPE_VIRTIO_INPUT)
 
+#define TYPE_VIRTIO_INPUT_HID "virtio-input-hid"
+#define TYPE_VIRTIO_KEYBOARD  "virtio-keyboard"
+#define TYPE_VIRTIO_MOUSE     "virtio-mouse"
+#define TYPE_VIRTIO_TABLET    "virtio-tablet"
+
+#define VIRTIO_INPUT_HID(obj) \
+        OBJECT_CHECK(VirtIOInputHID, (obj), TYPE_VIRTIO_INPUT_HID)
+#define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
+        OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
+
+#define DEFINE_VIRTIO_INPUT_PROPERTIES(_state, _field)       \
+        DEFINE_PROP_STRING("serial", _state, _field.serial)
+
 typedef struct VirtIOInput VirtIOInput;
 typedef struct VirtIOInputClass VirtIOInputClass;
 typedef struct VirtIOInputConfig VirtIOInputConfig;
+typedef struct VirtIOInputHID VirtIOInputHID;
 
 struct virtio_input_conf {
     char *serial;
@@ -95,6 +109,13 @@ struct VirtIOInputClass {
     void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
 };
 
+struct VirtIOInputHID {
+    VirtIOInput                       parent_obj;
+    QemuInputHandler                  *handler;
+    QemuInputHandlerState             *hs;
+    int                               ledstate;
+};
+
 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
 void virtio_input_init_config(VirtIOInput *vinput,
                               virtio_input_config *config);
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

In reply to Gerd Hoffmann
Quoted 8 lines · Gerd Hoffmann

This patch adds virtio-input support to qemu. It brings a abstract base class providing core support, other classes can build on it to actually implement input devices.

virtio-input basically sends linux input layer events (evdev) over virtio.

Two questions before I looked at code:
- can you do a writeup for the virtio spec?
might make it easier to review.
- does linux need to support this?
if yes we'll eventually want to take
the header from there.
maybe split out guest/host ABI?
also might be a good idea to make style there
linux-compliant (e.g. no typedefs, add typedefs
in another header).

#4 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Gerd Hoffmann

This patch adds virtio-input support to qemu. It brings a abstract base class providing core support, other classes can build on it to actually implement input devices.

virtio-input basically sends linux input layer events (evdev) over virtio.

Quoted 7 lines
Quoted 1 line

Two questions before I looked at code:
- can you do a writeup for the virtio spec?
might make it easier to review.

From cover letter:

<quote>

Guest driver:
https://www.kraxel.org/cgit/linux/log/?h=virtio-input

Specification:
https://www.kraxel.org/cgit/virtio-spec/log/?h=virtio-input
https://www.kraxel.org/virtio/virtio-v1.0-csprd03-virtio-input.html#x1-2640007

</quote>

Guess you havn't seen that (yet) because get_maintainers.pl doesn't really work for the cover letter, only the patches, and I forgot to cc you for the whole series. [ anyone has a solution for this btw? ]

Quoted 1 line

- does linux need to support this?

For pass-through (patch 4) yes, emulated hid devices (patch 3) not really. It is linux only for now because the code simply #includes the system header files for the linux input layer, so it wouldn't compile on something else.

Quoted 2 lines

if yes we'll eventually want to take
the header from there.

Yes, we can do that, for both linux input layer and virtio-input (once merged upstream) headers, then go build this on non-linux hosts too.

I'd suggest to do that as incremental patch, after guest driver merge.

Quoted 1 line

maybe split out guest/host ABI?

When copying over virtio-input header from linux kernel that needs to happen anyway.

Quoted 3 lines

also might be a good idea to make style there
linux-compliant (e.g. no typedefs, add typedefs
in another header).

Linux driver linked above already has that.

cheers,
Gerd

#5 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Quoted 26 lines · Gerd Hoffmann
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Gerd Hoffmann

This patch adds virtio-input support to qemu. It brings a abstract base class providing core support, other classes can build on it to actually implement input devices.

virtio-input basically sends linux input layer events (evdev) over virtio.

Quoted 7 lines
Quoted 1 line

Two questions before I looked at code:
- can you do a writeup for the virtio spec?
might make it easier to review.

From cover letter:

<quote>

Guest driver:
https://www.kraxel.org/cgit/linux/log/?h=virtio-input

Specification:
https://www.kraxel.org/cgit/virtio-spec/log/?h=virtio-input
https://www.kraxel.org/virtio/virtio-v1.0-csprd03-virtio-input.html#x1-2640007

Quoted 5 lines

</quote>

Guess you havn't seen that (yet) because get_maintainers.pl doesn't really work for the cover letter, only the patches, and I forgot to cc you for the whole series.

Right. I didn't review yet, just saw it in my inbox and asked some questions. I assumed there's no cover letter.

Quoted 1 line

[ anyone has a solution for this btw? ]

I have a patch to git that makes it Cc everyone who's copied on cover letter. This let you supply people to Cc while editing the cover letter.

Quoted 7 lines
Quoted 1 line

- does linux need to support this?

For pass-through (patch 4) yes, emulated hid devices (patch 3) not really. It is linux only for now because the code simply #includes the system header files for the linux input layer, so it wouldn't compile on something else.

Quoted 7 lines
Quoted 2 lines

if yes we'll eventually want to take
the header from there.

Yes, we can do that, for both linux input layer and virtio-input (once merged upstream) headers, then go build this on non-linux hosts too.

I'd suggest to do that as incremental patch, after guest driver merge.

Hmm but why? It's just code churn.

Quoted 14 lines
Quoted 1 line

maybe split out guest/host ABI?

When copying over virtio-input header from linux kernel that needs to happen anyway.

Quoted 3 lines

also might be a good idea to make style there
linux-compliant (e.g. no typedefs, add typedefs
in another header).

Linux driver linked above already has that.

cheers,
Gerd

#6 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Hi,

Quoted 9 lines
Quoted 7 lines
Quoted 2 lines

if yes we'll eventually want to take
the header from there.

Yes, we can do that, for both linux input layer and virtio-input (once merged upstream) headers, then go build this on non-linux hosts too.

I'd suggest to do that as incremental patch, after guest driver merge.

Hmm but why? It's just code churn.

Adding not-yet upstream files to the list of headers to sync over from linux isn't sane IMHO.

cheers,
Gerd

#7 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Quoted 10 lines · Gerd Hoffmann

Hi,

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

if yes we'll eventually want to take
the header from there.

Yes, we can do that, for both linux input layer and virtio-input (once merged upstream) headers, then go build this on non-linux hosts too.

I'd suggest to do that as incremental patch, after guest driver merge.

Quoted 8 lines
Quoted 1 line

Hmm but why? It's just code churn.

Adding not-yet upstream files to the list of headers to sync over from linux isn't sane IMHO.

cheers,
Gerd

Of course it isn't. But you can sync it manually. Once it's upstream, add it to list for automated sync.
Copy-pasting some defs from there in an unrelated header seems worse.

Signature · 1 line
MST
#8 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Hi,

Quoted 9 lines
Quoted 6 lines

Adding not-yet upstream files to the list of headers to sync over from linux isn't sane IMHO.

cheers,
Gerd

Of course it isn't. But you can sync it manually. Once it's upstream, add it to list for automated sync.

Hmm, well, not that simple, there is no whitelist for virtio headers but a "*virtio*.h" glob. So it'll simply sync automatic once landed upstream, and may get deleted by accident before.

I've sent the guest kernel driver meanwhile, maybe this goes in quickly and and renders the whole discussion moot ;)

cheers,
Gerd

#9 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Quoted 9 lines · Gerd Hoffmann

Hi,

Quoted 7 lines
Quoted 6 lines

Adding not-yet upstream files to the list of headers to sync over from linux isn't sane IMHO.

cheers,
Gerd

Quoted 6 lines
Quoted 2 lines

Of course it isn't. But you can sync it manually. Once it's upstream, add it to list for automated sync.

Hmm, well, not that simple, there is no whitelist for virtio headers but a "*virtio*.h" glob. So it'll simply sync automatic once landed upstream, and may get deleted by accident before.

Well no - by design we only update headers, never delete them. If someone does manage to delete a header it's just a question of running make before pushing upstream, isn't it?

Quoted 6 lines

I've sent the guest kernel driver meanwhile, maybe this goes in quickly and and renders the whole discussion moot ;)

cheers,
Gerd

#10 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Gerd Hoffmann

Hi,

Quoted 7 lines
Quoted 6 lines

Adding not-yet upstream files to the list of headers to sync over from linux isn't sane IMHO.

cheers,
Gerd

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Of course it isn't. But you can sync it manually. Once it's upstream, add it to list for automated sync.

Hmm, well, not that simple, there is no whitelist for virtio headers but a "*virtio*.h" glob. So it'll simply sync automatic once landed upstream, and may get deleted by accident before.

Well no - by design we only update headers, never delete them.

Hmm?

I'm talking about scripts/update-linux-headers.sh in the qemu tree. That does a "rm -rf" followed by copying over the bits from linux kernel. So when switching from my virtio-input branch back to master (in the linux kernel source tree) and re-running the script the header file will disappear ...

Sounds like you are talking about something completely different.

cheers,
Gerd

#11 lore raw

Re: [Qemu-devel] [PATCH 2/4] virtio-input: core code & base class

Quoted 28 lines · Gerd Hoffmann
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Gerd Hoffmann

Hi,

Quoted 7 lines
Quoted 6 lines

Adding not-yet upstream files to the list of headers to sync over from linux isn't sane IMHO.

cheers,
Gerd

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Of course it isn't. But you can sync it manually. Once it's upstream, add it to list for automated sync.

Hmm, well, not that simple, there is no whitelist for virtio headers but a "*virtio*.h" glob. So it'll simply sync automatic once landed upstream, and may get deleted by accident before.

Well no - by design we only update headers, never delete them.

Hmm?

I'm talking about scripts/update-linux-headers.sh in the qemu tree. That does a "rm -rf" followed by copying over the bits from linux kernel. So when switching from my virtio-input branch back to master (in the linux kernel source tree) and re-running the script the header file will disappear ...

Quoted 4 lines

Sounds like you are talking about something completely different.

cheers,
Gerd

What I referred to is that we don't do any of git add/git rm. User must manually run these to add/remove new headers.

Signature · 1 line
MST