From patchwork Tue Nov 7 18:02:41 2023 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: 741915 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1765153wrr; Tue, 7 Nov 2023 10:04:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjNG/ks6OjIzPlmJoProeeOGQBYhnohI2GsBM+BXF/ZWEwhKzjYXyfDZveyd8tJCk2dNAF X-Received: by 2002:a05:622a:50b:b0:417:b545:e962 with SMTP id l11-20020a05622a050b00b00417b545e962mr34309619qtx.7.1699380246210; Tue, 07 Nov 2023 10:04:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699380246; cv=none; d=google.com; s=arc-20160816; b=Q1h1en3NFuFSU4Q4ocF+kyomgDDBaO3ZLCV0cutLSolBMdaIEmK1TnRRqk0cztzVWm CQt1X0ZOI0ZP4+/Wsj5SqZcb4qhYbZaTAfXTuW44jfZYHQRd7ki7j7zcU3Ar7h5j3XL+ 1NrJ2Fw8OuBD1Jk1cKz4XF3RcF37gZ+Qb85Sx8iaub6ngfptF/H+B43FJM57DYGpiuyb PbDMmH5/HSz8zeDjjV0y35j0mRNo0TOzVFFbYxIiuSMsiGzJ6NHxtdec77BhDWLmjNzO KQzXFs+hzx1PNi6D30NfGXkOnLM3xGXG7O2RyVihu1UwtjVzbFm9/9cNNFxI/2AC9Kdp C66Q== 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=kZRUMwiWEGUH1111nhqAP/d0bCasvHH98Sdsmx1hRdc=; fh=TJJmyUUgRcCZXtFwaXktCcgbc+ZTKj0atn5yhJf6P90=; b=kClcBN8BjBFQmsRrcvsklG10trn/Od8XTCEhBOm4gmYsUgI8CCR+0Jdk99IAMD2QJH 9XXbVFTgAzbn9g9v0/2sfaoUlRgpLxKeteL3+VxW0ew8f3gYY8GUp3IUPu/6OPW9BpGZ gukf6r3+yqNavm4sUZ71gn3IWVVZDzk2RIgLHOm6bmFwKk+wnNju2zpAy3MH118IsqoO wCEhGkF0jnWY+SwMosOB5ygxRtU1rCmjo81piKhP76BUlmTxiTWalnmlFq/sw3LlzZGR dN0/luDw1yV0mBbTl8PtCNqRRgNzA2OpZoetcn94pjBwZz9DMb0oSj6RRvM6x70bqzFc nraw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fa5PCKPX; 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 h1-20020ac87d41000000b0041811753adbsi181368qtb.342.2023.11.07.10.04.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2023 10:04:06 -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=Fa5PCKPX; 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 1r0QPd-000858-0M; Tue, 07 Nov 2023 13:02: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 1r0QPb-00084j-3M for qemu-devel@nongnu.org; Tue, 07 Nov 2023 13:02:51 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0QPZ-0000db-F7 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 13:02:50 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40850b244beso45162005e9.2 for ; Tue, 07 Nov 2023 10:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699380168; x=1699984968; 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=kZRUMwiWEGUH1111nhqAP/d0bCasvHH98Sdsmx1hRdc=; b=Fa5PCKPXL1VSdVK2ytgFmIZHbyQogAr9WI/CA5VWqWjl61+73Bs/bN/szmxWMtnazX aj9CYqUW1TOrBzcIjnWk6969E3OcNyHTDrRPgRYX1I8NbuAt0aulDCON9Ajl5d5MW2Fh 9MYbWkEpsV0FyiUedYYwaJd5lxy0X5ck/qBoYRI8wVqCE4XzqfDnuCg7VZx9N5Ve1F71 fZyEMU9wekBEAAWWKWTy4U2G9pvqyzM0U4C90WKxsv4UMD4Hjozl0GGm3b4ulS1h+odS j+1aujhBFiC5LTCQTuc27uuc9usjlnNBnU9NNvRJFe/fOJg5Eux+8F5hwowWV53TBSyZ jCTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699380168; x=1699984968; 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=kZRUMwiWEGUH1111nhqAP/d0bCasvHH98Sdsmx1hRdc=; b=qpLY5AX6lqD2opz3clnfKGXlqCotaN7/5JU46JMQCbdMLqeUZEWbuAJuPT3VJZRHhA R4e0Q76pm0j9zmv/cyx8W+oOmYgv5BGt75H00PiNUyiU4aUOLFJPVGT9Y3eiEYIm5XOX HdkePfKF42p4A3H61SwPDbw9UTk4dWFvpnCfFsPY6/US9s+S7bWEPRlHbOevCya0baTU FP2uPo9THbgK50CEl3ZeOfdgp+0AAdoXGLcQf7xQrRDEnzhgRfeOmM+DGjNBFl38z3Dk KShB8I6YRcCFP+9YXjynWF9qu/aRD3r2CyXda6wrA5bJ77D+TSTAA3caj1BYlo7di+/M XIRQ== X-Gm-Message-State: AOJu0Yx2oIMbwvL9i70DmmzBvXym3Z6j/YkmEjwbMw8oO8/zKhVaLomm 8ilp1DRBoZwdJdhye03GYwBDBQ== X-Received: by 2002:a05:600c:4f92:b0:405:82c0:d9f3 with SMTP id n18-20020a05600c4f9200b0040582c0d9f3mr3196022wmq.30.1699380167943; Tue, 07 Nov 2023 10:02:47 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id b5-20020a05600c4e0500b00407b93d8085sm16656588wmq.27.2023.11.07.10.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 10:02:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D6DE16573E; Tue, 7 Nov 2023 18:02:46 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eric Blake , Gerd Hoffmann , =?utf-8?q?Alex_Benn=C3=A9e?= , Fam Zheng , Jason Wang , =?utf-8?q?Dan?= =?utf-8?q?iel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Marc-An?= =?utf-8?q?dr=C3=A9_Lureau?= , Viresh Kumar , Manos Pitsidianakis , Raphael Norwitz , Hanna Reitz , Erik Schilling , "Michael S. Tsirkin" , Mathieu Poirier , qemu-block@nongnu.org, Paolo Bonzini , Eduardo Habkost , Markus Armbruster , Stefan Hajnoczi , Mark Cave-Ayland , virtio-fs@redhat.com, Kevin Wolf , "Gonglei (Arei)" Subject: [PATCH v7 2/7] hw/virtio: convert vhost-user-base to async shutdown Date: Tue, 7 Nov 2023 18:02:41 +0000 Message-Id: <20231107180246.3456598-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231107180246.3456598-1-alex.bennee@linaro.org> References: <20231107180246.3456598-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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 620fa5cb4a..78cfa9a5bb 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: