Skip to contentSkip to conversation

vhost: do not get config notifier when one doesn't exist

PATCH In review Eric Farman 1 participant 2 messages Nov 2 – Nov 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: do not get config notifier when one doesn't exist

Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an assert for an uninitialized file descriptor in event_notifier_get_fd(), but it presumes that such a thing always exists.

Since it's only vhost_ops->vhost_set_config_call that expects to use this file descriptor, move the retrieval of that fd inside the non-null check to avoid an assertion failure when it does not exist.

Fixes e3b12d0c55e4 ("util/event_notifier: more strict API")
---
 hw/virtio/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost.c +1 -1
index b25919c5c7d..998518c3b2e 100644
@@ -2119,8 +2119,8 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
         virtio_config_get_guest_notifier(dev->vdev);
 
     assert(dev->vhost_ops);
-    int fd = event_notifier_get_fd(config_notifier);
     if (dev->vhost_ops->vhost_set_config_call) {
+        int fd = event_notifier_get_fd(config_notifier);
         r = dev->vhost_ops->vhost_set_config_call(dev, fd);
         if (!r) {
             event_notifier_set(config_notifier);
Signature · 1 line
2.53.0
#1 lore raw
Quoted 10 lines · Eric Farman

Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an assert for an uninitialized file descriptor in event_notifier_get_fd(), but it presumes that such a thing always exists.

Since it's only vhost_ops->vhost_set_config_call that expects to use this file descriptor, move the retrieval of that fd inside the non-null check to avoid an assertion failure when it does not exist.

Fixes e3b12d0c55e4 ("util/event_notifier: more strict API")

Ah, this is not going to work. VDPA has previously worked on s390x, but as it's the only place that sets vhost_ops->vhost_set_config_call we'll still end up failing the assertion in event_notifier_get_fd for that device type.

Quoted 18 lines
---
  hw/virtio/vhost.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost.c +1 -1
index b25919c5c7d..998518c3b2e 100644
@@ -2119,8 +2119,8 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
          virtio_config_get_guest_notifier(dev->vdev);
 
      assert(dev->vhost_ops);
-    int fd = event_notifier_get_fd(config_notifier);
      if (dev->vhost_ops->vhost_set_config_call) {
+        int fd = event_notifier_get_fd(config_notifier);
          r = dev->vhost_ops->vhost_set_config_call(dev, fd);
          if (!r) {
              event_notifier_set(config_notifier);