@samitouri / QOSamiQemu / commits / 658660c838

hw/virtio/virtio-bus: refactor virtio_bus_set_host_notifier()

The logic kept as is. Refactor to simplify further changes. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Raphael Norwitz <raphael.s.norwitz@gmail.com> Reviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Lei Yang <leiyang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420200339.708640-20-vsementsov@yandex-team.ru>

Vladimir Sementsov-Ogievskiy committed Apr 20, 2026 at 23:03 UTC 658660c838935836cb904d6c29f15767d952b256
1 file changed +8 -10
hw/virtio/virtio-bus.c
+8 -10
@@ -298,20 +298,18 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign)
298 __func__, strerror(-r), r);
299 return r;
300 }
301 - r = k->ioeventfd_assign(proxy, notifier, n, true);
302 - if (r < 0) {
303 - error_report("%s: unable to assign ioeventfd: %d", __func__, r);
304 - virtio_bus_cleanup_host_notifier(bus, n);
305 - }
306 - } else {
307 - k->ioeventfd_assign(proxy, notifier, n, false);
301 }
302
310 - if (r == 0) {
311 - virtio_queue_set_host_notifier_enabled(vq, assign);
303 + r = k->ioeventfd_assign(proxy, notifier, n, assign);
304 + if (r < 0 && assign) {
305 + error_report("%s: unable to assign ioeventfd: %d", __func__, r);
306 + virtio_bus_cleanup_host_notifier(bus, n);
307 + return r;
308 }
309
314 - return r;
310 + virtio_queue_set_host_notifier_enabled(vq, assign);
311 +
312 + return 0;
313 }
314
315 void virtio_bus_cleanup_host_notifier(VirtioBusState *bus, int n)