From patchwork Thu Feb 4 20:29:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 12068631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6886FC433E0 for ; Thu, 4 Feb 2021 20:31:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0014C64E3F for ; Thu, 4 Feb 2021 20:31:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0014C64E3F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7lHI-00006h-W6 for qemu-devel@archiver.kernel.org; Thu, 04 Feb 2021 15:31:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7lFr-0007Eq-1k for qemu-devel@nongnu.org; Thu, 04 Feb 2021 15:29:31 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:40707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7lFp-0002dv-MR for qemu-devel@nongnu.org; Thu, 04 Feb 2021 15:29:30 -0500 Received: by mail-wm1-x333.google.com with SMTP id c127so4122554wmf.5 for ; Thu, 04 Feb 2021 12:29:29 -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=vXzMO6i9R0x1KvOrRVIzXnXswl1dMtXqTbmX3II/M48=; b=ajeJPW5ndkDGNuEb4kuhLWMpnSBO3aSHobF+0r3an4Uwspf1lFGsAbCzuIiD9+Z0/d cq8sV8yD8/5NfzrE5hZjgjD6s1nLYl7vUM5FXyADEEgTMQzxhEUzGsTGPP8bb6USLoeL PxVVHTvVQyfIdALmEiFViY6qFbWrlePx7LoJd1Sv9153ikg9csdgXWKoYnKciPw7Koth aZSvP7366AabczkDMExD+xE+YRWlFQveR6byKJOhmDEpDNPbxENPqSdISlWdLrhbUcXs 8pdM9TDQPKMiKYjuzozzz0Q4bwu4FrHtRy0r38Qk66+JQY0dMhh94KBAJOwykToHEHnt e9LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vXzMO6i9R0x1KvOrRVIzXnXswl1dMtXqTbmX3II/M48=; b=OZvd1SXGf3Cz8w8z+dhX7RrtfYreoBj/nvF5u++0qO3v5g/Bxd9WZ44poVJQ0JPzNq mG5ytR0GPvjy3prNrxs+gGFPRVzk8A3wTWtpBOdPJODwAL+rnFmNwSPp67lznT4Q10cY UWyP52rbdUC9dvg4jC/wRNUQIG3aID0TutnrvaBM1U7nbj7AoNe/FEQ7aCJ+o59asmUZ /3KhBb3V0kNk2l2p4I76Yln+LavA4mYVMX3VtTwaKA1SI9tTvFh6Ktf7jNWTE/pIz7to ce0Kd2fR2UtYqtJSt1/3+hChBQMKaswB0oIX9F3lW8mMiCxFbASWOh01HxeOTxVBtoTp mZTQ== X-Gm-Message-State: AOAM531E3NBOOOkQA8892vuXTJQiQWHkh6Joe/Y70irSmWW008lB+nb7 A6QnNz+ykul8t9pwrqo1dMgxCgGqpyN02g== X-Google-Smtp-Source: ABdhPJz8+6VzEdzBb0fQETBegW8F3y3jWeL5lx58C6oKMnlWFAfb+39sa8/mOknMexWdo3zwPy5Zbg== X-Received: by 2002:a1c:7f93:: with SMTP id a141mr763821wmd.105.1612470568123; Thu, 04 Feb 2021 12:29:28 -0800 (PST) Received: from f2.Home (bzq-109-64-9-177.red.bezeqint.net. [109.64.9.177]) by smtp.gmail.com with ESMTPSA id f7sm8807834wre.78.2021.02.04.12.29.27 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Feb 2021 12:29:27 -0800 (PST) From: Yuri Benditovich To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 1/3] vhost-net: add VIRTIO_NET_F_HASH_REPORT to the list of kernel features Date: Thu, 4 Feb 2021 22:29:13 +0200 Message-Id: <20210204202915.15925-2-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204202915.15925-1-yuri.benditovich@daynix.com> References: <20210204202915.15925-1-yuri.benditovich@daynix.com> Received-SPF: none client-ip=2a00:1450:4864:20::333; envelope-from=yuri.benditovich@daynix.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In case of vhost TAP the kernel must support this feature, otherwise the device can't offer it. Signed-off-by: Yuri Benditovich --- hw/net/vhost_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 24d555e764..8282e440bd 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -45,6 +45,7 @@ static const int kernel_feature_bits[] = { VIRTIO_NET_F_MTU, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, + VIRTIO_NET_F_HASH_REPORT, VHOST_INVALID_FEATURE_BIT }; From patchwork Thu Feb 4 20:29:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 12068653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29203C433E0 for ; Thu, 4 Feb 2021 20:33:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C217364DDD for ; Thu, 4 Feb 2021 20:33:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C217364DDD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7lJG-0002Jf-Q8 for qemu-devel@archiver.kernel.org; Thu, 04 Feb 2021 15:33:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7lFu-0007Ik-Eu for qemu-devel@nongnu.org; Thu, 04 Feb 2021 15:29:34 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:38339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7lFq-0002eb-K9 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 15:29:33 -0500 Received: by mail-wm1-x336.google.com with SMTP id y187so4139559wmd.3 for ; Thu, 04 Feb 2021 12:29:30 -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=L7PVBmk+2nxLogepx4whST2GuDoJC+uo2HBF8DDdhak=; b=tPjeG6yWV72ECYG4Ny4LNsINTYj5ZNy/Jqz78LSDShHjdNBBqNIaeozVjBAOe2Bpee DbGGjEwGgBxJHAvQREW2a3hO0D6zEr8kyqTFSToIxA3k7tkEDEuKu2d9QJmGOlp7KKD8 JVBFIyieWC5fWVGUwghbvNsqPCsrreDKBBkBtXhDvh+tjF37synJnUyy+R/RJYJoe8jj 2Em1Mtw/Nkj4tdadBOyh8yJSA8FKCyC948UbXkIWnMREm+0tZ50lJ3Zhsg3AsLnSKUdh v/oo2uRI58gttZ2klZiTJ7Yk98JRSfmzMj5JKmcKg2TlhMb0JCfpI9HWFl3BfvlViBti w0lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L7PVBmk+2nxLogepx4whST2GuDoJC+uo2HBF8DDdhak=; b=jlLZnKoO/+avY8NIanjcQO8PoTaEcrJqefRFsftRqK7uIAdbsFM4o9SmwHk9cPtw80 75yUCAl2nHAB/F2qbHJTKcwYv4G/hfgq8l6voUkFjUnhQGopKl0h1PWXcBllGzRJULvw A+zskdZ051T7/JAMZpwyWKSWjt15tAIXLbVXxLa8v6SA3ygYyxgCnzkNush65QKNOuTH VYdFaUJna/WBJd+0Oj6/9qkLdpAFUIwTyiiZrDaYq0LrDBsqs/cO96u6PzCxobe9bO4Y LXiPdP6Vj+hi3om7uprO4HFi9dwcKUfvnxKXKvBNGVbEeoSGBJl9Zvv0OfvNoMt71fAI +stA== X-Gm-Message-State: AOAM533wExFCRuZHOYO7ADoqL3ElCUl1km6CLg8q25EB+fV6aCfOBa2C /WyMV233ntDysCU2nBmRsyJ+qw== X-Google-Smtp-Source: ABdhPJx7jVzE/HZCbr9I28b4vMFSAK8p2yvRLds345lrqA+cr7b4ZHnEIdSTv0+AhsmACiG6ePiBVQ== X-Received: by 2002:a05:600c:19c8:: with SMTP id u8mr754077wmq.59.1612470569295; Thu, 04 Feb 2021 12:29:29 -0800 (PST) Received: from f2.Home (bzq-109-64-9-177.red.bezeqint.net. [109.64.9.177]) by smtp.gmail.com with ESMTPSA id f7sm8807834wre.78.2021.02.04.12.29.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Feb 2021 12:29:28 -0800 (PST) From: Yuri Benditovich To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 2/3] net: add ability to hide (disable) vhost_net Date: Thu, 4 Feb 2021 22:29:14 +0200 Message-Id: <20210204202915.15925-3-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204202915.15925-1-yuri.benditovich@daynix.com> References: <20210204202915.15925-1-yuri.benditovich@daynix.com> Received-SPF: none client-ip=2a00:1450:4864:20::336; envelope-from=yuri.benditovich@daynix.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If 'vhost_net_disabled' in the NetClientState of the net device, get_vhost_net for TAP returns NULL. Network adapters can use this ability to hide the vhost_net temporary between resets in case some active features contradict with vhost. Signed-off-by: Yuri Benditovich --- hw/net/vhost_net.c | 4 +++- include/net/net.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 8282e440bd..7873d27a36 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -437,7 +437,9 @@ VHostNetState *get_vhost_net(NetClientState *nc) switch (nc->info->type) { case NET_CLIENT_DRIVER_TAP: - vhost_net = tap_get_vhost_net(nc); + if (!nc->vhost_net_disabled) { + vhost_net = tap_get_vhost_net(nc); + } break; #ifdef CONFIG_VHOST_NET_USER case NET_CLIENT_DRIVER_VHOST_USER: diff --git a/include/net/net.h b/include/net/net.h index 919facaad2..4479bdcec0 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -100,6 +100,7 @@ struct NetClientState { int vring_enable; int vnet_hdr_len; bool is_netdev; + bool vhost_net_disabled; QTAILQ_HEAD(, NetFilterState) filters; }; From patchwork Thu Feb 4 20:29:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Benditovich X-Patchwork-Id: 12068655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF1EC433DB for ; Thu, 4 Feb 2021 20:34:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76B9F64E7B for ; Thu, 4 Feb 2021 20:34:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76B9F64E7B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7lKN-0003DU-FI for qemu-devel@archiver.kernel.org; Thu, 04 Feb 2021 15:34:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7lFv-0007Jq-55 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 15:29:36 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:53850) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7lFs-0002ep-N8 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 15:29:34 -0500 Received: by mail-wm1-x331.google.com with SMTP id j11so4243486wmi.3 for ; Thu, 04 Feb 2021 12:29:31 -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=3sq4FAI5dt7o+cZJkil0F6/H4mLfESOkV51VC98s95A=; b=lzszdjTru2eXBOWLP2e0XhG1jwA4IgxnJ+Eg8CtI6aWXhXW1llJ2RkFD1HtXHmztVn yTFW1UoMF6FR+jNHOI+5pQKIxf20U9ZsoV8tWmfI8L1ZQpbLVopSC+cFzi/bcHQVpjc3 +tKLS9n+xu2ATLwyLDTgKMFbqeB+NdTyKktVPkTIg7zH+gpNH0OkNgXCyG3t2CwAz3XY DSX8Q28ybMSyQOxo9jRMiM8d9NfRJp5OaooCldb8PqelzD6TEHCAJNd28AmIwqzLueZX 02rkNy3qaW6xfCE1ijC06gVArsFbL3fNr7ds3dJux7sIyP1wxb1ekl4Fx4t7PLUQrWj9 K8mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3sq4FAI5dt7o+cZJkil0F6/H4mLfESOkV51VC98s95A=; b=oi/B9SQT7Pe3Q+sARMrnlqeJSZWNh78qP6WSxFqQDtC9L8hf1hfUxr8p40/kfaIn6J jEYajrNSiE0G7fBoZ/zJ6V4Yu7DjLKbKaBvM6Q461MXfNCPt01sfKbBt99CILO1/2nCd 7JASdIEXiKxVEMREUHH9Hjvr7v9z5NPRNZ9jq/hHqCWD3reKTP/gdotQclTYdnFp6MlG brZz+JawSXrR+/w/Eoov/zabIOg0tFWaOdMW9ACTS17qtP2USwnpxf4PuV+uTO0eN3Ld BB16+QopPIDW9ZZLZCiKVtv39AC66zvnYkA7L7TwD87Pv0VCrnCboMmybgXHnGT8pi/P K2yQ== X-Gm-Message-State: AOAM532vcH5MdcRno1M4Qh3p+COFK6F5vfn0ViEYXQTtAaYwFoF7M7Gm STn3IHUekYYnqV9YPs4B1CO1TyjEg29y2A== X-Google-Smtp-Source: ABdhPJyEX2UW0LppG7uTBhww97aSf51oviyMOc+L797TpcyhzstQjjErEgGKfMIUWEtXi/g+fDVF2g== X-Received: by 2002:a1c:cc14:: with SMTP id h20mr782936wmb.180.1612470570651; Thu, 04 Feb 2021 12:29:30 -0800 (PST) Received: from f2.Home (bzq-109-64-9-177.red.bezeqint.net. [109.64.9.177]) by smtp.gmail.com with ESMTPSA id f7sm8807834wre.78.2021.02.04.12.29.29 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Feb 2021 12:29:30 -0800 (PST) From: Yuri Benditovich To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 3/3] virtio-net: graceful fallback to vhost=off for tap netdev Date: Thu, 4 Feb 2021 22:29:15 +0200 Message-Id: <20210204202915.15925-4-yuri.benditovich@daynix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204202915.15925-1-yuri.benditovich@daynix.com> References: <20210204202915.15925-1-yuri.benditovich@daynix.com> Received-SPF: none client-ip=2a00:1450:4864:20::331; envelope-from=yuri.benditovich@daynix.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Currently virtio-net silently clears features if they are not supported by respective vhost. This may create migration problems in future if vhost features on the source and destination are different. Implement graceful fallback to no-vhost mode when some acked features contradict with vhost. The decision is taken on set_features call and the vhost will be disabled till next reset (or migration). Such fallback is currently enabled only for TAP netdev. Signed-off-by: Yuri Benditovich --- hw/net/virtio-net.c | 58 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5150f295e8..b353060e63 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -515,6 +515,15 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) return info; } +static void virtio_net_allow_vhost(VirtIONet *n, bool allow) +{ + int i; + for (i = 0; i < n->max_queues; i++) { + NetClientState *nc = qemu_get_subqueue(n->nic, i)->peer; + nc->vhost_net_disabled = !allow; + } +} + static void virtio_net_reset(VirtIODevice *vdev) { VirtIONet *n = VIRTIO_NET(vdev); @@ -552,6 +561,7 @@ static void virtio_net_reset(VirtIODevice *vdev) assert(!virtio_net_get_subqueue(nc)->async_tx.elem); } } + virtio_net_allow_vhost(n, true); } static void peer_test_vnet_hdr(VirtIONet *n) @@ -689,6 +699,15 @@ static void virtio_net_set_queues(VirtIONet *n) } } +static bool can_disable_vhost(VirtIONet *n) +{ + NetClientState *peer = qemu_get_queue(n->nic)->peer; + if (!get_vhost_net(peer)) { + return false; + } + return !peer || peer->info->type == NET_CLIENT_DRIVER_TAP; +} + static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue); static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, @@ -725,14 +744,14 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, return features; } - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); - virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); - features = vhost_net_get_features(get_vhost_net(nc->peer), features); - vdev->backend_features = features; + vdev->backend_features = vhost_net_get_features(get_vhost_net(nc->peer), features); - if (n->mtu_bypass_backend && - (n->host_features & 1ULL << VIRTIO_NET_F_MTU)) { - features |= (1ULL << VIRTIO_NET_F_MTU); + if (!can_disable_vhost(n)) { + features = vdev->backend_features; + if (n->mtu_bypass_backend && + (n->host_features & 1ULL << VIRTIO_NET_F_MTU)) { + features |= (1ULL << VIRTIO_NET_F_MTU); + } } return features; @@ -872,10 +891,25 @@ static void failover_add_primary(VirtIONet *n, Error **errp) error_propagate(errp, err); } +static bool check_vhost_features(VirtIONet *n, uint64_t features) +{ + NetClientState *nc = qemu_get_queue(n->nic); + uint64_t filtered; + if (n->rss_data.redirect) { + return false; + } + filtered = vhost_net_get_features(get_vhost_net(nc->peer), features); + if (filtered != features) { + return false; + } + return true; +} + static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) { VirtIONet *n = VIRTIO_NET(vdev); Error *err = NULL; + bool disable_vhost = false; int i; if (n->mtu_bypass_backend && @@ -894,13 +928,21 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) VIRTIO_F_VERSION_1), virtio_has_feature(features, VIRTIO_NET_F_HASH_REPORT)); - n->rsc4_enabled = virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT) && virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO4); n->rsc6_enabled = virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT) && virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO6); n->rss_data.redirect = virtio_has_feature(features, VIRTIO_NET_F_RSS); + if (can_disable_vhost(n)) { + disable_vhost = !check_vhost_features(n, features); + } + if (disable_vhost) { + warn_report("Some of requested features aren't supported by vhost, " + "vhost is turned off till next reset"); + virtio_net_allow_vhost(n, false); + } + if (n->has_vnet_hdr) { n->curr_guest_offloads = virtio_net_guest_offloads_by_features(features);