@@ -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);
@@ -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);
@@ -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);
@@ -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)
@@ -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);
@@ -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)
@@ -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);