Carry pci_device_save() error through to virtio_save().

Signed-off-by: Alex Williamson <alex.william...@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);
 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to