From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=50300 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4Jlt-0004fw-OS for qemu-devel@nongnu.org; Mon, 28 Mar 2011 17:14:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4Jls-0006nB-Ii for qemu-devel@nongnu.org; Mon, 28 Mar 2011 17:14:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4Jls-0006n6-5T for qemu-devel@nongnu.org; Mon, 28 Mar 2011 17:14:44 -0400 Date: Mon, 28 Mar 2011 23:14:22 +0200 From: "Michael S. Tsirkin" Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH 2/3] vhost: don't exit on memory errors List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Anthony Liguori , gleb@redhat.com, Jason Wang , Alex Williamson , Jes Sorensen , Amit Shah , Christoph Hellwig , armbru@redhat.com, kwolf@redhat.com When memory including one of the VQs goes away, handle that as a guest error instead of exiting qemu. Signed-off-by: Michael S. Tsirkin --- hw/vhost.c | 8 +++++--- hw/vhost.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 97a1299..c17a831 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -287,11 +287,11 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev, l = vq->ring_size; p = cpu_physical_memory_map(vq->ring_phys, &l, 1); if (!p || l != vq->ring_size) { - fprintf(stderr, "Unable to map ring buffer for ring %d\n", i); + virtio_error(dev->vdev, "Unable to map ring buffer for ring %d\n", i); return -ENOMEM; } if (p != vq->ring) { - fprintf(stderr, "Ring buffer relocated for ring %d\n", i); + virtio_error(dev->vdev, "Ring buffer relocated for ring %d\n", i); return -EBUSY; } cpu_physical_memory_unmap(p, l, 0, 0); @@ -330,7 +330,9 @@ static void vhost_client_set_memory(CPUPhysMemoryClient *client, if (dev->started) { r = vhost_verify_ring_mappings(dev, start_addr, size); - assert(r >= 0); + if (r < 0) { + return; + } } if (!dev->log_enabled) { diff --git a/hw/vhost.h b/hw/vhost.h index c8c595a..90b5bc8 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -39,6 +39,7 @@ struct vhost_dev { vhost_log_chunk_t *log; unsigned long long log_size; bool force; + VirtIODevice *vdev; }; int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force); -- 1.7.3.2.91.g446ac