From patchwork Wed Oct 6 20:59:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 237041 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o96KxJvW009753 for ; Wed, 6 Oct 2010 20:59:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933083Ab0JFU71 (ORCPT ); Wed, 6 Oct 2010 16:59:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20397 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933078Ab0JFU70 (ORCPT ); Wed, 6 Oct 2010 16:59:26 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o96KxNjI027191 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Oct 2010 16:59:23 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o96KxNm7012360; Wed, 6 Oct 2010 16:59:23 -0400 From: Alex Williamson Subject: [PATCH 4/6] virtio: Allow virtio_save() errors To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, cam@cs.ualberta.ca, quintela@redhat.com, anthony@codemonkey.ws, alex.williamson@redhat.com Date: Wed, 06 Oct 2010 14:59:22 -0600 Message-ID: <20101006205922.32127.35080.stgit@s20.home> In-Reply-To: <20101006204546.32127.70109.stgit@s20.home> References: <20101006204546.32127.70109.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 06 Oct 2010 20:59:37 +0000 (UTC) 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);