From patchwork Wed Nov 9 15:22:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 9419687 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 B782B60512 for ; Wed, 9 Nov 2016 15:44:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9F822933F for ; Wed, 9 Nov 2016 15:44:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EC5D29343; Wed, 9 Nov 2016 15:44:44 +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 3788A2933F for ; Wed, 9 Nov 2016 15:44:44 +0000 (UTC) Received: from localhost ([::1]:40757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4V3L-0007ii-EP for patchwork-qemu-devel@patchwork.kernel.org; Wed, 09 Nov 2016 10:44:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4Uhq-0004ml-Co for qemu-devel@nongnu.org; Wed, 09 Nov 2016 10:22:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4Uhn-0006KM-6m for qemu-devel@nongnu.org; Wed, 09 Nov 2016 10:22:30 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4Uhm-0006IS-W6 for qemu-devel@nongnu.org; Wed, 09 Nov 2016 10:22:27 -0500 Received: by mail-wm0-x241.google.com with SMTP id u144so29901919wmu.0 for ; Wed, 09 Nov 2016 07:22:26 -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=t5g6Z3DNGxlxp1VsLq/FQaMZSNgv85SBTqto7UH7RtXWOcLCMgA2gMRZdnB5SSEwCq NXtIAG8ZD8yniQlho65LP5xb8suiQlqpj4YKWGTLe+5osbKkkudUBV1D5rfuLRSQVrbV eGG7W+dJr4SnqLxnuHegCuWcq/ro/jW2DEQZ5pt9SAWuw3S/u8DyFYTAFlTKuM430Hhc zaNATfvr20RudIzTdcmV6Y2TUYekadH9MypHg3H8sT99i+hl09xXXh3H00iQY1V1lht2 DlPMLxQ6RWVM3BFKeTIG4Ei4Aeh66X3myGM/3cKKXAJ+4kJl61P5ycsMK/paHe+/yXna R31A== 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=Mk9+tF92rFSBwT03yRkzdpgvXFRazdYcNzU3F7LrE8zi0+UYLVr2CBMMMwJH56sO1K WpxTgUijjtDQgo7/mFV5HmBt8kf5Pa2LmsHtaZah//HOQMfNePSFY+FltSLiRJJynejR dLrk422LGM3t/RgBi3il2cEg+qra0LnC6lCYjcOykJrHufVZJh0+A7W9bv3ElNsLnLCl 88ho+S74yFK6yRtQXqp66CsnRiJPQH3cs3YngzZkboUdGUiQPKw07vk5qxQ7rzKMsR67 FQsf3MUINeWkRw2fuPjycTbLNoOy9joXzOjcwaS2klsfDfiSxwf1JwwtgKFPoeDMYW+h TDBA== X-Gm-Message-State: ABUngveu3iorvBUPKcxQ1pvDLfD8JdUtQu5K8chcOx3cnfwGVF1zfyINCvEMo8lTINmpOQ== X-Received: by 10.194.24.34 with SMTP id r2mr68222wjf.111.1478704945807; Wed, 09 Nov 2016 07:22:25 -0800 (PST) Received: from localhost.localdomain ([141.226.163.133]) by smtp.gmail.com with ESMTPSA id q125sm822641wmd.2.2016.11.09.07.22.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Nov 2016 07:22:25 -0800 (PST) From: yuri.benditovich@daynix.com To: "Michael S . Tsirkin" , Jason Wang , qemu-devel@nongnu.org Date: Wed, 9 Nov 2016 17:22:00 +0200 Message-Id: <1478704922-3400-2-git-send-email-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1478704922-3400-1-git-send-email-yuri.benditovich@daynix.com> References: <1478704922-3400-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::241 Subject: [Qemu-devel] [PATCH v2 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);