From patchwork Tue Mar 4 18:22:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonios Motakis X-Patchwork-Id: 326434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 589082C0096 for ; Wed, 5 Mar 2014 05:31:30 +1100 (EST) Received: from localhost ([::1]:47366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKu7k-0008AE-3L for incoming@patchwork.ozlabs.org; Tue, 04 Mar 2014 13:31:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKu75-00083z-Np for qemu-devel@nongnu.org; Tue, 04 Mar 2014 13:30:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKu6z-0006tu-1E for qemu-devel@nongnu.org; Tue, 04 Mar 2014 13:30:47 -0500 Received: from mail-we0-f176.google.com ([74.125.82.176]:44260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKu6y-0006th-RY for qemu-devel@nongnu.org; Tue, 04 Mar 2014 13:30:40 -0500 Received: by mail-we0-f176.google.com with SMTP id x48so5247539wes.7 for ; Tue, 04 Mar 2014 10:30:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ComlDaQRuffeROgHM5fxOfK9RRWTbb+dHg0I8Mk1T7U=; b=kxr7uQ1NKgZ6aAkAGfehGXPINh+s2dKBp5XHDGyHUqhrph9BA2s6GFP5JhspUr8bM2 tBmop74o1x8C8XcdjEw3YnPU5+kdhgplyDFfHzbNacG/MjRJw/Ik83qZc3qAUIN8r7MU LMxGs0MfJr5tR2JEtpvTBY62fKN3ROMVa6jIeUvMoCLFXVmBlAWA4eNUJ9C4CeMkb5K6 EEiGeCBckwFRA5lkaqk6QAtVWAsBL89HPm7avM3X4ECimThs6B5vXGzdKWokn6X0D7PV Mx61rXBPWmOihOBw/DFwZbsP30qe/jlLbxabxsraLO4IMLGWu7A3FW/cSt/TQ65rl6DA gkVQ== X-Gm-Message-State: ALoCoQk7syrd8bjZq5JCD5e/dn48YK3h/E8ZRSh4rVXQVu8VlehxQNJ3xiFeFwAeH3vxRVE3FZQd X-Received: by 10.194.203.200 with SMTP id ks8mr1339661wjc.61.1393957427122; Tue, 04 Mar 2014 10:23:47 -0800 (PST) Received: from localhost.localdomain (home.tvelocity.eu. [82.67.68.96]) by mx.google.com with ESMTPSA id br10sm55666369wjb.3.2014.03.04.10.23.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Mar 2014 10:23:46 -0800 (PST) From: Antonios Motakis To: qemu-devel@nongnu.org, snabb-devel@googlegroups.com Date: Tue, 4 Mar 2014 19:22:53 +0100 Message-Id: <1393957383-16685-11-git-send-email-a.motakis@virtualopensystems.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393957383-16685-1-git-send-email-a.motakis@virtualopensystems.com> References: <1393957383-16685-1-git-send-email-a.motakis@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.176 Cc: lukego@gmail.com, Antonios Motakis , tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v9 10/20] Gracefully handle ioctl failure in vhost_virtqueue_stop X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On stopping the vhost, a call to VHOST_GET_VRING_BASE is issued. The received value is stored as last_avail_idx, so the virtqueue can continue operating if the connection is resumed. Handle the failure of this call and use the current avail_idx. Some packets from the avail ring may be omitted but still we keep a sane value and can continue on reconnect. Signed-off-by: Antonios Motakis Signed-off-by: Nikolay Nikolaev --- hw/virtio/vhost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9e336ad..322e2c0 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -758,12 +758,13 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs); r = ioctl(dev->control, VHOST_GET_VRING_BASE, &state); if (r < 0) { + state.num = virtio_queue_get_avail_idx(vdev, idx); fprintf(stderr, "vhost VQ %d ring restore failed: %d\n", idx, r); fflush(stderr); } virtio_queue_set_last_avail_idx(vdev, idx, state.num); virtio_queue_invalidate_signalled_used(vdev, idx); - assert (r >= 0); + cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx), 0, virtio_queue_get_ring_size(vdev, idx)); cpu_physical_memory_unmap(vq->used, virtio_queue_get_used_size(vdev, idx),