From patchwork Thu Jan 4 21:09:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 759876 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp7183371wrw; Thu, 4 Jan 2024 13:11:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXlexhYJoS40F+ybLQTu3136bnWGkpJ9hv5OTuV90u5F29jggWObTP5CVjcpF9YCoo+9DB X-Received: by 2002:a05:6902:e10:b0:dbc:de49:636b with SMTP id df16-20020a0569020e1000b00dbcde49636bmr1163565ybb.12.1704402694193; Thu, 04 Jan 2024 13:11:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704402694; cv=none; d=google.com; s=arc-20160816; b=uarkc0gqRbFcqR3c5T4dVeN0z82JvGoYZt9ja5nDLfd52NPie58DvehBWmSAfHYb+P +pCjs2E2O+tEywAO+eJ1wJU6Ad/nMIHSg3lTnF43gZRo69IWUTr2QFpbA8nfktCSPCBG b1PAaUdJSB/AW8ugKViV3Ju9EXQSnEwgk1MFeNXTDDp4KoomMNy+mx89EVne7cwltptK h7A3D7xuONQ0iihVYBu3KNKCgXUcn/8vgUrpo3HJJyzcZTI30AG5ABoL4iosz9bcDh8j xMDVRuJyUOYLgCZbef1YwKAiOfX7kVFc+o/EIELQQx1Ft+nAEpqF6kqcrJUa7XJJ7CtI GXGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZD8gKWnWBsgVd7TCyN00x3s8+apLf0F3UjlTxysTxrM=; fh=FJgCuuUiQlhQb75y4DqgTcYU/2dmCchdcJEae1kKAEw=; b=xWLhH4N2ymJcfGsNF4VANKS82bWgb9xMUdhGx33LyyOvo2jmY87D3M4dhzNAy9oxHd uWcwhmX/WrzesD0L9hQIgQf/hu/ClDZPQzQeq1l6vKaZi8GvBtLbu+pV/mEzp+ROZQ1T 50bxi+A/cpA9T9k5PZYYBt0LMXcWv8mb08ek8MP35b3k4NvpO7avDFEgxFWVvYIGgk79 TQlVwORJfEZkpaNOw5PfMpB40k2LW9PdbNM2U0KMzOE5xAKsLensnunYDpb9in3qfg+6 fdoyRQ6FuoKYxk6fvdeAk3NkvT/7acWEk7Gz2P5ohTHEpo2idZoypY+o+YDCQ/Co7OiJ 6xuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E3A6MIaP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bp30-20020a05620a459e00b00781b9927e1bsi323799qkb.256.2024.01.04.13.11.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jan 2024 13:11:34 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E3A6MIaP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLUyP-0006un-9q; Thu, 04 Jan 2024 16:09:53 -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 1rLUyN-0006td-IK for qemu-devel@nongnu.org; Thu, 04 Jan 2024 16:09:51 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rLUyL-0007RO-Pk for qemu-devel@nongnu.org; Thu, 04 Jan 2024 16:09:51 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3368b1e056eso787992f8f.3 for ; Thu, 04 Jan 2024 13:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704402588; x=1705007388; 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=ZD8gKWnWBsgVd7TCyN00x3s8+apLf0F3UjlTxysTxrM=; b=E3A6MIaPkEyMw46IRgs6QAdxWIDnWKd0gC5hD1HjuZ8kbXg8vFx7RI3vYdFBdlk18h aBOY6S4YaYN28Vf+t/Z6Q60mwPyDnZgPiHS5y1tkfrX3gHcKBVeZu+HALfWYezaxJYQP GhtWcNnfT4IE3GEtR9zGPTreVChIeMmQOxamMD6DdEEDT8K5FIdMBpVfrkRNzc9nW2A/ LQ03ejYTe4233klTsfnE3yQheNTavORGKJqwcJMEZQMPv6Ihz2jJ3rXjZB6qsJ00b4ga 9tp4vxkzq07hA8bSUt8yleNhIuyO0mQEWWTbhqKmkrxOYCMyrXy2AhxWoaSQwNtIDhbd 8uig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704402588; x=1705007388; 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=ZD8gKWnWBsgVd7TCyN00x3s8+apLf0F3UjlTxysTxrM=; b=ajnOMLl+0+1Rp8CZHKRI26HRnoMfsCGvT8r7CXx0q1wEkfHd0O5a21aWnPYQalmNUD FjWlCVqmQQ01i0U5l1hs/SlodsRR+eyojhjrn5GX2a9fUhSJYvD2G7fBqaGpq/l5zLp2 a/4mTckd0oz0/Ir5k9Eis5qsw+x9TqEaZw098oFarKi4i1+HDs8Y5j+8uRGjyB4UOuhf OWqW9GOyUGHsTWd0FzYdQ8sQiIKweWUq/qxa07nwxF5uLxbcJ9lKML+KNUEejPlVviwX tuzjJItUaww0xBGLvNC199ANpjlyNakRTJm8r4aNf61oLOjkq513Ec5jLzEhnQiBXDut 9LlQ== X-Gm-Message-State: AOJu0YzqUSLAOsrRDsW25D5CMk0DEPbgqiRITGopaDzcMoS3tXlzlnmp tVYbXaX1itsJluxGmDLFnGCYGRkFADjG6Q== X-Received: by 2002:adf:fad0:0:b0:337:404d:4e9f with SMTP id a16-20020adffad0000000b00337404d4e9fmr609500wrs.79.1704402588522; Thu, 04 Jan 2024 13:09:48 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id c11-20020a5d414b000000b00336aa190139sm109726wrq.5.2024.01.04.13.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 13:09:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 46D3B5F933; Thu, 4 Jan 2024 21:09:45 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Mathieu Poirier , Kevin Wolf , Mark Cave-Ayland , Jason Wang , Erik Schilling , Eric Blake , Fam Zheng , =?utf-8?q?Marc-?= =?utf-8?q?Andr=C3=A9_Lureau?= , Eduardo Habkost , virtio-fs@redhat.com, Hanna Reitz , =?utf-8?q?Alex_Benn=C3=A9e?= , Manos Pitsidianakis , =?utf-8?q?Daniel_P=2E?= =?utf-8?q?_Berrang=C3=A9?= , qemu-block@nongnu.org, Markus Armbruster , "Gonglei (Arei)" , "Michael S. Tsirkin" , Raphael Norwitz , Paolo Bonzini , Viresh Kumar , Stefan Hajnoczi Subject: [PATCH v9 02/11] hw/virtio: convert vhost-user-base to async shutdown Date: Thu, 4 Jan 2024 21:09:36 +0000 Message-Id: <20240104210945.1223134-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240104210945.1223134-1-alex.bennee@linaro.org> References: <20240104210945.1223134-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We are about to convert at least one stubs which was using the async teardown so lets use it for all the cases. Signed-off-by: Alex Bennée --- hw/virtio/vhost-user-base.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 620fa5cb4a4..78cfa9a5bbc 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -201,6 +201,8 @@ static int vub_connect(DeviceState *dev) return 0; } +static void vub_event(void *opaque, QEMUChrEvent event); + static void vub_disconnect(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -211,9 +213,13 @@ static void vub_disconnect(DeviceState *dev) } vub->connected = false; - if (vhost_dev_is_started(&vub->vhost_dev)) { - vub_stop(vdev); - } + vub_stop(vdev); + vhost_dev_cleanup(&vub->vhost_dev); + + /* Re-instate the event handler for new connections */ + qemu_chr_fe_set_handlers(&vub->chardev, + NULL, NULL, vub_event, + NULL, dev, NULL, true); } static void vub_event(void *opaque, QEMUChrEvent event) @@ -230,7 +236,9 @@ static void vub_event(void *opaque, QEMUChrEvent event) } break; case CHR_EVENT_CLOSED: - vub_disconnect(dev); + /* defer close until later to avoid circular close */ + vhost_user_async_close(dev, &vub->chardev, &vub->vhost_dev, + vub_disconnect, vub_event); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: