From patchwork Mon Nov 7 08:20:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 9414427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 220D26048F for ; Mon, 7 Nov 2016 08:21:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FAA21FEC1 for ; Mon, 7 Nov 2016 08:21:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02A2B28DF6; Mon, 7 Nov 2016 08:21:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 69AFC1FEC1 for ; Mon, 7 Nov 2016 08:21:23 +0000 (UTC) Received: from localhost ([::1]:52101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3fBC-00033l-N9 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 07 Nov 2016 03:21:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3fAi-00032L-6H for qemu-devel@nongnu.org; Mon, 07 Nov 2016 03:20:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3fAf-00045A-T2 for qemu-devel@nongnu.org; Mon, 07 Nov 2016 03:20:52 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:33466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c3fAf-00044T-M2 for qemu-devel@nongnu.org; Mon, 07 Nov 2016 03:20:49 -0500 Received: by mail-wm0-x243.google.com with SMTP id u144so15095908wmu.0 for ; Mon, 07 Nov 2016 00:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zb9XxksgP0Rwg4PZ56muFRnpcg1k2+6vqQ7cXUT+8no=; b=FcRk4UlQjeGsJObXzLsjycoRrpoNqHgU/T+kzY7Jo509p3CEgwRglSd4dI1wyJRTzZ S3aIh4qg5LaDtzE3j2Iuy0cAkBi68+R7jie4s2fRnxWxtkQQX25rnSXU5hLW5qh8BVyK AnbWKJ/CbgMvsAk+4oB4K48orY19bOG0bdxf9RCH1bBAMsPG07ferSdyi+ed4Q52pvFL EwEGoukjiez0QYrtzNud6hS9VRvX2CCuMpOOGBPsVkedXZ8+/ikPJFG7/0dccJGxpHVH ZBElGR88GYMVDXuKDQXVQOG6jivnQl3t+j8U94ZdZFEVTVfUaMfCxIBqHTYubDeeWqIR qxXw== 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=zb9XxksgP0Rwg4PZ56muFRnpcg1k2+6vqQ7cXUT+8no=; b=Eml47QHwpqDfcy7nDA68pw4SPHuBIT7JhdNOaHXOP5Vg14tfN+8hvOwHbj5VHbKx4y 84Gx++HGtUwjb5lk2uXruh1dS6j4sF3lnE4tobS+Jla8kHij3xOkgA+M5csPAB69I/iF 016Dtbij9QHWATy+U5lbotdF27EI1L+vnQv9wnSaGZytIZ/GGKOFM0SqFhAPxYZg2REh Af+8tajOgtPR4cch5LOQjsuP7C3jds34d386VwYZlrrp2Wf+m264x1nWQiUply1SEOsU /UhR0OiBdqHQQAwCvBtEf98qWfo6MHSIx0J2WhxcsUqO751FuNfOCuB2vNqTHy0y33CM XNbw== X-Gm-Message-State: ABUngvdhh61U3Zu2boy6sU4ycBN3HTGvK9VK1gHz+627X58NuiZJYeLVqWASRDOSMbsDDQ== X-Received: by 10.194.91.148 with SMTP id ce20mr5611079wjb.59.1478506848564; Mon, 07 Nov 2016 00:20:48 -0800 (PST) Received: from localhost.localdomain ([141.226.163.133]) by smtp.gmail.com with ESMTPSA id vf8sm29494241wjc.27.2016.11.07.00.20.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Nov 2016 00:20:48 -0800 (PST) From: yuri.benditovich@daynix.com To: "Michael S . Tsirkin" , Jason Wang , qemu-devel@nongnu.org Date: Mon, 7 Nov 2016 10:20:27 +0200 Message-Id: <1478506829-9208-2-git-send-email-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1478506829-9208-1-git-send-email-yuri.benditovich@daynix.com> References: <1478506829-9208-1-git-send-email-yuri.benditovich@daynix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH 1/3] net: Add virtio queue interface to update used index from vring state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dmitry@daynix.com, yan@daynix.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Yuri Benditovich Bring virtio queue to correct internal state for host-to-guest operations when vhost is temporary stopped. Signed-off-by: Yuri Benditovich --- hw/virtio/virtio.c | 5 +++++ include/hw/virtio/virtio.h | 1 + 2 files changed, 6 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d48d1a9..7e1274a 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1983,6 +1983,11 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx) vdev->vq[n].shadow_avail_idx = idx; } +void virtio_queue_update_used_idx(VirtIODevice *vdev, int n) +{ + vdev->vq[n].used_idx = vring_used_idx(&vdev->vq[n]); +} + void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n) { vdev->vq[n].signalled_used_valid = false; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b913aac..b9a9d6e 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -260,6 +260,7 @@ hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n); uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n); void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx); void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n); +void virtio_queue_update_used_idx(VirtIODevice *vdev, int n); VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n); uint16_t virtio_get_queue_index(VirtQueue *vq); EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);