From patchwork Mon Mar 28 21:14:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 88687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E2C5AB7007 for ; Tue, 29 Mar 2011 08:16:04 +1100 (EST) Received: from localhost ([127.0.0.1]:60654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4Jn6-0004w1-T2 for incoming@patchwork.ozlabs.org; Mon, 28 Mar 2011 17:16:00 -0400 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 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 p2SLEfkq022515 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 28 Mar 2011 17:14:41 -0400 Received: from redhat.com (vpn-200-95.tlv.redhat.com [10.35.200.95]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id p2SLEank029801; Mon, 28 Mar 2011 17:14:37 -0400 Date: Mon, 28 Mar 2011 23:14:22 +0200 From: "Michael S. Tsirkin" 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 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Subject: [Qemu-devel] [PATCH 2/3] vhost: don't exit on memory errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);