qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Cedric Le Goater <clg@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,
	Steve Sistare <steven.sistare@oracle.com>
Subject: [PATCH V1 7/8] vfio: vfio_find_ram_discard_listener
Date: Tue,  9 Jul 2024 13:58:56 -0700	[thread overview]
Message-ID: <1720558737-451106-8-git-send-email-steven.sistare@oracle.com> (raw)
In-Reply-To: <1720558737-451106-1-git-send-email-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>
---
 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 72a692a..5c7baad 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -561,6 +561,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)
 {
@@ -1285,19 +1305,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



  parent reply	other threads:[~2024-07-09 21:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 20:58 [PATCH V1 0/8] Live update: vfio Steve Sistare
2024-07-09 20:58 ` [PATCH V1 1/8] migration: cpr_needed_for_reuse Steve Sistare
2024-07-09 20:58 ` [PATCH V1 2/8] pci: export msix_is_pending Steve Sistare
2024-07-09 20:58 ` [PATCH V1 3/8] vfio-pci: refactor for cpr Steve Sistare
2024-07-09 20:58 ` [PATCH V1 4/8] vfio-pci: cpr part 1 (fd and dma) Steve Sistare
2024-07-10 20:03   ` Alex Williamson
2024-07-10 20:32     ` Steven Sistare
2024-07-16 14:42   ` Steven Sistare
2024-07-09 20:58 ` [PATCH V1 5/8] vfio-pci: cpr part 2 (msi) Steve Sistare
2024-07-09 20:58 ` [PATCH V1 6/8] vfio-pci: cpr part 3 (intx) Steve Sistare
2024-07-09 20:58 ` Steve Sistare [this message]
2024-07-09 20:58 ` [PATCH V1 8/8] vfio-pci: recover from unmap-all-vaddr failure Steve Sistare
2024-08-12 18:19 ` [PATCH V1 0/8] Live update: vfio Steven Sistare

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=1720558737-451106-8-git-send-email-steven.sistare@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=alex.williamson@redhat.com \
    --cc=clg@redhat.com \
    --cc=farosas@suse.de \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).