Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2225304/?format=api
{ "id": 2225304, "url": "http://patchwork.ozlabs.org/api/patches/2225304/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260420200339.708640-8-vsementsov@yandex-team.ru/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "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-8-vsementsov@yandex-team.ru>", "list_archive_url": null, "date": "2026-04-20T20:03:22", "name": "[v6,07/22] virtio: move common part of _set_guest_notifier to generic code", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "835a1bb4cd7e16b75b04919fa8033b521caa65dd", "submitter": { "id": 84116, "url": "http://patchwork.ozlabs.org/api/people/84116/?format=api", "name": "Vladimir Sementsov-Ogievskiy", "email": "vsementsov@yandex-team.ru" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260420200339.708640-8-vsementsov@yandex-team.ru/mbox/", "series": [ { "id": 500672, "url": "http://patchwork.ozlabs.org/api/series/500672/?format=api", "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/2225304/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225304/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=ZFxxCl8o;\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 4fzxLs10X3z1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 06:05:57 +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 1wEuqy-0001bj-Bt; Mon, 20 Apr 2026 16:04:20 -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 1wEuqo-0001Mj-0F; Mon, 20 Apr 2026 16:04:11 -0400", "from forwardcorp1d.mail.yandex.net\n ([2a02:6b8:c41:1300:1:45:d181:df01])\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-0001mn-Uc; Mon, 20 Apr 2026 16:04:08 -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 3EE258075D;\n Mon, 20 Apr 2026 23:04:00 +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-9ePIJgih; Mon, 20 Apr 2026 23:03:59 +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=1776715439;\n bh=BuHCkvPCUH8ek8ltWnzcAd7N450RrqnWYvfnQTDG1rQ=;\n h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From;\n b=ZFxxCl8oDm+/nXDeUhZTdW8teIsxEJcKRtNwnFBH21SggVPZ8HHb4pl7MvjK3QowU\n NmBiYAel/WBJh9WneX0hc3KpASfMVMIOcYm0+w+U0HcE/Q4dUawUOLGV9Eac0htjuW\n YL/K1M67crZFF2lmbRIUuzcbaRlLLWJM5KyNzWOE=", "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, Eric Farman <farman@linux.ibm.com>,\n Cornelia Huck <cohuck@redhat.com>, Halil Pasic <pasic@linux.ibm.com>,\n Richard Henderson <richard.henderson@linaro.org>,\n Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>,\n Matthew Rosato <mjrosato@linux.ibm.com>,\n Christian Borntraeger <borntraeger@linux.ibm.com>,\n qemu-s390x@nongnu.org (open list:virtio-ccw)", "Subject": "[PATCH v6 07/22] virtio: move common part of _set_guest_notifier to\n generic code", "Date": "Mon, 20 Apr 2026 23:03:22 +0300", "Message-ID": "<20260420200339.708640-8-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=2a02:6b8:c41:1300:1:45:d181:df01;\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": "virtio-pci, virtio-mmio and virtio-ccw handle config notifier equally\nbut with different code (mmio adds a separate function, when pci use\ncommon function). Let's chose the more compact way (pci) and reuse it\nfor mmio.\n\nSigned-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>\nAcked-by: Eric Farman <farman@linux.ibm.com>\n---\n hw/s390x/virtio-ccw.c | 35 ++++++++++++-------------\n hw/virtio/virtio-mmio.c | 41 +++++------------------------\n hw/virtio/virtio-pci.c | 34 +++---------------------\n hw/virtio/virtio.c | 47 +++++++++++++++++++++++++++++++---\n include/hw/virtio/virtio-pci.h | 3 ---\n include/hw/virtio/virtio.h | 15 ++++++++---\n 6 files changed, 82 insertions(+), 93 deletions(-)", "diff": "diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c\nindex ba55bf4fe97..cdad862ec23 100644\n--- a/hw/s390x/virtio-ccw.c\n+++ b/hw/s390x/virtio-ccw.c\n@@ -1025,20 +1025,27 @@ static int virtio_ccw_set_guest_notifier(VirtioCcwDevice *dev, int n,\n VirtQueue *vq = virtio_get_queue(vdev, n);\n EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);\n VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);\n+ int r;\n \n- if (assign) {\n- int r = event_notifier_init(notifier, 0);\n-\n- if (r < 0) {\n- return r;\n+ if (!assign) {\n+ if (k->guest_notifier_mask && vdev->use_guest_notifier_mask) {\n+ k->guest_notifier_mask(vdev, n, true);\n }\n- virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);\n+ if (with_irqfd) {\n+ virtio_ccw_remove_irqfd(dev, n);\n+ }\n+ }\n+\n+ r = virtio_set_guest_notifier(vdev, n, assign, with_irqfd);\n+ if (r < 0) {\n+ return r;\n+ }\n+\n+ if (assign) {\n if (with_irqfd) {\n r = virtio_ccw_add_irqfd(dev, n);\n if (r) {\n- virtio_queue_set_guest_notifier_fd_handler(vq, false,\n- with_irqfd);\n- event_notifier_cleanup(notifier);\n+ virtio_set_guest_notifier(vdev, n, false, with_irqfd);\n return r;\n }\n }\n@@ -1054,16 +1061,8 @@ static int virtio_ccw_set_guest_notifier(VirtioCcwDevice *dev, int n,\n k->guest_notifier_pending(vdev, n)) {\n event_notifier_set(notifier);\n }\n- } else {\n- if (k->guest_notifier_mask && vdev->use_guest_notifier_mask) {\n- k->guest_notifier_mask(vdev, n, true);\n- }\n- if (with_irqfd) {\n- virtio_ccw_remove_irqfd(dev, n);\n- }\n- virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);\n- event_notifier_cleanup(notifier);\n }\n+\n return 0;\n }\n \ndiff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c\nindex 742ca3d3e4d..58c6d46aab4 100644\n--- a/hw/virtio/virtio-mmio.c\n+++ b/hw/virtio/virtio-mmio.c\n@@ -670,18 +670,11 @@ static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign,\n VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);\n VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);\n- VirtQueue *vq = virtio_get_queue(vdev, n);\n- EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);\n+ int r;\n \n- if (assign) {\n- int r = event_notifier_init(notifier, 0);\n- if (r < 0) {\n- return r;\n- }\n- virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd);\n- } else {\n- virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd);\n- event_notifier_cleanup(notifier);\n+ r = virtio_set_guest_notifier(vdev, n, assign, with_irqfd);\n+ if (r < 0) {\n+ return r;\n }\n \n if (vdc->guest_notifier_mask && vdev->use_guest_notifier_mask) {\n@@ -690,30 +683,7 @@ static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign,\n \n return 0;\n }\n-static int virtio_mmio_set_config_guest_notifier(DeviceState *d, bool assign,\n- bool with_irqfd)\n-{\n- VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);\n- VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);\n- VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);\n- EventNotifier *notifier = virtio_config_get_guest_notifier(vdev);\n- int r = 0;\n \n- if (assign) {\n- r = event_notifier_init(notifier, 0);\n- if (r < 0) {\n- return r;\n- }\n- virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);\n- } else {\n- virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd);\n- event_notifier_cleanup(notifier);\n- }\n- if (vdc->guest_notifier_mask && vdev->use_guest_notifier_mask) {\n- vdc->guest_notifier_mask(vdev, VIRTIO_CONFIG_IRQ_IDX, !assign);\n- }\n- return r;\n-}\n static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,\n bool assign)\n {\n@@ -735,7 +705,8 @@ static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs,\n goto assign_error;\n }\n }\n- r = virtio_mmio_set_config_guest_notifier(d, assign, with_irqfd);\n+ r = virtio_mmio_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, assign,\n+ with_irqfd);\n if (r < 0) {\n goto assign_error;\n }\ndiff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c\nindex bcab2d18b80..fd9719547f9 100644\n--- a/hw/virtio/virtio-pci.c\n+++ b/hw/virtio/virtio-pci.c\n@@ -1208,43 +1208,17 @@ static void virtio_pci_vector_poll(PCIDevice *dev,\n }\n }\n \n-void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, 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 static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,\n bool with_irqfd)\n {\n VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);\n VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);\n VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);\n- VirtQueue *vq = NULL;\n- EventNotifier *notifier = NULL;\n+ int r;\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-\n- if (assign) {\n- int r = event_notifier_init(notifier, 0);\n- if (r < 0) {\n- return r;\n- }\n- virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, true, with_irqfd);\n- } else {\n- virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, false,\n- with_irqfd);\n- event_notifier_cleanup(notifier);\n+ r = virtio_set_guest_notifier(vdev, n, assign, with_irqfd);\n+ if (r < 0) {\n+ return r;\n }\n \n if (!msix_enabled(&proxy->pci_dev) &&\ndiff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c\nindex 8fcf6cfd0b4..4941b0c2861 100644\n--- a/hw/virtio/virtio.c\n+++ b/hw/virtio/virtio.c\n@@ -3835,8 +3835,10 @@ static void virtio_config_guest_notifier_read(EventNotifier *n)\n virtio_notify_config(vdev);\n }\n }\n-void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,\n- bool with_irqfd)\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@@ -3851,7 +3853,7 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,\n }\n }\n \n-void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,\n+static void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,\n bool assign, bool with_irqfd)\n {\n EventNotifier *n;\n@@ -3868,6 +3870,45 @@ void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,\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+\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+ event_notifier_cleanup(notifier);\n+ }\n+\n+ return 0;\n+}\n+\n EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)\n {\n return &vq->guest_notifier;\ndiff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h\nindex 5cb20b73f62..ee50fb0d551 100644\n--- a/include/hw/virtio/virtio-pci.h\n+++ b/include/hw/virtio/virtio-pci.h\n@@ -250,9 +250,6 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t);\n * @fixed_queues.\n */\n unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues);\n-void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq,\n- int n, bool assign,\n- bool with_irqfd);\n \n int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset,\n uint64_t length, uint8_t id);\ndiff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h\nindex 6344bd7b689..d9fde425581 100644\n--- a/include/hw/virtio/virtio.h\n+++ b/include/hw/virtio/virtio.h\n@@ -420,8 +420,6 @@ void virtio_queue_update_used_idx(VirtIODevice *vdev, int n);\n VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);\n uint16_t virtio_get_queue_index(VirtQueue *vq);\n EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);\n-void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,\n- bool with_irqfd);\n int virtio_device_start_ioeventfd(VirtIODevice *vdev);\n int virtio_device_grab_ioeventfd(VirtIODevice *vdev);\n void virtio_device_release_ioeventfd(VirtIODevice *vdev);\n@@ -435,8 +433,17 @@ void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);\n VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);\n VirtQueue *virtio_vector_next_queue(VirtQueue *vq);\n EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev);\n-void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,\n- bool assign, bool with_irqfd);\n+\n+/**\n+ * virtio_set_guest_notifier - set/unset queue or config guest notifier\n+ *\n+ * @vdev: the VirtIO device\n+ * @n: queue number, or VIRTIO_CONFIG_IRQ_IDX to set config notifer\n+ * @assign: true to set notifier, false to unset\n+ * @with_irqfd: irqfd enabled\n+ */\n+int virtio_set_guest_notifier(VirtIODevice *vdev, int n, bool assign,\n+ bool with_irqfd);\n \n static inline void virtio_add_feature(uint64_t *features, unsigned int fbit)\n {\n", "prefixes": [ "v6", "07/22" ] }