[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V1 03/26] vfio: vfio_find_ram_discard_listener
From: |
Steve Sistare |
Subject: |
[PATCH V1 03/26] vfio: vfio_find_ram_discard_listener |
Date: |
Wed, 29 Jan 2025 06:42:59 -0800 |
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>
---
hw/vfio/common.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index f7499a9..7370332 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -555,6 +555,26 @@ static bool vfio_get_section_iova_range(VFIOContainerBase
*bcontainer,
return true;
}
+static 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)
{
@@ -1266,19 +1286,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 -
--
1.8.3.1
- [PATCH V1 00/26] Live update: vfio and iommufd, Steve Sistare, 2025/01/29
- [PATCH V1 01/26] migration: cpr helpers, Steve Sistare, 2025/01/29
- [PATCH V1 06/26] vfio/container: preserve DMA mappings, Steve Sistare, 2025/01/29
- [PATCH V1 04/26] vfio/container: register container for cpr, Steve Sistare, 2025/01/29
- [PATCH V1 02/26] migration: lower handler priority, Steve Sistare, 2025/01/29
- [PATCH V1 07/26] vfio/container: recover from unmap-all-vaddr failure, Steve Sistare, 2025/01/29
- [PATCH V1 11/26] vfio-pci: skip reset during cpr, Steve Sistare, 2025/01/29
- [PATCH V1 03/26] vfio: vfio_find_ram_discard_listener,
Steve Sistare <=
- [PATCH V1 20/26] vfio/iommufd: export iommufd_cdev_get_info_iova_range, Steve Sistare, 2025/01/29
- [PATCH V1 08/26] pci: skip reset during cpr, Steve Sistare, 2025/01/29
- [PATCH V1 05/26] vfio/container: preserve descriptors, Steve Sistare, 2025/01/29
- [PATCH V1 09/26] pci: export msix_is_pending, Steve Sistare, 2025/01/29
- [PATCH V1 13/26] vfio-pci: preserve INTx, Steve Sistare, 2025/01/29
- [PATCH V1 14/26] migration: close kvm after cpr, Steve Sistare, 2025/01/29
- [PATCH V1 19/26] vfio/iommufd: use IOMMU_IOAS_MAP_FILE, Steve Sistare, 2025/01/29
- [PATCH V1 21/26] iommufd: change process ioctl, Steve Sistare, 2025/01/29
- [PATCH V1 12/26] vfio-pci: preserve MSI, Steve Sistare, 2025/01/29
- [PATCH V1 16/26] vfio: return mr from vfio_get_xlat_addr, Steve Sistare, 2025/01/29