Skip to contentSkip to conversation

virtio-input; live migration support, various bugfixes.

GIT PULL Gerd Hoffmann 2 participants 9 messages Apr 11, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

Here comes a virtio-input update, with a bugfix collection from Ladi Prosek and live migration support.

please pull,
Gerd

The following changes since commit 9628af036fade986dcc94f4484bc75c6b1a06d84:

Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160408' into staging (2016-04-08 13:45:52 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-input-20160411-1

for you to fetch changes up to e2392a72e88104272f3986f0846e4f2f45453b26:

virtio-input: fix emulated tablet axis ranges (2016-04-11 11:45:11 +0200)

----------------------------------------------------------------
virtio-input; live migration support, various bugfixes.

----------------------------------------------------------------
Gerd Hoffmann (1):
virtio-input: add live migration support

Ladi Prosek (4):
virtio-input: add missing key mappings
virtio-input: retrieve EV_LED host config bits
virtio-input: implement pass-through evdev writes
virtio-input: fix emulated tablet axis ranges

 hw/input/virtio-input-hid.c  |  6 ++++--
 hw/input/virtio-input-host.c | 24 ++++++++++++++++++++++++
 hw/input/virtio-input.c      | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/5] virtio-input: add missing key mappings

From: Ladi Prosek <[email protected]>

KEY_PAUSE is flat out missing. KEY_SYSRQ already has a keycode assigned but it's not what I'm seeing on my system. The mapping doesn't appear to have to be unique so both keycodes now map to KEY_SYSRQ which is what the "Keyboard PrintScreen", HID usage ID 0x46, translates to.

Message-id: [email protected]

---
 hw/input/virtio-input-hid.c | 2 ++
 1 file changed, 2 insertions(+)
hw/input/virtio-input-hid.c +2 -0
index 5d12157..fe6d37f 100644
@@ -121,6 +121,8 @@ static const unsigned int keymap_qcode[Q_KEY_CODE__MAX] = {
 
     [Q_KEY_CODE_CTRL_R]              = KEY_RIGHTCTRL,
     [Q_KEY_CODE_SYSRQ]               = KEY_SYSRQ,
+    [Q_KEY_CODE_PRINT]               = KEY_SYSRQ,
+    [Q_KEY_CODE_PAUSE]               = KEY_PAUSE,
     [Q_KEY_CODE_ALT_R]               = KEY_RIGHTALT,
 
     [Q_KEY_CODE_HOME]                = KEY_HOME,
Signature · 1 line
1.8.3.1
#2 lore raw

[Qemu-devel] [PULL 2/5] virtio-input: retrieve EV_LED host config bits

In reply to Gerd Hoffmann

From: Ladi Prosek <[email protected]>

VIRTIO_INPUT_CFG_EV_BITS with subsel of EV_LED was always returning an empty bitmap for pass-through input devices.

Message-id: [email protected]

---
 hw/input/virtio-input-host.c | 1 +
 1 file changed, 1 insertion(+)
hw/input/virtio-input-host.c +1 -0
index 9e0f46d..97b7dd6 100644
@@ -125,6 +125,7 @@ static void virtio_input_host_realize(DeviceState *dev, Error **errp)
     virtio_input_bits_config(vih, EV_ABS, ABS_CNT);
     virtio_input_bits_config(vih, EV_MSC, MSC_CNT);
     virtio_input_bits_config(vih, EV_SW,  SW_CNT);
+    virtio_input_bits_config(vih, EV_LED, LED_CNT);
 
     qemu_set_fd_handler(vih->fd, virtio_input_host_event, NULL, vih);
     return;
Signature · 1 line
1.8.3.1
#3 lore raw

[Qemu-devel] [PULL 4/5] virtio-input: add live migration support

In reply to Gerd Hoffmann

virtio-input is simple enough that it doesn't need to xfer any state. Still we have to wire up savevm manually, so the generic pci and virtio are saved correctly.

Additionally we need to do some post-load processing to figure whenever the guest uses the device or not, so we can give input routing hints to the qemu input layer using qemu_input_handler_{activate,deactivate}.

Message-id: [email protected]

---
 hw/input/virtio-input.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
hw/input/virtio-input.c +40 -0
index 672c207..ac019c7 100644
@@ -14,6 +14,8 @@
 
 #include "standard-headers/linux/input.h"
 
+#define VIRTIO_INPUT_VM_VERSION 1
+
 /* ----------------------------------------------------------------- */
 
 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event)
@@ -214,6 +216,38 @@ static void virtio_input_reset(VirtIODevice *vdev)
     }
 }
 
+static void virtio_input_save(QEMUFile *f, void *opaque)
+{
+    VirtIOInput *vinput = opaque;
+    VirtIODevice *vdev = VIRTIO_DEVICE(vinput);
+
+    virtio_save(vdev, f);
+}
+
+static int virtio_input_load(QEMUFile *f, void *opaque, int version_id)
+{
+    VirtIOInput *vinput = opaque;
+    VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(vinput);
+    VirtIODevice *vdev = VIRTIO_DEVICE(vinput);
+    int ret;
+
+    if (version_id != VIRTIO_INPUT_VM_VERSION) {
+        return -EINVAL;
+    }
+
+    ret = virtio_load(vdev, f, version_id);
+    if (ret) {
+        return ret;
+    }
+
+    /* post_load() */
+    vinput->active = vdev->status & VIRTIO_CONFIG_S_DRIVER_OK;
+    if (vic->change_active) {
+        vic->change_active(vinput);
+    }
+    return 0;
+}
+
 static void virtio_input_device_realize(DeviceState *dev, Error **errp)
 {
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
@@ -245,14 +279,20 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp)
                 vinput->cfg_size);
     vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt);
     vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts);
+
+    register_savevm(dev, "virtio-input", -1, VIRTIO_INPUT_VM_VERSION,
+                    virtio_input_save, virtio_input_load, vinput);
 }
 
 static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
 {
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+    VirtIOInput *vinput = VIRTIO_INPUT(dev);
     Error *local_err = NULL;
 
+    unregister_savevm(dev, "virtio-input", vinput);
+
     if (vic->unrealize) {
         vic->unrealize(dev, &local_err);
         if (local_err) {
Signature · 1 line
1.8.3.1
#4 lore raw

[Qemu-devel] [PULL 5/5] virtio-input: fix emulated tablet axis ranges

In reply to Gerd Hoffmann

From: Ladi Prosek <[email protected]>

The reported maximum was wrong. The X and Y coordinates are 0-based so if size is 8000 maximum must be 7FFF.

Message-id: [email protected]

---
 hw/input/virtio-input-hid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/input/virtio-input-hid.c +2 -2
index fe6d37f..3ee0c18 100644
@@ -484,12 +484,12 @@ static struct virtio_input_config virtio_tablet_config[] = {
         .select    = VIRTIO_INPUT_CFG_ABS_INFO,
         .subsel    = ABS_X,
         .size      = sizeof(virtio_input_absinfo),
-        .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE),
+        .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
     },{
         .select    = VIRTIO_INPUT_CFG_ABS_INFO,
         .subsel    = ABS_Y,
         .size      = sizeof(virtio_input_absinfo),
-        .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE),
+        .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
     },
     { /* end of list */ },
 };
Signature · 1 line
1.8.3.1
#5 lore raw

[Qemu-devel] [PULL 3/5] virtio-input: implement pass-through evdev writes

In reply to Gerd Hoffmann

From: Ladi Prosek <[email protected]>

The write path for pass-through devices, commonly used for controlling keyboard LEDs via EV_LED, was not implemented. This commit adds the necessary plumbing to connect the status virtio queue to the host evdev file descriptor.

Message-id: [email protected]

---
 hw/input/virtio-input-host.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
hw/input/virtio-input-host.c +23 -0
index 97b7dd6..96124f4 100644
@@ -146,6 +146,28 @@ static void virtio_input_host_unrealize(DeviceState *dev, Error **errp)
     }
 }
 
+static void virtio_input_host_handle_status(VirtIOInput *vinput,
+                                            virtio_input_event *event)
+{
+    VirtIOInputHost *vih = VIRTIO_INPUT_HOST(vinput);
+    struct input_event evdev;
+    int rc;
+
+    if (gettimeofday(&evdev.time, NULL)) {
+        perror("virtio_input_host_handle_status: gettimeofday");
+        return;
+    }
+
+    evdev.type = le16_to_cpu(event->type);
+    evdev.code = le16_to_cpu(event->code);
+    evdev.value = le32_to_cpu(event->value);
+
+    rc = write(vih->fd, &evdev, sizeof(evdev));
+    if (rc == -1) {
+        perror("virtio_input_host_handle_status: write");
+    }
+}
+
 static const VMStateDescription vmstate_virtio_input_host = {
     .name = "virtio-input-host",
     .unmigratable = 1,
@@ -165,6 +187,7 @@ static void virtio_input_host_class_init(ObjectClass *klass, void *data)
     dc->props          = virtio_input_host_properties;
     vic->realize       = virtio_input_host_realize;
     vic->unrealize     = virtio_input_host_unrealize;
+    vic->handle_status = virtio_input_host_handle_status;
 }
 
 static void virtio_input_host_init(Object *obj)
Signature · 1 line
1.8.3.1
#6 lore raw
In reply to Gerd Hoffmann
Quoted 15 lines · Gerd Hoffmann

Hi,

Here comes a virtio-input update, with a bugfix collection from Ladi Prosek and live migration support.

please pull,
Gerd

The following changes since commit 9628af036fade986dcc94f4484bc75c6b1a06d84:

Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160408' into staging (2016-04-08 13:45:52 +0100)

are available in the git repository at:

Quoted 8 lines

git://git.kraxel.org/qemu tags/pull-input-20160411-1

for you to fetch changes up to e2392a72e88104272f3986f0846e4f2f45453b26:

virtio-input: fix emulated tablet axis ranges (2016-04-11 11:45:11 +0200)

----------------------------------------------------------------
virtio-input; live migration support, various bugfixes.

Hi. I'm afraid this doesn't compile on ppc64be:

/home/pm215/qemu/hw/input/virtio-input-hid.c:487:9: error: suggest parentheses around ‘-’ in operand of ‘&’ [-Werror=parentheses]

         .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
         ^
/home/pm215/qemu/hw/input/virtio-input-hid.c:492:9: error: suggest
parentheses around ‘-’ in operand of ‘&’ [-Werror=parentheses]
         .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
         ^

It looks like the const_le32() and const_le16() macros in include/hw/virtio/virtio-input.h are missing brackets around the macro argument -- can you send a patch which adds the missing brackets, please?

(Side question, why is an apparently generic endianness support macro implemented in virtio-input.h ?)

thanks
-- PMM

#7 lore raw
Quoted 11 lines

Hi. I'm afraid this doesn't compile on ppc64be:

/home/pm215/qemu/hw/input/virtio-input-hid.c:487:9: error: suggest parentheses around ‘-’ in operand of ‘&’ [-Werror=parentheses]

         .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
         ^
/home/pm215/qemu/hw/input/virtio-input-hid.c:492:9: error: suggest
parentheses around ‘-’ in operand of ‘&’ [-Werror=parentheses]
         .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
         ^
Quoted 3 lines

It looks like the const_le32() and const_le16() macros in include/hw/virtio/virtio-input.h are missing brackets around the macro argument

Indeed. /me needs a be machine.

Quoted 1 line

-- can you send a patch which adds the missing brackets, please?

Sure.

Quoted 2 lines

(Side question, why is an apparently generic endianness support macro implemented in virtio-input.h ?)

Suggestions for a better place? Looks like there isn't something like byteorder.h ...

cheers,
Gerd

#8 lore raw
Quoted 11 lines · Gerd Hoffmann
Quoted 11 lines

Hi. I'm afraid this doesn't compile on ppc64be:

/home/pm215/qemu/hw/input/virtio-input-hid.c:487:9: error: suggest parentheses around ‘-’ in operand of ‘&’ [-Werror=parentheses]

         .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
         ^
/home/pm215/qemu/hw/input/virtio-input-hid.c:492:9: error: suggest
parentheses around ‘-’ in operand of ‘&’ [-Werror=parentheses]
         .u.abs.max = const_le32(INPUT_EVENT_ABS_SIZE - 1),
         ^
Quoted 5 lines
Quoted 3 lines

It looks like the const_le32() and const_le16() macros in include/hw/virtio/virtio-input.h are missing brackets around the macro argument

Indeed. /me needs a be machine.

If you have access to the gcc compile farm, there's a ppc64be box in it.

Quoted 2 lines

Suggestions for a better place? Looks like there isn't something like byteorder.h ...

include/qemu/bswap.h.

thanks
-- PMM