From nobody Tue Nov 26 13:45:55 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1707909259; cv=none; d=zohomail.com; s=zohoarc; b=bf1583VaAufsTJkw3I6QeeIGS/nFK/rE168uiz5ZCvnD4SJAQQoJuEs1ynQfIiBNHlVd2HTy1MDojdGpHCMGeXE3iW1XWHK3YR892sQUl0abBuGpzIgXXmXVDa5T8X8A9l9HN002Zmi1fsnHHuJbmhZwx/FJJB7j4z+Z8cBLb6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707909259; 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=YVJ2xCGDmS5//nzvgjYPTRhJxVogUUB55jW/DQR2itg=; b=e6FIDkcQqrrxUU4RB+sFfMciut4+OiyxoVCwGCuIENtg99+cHIb2Zq/HXuj0UcHU0eJSRsi8dDKzZ6PH9dKMdYzfdxwuX9VmG6dNz6SN83u0xA1cxq5jFwTX7yTaaUW5i58Kq4mCY3IJie8M/I67yGW+dxdVdHKEMnuLiTF1Z3Y= 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 1707909259674729.9900563589712; Wed, 14 Feb 2024 03:14:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDCo-0008IA-UG; Wed, 14 Feb 2024 06:13:34 -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 1raDCm-0008Hy-60 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCi-0006gy-8g for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:30 -0500 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-F6d-m2mXPTCLQd8Mmrgs7A-1; Wed, 14 Feb 2024 06:13:24 -0500 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a2f71c83b7eso154150766b.1 for ; Wed, 14 Feb 2024 03:13:24 -0800 (PST) Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id tb20-20020a1709078b9400b00a3cf436af4fsm1741603ejc.3.2024.02.14.03.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YVJ2xCGDmS5//nzvgjYPTRhJxVogUUB55jW/DQR2itg=; b=eCjy6GWjb5jsOrkQvVy6iyplyw5OG6m463Gkb4ei2hEuBO+yM9QBpNc10l9lwZnKn8nhLC +D9yXk63vocD9AEfzY1UOE9KwRfd+KMIODXyA3HW/TamZeaqj0x9T++ce+MIc6e5xcnVkj sVLYAaVm9H/zoV5FJM2FP+UdG2K31fI= X-MC-Unique: F6d-m2mXPTCLQd8Mmrgs7A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909202; x=1708514002; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YVJ2xCGDmS5//nzvgjYPTRhJxVogUUB55jW/DQR2itg=; b=NzdtSqxgjzvFFPSO6u3X7xMtTyTDYliD6KnEouLnlzyMfSLNQuseLpFqMT6Bdm8XqL EYzJxKmYoVRTkZUmGomVrXADMmCFK47IjNVS7iVHfGzXaeYshhuDp+QaoyQYxuAl5s3p ptX8pAXr73V7NnFsNtLRFkSjTri7CVGhumMY/ZJOFBUrqx6RO4asr+Rcd3ltJr887pYg bma3UA6hJjNc5SzIFuQvqvI0uzB0lDscRX0ZZRqS5Da3OAeDG9LFsngNPkheIFZDiTuE Dns8C8muDWhgF4l1/H4baPzKKUydZvvEB+mzeULcx0Pn9NQ4ARByzcKH5648XbkvLMAB EcFw== X-Gm-Message-State: AOJu0YxpNJlv/5fGMzF3y3SVegpDlI+elwsYsRYyncYb15QK5evdHDhi 3yHxXzF7q3Gu6/N9v3uESRdbN6cqX1n6v3nVxo2IFXX4jsTH7YEcRAbOkxPmKsz0DXV6etzytsn jSCGf4484WuImzy/99HOoz/vjWMF884g+A8FTIrscBIIXbj5HB3aOqS/xczrm3yWR8TZpQ1MzpR VeRxBxZpPAId0in9Ihktb0qcKvwAbX6w== X-Received: by 2002:a17:906:134c:b0:a3c:cd77:87f9 with SMTP id x12-20020a170906134c00b00a3ccd7787f9mr1630862ejb.58.1707909202628; Wed, 14 Feb 2024 03:13:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/IvSL0WABmOl0nXkIHWAqBTJNqOkoVMQvo1899o7iw2e2j4vP7/Af7A3d+KiojeqEzcyZmg== X-Received: by 2002:a17:906:134c:b0:a3c:cd77:87f9 with SMTP id x12-20020a170906134c00b00a3ccd7787f9mr1630853ejb.58.1707909202323; Wed, 14 Feb 2024 03:13:22 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXRv6+nEZO1qiCqKKYqkkipb+MpIyOHp5HSDxMz2Wy1XloRTD3il9kxiv33PpN7+BDa3zCqIfT/VsBf6UmrYMvGMzjL9iLc Date: Wed, 14 Feb 2024 06:13:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?Q?Benn=C3=A9e?= Subject: [PULL 02/60] hw/virtio: convert vhost-user-base to async shutdown Message-ID: <64a312a2737e3aab97f103b76f8e76a97770e670.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1707909261301100007 From: Alex Benn=C3=A9e 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 Message-Id: <20240104210945.1223134-3-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 MST