* [PATCH 0/5] virtio: allow virtio_error() in IOThreads
@ 2025-09-22 22:01 Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 1/5] vhost: use virtio_config_get_guest_notifier() Stefan Hajnoczi
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-09-22 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefan Hajnoczi, Stefano Garzarella
The hw/virtio/ code calls virtio_error() when the guest driver does something
invalid. virtio_error() is currently not usable outside the Big QEMU Lock (BQL)
because it calls into the interrupt code path (MSI, etc) that requires the BQL.
Make the hw/virtio.c code aware of the IOThread case where the BQL is not held
and use irqfd there. This makes virtio_error() available to IOThreads.
Stefan Hajnoczi (5):
vhost: use virtio_config_get_guest_notifier()
virtio: unify virtio_notify_irqfd() and virtio_notify()
virtio: support irqfd in virtio_notify_config()
tests/libqos: extract qvirtqueue_set_avail_idx()
tests/virtio-scsi: add a virtio_error() IOThread test
include/hw/virtio/virtio.h | 1 -
tests/qtest/libqos/virtio.h | 2 ++
hw/block/virtio-blk.c | 6 +-----
hw/scsi/virtio-scsi.c | 6 +-----
hw/virtio/vhost.c | 11 +++++++----
hw/virtio/virtio.c | 35 ++++++++++++++++++----------------
tests/qtest/libqos/virtio.c | 16 ++++++++++++----
tests/qtest/virtio-scsi-test.c | 32 +++++++++++++++++++++++++++++++
hw/virtio/trace-events | 1 -
9 files changed, 74 insertions(+), 36 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/5] vhost: use virtio_config_get_guest_notifier()
2025-09-22 22:01 [PATCH 0/5] virtio: allow virtio_error() in IOThreads Stefan Hajnoczi
@ 2025-09-22 22:01 ` Stefan Hajnoczi
2025-09-23 8:33 ` Philippe Mathieu-Daudé
2025-09-22 22:01 ` [PATCH 2/5] virtio: unify virtio_notify_irqfd() and virtio_notify() Stefan Hajnoczi
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-09-22 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefan Hajnoczi, Stefano Garzarella
There is a getter function so avoid accessing the ->config_notifier
field directly.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/virtio/vhost.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6557c58d12..37b39aa0c2 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1817,7 +1817,7 @@ void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask)
int r;
EventNotifier *notifier =
&hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier;
- EventNotifier *config_notifier = &vdev->config_notifier;
+ EventNotifier *config_notifier = virtio_config_get_guest_notifier(vdev);
assert(hdev->vhost_ops);
if ((hdev->started == false) ||
@@ -1848,13 +1848,15 @@ static void vhost_stop_config_intr(struct vhost_dev *dev)
static void vhost_start_config_intr(struct vhost_dev *dev)
{
int r;
+ EventNotifier *config_notifier =
+ virtio_config_get_guest_notifier(dev->vdev);
assert(dev->vhost_ops);
- int fd = event_notifier_get_fd(&dev->vdev->config_notifier);
+ int fd = event_notifier_get_fd(config_notifier);
if (dev->vhost_ops->vhost_set_config_call) {
r = dev->vhost_ops->vhost_set_config_call(dev, fd);
if (!r) {
- event_notifier_set(&dev->vdev->config_notifier);
+ event_notifier_set(config_notifier);
}
}
}
@@ -2139,12 +2141,13 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
{
int i;
int rc = 0;
+ EventNotifier *config_notifier = virtio_config_get_guest_notifier(vdev);
/* should only be called after backend is connected */
assert(hdev->vhost_ops);
event_notifier_test_and_clear(
&hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
- event_notifier_test_and_clear(&vdev->config_notifier);
+ event_notifier_test_and_clear(config_notifier);
event_notifier_cleanup(
&hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/5] virtio: unify virtio_notify_irqfd() and virtio_notify()
2025-09-22 22:01 [PATCH 0/5] virtio: allow virtio_error() in IOThreads Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 1/5] vhost: use virtio_config_get_guest_notifier() Stefan Hajnoczi
@ 2025-09-22 22:01 ` Stefan Hajnoczi
2025-09-23 8:41 ` Philippe Mathieu-Daudé
2025-09-22 22:01 ` [PATCH 3/5] virtio: support irqfd in virtio_notify_config() Stefan Hajnoczi
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-09-22 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefan Hajnoczi, Stefano Garzarella
The difference between these two functions:
- virtio_notify() uses the interrupt code path (MSI or classic IRQs)
- virtio_notify_irqfd() uses guest notifiers (irqfds)
virtio_notify() can only be called with the BQL held because the
interrupt code path requires the BQL. Device models use
virtio_notify_irqfd() from IOThreads since the BQL is not held.
The two functions can be unified by pushing down the if
(qemu_in_iothread()) check from virtio-blk and virtio-scsi into core
virtio code. This is in preparation for the next commit that will add
irqfd support to virtio_notify_config() and where it's unattractive to
introduce another irqfd-only API for device model callers.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
include/hw/virtio/virtio.h | 1 -
hw/block/virtio-blk.c | 6 +-----
hw/scsi/virtio-scsi.c | 6 +-----
hw/virtio/virtio.c | 28 +++++++++++++---------------
hw/virtio/trace-events | 1 -
5 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index c594764f23..8435f5e8fc 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -290,7 +290,6 @@ int virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
unsigned int *out_bytes, unsigned max_in_bytes,
unsigned max_out_bytes);
-void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq);
void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
int virtio_save(VirtIODevice *vdev, QEMUFile *f);
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 9bab2716c1..64efce4846 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -62,11 +62,7 @@ void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
iov_discard_undo(&req->inhdr_undo);
iov_discard_undo(&req->outhdr_undo);
virtqueue_push(req->vq, &req->elem, req->in_len);
- if (qemu_in_iothread()) {
- virtio_notify_irqfd(vdev, req->vq);
- } else {
- virtio_notify(vdev, req->vq);
- }
+ virtio_notify(vdev, req->vq);
}
static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 34ae14f7bf..d817fc42b4 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -116,11 +116,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req, QemuMutex *vq_lock)
}
virtqueue_push(vq, &req->elem, req->qsgl.size + req->resp_iov.size);
- if (s->dataplane_started && !s->dataplane_fenced) {
- virtio_notify_irqfd(vdev, vq);
- } else {
- virtio_notify(vdev, vq);
- }
+ virtio_notify(vdev, vq);
if (vq_lock) {
qemu_mutex_unlock(vq_lock);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 9a81ad912e..13830debfd 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -31,6 +31,7 @@
#include "hw/qdev-properties.h"
#include "hw/virtio/virtio-access.h"
#include "system/dma.h"
+#include "system/iothread.h"
#include "system/runstate.h"
#include "virtio-qmp.h"
@@ -2654,16 +2655,8 @@ static void virtio_notify_irqfd_deferred_fn(void *opaque)
event_notifier_set(notifier);
}
-void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq)
+static void virtio_irq(VirtQueue *vq)
{
- WITH_RCU_READ_LOCK_GUARD() {
- if (!virtio_should_notify(vdev, vq)) {
- return;
- }
- }
-
- trace_virtio_notify_irqfd(vdev, vq);
-
/*
* virtio spec 1.0 says ISR bit 0 should be ignored with MSI, but
* windows drivers included in virtio-win 1.8.0 (circa 2015) are
@@ -2680,13 +2673,18 @@ void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq)
* to an atomic operation.
*/
virtio_set_isr(vq->vdev, 0x1);
- defer_call(virtio_notify_irqfd_deferred_fn, &vq->guest_notifier);
-}
-static void virtio_irq(VirtQueue *vq)
-{
- virtio_set_isr(vq->vdev, 0x1);
- virtio_notify_vector(vq->vdev, vq->vector);
+ /*
+ * The interrupt code path requires the Big QEMU Lock (BQL), so use the
+ * notifier instead when in an IOThread. This assumes that device models
+ * have already called ->set_guest_notifiers() sometime before calling this
+ * function.
+ */
+ if (qemu_in_iothread()) {
+ defer_call(virtio_notify_irqfd_deferred_fn, &vq->guest_notifier);
+ } else {
+ virtio_notify_vector(vq->vdev, vq->vector);
+ }
}
void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 76f0d458b2..658cc365e7 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -75,7 +75,6 @@ virtqueue_flush(void *vq, unsigned int count) "vq %p count %u"
virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_num) "vq %p elem %p in_num %u out_num %u"
virtio_queue_notify(void *vdev, int n, void *vq) "vdev %p n %d vq %p"
virtio_notify_irqfd_deferred_fn(void *vdev, void *vq) "vdev %p vq %p"
-virtio_notify_irqfd(void *vdev, void *vq) "vdev %p vq %p"
virtio_notify(void *vdev, void *vq) "vdev %p vq %p"
virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u"
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/5] virtio: support irqfd in virtio_notify_config()
2025-09-22 22:01 [PATCH 0/5] virtio: allow virtio_error() in IOThreads Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 1/5] vhost: use virtio_config_get_guest_notifier() Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 2/5] virtio: unify virtio_notify_irqfd() and virtio_notify() Stefan Hajnoczi
@ 2025-09-22 22:01 ` Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx() Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 5/5] tests/virtio-scsi: add a virtio_error() IOThread test Stefan Hajnoczi
4 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-09-22 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefan Hajnoczi, Stefano Garzarella
virtio_error() calls virtio_notify_config() to inject a VIRTIO
Configuration Change Notification. This doesn't work from IOThreads
because the BQL is not held and the interrupt code path requires the
BQL.
Follow the same approach as virtio_notify() and use ->config_notifier
(an irqfd) when called from the IOThread.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/virtio/virtio.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 13830debfd..ced0fea4fc 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2706,7 +2706,12 @@ void virtio_notify_config(VirtIODevice *vdev)
virtio_set_isr(vdev, 0x3);
vdev->generation++;
- virtio_notify_vector(vdev, vdev->config_vector);
+
+ if (qemu_in_iothread()) {
+ defer_call(virtio_notify_irqfd_deferred_fn, &vdev->config_notifier);
+ } else {
+ virtio_notify_vector(vdev, vdev->config_vector);
+ }
}
static bool virtio_device_endian_needed(void *opaque)
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx()
2025-09-22 22:01 [PATCH 0/5] virtio: allow virtio_error() in IOThreads Stefan Hajnoczi
` (2 preceding siblings ...)
2025-09-22 22:01 ` [PATCH 3/5] virtio: support irqfd in virtio_notify_config() Stefan Hajnoczi
@ 2025-09-22 22:01 ` Stefan Hajnoczi
2025-09-23 8:45 ` Philippe Mathieu-Daudé
2025-09-23 13:07 ` Fabiano Rosas
2025-09-22 22:01 ` [PATCH 5/5] tests/virtio-scsi: add a virtio_error() IOThread test Stefan Hajnoczi
4 siblings, 2 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-09-22 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefan Hajnoczi, Stefano Garzarella
Setting the vring's avail.idx can be useful for low-level VIRTIO tests,
especially for testing error scenarios with invalid vrings. Extract it
into a new function so that the next commit can add a test that uses
this new test API.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/qtest/libqos/virtio.h | 2 ++
tests/qtest/libqos/virtio.c | 16 ++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/tests/qtest/libqos/virtio.h b/tests/qtest/libqos/virtio.h
index 7adc7cbd10..e238f1726f 100644
--- a/tests/qtest/libqos/virtio.h
+++ b/tests/qtest/libqos/virtio.h
@@ -143,6 +143,8 @@ uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq, uint64_t data,
uint32_t len, bool write, bool next);
uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq,
QVRingIndirectDesc *indirect);
+void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d,
+ QVirtQueue *vq, uint16_t idx);
void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
uint32_t free_head);
bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_idx,
diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c
index 5a709d0bc5..010ff40834 100644
--- a/tests/qtest/libqos/virtio.c
+++ b/tests/qtest/libqos/virtio.c
@@ -265,8 +265,9 @@ void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq,
/* vq->avail->flags */
qvirtio_writew(vq->vdev, qts, vq->avail, 0);
- /* vq->avail->idx */
- qvirtio_writew(vq->vdev, qts, vq->avail + 2, 0);
+
+ qvirtqueue_set_avail_idx(qts, vq->vdev, vq, 0);
+
/* vq->avail->used_event */
qvirtio_writew(vq->vdev, qts, vq->avail + 4 + (2 * vq->size), 0);
@@ -388,6 +389,13 @@ uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq,
return vq->free_head++; /* Return and increase, in this order */
}
+void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d,
+ QVirtQueue *vq, uint16_t idx)
+{
+ /* vq->avail->idx */
+ qvirtio_writew(d, qts, vq->avail + 2, idx);
+}
+
void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
uint32_t free_head)
{
@@ -400,8 +408,8 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
/* vq->avail->ring[idx % vq->size] */
qvirtio_writew(d, qts, vq->avail + 4 + (2 * (idx % vq->size)), free_head);
- /* vq->avail->idx */
- qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
+
+ qvirtqueue_set_avail_idx(qts, d, vq, idx + 1);
/* Must read after idx is updated */
flags = qvirtio_readw(d, qts, vq->used);
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/5] tests/virtio-scsi: add a virtio_error() IOThread test
2025-09-22 22:01 [PATCH 0/5] virtio: allow virtio_error() in IOThreads Stefan Hajnoczi
` (3 preceding siblings ...)
2025-09-22 22:01 ` [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx() Stefan Hajnoczi
@ 2025-09-22 22:01 ` Stefan Hajnoczi
4 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-09-22 22:01 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefan Hajnoczi, Stefano Garzarella
Now that virtio_error() calls should work in an IOThread, add a
virtio-scsi IOThread test cases that triggers virtio_error().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/qtest/virtio-scsi-test.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c
index db10d572d0..e2350c52f6 100644
--- a/tests/qtest/virtio-scsi-test.c
+++ b/tests/qtest/virtio-scsi-test.c
@@ -311,6 +311,31 @@ fail:
unlink(tmp_path);
}
+static void test_iothread_virtio_error(void *obj, void *data,
+ QGuestAllocator *t_alloc)
+{
+ QVirtioSCSIPCI *scsi_pci = obj;
+ QVirtioSCSI *scsi = &scsi_pci->scsi;
+ QVirtioSCSIQueues *vs;
+ QVirtQueue *vq;
+
+ alloc = t_alloc;
+ vs = qvirtio_scsi_init(scsi->vdev);
+ vq = vs->vq[2];
+
+ /* Move avail.idx out of bounds to trigger virtio_error() */
+ qvirtqueue_set_avail_idx(global_qtest, scsi->vdev, vq, vq->size * 2);
+ scsi->vdev->bus->virtqueue_kick(scsi->vdev, vq);
+
+ /*
+ * Reset the device out of the error state. If QEMU hangs or crashes then
+ * this will fail.
+ */
+ qvirtio_reset(scsi->vdev);
+
+ qvirtio_scsi_pci_free(vs);
+}
+
static void *virtio_scsi_hotplug_setup(GString *cmd_line, void *arg)
{
g_string_append(cmd_line,
@@ -383,6 +408,13 @@ static void register_virtio_scsi_test(void)
};
qos_add_test("iothread-attach-node", "virtio-scsi-pci",
test_iothread_attach_node, &opts);
+
+ opts.before = virtio_scsi_setup_iothread;
+ opts.edge = (QOSGraphEdgeOptions) {
+ .extra_device_opts = "iothread=thread0",
+ };
+ qos_add_test("iothread-virtio-error", "virtio-scsi-pci",
+ test_iothread_virtio_error, &opts);
}
libqos_init(register_virtio_scsi_test);
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/5] vhost: use virtio_config_get_guest_notifier()
2025-09-22 22:01 ` [PATCH 1/5] vhost: use virtio_config_get_guest_notifier() Stefan Hajnoczi
@ 2025-09-23 8:33 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-23 8:33 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefano Garzarella
On 23/9/25 00:01, Stefan Hajnoczi wrote:
> There is a getter function so avoid accessing the ->config_notifier
> field directly.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> hw/virtio/vhost.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/5] virtio: unify virtio_notify_irqfd() and virtio_notify()
2025-09-22 22:01 ` [PATCH 2/5] virtio: unify virtio_notify_irqfd() and virtio_notify() Stefan Hajnoczi
@ 2025-09-23 8:41 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-23 8:41 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefano Garzarella
On 23/9/25 00:01, Stefan Hajnoczi wrote:
> The difference between these two functions:
> - virtio_notify() uses the interrupt code path (MSI or classic IRQs)
> - virtio_notify_irqfd() uses guest notifiers (irqfds)
>
> virtio_notify() can only be called with the BQL held because the
> interrupt code path requires the BQL. Device models use
> virtio_notify_irqfd() from IOThreads since the BQL is not held.
>
> The two functions can be unified by pushing down the if
> (qemu_in_iothread()) check from virtio-blk and virtio-scsi into core
> virtio code. This is in preparation for the next commit that will add
> irqfd support to virtio_notify_config() and where it's unattractive to
> introduce another irqfd-only API for device model callers.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> include/hw/virtio/virtio.h | 1 -
> hw/block/virtio-blk.c | 6 +-----
> hw/scsi/virtio-scsi.c | 6 +-----
> hw/virtio/virtio.c | 28 +++++++++++++---------------
> hw/virtio/trace-events | 1 -
> 5 files changed, 15 insertions(+), 27 deletions(-)
Nice cleanup.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx()
2025-09-22 22:01 ` [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx() Stefan Hajnoczi
@ 2025-09-23 8:45 ` Philippe Mathieu-Daudé
2025-09-23 13:07 ` Fabiano Rosas
1 sibling, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-23 8:45 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Fabiano Rosas, Paolo Bonzini,
Stefano Garzarella
On 23/9/25 00:01, Stefan Hajnoczi wrote:
> Setting the vring's avail.idx can be useful for low-level VIRTIO tests,
> especially for testing error scenarios with invalid vrings. Extract it
> into a new function so that the next commit can add a test that uses
> this new test API.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> tests/qtest/libqos/virtio.h | 2 ++
> tests/qtest/libqos/virtio.c | 16 ++++++++++++----
> 2 files changed, 14 insertions(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx()
2025-09-22 22:01 ` [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx() Stefan Hajnoczi
2025-09-23 8:45 ` Philippe Mathieu-Daudé
@ 2025-09-23 13:07 ` Fabiano Rosas
1 sibling, 0 replies; 10+ messages in thread
From: Fabiano Rosas @ 2025-09-23 13:07 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel
Cc: Kevin Wolf, Michael S. Tsirkin, qemu-block, Hanna Reitz,
Laurent Vivier, Fam Zheng, Paolo Bonzini, Stefan Hajnoczi,
Stefano Garzarella
Stefan Hajnoczi <stefanha@redhat.com> writes:
> Setting the vring's avail.idx can be useful for low-level VIRTIO tests,
> especially for testing error scenarios with invalid vrings. Extract it
> into a new function so that the next commit can add a test that uses
> this new test API.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Fabiano Rosas <farosas@suse.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-09-23 13:10 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 22:01 [PATCH 0/5] virtio: allow virtio_error() in IOThreads Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 1/5] vhost: use virtio_config_get_guest_notifier() Stefan Hajnoczi
2025-09-23 8:33 ` Philippe Mathieu-Daudé
2025-09-22 22:01 ` [PATCH 2/5] virtio: unify virtio_notify_irqfd() and virtio_notify() Stefan Hajnoczi
2025-09-23 8:41 ` Philippe Mathieu-Daudé
2025-09-22 22:01 ` [PATCH 3/5] virtio: support irqfd in virtio_notify_config() Stefan Hajnoczi
2025-09-22 22:01 ` [PATCH 4/5] tests/libqos: extract qvirtqueue_set_avail_idx() Stefan Hajnoczi
2025-09-23 8:45 ` Philippe Mathieu-Daudé
2025-09-23 13:07 ` Fabiano Rosas
2025-09-22 22:01 ` [PATCH 5/5] tests/virtio-scsi: add a virtio_error() IOThread test Stefan Hajnoczi
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).