From patchwork Tue Dec 13 08:12:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 9471883 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 9CBC7607EE for ; Tue, 13 Dec 2016 08:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EE5A284CE for ; Tue, 13 Dec 2016 08:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83CBD28537; Tue, 13 Dec 2016 08:14:19 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 69E3F284CE for ; Tue, 13 Dec 2016 08:14:18 +0000 (UTC) Received: from localhost ([::1]:36076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGiE5-0001lL-35 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Dec 2016 03:14:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGiDg-0001kC-RS for qemu-devel@nongnu.org; Tue, 13 Dec 2016 03:13:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGiDd-0003yp-Mo for qemu-devel@nongnu.org; Tue, 13 Dec 2016 03:13:52 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36092) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cGiDd-0003uo-Gd for qemu-devel@nongnu.org; Tue, 13 Dec 2016 03:13:49 -0500 Received: by mail-wm0-f66.google.com with SMTP id m203so16565146wma.3 for ; Tue, 13 Dec 2016 00:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=BeUG3e+pRE0E4oMzd0GsJNnF4AYh8UUGFufy+AwV/I0=; b=Prr2FvG7vYRzrJVgYxxPYOFgH03b1nUTbVDgCB5pJfAapz5khzyL92wnPv/jXgZy82 WWSV/pYPlUxtznAj3PM1KQx2GYtqTCvxgho/cMPHeX6SnKVvSejHoWwO7KOkfymQmal5 Oq02JB9io+Pu7jMammL4h8oA67UORwfYHE+/ca4s5nm3KhiHrv1YiudDXX+DrhnfsMtT nBkXSOrh/e7vpZwq31847iJTimWmriBoAqKgg5Tzqres7x/MdB8hcB4THIWujX5Fr1v5 Y/UkDIkXYNO6qw8aDzNEWu1SPdrWY4EfHX4tYjp/fnm0dKYCiJJPvH1+riOd6czUsTrZ nvWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=BeUG3e+pRE0E4oMzd0GsJNnF4AYh8UUGFufy+AwV/I0=; b=aRCgxN9eymeW8ODrniZ6WPXGxx8HTsnVnvP5s2Wxkywxia/KYPl4k5d+jZDmy4YdSL nlaSLLoltUFfFB3sa4fX59yUr9lh60Gki82j651py1nNP/Qc8goY4a2DzWJJfFa/QFC3 kSKWyaGecwBA5CgDONRWMove8JQAieAOEwMNbarTwlDZAr6FlpJRmT+2sX7lkrLK13qH gawKhObppsDGOcpjTReISndon5hIhbKabWGe6SX/n+CD2+TZmH4lijJcPUP7xrh7xSUd L7eAryp27fQnAINia9+3FA5AWWrSSwBKEhKLGLDNXsPxjb2/i1/VQPod5CAGx9U8Etay 4xFg== X-Gm-Message-State: AKaTC00ZW9eIimOWCL4NVSFg9Wft8VmGTwOh6XA4uySXphSdXhMwIiQbsuaZmqgULjemHA== X-Received: by 10.28.230.72 with SMTP id d69mr1457672wmh.119.1481616746076; Tue, 13 Dec 2016 00:12:26 -0800 (PST) Received: from localhost.localdomain ([141.226.163.133]) by smtp.gmail.com with ESMTPSA id d17sm60996111wjr.14.2016.12.13.00.12.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Dec 2016 00:12:25 -0800 (PST) From: Yuri Benditovich To: qemu-devel@nongnu.org, Jason Wang , "Michael S . Tsirkin" Date: Tue, 13 Dec 2016 10:12:05 +0200 Message-Id: <1481616728-148412-2-git-send-email-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1481616728-148412-1-git-send-email-yuri.benditovich@daynix.com> References: <1481616728-148412-1-git-send-email-yuri.benditovich@daynix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.66 Subject: [Qemu-devel] [PATCH v3 1/4] 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 1af2de2..45536e4 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1995,6 +1995,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 ab0e030..a1a75ed 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -266,6 +266,7 @@ hwaddr virtio_queue_get_used_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);