From 87669f5c48deb97d0340774f07afcf7ba5f57fdb Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Wed, 29 Feb 2012 12:43:12 +0100 Subject: [PATCH 1/3] We should check the return code of virtio_load RH-Author: Orit Wasserman Message-id: <1330519392-17668-1-git-send-email-owasserm@redhat.com> Patchwork-id: 37776 O-Subject: [6.3 qemu-kvm PATCH] We should check the return code of virtio_load Bugzilla: 796063 RH-Acked-by: Paolo Bonzini RH-Acked-by: Laszlo Ersek RH-Acked-by: Alex Williamson Bugzilla: 796063 Upstream status: Submitted Brew build: https://brewweb.devel.redhat.com/taskinfo?taskID=4097488 This fixes the crash when migration to RHEL 6.2.z (or 6.3) from an older version. The migration will still fail, a separated patch will be posted for the migration Ulrich, Thanks for finding the crash and it's fix. Signed-off-by: Ulrich Obergfell Signed-off-by: Orit Wasserman --- hw/virtio-balloon.c | 6 +++++- hw/virtio-blk.c | 6 +++++- hw/virtio-net.c | 6 +++++- hw/virtio-scsi.c | 7 ++++++- hw/virtio-serial-bus.c | 6 +++++- 5 files changed, 26 insertions(+), 5 deletions(-) Signed-off-by: Michal Novotny --- hw/virtio-balloon.c | 6 +++++- hw/virtio-blk.c | 6 +++++- hw/virtio-net.c | 6 +++++- hw/virtio-scsi.c | 7 ++++++- hw/virtio-serial-bus.c | 6 +++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 604985f..15b0611 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -258,11 +258,15 @@ static void virtio_balloon_save(QEMUFile *f, void *opaque) static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id) { VirtIOBalloon *s = opaque; + int ret; if (version_id != 1) return -EINVAL; - virtio_load(&s->vdev, f); + ret = virtio_load(&s->vdev, f); + if (ret) { + return ret; + } s->num_pages = qemu_get_be32(f); s->actual = qemu_get_be32(f); diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 919bb73..b19b4c2 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -540,11 +540,15 @@ static void virtio_blk_save(QEMUFile *f, void *opaque) static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) { VirtIOBlock *s = opaque; + int ret; if (version_id != 2) return -EINVAL; - virtio_load(&s->vdev, f); + ret = virtio_load(&s->vdev, f); + if (ret) { + return ret; + } while (qemu_get_sbyte(f)) { VirtIOBlockReq *req = virtio_blk_alloc_request(s); qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem)); diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 0b03b57..01d9467 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -845,11 +845,15 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) { VirtIONet *n = opaque; int i; + int ret; if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION) return -EINVAL; - virtio_load(&n->vdev, f); + ret = virtio_load(&n->vdev, f); + if (ret) { + return ret; + } qemu_get_buffer(f, n->mac, ETH_ALEN); n->tx_waiting = qemu_get_be32(f); diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 8c03d89..b155755 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -559,7 +559,12 @@ static void virtio_scsi_save(QEMUFile *f, void *opaque) static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id) { VirtIOSCSI *s = opaque; - virtio_load(&s->vdev, f); + int ret; + + ret = virtio_load(&s->vdev, f); + if (ret) { + return ret; + } return 0; } diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 291a706..814ddb6 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -614,13 +614,17 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id) size_t ports_map_size; uint32_t max_nr_ports, nr_active_ports, *ports_map; unsigned int i; + int ret; if (version_id > 3) { return -EINVAL; } /* The virtio device */ - virtio_load(&s->vdev, f); + ret = virtio_load(&s->vdev, f); + if (ret) { + return ret; + } if (version_id < 2) { return 0; -- 1.7.7.6