From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S359n-0006NH-5a for qemu-devel@nongnu.org; Thu, 01 Mar 2012 07:30:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S359h-0004iI-TY for qemu-devel@nongnu.org; Thu, 01 Mar 2012 07:30:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S359h-0004hx-Io for qemu-devel@nongnu.org; Thu, 01 Mar 2012 07:30:45 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q21CUgvQ025799 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Mar 2012 07:30:42 -0500 Date: Thu, 1 Mar 2012 14:30:46 +0200 From: "Michael S. Tsirkin" Message-ID: <20120301123045.GA4991@redhat.com> References: <1330601288-3558-1-git-send-email-owasserm@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1330601288-3558-1-git-send-email-owasserm@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] We should check the virtio_load return code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Orit Wasserman Cc: amit.shah@redhat.com, pbonzini@redhat.com, Ulrich Obergfell , qemu-devel@nongnu.org, armbru@redhat.com On Thu, Mar 01, 2012 at 01:28:08PM +0200, Orit Wasserman wrote: > Otherwise we crash on error. > Instruction to reporduce the crash with migration: > 1) run a guest with -device virtio-blk-pci,drive=drive_name,scsi=on > 2) run destination with > -device virtio-blk-pci,drive=drive_name,scsi=off ... -incoming ... > 3) migrate from 1 to 2. > > Signed-off-by: Ulrich Obergfell > Signed-off-by: Orit Wasserman Acked-by: Michael S. Tsirkin > --- > 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; > -- > 1.7.6.5