{"id":2225309,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2225309/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260420200339.708640-9-vsementsov@yandex-team.ru/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260420200339.708640-9-vsementsov@yandex-team.ru>","list_archive_url":null,"date":"2026-04-20T20:03:23","name":"[v6,08/22] virtio: drop *_set_guest_notifier_fd_handler() helpers","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6d3b303cdb5f89509ec0c118082a3036ce065d07","submitter":{"id":84116,"url":"http://patchwork.ozlabs.org/api/1.2/people/84116/?format=json","name":"Vladimir Sementsov-Ogievskiy","email":"vsementsov@yandex-team.ru"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260420200339.708640-9-vsementsov@yandex-team.ru/mbox/","series":[{"id":500672,"url":"http://patchwork.ozlabs.org/api/1.2/series/500672/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500672","date":"2026-04-20T20:03:18","name":"vhost refactoring and fixes","version":6,"mbox":"http://patchwork.ozlabs.org/series/500672/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225309/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225309/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=yandex-team.ru header.i=@yandex-team.ru\n header.a=rsa-sha256 header.s=default header.b=gHkjerAC;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)","mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net;\n dkim=pass header.i=@yandex-team.ru"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fzxMW3y9Nz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 06:06:31 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wEur2-0001ll-H9; Mon, 20 Apr 2026 16:04:24 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <vsementsov@yandex-team.ru>)\n id 1wEuql-0001LT-AX\n for qemu-devel@nongnu.org; Mon, 20 Apr 2026 16:04:08 -0400","from forwardcorp1d.mail.yandex.net ([178.154.239.200])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <vsementsov@yandex-team.ru>)\n id 1wEuqi-0001o6-Iw\n for qemu-devel@nongnu.org; Mon, 20 Apr 2026 16:04:07 -0400","from mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net\n (mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net\n [IPv6:2a02:6b8:c42:94a9:0:640:a3fa:0])\n by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 808CC8071E;\n Mon, 20 Apr 2026 23:04:01 +0300 (MSK)","from vsementsov-lin (unknown [2a02:6bf:8080:54b::1:34])\n by mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA\n id f3YMX10K1Sw0-AuQU5g2R; Mon, 20 Apr 2026 23:04:00 +0300"],"Precedence":"bulk","X-Yandex-Fwd":"1","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru;\n s=default; t=1776715440;\n bh=Fq8VchYgWYio+J+istM1mBldZkLvILQJGVqd5bh/k8w=;\n h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From;\n b=gHkjerACyrm9ITPYHq4/+awNzKg7Y+jVE/8AV1z+Fuw7PYulxKUc3sWY6zKA4zRd1\n fGutSlx8RI8T0LpIepS78AKBq26j6neOCm6pO2S7/51H0coayT7y3s0/5mRqxihjJW\n A3VStVysaGP+Qqnips3hoDBjMZUIAPOVDjZzHBgE=","From":"Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>","To":"mst@redhat.com","Cc":"sgarzare@redhat.com, raphael@enfabrica.net, qemu-devel@nongnu.org,\n vsementsov@yandex-team.ru, yc-core@yandex-team.ru,\n d-tatianin@yandex-team.ru","Subject":"[PATCH v6 08/22] virtio: drop *_set_guest_notifier_fd_handler()\n helpers","Date":"Mon, 20 Apr 2026 23:03:23 +0300","Message-ID":"<20260420200339.708640-9-vsementsov@yandex-team.ru>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260420200339.708640-1-vsementsov@yandex-team.ru>","References":"<20260420200339.708640-1-vsementsov@yandex-team.ru>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=178.154.239.200;\n envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Now they don't make code more readable. Let's better put the whole\nlogic into virtio_queue_set_guest_notifier().\n\nSigned-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>\nReviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru>\n---\n hw/virtio/virtio.c | 75 +++++++++++-----------------------------------\n 1 file changed, 17 insertions(+), 58 deletions(-)","diff":"diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c\nindex 4941b0c2861..30ac7d7b37a 100644\n--- a/hw/virtio/virtio.c\n+++ b/hw/virtio/virtio.c\n@@ -3836,73 +3836,32 @@ static void virtio_config_guest_notifier_read(EventNotifier *n)\n     }\n }\n \n-static void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq,\n-                                                       bool assign,\n-                                                       bool with_irqfd)\n-{\n-    if (assign && !with_irqfd) {\n-        event_notifier_set_handler(&vq->guest_notifier,\n-                                   virtio_queue_guest_notifier_read);\n-    } else {\n-        event_notifier_set_handler(&vq->guest_notifier, NULL);\n-    }\n-    if (!assign) {\n-        /* Test and clear notifier before closing it,\n-         * in case poll callback didn't have time to run. */\n-        virtio_queue_guest_notifier_read(&vq->guest_notifier);\n-    }\n-}\n-\n-static void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,\n-                                                 bool assign, bool with_irqfd)\n-{\n-    EventNotifier *n;\n-    n = &vdev->config_notifier;\n-    if (assign && !with_irqfd) {\n-        event_notifier_set_handler(n, virtio_config_guest_notifier_read);\n-    } else {\n-        event_notifier_set_handler(n, NULL);\n-    }\n-    if (!assign) {\n-        /* Test and clear notifier before closing it,*/\n-        /* in case poll callback didn't have time to run. */\n-        virtio_config_guest_notifier_read(n);\n-    }\n-}\n-\n-static void virtio_set_guest_notifier_fd_handler(VirtIODevice *vdev,\n-                                                 VirtQueue *vq,\n-                                                 int n, bool assign,\n-                                                 bool with_irqfd)\n-{\n-    if (n == VIRTIO_CONFIG_IRQ_IDX) {\n-        virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);\n-    } else {\n-        virtio_queue_set_guest_notifier_fd_handler(vq, assign, with_irqfd);\n-    }\n-}\n-\n int virtio_set_guest_notifier(VirtIODevice *vdev, int n, bool assign,\n                               bool with_irqfd)\n {\n-    VirtQueue *vq = NULL;\n-    EventNotifier *notifier = NULL;\n-\n-    if (n == VIRTIO_CONFIG_IRQ_IDX) {\n-        notifier = virtio_config_get_guest_notifier(vdev);\n-    } else {\n-        vq = virtio_get_queue(vdev, n);\n-        notifier = virtio_queue_get_guest_notifier(vq);\n-    }\n+    bool is_config = n == VIRTIO_CONFIG_IRQ_IDX;\n+    VirtQueue *vq = is_config ? NULL : virtio_get_queue(vdev, n);\n+    EventNotifier *notifier = is_config ?\n+        virtio_config_get_guest_notifier(vdev) :\n+        virtio_queue_get_guest_notifier(vq);\n+    EventNotifierHandler *read_fn = is_config ?\n+        virtio_config_guest_notifier_read :\n+        virtio_queue_guest_notifier_read;\n \n     if (assign) {\n         int r = event_notifier_init(notifier, 0);\n         if (r < 0) {\n             return r;\n         }\n-        virtio_set_guest_notifier_fd_handler(vdev, vq, n, true, with_irqfd);\n-    } else {\n-        virtio_set_guest_notifier_fd_handler(vdev, vq, n, false, with_irqfd);\n+    }\n+\n+    event_notifier_set_handler(notifier,\n+                               (assign && !with_irqfd) ? read_fn : NULL);\n+\n+    if (!assign) {\n+        /* Test and clear notifier before closing it,*/\n+        /* in case poll callback didn't have time to run. */\n+        read_fn(notifier);\n         event_notifier_cleanup(notifier);\n     }\n \n","prefixes":["v6","08/22"]}