From patchwork Thu Jun 18 18:05:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 486464 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 0F5BE1401F0 for ; Fri, 19 Jun 2015 04:06:34 +1000 (AEST) Received: from localhost ([::1]:54349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5eCu-0006ZN-It for incoming@patchwork.ozlabs.org; Thu, 18 Jun 2015 14:06:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5eCS-0006HQ-Ax for qemu-devel@nongnu.org; Thu, 18 Jun 2015 14:06:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5eCD-00044x-6f for qemu-devel@nongnu.org; Thu, 18 Jun 2015 14:06:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5eCC-00043t-PW for qemu-devel@nongnu.org; Thu, 18 Jun 2015 14:05:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 606D8344EBE; Thu, 18 Jun 2015 18:05:47 +0000 (UTC) Received: from work.redhat.com (vpn1-4-219.ams2.redhat.com [10.36.4.219]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5II5iiU005741; Thu, 18 Jun 2015 14:05:45 -0400 From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Thu, 18 Jun 2015 21:05:44 +0300 Message-Id: <1434650744-6585-1-git-send-email-marcel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: marcel@redhat.com, famz@redhat.com, n.nikolaev@virtualopensystems.com, mst@redhat.com Subject: [Qemu-devel] [PATCH] net/virtio: fix multi-queue negotiation 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 Clear host multi-queue related features if the peer doesn't support it. Signed-off-by: Marcel Apfelbaum --- Notes: This fixes a guest CPU soft lock, however the virtio-net device will not work correctly. It seems that is peer's "fault", not knowing how to handle the situation. However, I submit this patch since it corrects the negotiation and saves us from a guest crash (!). Any ideas from the virtio/multi-queue developers on how to debug this further are welcomed. hw/net/virtio-net.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9281aa1..63e59e8 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -367,6 +367,11 @@ static int peer_has_ufo(VirtIONet *n) return n->has_ufo; } +static int peer_has_multiqueue(VirtIONet *n) +{ + return n->multiqueue; +} + static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, int version_1) { @@ -469,6 +474,13 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features) virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO); } + if (!peer_has_multiqueue(n)) { + virtio_clear_feature(&features, VIRTIO_NET_F_MQ); + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE); + virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_VQ); + virtio_clear_feature(&features, VIRTIO_NET_F_CTRL_RX); + } + if (!get_vhost_net(nc->peer)) { virtio_add_feature(&features, VIRTIO_F_VERSION_1); return features; @@ -1314,7 +1326,6 @@ static void virtio_net_tx_bh(void *opaque) static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue) { n->multiqueue = multiqueue; - virtio_net_set_queues(n); }