All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PULL v2 6/9] virtio-input: add live migration support
Date: Wed, 13 Apr 2016 17:45:00 +0200	[thread overview]
Message-ID: <1460562303-17079-7-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1460562303-17079-1-git-send-email-kraxel@redhat.com>

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}.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1459859501-16965-1-git-send-email-kraxel@redhat.com
---
 hw/input/virtio-input.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index 672c207..ac019c7 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -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) {
-- 
1.8.3.1

  parent reply	other threads:[~2016-04-13 15:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 15:44 [Qemu-devel] [PULL v2 0/9] virtio-input; live migration support, various bugfixes Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 1/9] virtio-input: add parenthesis to const_le{16, 32} Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 2/9] move const_le{16, 23} to qemu/bswap.h, add comment Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 3/9] virtio-input: add missing key mappings Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 4/9] virtio-input: retrieve EV_LED host config bits Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 5/9] virtio-input: implement pass-through evdev writes Gerd Hoffmann
2016-04-13 15:45 ` Gerd Hoffmann [this message]
2016-04-13 15:45 ` [Qemu-devel] [PULL v2 7/9] virtio-input: fix emulated tablet axis ranges Gerd Hoffmann
2016-04-13 15:45 ` [Qemu-devel] [PULL v2 8/9] input-linux: refine mouse detection Gerd Hoffmann
2016-04-14  7:42   ` Ladi Prosek
2016-04-14  8:07     ` Gerd Hoffmann
2016-04-13 15:45 ` [Qemu-devel] [PULL v2 9/9] virtio-input: support absolute axis config in pass-through Gerd Hoffmann
2016-04-14  9:06 ` [Qemu-devel] [PULL v2 0/9] virtio-input; live migration support, various bugfixes Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460562303-17079-7-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.