diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2024-04-04 20:56:11 +0200 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2024-04-10 19:17:04 +0300 |
commit | e070e5e6748e3217028fa21aa30bb51f862368c8 (patch) | |
tree | cbaab21ee39ce75f08409b000d2af0d4cca2ece5 | |
parent | d6e7ec1f8e9a38f55cfd2c581fa8e3afe05b0499 (diff) |
hw/virtio: Introduce virtio_bh_new_guarded() helper
Introduce virtio_bh_new_guarded(), similar to qemu_bh_new_guarded()
but using the transport memory guard, instead of the device one
(there can only be one virtio device per virtio bus).
Inspired-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20240409105537.18308-2-philmd@linaro.org>
(cherry picked from commit ec0504b989ca61e03636384d3602b7bf07ffe4da)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: trivial #include context fixup in include/hw/virtio/virtio.h)
-rw-r--r-- | hw/virtio/virtio.c | 10 | ||||
-rw-r--r-- | include/hw/virtio/virtio.h | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e4f8ed1e63..4a35d7cb0c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -5029,3 +5029,13 @@ static void virtio_register_types(void) } type_init(virtio_register_types) + +QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name) +{ + DeviceState *transport = qdev_get_parent_bus(dev)->parent; + + return qemu_bh_new_full(cb, opaque, name, + &transport->mem_reentrancy_guard); +} diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 96a56430a6..c1a7c9bd3b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -23,6 +23,7 @@ #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" #include "hw/virtio/vhost.h" +#include "block/aio.h" /* * A guest should never accept this. It implies negotiation is broken @@ -463,4 +464,10 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev) bool virtio_legacy_allowed(VirtIODevice *vdev); bool virtio_legacy_check_disabled(VirtIODevice *vdev); +QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name); +#define virtio_bh_new_guarded(dev, cb, opaque) \ + virtio_bh_new_guarded_full((dev), (cb), (opaque), (stringify(cb))) + #endif |