From patchwork Tue Sep 22 03:27:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?aGFpYmluemhhbmco5byg5rW35paMKQ==?= X-Patchwork-Id: 11791463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F9C36CB for ; Tue, 22 Sep 2020 03:28:44 +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 57E4423A32 for ; Tue, 22 Sep 2020 03:28:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=tencent.com header.i=@tencent.com header.b="ivYhmu4T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57E4423A32 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=tencent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKYyv-0001Rh-UF for patchwork-qemu-devel@patchwork.kernel.org; Mon, 21 Sep 2020 23:28:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKYyS-0000zh-AU for qemu-devel@nongnu.org; Mon, 21 Sep 2020 23:28:13 -0400 Received: from mail4.tencent.com ([183.57.53.109]:60920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKYyL-000532-Bv for qemu-devel@nongnu.org; Mon, 21 Sep 2020 23:28:09 -0400 Received: from EX-SZ018.tencent.com (unknown [10.28.6.39]) by mail4.tencent.com (Postfix) with ESMTP id C6BF072578; Tue, 22 Sep 2020 11:27:54 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tencent.com; s=s202002; t=1600745274; bh=5qpVKvA2egJXwbKcD4TeoqIYuhE5xklLswijF2foncQ=; h=From:To:CC:Subject:Date; b=ivYhmu4Tx7C000J9uqW2TswCEvCCi13OblfP3IxLbajRhYv2HbTtvnqkPgwWf4SdD L7ty+ySlX57G/jdCayGHQ4zAOupFTZwKf/G2I1u/O2ss0Jr1fBCQQsYz3kGhfdFGUc SNnonGN0RgXfx0w6vo6reae8/C8gROWlU3nXXgZ0= Received: from EX-SZ007.tencent.com (10.28.6.31) by EX-SZ018.tencent.com (10.28.6.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 22 Sep 2020 11:27:54 +0800 Received: from EX-SZ006.tencent.com (10.28.6.30) by EX-SZ007.tencent.com (10.28.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 22 Sep 2020 11:27:54 +0800 Received: from EX-SZ006.tencent.com ([fe80::a84e:872e:7c90:2930]) by EX-SZ006.tencent.com ([fe80::a84e:872e:7c90:2930%2]) with mapi id 15.01.2106.002; Tue, 22 Sep 2020 11:27:54 +0800 From: =?eucgb2312_cn?b?aGFpYmluemhhbmco1cW6o7HzKQ==?= To: "Michael S. Tsirkin" , Jason Wang , Adrian Moreno Subject: [PATCH] vhost-user: save features of multiqueues if chardev is closed Thread-Topic: [PATCH] vhost-user: save features of multiqueues if chardev is closed Thread-Index: AQHWkJBbURiqOHG7gEeDe0rUGA5Yvw== Date: Tue, 22 Sep 2020 03:27:54 +0000 Message-ID: <46CBC206-E0CA-4249-81CD-10F75DA30441@tencent.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [9.19.161.114] Content-ID: <690BCF2A1B3C524FBC55E4FBA166007B@tencent.com> MIME-Version: 1.0 Received-SPF: pass client-ip=183.57.53.109; envelope-from=haibinzhang@tencent.com; helo=mail4.tencent.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/21 23:27:55 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, CHARSET_FARAWAY_HEADER=3.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "xtay.haibin@gmail.com" , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Fore-commit(c6beefd674) only saves features of queue0, this makes wrong features of other queues in multiqueues situation. For examples: qemu-system-aarch64 ... \ -chardev socket,id=charnet0,path=/var/run/vhost_sock \ -netdev vhost-user,chardev=charnet0,queues=2,id=hostnet0 \ ... There are two queues in nic assocated with one chardev. When chardev is reconnected, it is necessary to save and restore features of all queues. Signed-of-by: Haibin Zhang --- net/vhost-user.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/vhost-user.c b/net/vhost-user.c index 17532daaf3..ffbd94d944 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -226,7 +226,7 @@ static void chr_closed_bh(void *opaque) NetClientState *ncs[MAX_QUEUE_NUM]; NetVhostUserState *s; Error *err = NULL; - int queues; + int queues, i; queues = qemu_find_net_clients_except(name, ncs, NET_CLIENT_DRIVER_NIC, @@ -235,8 +235,12 @@ static void chr_closed_bh(void *opaque) s = DO_UPCAST(NetVhostUserState, nc, ncs[0]); - if (s->vhost_net) { - s->acked_features = vhost_net_get_acked_features(s->vhost_net); + for (i = queues -1; i >= 0; i--) { + s = DO_UPCAST(NetVhostUserState, nc, ncs[i]); + + if (s->vhost_net) { + s->acked_features = vhost_net_get_acked_features(s->vhost_net); + } } qmp_set_link(name, false, &err);