From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] We should check virtio_load return code
Date: Tue, 28 Feb 2012 14:40:00 +0100 [thread overview]
Message-ID: <jiilfg$vkr$1@dough.gmane.org> (raw)
In-Reply-To: <1330435867-17860-1-git-send-email-owasserm@redhat.com>
Il 28/02/2012 14:31, Orit Wasserman ha scritto:
> Otherwise we crash on error.
>
> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
> Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
> ---
> hw/virtio-balloon.c | 6 +++++-
> hw/virtio-blk.c | 7 ++++++-
> hw/virtio-net.c | 6 +++++-
> hw/virtio-scsi.c | 7 ++++++-
> hw/virtio-serial-bus.c | 6 +++++-
> 5 files changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
> index ce9d2c9..075ed87 100644
> --- a/hw/virtio-balloon.c
> +++ b/hw/virtio-balloon.c
> @@ -211,11 +211,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 49990f8..d4bb400 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -537,11 +537,16 @@ 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 bc5e3a8..3f190d4 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -891,11 +891,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 e607edc..9797847 100644
> --- a/hw/virtio-scsi.c
> +++ b/hw/virtio-scsi.c
> @@ -558,7 +558,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 e22940e..4a33872 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -590,13 +590,17 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
> VirtIOSerialPort *port;
> 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;
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2012-02-28 13:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-28 13:31 [Qemu-devel] [PATCH] We should check virtio_load return code Orit Wasserman
2012-02-28 13:40 ` Paolo Bonzini [this message]
2012-03-01 9:29 ` Amit Shah
2012-03-01 9:56 ` Markus Armbruster
2012-03-01 11:00 ` Orit Wasserman
2012-03-01 11:14 ` Paolo Bonzini
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='jiilfg$vkr$1@dough.gmane.org' \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.