From patchwork Tue May 14 06:12:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Feng X-Patchwork-Id: 1934866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=HEumDjib; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VdmMb2XGlz20KD for ; Tue, 14 May 2024 16:16:27 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6lRH-0005in-S5; Tue, 14 May 2024 02:15:03 -0400 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 1s6lRF-0005gs-6L for qemu-devel@nongnu.org; Tue, 14 May 2024 02:15:02 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6lRC-0001vj-EM for qemu-devel@nongnu.org; Tue, 14 May 2024 02:15:00 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6f4ed9dc7beso1887260b3a.1 for ; Mon, 13 May 2024 23:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1715667174; x=1716271974; 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=5U88MQ1EYnI1xEBI7BtZA3bCgLHI2CS0/Ml/sSklTY0=; b=HEumDjibxNzDDectm4FX5oTUDcRn9fEK04ZaiuhNnTm5DTHWLl6INVPaNqhEdMkyah Jr6/8qff6shuTw3rx6o8K/fsFPrQR/CvCtXr3IFR41+4cg8tA2LGNauI81TlqAANQZWw n9XOAszKOsykXL/CLSm7Apyr2syscFhLcmTM3PoJV3Dk3josq74IKVZhQKRYkVlZhmYd DInB61OaYZKzKn2Glo9NUYyUF2Uembs8tgWbSs7pHLHOleJBvRazmqB0SBrooK0Fn++d U0zD51GA9HnZf/op95imOPSkvSjyH2qaS8oLDrA+RG7dxQFMqs7GZiXXr/4JD+9ydYjw PmBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715667174; x=1716271974; 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=5U88MQ1EYnI1xEBI7BtZA3bCgLHI2CS0/Ml/sSklTY0=; b=k52Jt/66smPLVF02Jrwv3ghmjZEoMRnKkOn1R2f8TRV94F5/eRZE6UFpYhl46+pzDO +v1PRU/V9fgmEyl8G2drIStlXBGbuLmNT/lKwm9oQXLrl59XRE8TNQgqQUHPtalMUhZI xNrszElmyIvIzI4pSeeCVxWmuDiEPyWFq5R2R1tpEpDQbSCcPw6h5L+bGW9Jc+2efU4w KVLl0B4YMXxc6jHOVSXq1mGf650QueQubKtdVOluNNsYN6iZyF17Mr3XbfenkIdRvOlA vCQPEDwbrBIoA0xdAnxOgtIiplKJ3QSsQB8nt6f1NXcnZuTzSGGdc3jrSeaTXOSOMY3d 8wDg== X-Forwarded-Encrypted: i=1; AJvYcCWyhjFIDwJGZ18wMkyp0c8IR2iAzN2zljWKizVYpA4IbZscv1d9vvkhE8aITBvTgtcFMzEvD2onwlozNqQg+jpn6Az49yQ= X-Gm-Message-State: AOJu0Yys/ikR4q2W7bvtF1qQXZpjWCtHehTCFsmSNMXd/jyBVvPyAxpW FXudVfNFEUZ/CXJvL6z6kxUILcs+jdThIKZZdh58H6YHrPlxXFyE3E4zwaxAFh0= X-Google-Smtp-Source: AGHT+IGrTLNxS5eKWBTmHGQSnqKYSEFm/x50FhLJq+kLIZ1WBh3tr9l9iEBHTyKmWMW5JPbWQRlhBQ== X-Received: by 2002:a05:6a00:2d05:b0:6f3:8468:8bb with SMTP id d2e1a72fcca58-6f4df44e1c1mr17875618b3a.17.1715667174060; Mon, 13 May 2024 23:12:54 -0700 (PDT) Received: from localhost.localdomain.cc (vps-bd302c4a.vps.ovh.ca. [15.235.142.94]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2a9d94csm8624098b3a.95.2024.05.13.23.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 23:12:53 -0700 (PDT) From: Li Feng To: "Michael S. Tsirkin" , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-block@nongnu.org (open list:Block layer core), qemu-devel@nongnu.org (open list:All patches CC here) Cc: Yajun Wu , Stefano Garzarella Subject: [PATCH v3 1/2] Revert "vhost-user: fix lost reconnect" Date: Tue, 14 May 2024 14:12:27 +0800 Message-ID: <20240514061239.86461-2-fengli@smartx.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514061239.86461-1-fengli@smartx.com> References: <20240514061239.86461-1-fengli@smartx.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::436; envelope-from=fengli@smartx.com; helo=mail-pf1-x436.google.com X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This reverts commit f02a4b8e6431598612466f76aac64ab492849abf. Since the current patch cannot completely fix the lost reconnect problem, there is a scenario that is not considered: - When the virtio-blk driver is removed from the guest os, s->connected has no chance to be set to false, resulting in subsequent reconnection not being executed. The next patch will completely fix this issue with a better approach. Signed-off-by: Li Feng --- hw/block/vhost-user-blk.c | 2 +- hw/scsi/vhost-user-scsi.c | 3 +-- hw/virtio/vhost-user-base.c | 2 +- hw/virtio/vhost-user.c | 10 ++-------- include/hw/virtio/vhost-user.h | 3 +-- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9e6bbc6950..41d1ac3a5a 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -384,7 +384,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &s->chardev, &s->dev, - vhost_user_blk_disconnect, vhost_user_blk_event); + vhost_user_blk_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index a63b1f4948..48a59e020e 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -214,8 +214,7 @@ static void vhost_user_scsi_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &vs->conf.chardev, &vsc->dev, - vhost_user_scsi_disconnect, - vhost_user_scsi_event); + vhost_user_scsi_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index a83167191e..4b54255682 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -254,7 +254,7 @@ static void vub_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &vub->chardev, &vub->vhost_dev, - vub_disconnect, vub_event); + vub_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index cdf9af4a4b..c929097e87 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2776,7 +2776,6 @@ typedef struct { DeviceState *dev; CharBackend *cd; struct vhost_dev *vhost; - IOEventHandler *event_cb; } VhostAsyncCallback; static void vhost_user_async_close_bh(void *opaque) @@ -2791,10 +2790,7 @@ static void vhost_user_async_close_bh(void *opaque) */ if (vhost->vdev) { data->cb(data->dev); - } else if (data->event_cb) { - qemu_chr_fe_set_handlers(data->cd, NULL, NULL, data->event_cb, - NULL, data->dev, NULL, true); - } + } g_free(data); } @@ -2806,8 +2802,7 @@ static void vhost_user_async_close_bh(void *opaque) */ void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb, - IOEventHandler *event_cb) + vu_async_close_fn cb) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { /* @@ -2823,7 +2818,6 @@ void vhost_user_async_close(DeviceState *d, data->dev = d; data->cd = chardev; data->vhost = vhost; - data->event_cb = event_cb; /* Disable any further notifications on the chardev */ qemu_chr_fe_set_handlers(chardev, diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index d7c09ffd34..324cd8663a 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -108,7 +108,6 @@ typedef void (*vu_async_close_fn)(DeviceState *cb); void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb, - IOEventHandler *event_cb); + vu_async_close_fn cb); #endif From patchwork Tue May 14 06:12:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Feng X-Patchwork-Id: 1934865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=VPIZ11AM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VdmLz0KG7z20KD for ; Tue, 14 May 2024 16:15:55 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6lRU-000644-LJ; Tue, 14 May 2024 02:15:16 -0400 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 1s6lRS-000639-UL for qemu-devel@nongnu.org; Tue, 14 May 2024 02:15:14 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6lRE-00020T-9I for qemu-devel@nongnu.org; Tue, 14 May 2024 02:15:14 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6f44881ad9eso4107071b3a.3 for ; Mon, 13 May 2024 23:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1715667178; x=1716271978; 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=zzHwXd5rAuGL7sHHNS+hdDBoLK+U/OepNXP6dTW3cz8=; b=VPIZ11AM8mpzVIk8ls+DCECsmGhLrXP6p3QQZicfCNcqT7Cnhr+zjvlXaSw/xuO3Ay vktBzuLB3x5b6bVNnhoN046JDv7qEijxGsYYLlQUjT5osXCHS0tzaBzL1toFcigTywH5 5TiUybY7Mk08KqR3funwB6raQsA1phj4riNiQ2+AGYBw8KxgbzdTEBmbe4wub32sQPSd S844tKu/22NPg5OWH/dUduaXl5+/VNm7sHNt+D6TQwDZaFPwDrFL/aJQP07GvSUbDX4M gqhnShuMtnw7BF3hFKgdQqo8YWu0RwChkhz1UeR9whRP069riF073b2u/l0UbqMcLtGc HL4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715667178; x=1716271978; 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=zzHwXd5rAuGL7sHHNS+hdDBoLK+U/OepNXP6dTW3cz8=; b=DjNzuiZZNldu4VFF8EY5FeC1MEX/qhi8jdZ0685flv7R8LX80tE87pq+730tcFr8Lu 1s+WQEpFn912zH7XCneg+ubRynnhvudQ9aLrHT+iLgGs0UK8HU6uNCMFDglWqdVsTcpz eGukF2JliNeVDdn3HigVPv7aXc5HtsfcOtT4tWOGs2wtfE7opinXadnAjP2wSoEOpOyK 8kKiJU3IxiZTpb6R/8hNeV3nrS4ER5gaCHXbLhz/7IfOAR5RRNwxJ8urgWrL26zRAye3 VxnjRqL3QEgOHqgidWdvF6nADb/MJetu/EnGlaYlvXk3q1cKRvoTWWQPBpAVfaaI4Tiv j2XA== X-Forwarded-Encrypted: i=1; AJvYcCUgaLnNVjTOuO1aP4MV6etzRg+P38aLC8+zKBDDBv9cD1fqrAPyFyYIm4D9jNCyjOTYHnJPPzujSQu2kQdU8sKNqOXPyG0= X-Gm-Message-State: AOJu0YxDH0r6SV2NZh9LhAIoSETIgwC5TOO9dQAoPXghsqxZzGC7VH0K Rv19m2n5OAh8i3ZZFFDnUS5wrfUcF38mbQtBWgqXRY6dORQi9bzsgoGdIERKVGw= X-Google-Smtp-Source: AGHT+IHGSTvBS4PE7SQRPAzT1EN1I+5d4jUvjq2DhQ1abL03yup60vx0Hkq37RVssbjGxcMkXJvqZQ== X-Received: by 2002:a05:6a20:d807:b0:1af:f927:55db with SMTP id adf61e73a8af0-1aff9275760mr4663942637.59.1715667178112; Mon, 13 May 2024 23:12:58 -0700 (PDT) Received: from localhost.localdomain.cc (vps-bd302c4a.vps.ovh.ca. [15.235.142.94]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2a9d94csm8624098b3a.95.2024.05.13.23.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 23:12:57 -0700 (PDT) From: Li Feng To: Raphael Norwitz , "Michael S. Tsirkin" , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-block@nongnu.org (open list:Block layer core), qemu-devel@nongnu.org (open list:All patches CC here) Cc: Yajun Wu , Stefano Garzarella Subject: [PATCH v3 2/2] vhost-user: fix lost reconnect again Date: Tue, 14 May 2024 14:12:28 +0800 Message-ID: <20240514061239.86461-3-fengli@smartx.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514061239.86461-1-fengli@smartx.com> References: <20240514061239.86461-1-fengli@smartx.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::433; envelope-from=fengli@smartx.com; helo=mail-pf1-x433.google.com X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When the vhost-user is reconnecting to the backend, and if the vhost-user fails at the get_features in vhost_dev_init(), then the reconnect will fail and it will not be retriggered forever. The reason is: When the vhost-user fail at get_features, the vhost_dev_cleanup will be called immediately. vhost_dev_cleanup calls 'memset(hdev, 0, sizeof(struct vhost_dev))'. The reconnect path is: vhost_user_blk_event vhost_user_async_close(.. vhost_user_blk_disconnect ..) qemu_chr_fe_set_handlers <----- clear the notifier callback schedule vhost_user_async_close_bh The vhost->vdev is null, so the vhost_user_blk_disconnect will not be called, then the event fd callback will not be reinstalled. With this patch, the vhost_user_blk_disconnect will call the vhost_dev_cleanup() again, it's safe. In addition, the CLOSE event may occur in a scenario where connected is false. At this time, the event handler will be cleared. We need to ensure that the event handler can remain installed. All vhost-user devices have this issue, including vhost-user-blk/scsi. Fixes: 71e076a07d ("hw/virtio: generalise CHR_EVENT_CLOSED handling") Signed-off-by: Li Feng --- hw/block/vhost-user-blk.c | 3 ++- hw/scsi/vhost-user-scsi.c | 3 ++- hw/virtio/vhost-user-base.c | 3 ++- hw/virtio/vhost-user.c | 10 +--------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 41d1ac3a5a..c6842ced48 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -353,7 +353,7 @@ static void vhost_user_blk_disconnect(DeviceState *dev) VHostUserBlk *s = VHOST_USER_BLK(vdev); if (!s->connected) { - return; + goto done; } s->connected = false; @@ -361,6 +361,7 @@ static void vhost_user_blk_disconnect(DeviceState *dev) vhost_dev_cleanup(&s->dev); +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_event, NULL, dev, NULL, true); diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 48a59e020e..b49a11d23b 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -181,7 +181,7 @@ static void vhost_user_scsi_disconnect(DeviceState *dev) VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev); if (!s->connected) { - return; + goto done; } s->connected = false; @@ -189,6 +189,7 @@ static void vhost_user_scsi_disconnect(DeviceState *dev) vhost_dev_cleanup(&vsc->dev); +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&vs->conf.chardev, NULL, NULL, vhost_user_scsi_event, NULL, dev, NULL, true); diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 4b54255682..11e72b1e3b 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -225,13 +225,14 @@ static void vub_disconnect(DeviceState *dev) VHostUserBase *vub = VHOST_USER_BASE(vdev); if (!vub->connected) { - return; + goto done; } vub->connected = false; vub_stop(vdev); vhost_dev_cleanup(&vub->vhost_dev); +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&vub->chardev, NULL, NULL, vub_event, diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index c929097e87..c407ea8939 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2781,16 +2781,8 @@ typedef struct { static void vhost_user_async_close_bh(void *opaque) { VhostAsyncCallback *data = opaque; - struct vhost_dev *vhost = data->vhost; - /* - * If the vhost_dev has been cleared in the meantime there is - * nothing left to do as some other path has completed the - * cleanup. - */ - if (vhost->vdev) { - data->cb(data->dev); - } + data->cb(data->dev); g_free(data); }