From patchwork Wed Oct 21 09:07:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 533689 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 3C78F1402CC for ; Wed, 21 Oct 2015 20:09:24 +1100 (AEDT) Received: from localhost ([::1]:50015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZopOc-0004fq-7Z for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2015 05:09:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZopMm-0001SE-ME for qemu-devel@nongnu.org; Wed, 21 Oct 2015 05:07:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZopMl-0004IR-PE for qemu-devel@nongnu.org; Wed, 21 Oct 2015 05:07:28 -0400 Received: from mga09.intel.com ([134.134.136.24]:14557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZopMl-0004Gs-K5 for qemu-devel@nongnu.org; Wed, 21 Oct 2015 05:07:27 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 21 Oct 2015 02:07:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,711,1437462000"; d="scan'208";a="585186168" Received: from yliu-dev.sh.intel.com ([10.239.66.49]) by FMSMGA003.fm.intel.com with ESMTP; 21 Oct 2015 02:07:04 -0700 From: Yuanhan Liu To: qemu-devel@nongnu.org Date: Wed, 21 Oct 2015 17:07:18 +0800 Message-Id: <1445418438-24244-5-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1445418438-24244-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1445418438-24244-1-git-send-email-yuanhan.liu@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Cc: Yuanhan Liu Subject: [Qemu-devel] [PATCH v2 5/5] vhost: send VHOST_USER_SET_VRING_ENABLE at start/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 Send VHOST_USER_SET_VRING_ENABLE at start/stop when multiple queue is negotiated, to inform the backend that we are ready or not. And exclude VHOST_USER_GET_QUEUE_NUM as one time request, as we need to get max_queues for each vhost_dev. Suggested-by: Michael S. Tsirkin Signed-off-by: Yuanhan Liu --- hw/virtio/vhost-user.c | 1 - hw/virtio/vhost.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 12a9104..6532a73 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -194,7 +194,6 @@ static bool vhost_user_one_time_request(VhostUserRequest request) case VHOST_USER_SET_OWNER: case VHOST_USER_RESET_OWNER: case VHOST_USER_SET_MEM_TABLE: - case VHOST_USER_GET_QUEUE_NUM: return true; default: return false; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index c0ed5b2..54a4633 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1146,6 +1146,19 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) } } + /* + * Send VHOST_USER_SET_VRING_ENABLE message when multiple queue + * is negotiated to inform the back end that we are ready. + * + * Only set enable to 1 for first queue pair, as we enable one + * queue pair by default. + */ + if (hdev->max_queues > 1 && + hdev->vhost_ops->vhost_backend_set_vring_enable) { + hdev->vhost_ops->vhost_backend_set_vring_enable(hdev, + hdev->vq_index == 0); + } + return 0; fail_log: vhost_log_put(hdev, false); @@ -1180,5 +1193,10 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) hdev->started = false; hdev->log = NULL; hdev->log_size = 0; + + if (hdev->max_queues > 1 && + hdev->vhost_ops->vhost_backend_set_vring_enable) { + hdev->vhost_ops->vhost_backend_set_vring_enable(hdev, 0); + } }