qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Erik Schilling" <erik.schilling@linaro.org>,
	"Raphael Norwitz" <raphael.norwitz@nutanix.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	virtio-fs@redhat.com,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Mathieu Poirier" <mathieu.poirier@linaro.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	qemu-block@nongnu.org, "Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"Fam Zheng" <fam@euphon.net>, "Kevin Wolf" <kwolf@redhat.com>
Subject: [PATCH v8 2/7] hw/virtio: convert vhost-user-base to async shutdown
Date: Tue,  7 Nov 2023 18:07:47 +0000	[thread overview]
Message-ID: <20231107180752.3458672-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20231107180752.3458672-1-alex.bennee@linaro.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 <alex.bennee@linaro.org>
---
 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:
-- 
2.39.2



  parent reply	other threads:[~2023-11-07 18:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 18:07 [PATCH v8 0/7] virtio: cleanup vhost-user-generic and reduce c&p Alex Bennée
2023-11-07 18:07 ` [PATCH v8 1/7] virtio: split into vhost-user-base and vhost-user-device Alex Bennée
2023-11-07 18:07 ` Alex Bennée [this message]
2023-11-07 18:07 ` [PATCH v8 3/7] hw/virtio: derive vhost-user-rng from vhost-user-base Alex Bennée
2023-11-07 18:07 ` [PATCH v8 4/7] hw/virtio: derive vhost-user-gpio " Alex Bennée
2023-11-07 18:07 ` [PATCH v8 5/7] hw/virtio: derive vhost-user-i2c " Alex Bennée
2023-11-07 18:07 ` [PATCH v8 6/7] hw/virtio: add vhost-user-snd and virtio-snd-pci devices Alex Bennée
2023-11-07 18:07 ` [PATCH v8 7/7] docs/system: add a basic enumeration of vhost-user devices Alex Bennée
2023-11-07 19:00   ` Philippe Mathieu-Daudé
2023-11-07 18:11 ` [PATCH v8 0/7] virtio: cleanup vhost-user-generic and reduce c&p Michael S. Tsirkin
2023-11-07 19:10   ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231107180752.3458672-3-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=erik.schilling@linaro.org \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mathieu.poirier@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=stefanha@redhat.com \
    --cc=viresh.kumar@linaro.org \
    --cc=virtio-fs@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).