qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, cam@cs.ualberta.ca,
	kvm@vger.kernel.org, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 4/6] virtio: Allow virtio_save() errors
Date: Wed, 06 Oct 2010 14:59:22 -0600	[thread overview]
Message-ID: <20101006205922.32127.35080.stgit@s20.home> (raw)
In-Reply-To: <20101006204546.32127.70109.stgit@s20.home>

Carry pci_device_save() error through to virtio_save().

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/virtio-balloon.c    |    6 +++++-
 hw/virtio-blk.c        |    6 +++++-
 hw/virtio-net.c        |    7 ++++++-
 hw/virtio-pci.c        |   10 ++++++++--
 hw/virtio-serial-bus.c |    6 +++++-
 hw/virtio.c            |   14 ++++++++++----
 hw/virtio.h            |    4 ++--
 7 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index 719e72c..2bf009d 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -230,8 +230,12 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target,
 static int virtio_balloon_save(QEMUFile *f, void *opaque)
 {
     VirtIOBalloon *s = opaque;
+    int ret;
 
-    virtio_save(&s->vdev, f);
+    ret = virtio_save(&s->vdev, f);
+    if (ret < 0) {
+        return ret;
+    }
 
     qemu_put_be32(f, s->num_pages);
     qemu_put_be32(f, s->actual);
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 3770901..b4772bf 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -464,8 +464,12 @@ static int virtio_blk_save(QEMUFile *f, void *opaque)
 {
     VirtIOBlock *s = opaque;
     VirtIOBlockReq *req = s->rq;
+    int ret;
 
-    virtio_save(&s->vdev, f);
+    ret = virtio_save(&s->vdev, f);
+    if (ret < 0) {
+        return ret;
+    }
     
     while (req) {
         qemu_put_sbyte(f, 1);
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 1b683d9..6673320 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -782,6 +782,7 @@ static void virtio_net_tx_bh(void *opaque)
 static int virtio_net_save(QEMUFile *f, void *opaque)
 {
     VirtIONet *n = opaque;
+    int ret;
 
     if (n->vhost_started) {
         /* TODO: should we really stop the backend?
@@ -789,7 +790,11 @@ static int virtio_net_save(QEMUFile *f, void *opaque)
         vhost_net_stop(tap_get_vhost_net(n->nic->nc.peer), &n->vdev);
         n->vhost_started = 0;
     }
-    virtio_save(&n->vdev, f);
+
+    ret = virtio_save(&n->vdev, f);
+    if (ret < 0) {
+        return ret;
+    }
 
     qemu_put_buffer(f, n->mac, ETH_ALEN);
     qemu_put_be32(f, n->tx_waiting);
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 86e6b0a..a7603bb 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -121,13 +121,19 @@ static void virtio_pci_notify(void *opaque, uint16_t vector)
         qemu_set_irq(proxy->pci_dev.irq[0], proxy->vdev->isr & 1);
 }
 
-static void virtio_pci_save_config(void * opaque, QEMUFile *f)
+static int virtio_pci_save_config(void * opaque, QEMUFile *f)
 {
     VirtIOPCIProxy *proxy = opaque;
-    pci_device_save(&proxy->pci_dev, f);
+    int ret;
+
+    ret = pci_device_save(&proxy->pci_dev, f);
+    if (ret < 0) {
+        return ret;
+    }
     msix_save(&proxy->pci_dev, f);
     if (msix_present(&proxy->pci_dev))
         qemu_put_be16(f, proxy->vdev->config_vector);
+    return 0;
 }
 
 static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 7f00fcf..ca57dda 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -459,9 +459,13 @@ static int virtio_serial_save(QEMUFile *f, void *opaque)
     VirtIOSerialPort *port;
     uint32_t nr_active_ports;
     unsigned int i;
+    int ret;
 
     /* The virtio device */
-    virtio_save(&s->vdev, f);
+    ret = virtio_save(&s->vdev, f);
+    if (ret < 0) {
+        return ret;
+    }
 
     /* The config space */
     qemu_put_be16s(f, &s->config.cols);
diff --git a/hw/virtio.c b/hw/virtio.c
index fbef788..27b0e84 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -640,12 +640,16 @@ void virtio_notify_config(VirtIODevice *vdev)
     virtio_notify_vector(vdev, vdev->config_vector);
 }
 
-void virtio_save(VirtIODevice *vdev, QEMUFile *f)
+int virtio_save(VirtIODevice *vdev, QEMUFile *f)
 {
-    int i;
+    int i, ret;
 
-    if (vdev->binding->save_config)
-        vdev->binding->save_config(vdev->binding_opaque, f);
+    if (vdev->binding->save_config) {
+        ret = vdev->binding->save_config(vdev->binding_opaque, f);
+        if (ret < 0) {
+            return ret;
+        }
+    }
 
     qemu_put_8s(f, &vdev->status);
     qemu_put_8s(f, &vdev->isr);
@@ -671,6 +675,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
         if (vdev->binding->save_queue)
             vdev->binding->save_queue(vdev->binding_opaque, i, f);
     }
+
+    return 0;
 }
 
 int virtio_load(VirtIODevice *vdev, QEMUFile *f)
diff --git a/hw/virtio.h b/hw/virtio.h
index 96514e6..5c5da3a 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -88,7 +88,7 @@ typedef struct VirtQueueElement
 
 typedef struct {
     void (*notify)(void * opaque, uint16_t vector);
-    void (*save_config)(void * opaque, QEMUFile *f);
+    int (*save_config)(void * opaque, QEMUFile *f);
     void (*save_queue)(void * opaque, int n, QEMUFile *f);
     int (*load_config)(void * opaque, QEMUFile *f);
     int (*load_queue)(void * opaque, int n, QEMUFile *f);
@@ -150,7 +150,7 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes);
 
 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
 
-void virtio_save(VirtIODevice *vdev, QEMUFile *f);
+int virtio_save(VirtIODevice *vdev, QEMUFile *f);
 
 int virtio_load(VirtIODevice *vdev, QEMUFile *f);
 

  parent reply	other threads:[~2010-10-06 20:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-06 20:58 [Qemu-devel] [PATCH 0/6] Save state error handling (kill off no_migrate) Alex Williamson
2010-10-06 20:59 ` [Qemu-devel] [PATCH 1/6] savevm: Allow SaveStateHandler() to return error Alex Williamson
2010-10-06 20:59 ` [Qemu-devel] [PATCH 2/6] savevm: Allow vmsd->pre_save " Alex Williamson
2010-10-06 20:59 ` [Qemu-devel] [PATCH 3/6] pci: Allow pci_device_save() " Alex Williamson
2010-10-06 20:59 ` Alex Williamson [this message]
2010-10-06 20:59 ` [Qemu-devel] [PATCH 5/6] savevm: Allow set_params and save_live_state to error Alex Williamson
2010-10-06 20:59 ` [Qemu-devel] [PATCH 6/6] savevm: Remove register_device_unmigratable() Alex Williamson
2010-10-07 16:55 ` [Qemu-devel] Re: [PATCH 0/6] Save state error handling (kill off no_migrate) Alex Williamson
2010-11-08 11:40 ` Michael S. Tsirkin
2010-11-08 14:59   ` Alex Williamson
2010-11-08 16:54     ` Michael S. Tsirkin
2010-11-08 17:20       ` Alex Williamson
2010-11-08 20:59         ` Michael S. Tsirkin
2010-11-08 21:23           ` Alex Williamson
2010-11-09 12:00             ` Michael S. Tsirkin
2010-11-09 14:58               ` Alex Williamson
2010-11-09 15:07                 ` Michael S. Tsirkin
2010-11-09 15:34                   ` Alex Williamson
2010-11-09 15:42                     ` Michael S. Tsirkin
2010-11-09 15:47                       ` Alex Williamson
2010-11-09 16:15                         ` Michael S. Tsirkin
2010-11-09 16:30                           ` Alex Williamson
2010-11-09 16:49                             ` Michael S. Tsirkin
2010-11-09 17:44                               ` Alex Williamson
2010-11-09 19:35                                 ` Alex Williamson
2010-11-16 10:23 ` Juan Quintela

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=20101006205922.32127.35080.stgit@s20.home \
    --to=alex.williamson@redhat.com \
    --cc=cam@cs.ualberta.ca \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).