From nobody Wed Nov 27 13:05:48 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1699380246; cv=none; d=zohomail.com; s=zohoarc; b=JuU1sVN8cN+7WVQ4lN4LAXJwZtnhIQWwadNYMHwoOFJPmEFqGZwayWU+9fUGXo5yMTXThBebZQa7yFdck2QCAt9PgkBeXy8OcVscKeelkT02zfOWEZhMOIkP7eSrMzmtwX+eGZIGEGn5WmlLKLNWU29QAwPMf9wvWH1v4MwvzAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699380246; h=Content-Type: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=kZRUMwiWEGUH1111nhqAP/d0bCasvHH98Sdsmx1hRdc=; b=mQ1P20+GAOdWXimXINYWivTDw+AYKc4qgAu6o6genQb7sbzg0gbsG9BuKosVMIJ6hako6Vyv5gstnSZBB9d9YMNkLkUlOtpvqBYcd/CM3JoTB89EhgKJDD80f6eDTUlvJ+mTWzNtDg1AAw/SHFdmHyO2xY0rSpIgKKAR/dt3ryI= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699380246570366.05722546553613; Tue, 7 Nov 2023 10:04:06 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IH5Ryzsi9s/1ylT5IsaR8y0tc+oSuQ7xkUfXzGmGXVbCjonk34PYJZKQK1B2eV24Pca0Bsrvg== 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) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Eric Blake , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Fam Zheng , Jason Wang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , 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 Content-Type: text/plain; charset="utf-8" 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: 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1699380247859100003 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=C3=A9e --- 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; } =20 +static void vub_event(void *opaque, QEMUChrEvent event); + static void vub_disconnect(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -211,9 +213,13 @@ static void vub_disconnect(DeviceState *dev) } vub->connected =3D false; =20 - 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); } =20 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: --=20 2.39.2