From nobody Wed Nov 27 06:47:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1700719098; cv=none; d=zohomail.com; s=zohoarc; b=Yd8Ak66YDjKwkmMKroZTOFIvA9olpx64wo7bFLIFRKfkQr6/5xFWVoaeUhDSnguSdLbX+ZmWrZZvL31y1X6HT9/Wp+e+vtUtE2fQ1xXpj3Qiiunf+ESV4DrDPiZdS9Gu/ftEfYCqU/UF3dvF+T/OSBP5mth+CiTfVTDST78yywg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700719098; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=964uo+5Y+U8YzWWZaokHxWreZ+eFgGhXnwjQzLz2WuU=; b=XfxNGK1DcWSyuYWatqI30GFHyhHL23H+vm09ge8Bl7tmiqafiB9MrgD/iJHwv2TT/5+TKh0/yNnmMu8rOn7Hmg3gpzxmcnQACAzzEmWfu+/4stW1n08HaLapIkbkC/oWNH8WV6+u0x2GXRLaeaan/gZvXE0EbZQewWKcd0bY72E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 170071909865461.65601771825118; Wed, 22 Nov 2023 21:58:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r62iG-0003fy-Dr; Thu, 23 Nov 2023 00:57:20 -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 1r62iA-0003ej-Oc for qemu-devel@nongnu.org; Thu, 23 Nov 2023 00:57:15 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r62i6-0005Qs-9B for qemu-devel@nongnu.org; Thu, 23 Nov 2023 00:57:14 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cc0d0a0355so3650195ad.3 for ; Wed, 22 Nov 2023 21:55:08 -0800 (PST) Received: from localhost.localdomain.localdomain ([8.210.91.195]) by smtp.gmail.com with ESMTPSA id jl14-20020a170903134e00b001cf6453b237sm417071plb.236.2023.11.22.21.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 21:55:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1700718907; x=1701323707; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=964uo+5Y+U8YzWWZaokHxWreZ+eFgGhXnwjQzLz2WuU=; b=kJRxibFf6d+gjRjQ8V0CIQe1D3ogG6FxLJc0m/tFefKUDUl2nHOA8qPt5V5bylllup mI5aN/125kwmrbxhcUNB+c2ZvIpOQfUYAXmABk3HUXWQIwtOkjewaPYEFvKZFZ1VekkD AUn+cYHRRiPcbpjtildt5dzObyUwkApDQzskY9dJ1n2hEqoaFIptQZ+L+IxM0qqFr0M6 WhtJkPqjeOta2heUz+YMCjgY+XcOPRuFn+6mT5BNYIZGR938ZNiVW1+Ve8F/Cb83GCif HWinVLt2ifZdYfxGdSICBVYtkt+OXzBOWahwabGNsXE3y39dOzEjhwCqKj3A4jJ5wtNm aVLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700718907; x=1701323707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=964uo+5Y+U8YzWWZaokHxWreZ+eFgGhXnwjQzLz2WuU=; b=VNJDmTOCd3d3K9+8DGaArRcdmRDmrlDbTRcNNhUs0Lmh7OouyvEa4oh7KvyrU1buG3 FDwar9Ex//GYsHZREYux+tjTlLi2mIg4XbT4DdXf8tRDiF6NhvMAyztagq2h9VZrHq0i Ms7p3TLDo0m/hIXTezsYG8iOU83c+ngvazGxgZ3MmDtsN9+JoD8lizWq60T2C13K2H1v 3i3GFN/zbjPeI8CKLZi57GU5t/qwiAVXoaa3dNMc7cdLxGx+emwbozxqAODUpCJmCJo2 6BGX2j9pev7s2KHi2qhX0CVWQmX6xsTDKbf2iCHn9kP37zgejRDAgGmTzqFwLRRaDpo/ +GDg== X-Gm-Message-State: AOJu0Yx5LI39caoUzNw4UeYwLULZByageWxPp8bLqcidGzt+pPg/kSQI 03cBthvVoVudRzsOyhVKAaUL3g== X-Google-Smtp-Source: AGHT+IHs93kLRNzvba/VUnnn0N7gKQr5FX516kpOaIX7sOJrgiA4V4iSrrjJ+QFGg8ldUcXYKiK1Dg== X-Received: by 2002:a17:902:f7c6:b0:1cf:8c88:51cb with SMTP id h6-20020a170902f7c600b001cf8c8851cbmr476181plw.62.1700718907245; Wed, 22 Nov 2023 21:55:07 -0800 (PST) From: Li Feng To: Raphael Norwitz , "Michael S. Tsirkin" , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Viresh Kumar , qemu-block@nongnu.org (open list:Block layer core), qemu-devel@nongnu.org (open list:All patches CC here) Cc: Li Feng Subject: [PATCH 1/2] vhost-user: fix the reconnect error Date: Thu, 23 Nov 2023 13:54:11 +0800 Message-ID: <20231123055431.217792-2-fengli@smartx.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231123055431.217792-1-fengli@smartx.com> References: <20231123055431.217792-1-fengli@smartx.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::62a; envelope-from=fengli@smartx.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1700719099981100003 Content-Type: text/plain; charset="utf-8" If the error occurs in vhost_dev_init, the value of s->connected is set to = true in advance, and there is no chance to enter this function execution again in the future. Signed-off-by: Li Feng Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 8 +++----- hw/scsi/vhost-user-scsi.c | 3 ++- hw/virtio/vhost-user-gpio.c | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 818b833108..2863d80d15 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -326,7 +326,6 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) if (s->connected) { return 0; } - s->connected =3D true; =20 s->dev.num_queues =3D s->num_queues; s->dev.nvqs =3D s->num_queues; @@ -343,15 +342,14 @@ static int vhost_user_blk_connect(DeviceState *dev, E= rror **errp) return ret; } =20 + s->connected =3D true; + /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { ret =3D vhost_user_blk_start(vdev, errp); - if (ret < 0) { - return ret; - } } =20 - return 0; + return ret; } =20 static void vhost_user_blk_disconnect(DeviceState *dev) diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 4486500cac..2060f9f94b 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -147,7 +147,6 @@ static int vhost_user_scsi_connect(DeviceState *dev, Er= ror **errp) if (s->connected) { return 0; } - s->connected =3D true; =20 vsc->dev.num_queues =3D vs->conf.num_queues; vsc->dev.nvqs =3D VIRTIO_SCSI_VQ_NUM_FIXED + vs->conf.num_queues; @@ -161,6 +160,8 @@ static int vhost_user_scsi_connect(DeviceState *dev, Er= ror **errp) return ret; } =20 + s->connected =3D true; + /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { ret =3D vhost_user_scsi_start(s, errp); diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index aff2d7eff6..a83437a5da 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -229,7 +229,6 @@ static int vu_gpio_connect(DeviceState *dev, Error **er= rp) if (gpio->connected) { return 0; } - gpio->connected =3D true; =20 vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); gpio->vhost_user.supports_config =3D true; @@ -243,6 +242,8 @@ static int vu_gpio_connect(DeviceState *dev, Error **er= rp) return ret; } =20 + gpio->connected =3D true; + /* restore vhost state */ if (virtio_device_started(vdev, vdev->status)) { vu_gpio_start(vdev); --=20 2.42.0