From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Steve Sistare" <steven.sistare@oracle.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Zhenzhong Duan" <zhenzhong.duan@intel.com>
Subject: [PULL 15/16] vfio: vfio_find_ram_discard_listener
Date: Thu, 5 Jun 2025 10:42:44 +0200 [thread overview]
Message-ID: <20250605084245.1520562-16-clg@redhat.com> (raw)
In-Reply-To: <20250605084245.1520562-1-clg@redhat.com>
From: Steve Sistare <steven.sistare@oracle.com>
Define vfio_find_ram_discard_listener as a subroutine so additional calls to
it may be added in a subsequent patch.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/1748546679-154091-8-git-send-email-steven.sistare@oracle.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/hw/vfio/vfio-container-base.h | 3 +++
hw/vfio/listener.c | 35 +++++++++++++++++----------
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h
index 3feb773e5f41706a310b676c088ff95a85304325..9d37f86115a873eb164ae90c5ebaf2acd2c6a5d8 100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -253,4 +253,7 @@ struct VFIOIOMMUClass {
void (*release)(VFIOContainerBase *bcontainer);
};
+VFIORamDiscardListener *vfio_find_ram_discard_listener(
+ VFIOContainerBase *bcontainer, MemoryRegionSection *section);
+
#endif /* HW_VFIO_VFIO_CONTAINER_BASE_H */
diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c
index 74958661236e230751e52dbfc7857426358dcaac..203ed0314ec46225651a51d91df9c2e7c76168ed 100644
--- a/hw/vfio/listener.c
+++ b/hw/vfio/listener.c
@@ -456,6 +456,26 @@ static void vfio_device_error_append(VFIODevice *vbasedev, Error **errp)
}
}
+VFIORamDiscardListener *vfio_find_ram_discard_listener(
+ VFIOContainerBase *bcontainer, MemoryRegionSection *section)
+{
+ VFIORamDiscardListener *vrdl = NULL;
+
+ QLIST_FOREACH(vrdl, &bcontainer->vrdl_list, next) {
+ if (vrdl->mr == section->mr &&
+ vrdl->offset_within_address_space ==
+ section->offset_within_address_space) {
+ break;
+ }
+ }
+
+ if (!vrdl) {
+ hw_error("vfio: Trying to sync missing RAM discard listener");
+ /* does not return */
+ }
+ return vrdl;
+}
+
static void vfio_listener_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -1086,19 +1106,8 @@ vfio_sync_ram_discard_listener_dirty_bitmap(VFIOContainerBase *bcontainer,
MemoryRegionSection *section)
{
RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr);
- VFIORamDiscardListener *vrdl = NULL;
-
- QLIST_FOREACH(vrdl, &bcontainer->vrdl_list, next) {
- if (vrdl->mr == section->mr &&
- vrdl->offset_within_address_space ==
- section->offset_within_address_space) {
- break;
- }
- }
-
- if (!vrdl) {
- hw_error("vfio: Trying to sync missing RAM discard listener");
- }
+ VFIORamDiscardListener *vrdl =
+ vfio_find_ram_discard_listener(bcontainer, section);
/*
* We only want/can synchronize the bitmap for actually mapped parts -
--
2.49.0
next prev parent reply other threads:[~2025-06-05 8:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 8:42 [PULL 00/16] vfio queue Cédric Le Goater
2025-06-05 8:42 ` [PULL 01/16] vfio/igd: OpRegion not found fix error typo Cédric Le Goater
2025-06-05 8:42 ` [PULL 02/16] vfio: add more VFIOIOMMUClass docs Cédric Le Goater
2025-06-05 8:42 ` [PULL 03/16] vfio: move more cleanup into vfio_pci_put_device() Cédric Le Goater
2025-06-05 8:42 ` [PULL 04/16] vfio: move config space read into vfio_pci_config_setup() Cédric Le Goater
2025-06-05 8:42 ` [PULL 05/16] vfio: refactor out IRQ signalling setup Cédric Le Goater
2025-06-05 8:42 ` [PULL 06/16] vfio/iommufd: Add comment emphasizing no movement of hiod->realize() call Cédric Le Goater
2025-06-05 8:42 ` [PULL 07/16] vfio/igd: Fix incorrect error propagation in vfio_pci_igd_opregion_detect() Cédric Le Goater
2025-06-05 8:42 ` [PULL 08/16] vfio: return mr from vfio_get_xlat_addr Cédric Le Goater
2025-06-05 8:42 ` [PULL 09/16] vfio/container: pass MemoryRegion to DMA operations Cédric Le Goater
2025-06-05 8:42 ` [PULL 10/16] backends/iommufd: Add a helper to invalidate user-managed HWPT Cédric Le Goater
2025-06-05 8:42 ` [PULL 11/16] vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD Cédric Le Goater
2025-06-05 8:42 ` [PULL 12/16] vfio/iommufd: Implement [at|de]tach_hwpt handlers Cédric Le Goater
2025-06-05 8:42 ` [PULL 13/16] vfio/iommufd: Save vendor specific device info Cédric Le Goater
2025-06-05 8:42 ` [PULL 14/16] MAINTAINERS: Add reviewer for CPR Cédric Le Goater
2025-06-05 8:42 ` Cédric Le Goater [this message]
2025-06-05 8:42 ` [PULL 16/16] vfio: move vfio-cpr.h Cédric Le Goater
2025-06-05 19:00 ` [PULL 00/16] vfio queue Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250605084245.1520562-16-clg@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=steven.sistare@oracle.com \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).