From nobody Tue Feb 10 08:03:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671530585263853.308740368694; Tue, 20 Dec 2022 02:03:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Ym8-0007wv-3C; Tue, 20 Dec 2022 04:19:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7Ylj-0007r7-S5 for qemu-devel@nongnu.org; Tue, 20 Dec 2022 04:18:47 -0500 Received: from prt-mail.chinatelecom.cn ([42.123.76.219] helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Yle-00086z-3d for qemu-devel@nongnu.org; Tue, 20 Dec 2022 04:18:39 -0500 Received: from clientip-171.223.98.159 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 7AA862800CF; Tue, 20 Dec 2022 17:18:25 +0800 (CST) Received: from ([171.223.98.159]) by app0025 with ESMTP id 2e4a1575174248df8c6a8609e0b3439a for qemu-devel@nongnu.org; Tue, 20 Dec 2022 17:18:27 CST HMM_SOURCE_IP: 172.18.0.218:35458.223668886 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: 2e4a1575174248df8c6a8609e0b3439a X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 171.223.98.159 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: qemu-devel Cc: "Michael S. Tsirkin" , Jason Wang , Liuxiangdong , =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= , Guoyi Tu Subject: [PATCH RESEND v5 3/3] vhost-user: Fix the virtio features negotiation flaw Date: Tue, 20 Dec 2022 17:18:00 +0800 Message-Id: <42320fe9f331fb62f8a27b3afbf33f77f3487e8f.1671526980.git.huangy81@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=42.123.76.219; envelope-from=huangy81@chinatelecom.cn; helo=chinatelecom.cn 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671530586342100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) This patch aims to fix unexpected negotiation features for vhost-user netdev interface. When openvswitch reconnect Qemu after an unexpected disconnection and Qemu therefore start the vhost_dev, acked_features field in vhost_dev is initialized with value fetched from acked_features field in NetVhostUserState, which should be up-to-date at that moment but Qemu could not make it actually during the time window of virtio features negotiation. So we save the acked_features right after being configured by guest virtio driver so it can be used to restore acked_features field in vhost_dev correctly. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) Signed-off-by: Guoyi Tu Signed-off-by: Liuxiangdong --- hw/net/vhost_net-stub.c | 5 +++++ hw/net/vhost_net.c | 7 +++++++ hw/net/virtio-net.c | 6 ++++++ include/net/vhost_net.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c index 9f7daae..66ed5f0 100644 --- a/hw/net/vhost_net-stub.c +++ b/hw/net/vhost_net-stub.c @@ -113,3 +113,8 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, Net= ClientState *nc, { return 0; } + +void vhost_net_save_acked_features(NetClientState *nc) +{ + +} diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 043058f..89866c3 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -144,6 +144,13 @@ uint64_t vhost_net_get_acked_features(VHostNetState *n= et) return net->dev.acked_features; } =20 +void vhost_net_save_acked_features(NetClientState *nc) +{ + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) { + vhost_user_save_acked_features(nc); + } +} + static int vhost_net_get_fd(NetClientState *backend) { switch (backend->info->type) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9cbdfa5..105fc30 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -980,6 +980,12 @@ static void virtio_net_set_features(VirtIODevice *vdev= , uint64_t features) continue; } vhost_net_ack_features(get_vhost_net(nc->peer), features); + + /* + * keep acked_features in NetVhostUserState up-to-date so it + * can't miss any features configured by guest virtio driver. + */ + vhost_net_save_acked_features(nc->peer); } =20 if (virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 40b9a40..dfb1375 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -52,4 +52,6 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetCli= entState *nc, int vq_index); int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, int vq_index); + +void vhost_net_save_acked_features(NetClientState *nc); #endif --=20 1.8.3.1