qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/1] virtio: fail device if set_event_notifier fails
@ 2017-03-02 18:59 Halil Pasic
  2017-03-03 12:21 ` Cornelia Huck
  0 siblings, 1 reply; 10+ messages in thread
From: Halil Pasic @ 2017-03-02 18:59 UTC (permalink / raw)
  To: qemu-devel, Michael S. Tsirkin; +Cc: Cornelia Huck, Halil Pasic

The function virtio_notify_irqfd used to ignore the return code of
event_notifier_set. Let's fail the device should this occur.

Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>

---

This patch is most likely flawed because virtio_notify_irqfd
is probably supposed to be thread-safe and neither strerror
nor virtio_error are that. Anyway lets get the discussion started with this.

There was a suggestion by Michael to make event_notifier_set void
and assert inside. After some thinking, I settled at the opinion,
that neither doing nothing nor crashing the guest is a good idea
should this failure happen in production. So I came up with this.

Looking forward to your feedback.
---
 hw/virtio/virtio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 23483c7..e05f3e5 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1555,6 +1555,8 @@ static bool virtio_should_notify(VirtIODevice *vdev, VirtQueue *vq)
 void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq)
 {
     bool should_notify;
+    int rc;
+
     rcu_read_lock();
     should_notify = virtio_should_notify(vdev, vq);
     rcu_read_unlock();
@@ -1581,7 +1583,11 @@ void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq)
      * to an atomic operation.
      */
     virtio_set_isr(vq->vdev, 0x1);
-    event_notifier_set(&vq->guest_notifier);
+    rc = event_notifier_set(&vq->guest_notifier);
+    if (unlikely(rc)) {
+        virtio_error(vdev, "guest notifier broken for vdev at %p (%s)", vdev,
+                     strerror(-rc));
+    }
 }
 
 static void virtio_irq(VirtQueue *vq)
-- 
2.8.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-03-29 11:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-02 18:59 [Qemu-devel] [PATCH 1/1] virtio: fail device if set_event_notifier fails Halil Pasic
2017-03-03 12:21 ` Cornelia Huck
2017-03-03 12:43   ` Halil Pasic
2017-03-03 12:50     ` Cornelia Huck
2017-03-03 13:08       ` Halil Pasic
2017-03-06 14:56         ` Cornelia Huck
2017-03-06 15:21           ` Halil Pasic
2017-03-06 16:04             ` Cornelia Huck
2017-03-23 17:09               ` Michael S. Tsirkin
2017-03-29 11:12                 ` Halil Pasic

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).