All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Alexander Graf" <agraf@suse.de>,
	"Anthony Liguori" <aliguori@amazon.com>,
	"Amit Shah" <amit.shah@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	=?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>,
	"Greg Kurz" <gkurz@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PULL 17/37] virtio: introduce device specific migration calls
Date: Sun, 29 Jun 2014 19:59:03 +0300	[thread overview]
Message-ID: <1404060115-27410-18-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1404060115-27410-1-git-send-email-mst@redhat.com>

From: Greg Kurz <gkurz@linux.vnet.ibm.com>

In order to migrate virtio subsections, they should be streamed after
the device itself. We need the device specific code to be called from
the common migration code to achieve this. This patch introduces load
and save methods for this purpose.

Suggested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/virtio/virtio.h  |  4 +++-
 hw/block/virtio-blk.c       |  2 +-
 hw/char/virtio-serial-bus.c |  2 +-
 hw/net/virtio-net.c         |  2 +-
 hw/scsi/virtio-scsi.c       |  2 +-
 hw/virtio/virtio-balloon.c  |  2 +-
 hw/virtio/virtio-rng.c      |  2 +-
 hw/virtio/virtio.c          | 13 ++++++++++++-
 8 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 3e54e90..3505ce5 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -150,6 +150,8 @@ typedef struct VirtioDeviceClass {
      * must mask in frontend instead.
      */
     void (*guest_notifier_mask)(VirtIODevice *vdev, int n, bool mask);
+    void (*save)(VirtIODevice *vdev, QEMUFile *f);
+    int (*load)(VirtIODevice *vdev, QEMUFile *f, int version_id);
 } VirtioDeviceClass;
 
 void virtio_init(VirtIODevice *vdev, const char *name,
@@ -184,7 +186,7 @@ void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
 
 void virtio_save(VirtIODevice *vdev, QEMUFile *f);
 
-int virtio_load(VirtIODevice *vdev, QEMUFile *f);
+int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id);
 
 void virtio_notify_config(VirtIODevice *vdev);
 
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index a222e3f..5e2693a 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -635,7 +635,7 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
     if (version_id != 2)
         return -EINVAL;
 
-    ret = virtio_load(vdev, f);
+    ret = virtio_load(vdev, f, version_id);
     if (ret) {
         return ret;
     }
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index e2174b1..f919ec2 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -670,7 +670,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
     }
 
     /* The virtio device */
-    ret = virtio_load(VIRTIO_DEVICE(s), f);
+    ret = virtio_load(VIRTIO_DEVICE(s), f, version_id);
     if (ret) {
         return ret;
     }
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index ea1a081..acfe91c 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1362,7 +1362,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
     if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
         return -EINVAL;
 
-    ret = virtio_load(vdev, f);
+    ret = virtio_load(vdev, f, version_id);
     if (ret) {
         return ret;
     }
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 8c8c9d1..6b4fd6f 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -549,7 +549,7 @@ static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
     VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
     int ret;
 
-    ret = virtio_load(vdev, f);
+    ret = virtio_load(vdev, f, version_id);
     if (ret) {
         return ret;
     }
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 2a2e58a..165592e 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -343,7 +343,7 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
     if (version_id != 1)
         return -EINVAL;
 
-    ret = virtio_load(vdev, f);
+    ret = virtio_load(vdev, f, version_id);
     if (ret) {
         return ret;
     }
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index b6ab361..025de81 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -113,7 +113,7 @@ static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id)
     if (version_id != 1) {
         return -EINVAL;
     }
-    virtio_load(vdev, f);
+    virtio_load(vdev, f, version_id);
 
     /* We may have an element ready but couldn't process it due to a quota
      * limit.  Make sure to try again after live migration when the quota may
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index c1d538c..7f9ac5e 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -843,6 +843,7 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
 {
     BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
     int i;
 
     if (k->save_config) {
@@ -877,6 +878,10 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
             k->save_queue(qbus->parent, i, f);
         }
     }
+
+    if (vdc->save != NULL) {
+        vdc->save(vdev, f);
+    }
 }
 
 int virtio_set_features(VirtIODevice *vdev, uint32_t val)
@@ -895,7 +900,7 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val)
     return bad ? -1 : 0;
 }
 
-int virtio_load(VirtIODevice *vdev, QEMUFile *f)
+int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
 {
     int i, ret;
     int32_t config_len;
@@ -904,6 +909,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
     uint32_t supported_features;
     BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
 
     if (k->load_config) {
         ret = k->load_config(qbus->parent, f);
@@ -983,6 +989,11 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
     }
 
     virtio_notify_vector(vdev, VIRTIO_NO_VECTOR);
+
+    if (vdc->load != NULL) {
+        return vdc->load(vdev, f, version_id);
+    }
+
     return 0;
 }
 
-- 
MST

  parent reply	other threads:[~2014-06-29 16:58 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-29 16:58 [Qemu-devel] [PULL 00/37] pc,vhost,virtio fixes, enhancements Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 01/37] numa: fix comment Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 02/37] openrisc: " Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 03/37] numa: " Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 04/37] pc: Move q35 compat props to PC_COMPAT_* Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 05/37] pc: Fix "prog_if" typo on PC_COMPAT_2_0 Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 06/37] mc146818rtc: add rtc-reset-reinjection QMP command Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 07/37] vhost-user: fix wrong ids in documentation Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 08/37] pc: make isapc and pc-0.10 to pc-0.13 have 1.7.0 memory layout Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 09/37] Allow mismatched virtio config-len Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 10/37] numa: Keep track of NUMA nodes present on the command-line Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 11/37] numa: Reject duplicate node IDs Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 12/37] numa: Reject configuration if not all node IDs are present Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 13/37] vhost-user: fix regions provied with VHOST_USER_SET_MEM_TABLE message Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 14/37] vhost-user: typo fixups Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 15/37] virtio-net: byteswap virtio-net header Michael S. Tsirkin
2014-06-29 16:58 ` [Qemu-devel] [PULL 16/37] virtio-serial: don't migrate the config space Michael S. Tsirkin
2014-06-29 16:59 ` Michael S. Tsirkin [this message]
2014-06-29 16:59 ` [Qemu-devel] [PULL 18/37] virtio-net: implement per-device migration calls Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 19/37] virtio-blk: " Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 20/37] virtio-serial: " Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 21/37] virtio-balloon: " Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 22/37] virtio-rng: " Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 23/37] virtio: add subsections to the migration stream Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 24/37] exec: introduce target_words_bigendian() helper Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 25/37] cpu: introduce CPUClass::virtio_is_big_endian() Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 26/37] virtio: add endian-ambivalent support to VirtIODevice Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 27/37] virtio: memory accessors for endian-ambivalent targets Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 28/37] virtio: allow byte swapping for vring Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 29/37] virtio-net: use virtio wrappers to access headers Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 30/37] virtio-balloon: use virtio wrappers to access page frame numbers Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 31/37] virtio-blk: use virtio wrappers to access headers Michael S. Tsirkin
2014-06-29 16:59 ` [Qemu-devel] [PULL 32/37] virtio-scsi: " Michael S. Tsirkin
2014-06-29 17:00 ` [Qemu-devel] [PULL 33/37] virtio-serial-bus: " Michael S. Tsirkin
2014-06-29 17:00 ` [Qemu-devel] [PULL 34/37] virtio-9p: " Michael S. Tsirkin
2014-06-29 17:00 ` [Qemu-devel] [PULL 35/37] target-ppc: enable virtio endian ambivalent support Michael S. Tsirkin
2014-06-29 17:00 ` [Qemu-devel] [PULL 36/37] vhost-net: disable when cross-endian Michael S. Tsirkin
2014-06-29 17:00 ` [Qemu-devel] [PULL 37/37] tests: add human format test for string output visitor Michael S. Tsirkin
2014-07-09 19:14   ` Andreas Färber
2014-07-09 19:34     ` Peter Maydell
2014-06-29 17:36 ` [Qemu-devel] [PULL 00/37] pc,vhost,virtio fixes, enhancements Peter Maydell
2014-06-29 20:34   ` Michael S. Tsirkin
2014-06-29 20:41     ` 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=1404060115-27410-18-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aliguori@amazon.com \
    --cc=amit.shah@redhat.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.