[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/26] vfio/container: pass listener_begin/commit callbacks
From: |
John Levon |
Subject: |
[PATCH 02/26] vfio/container: pass listener_begin/commit callbacks |
Date: |
Wed, 8 Jan 2025 11:50:08 +0000 |
From: John Levon <levon@movementarian.org>
The vfio-user container will later need to hook into these callbacks;
set up vfio to use them, and optionally pass them through to the
container.
Signed-off-by: John Levon <john.levon@nutanix.com>
---
hw/vfio/common.c | 28 +++++++++++++++++++++++++++
include/hw/vfio/vfio-container-base.h | 2 ++
2 files changed, 30 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 0e3ea71aae..0cacc66c85 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -557,6 +557,32 @@ static bool vfio_get_section_iova_range(VFIOContainerBase
*bcontainer,
return true;
}
+static void vfio_listener_begin(MemoryListener *listener)
+{
+ VFIOContainerBase *bcontainer = container_of(listener, VFIOContainerBase,
+ listener);
+ void (*listener_begin)(VFIOContainerBase *bcontainer);
+
+ listener_begin = VFIO_IOMMU_GET_CLASS(bcontainer)->listener_begin;
+
+ if (listener_begin) {
+ listener_begin(bcontainer);
+ }
+}
+
+static void vfio_listener_commit(MemoryListener *listener)
+{
+ VFIOContainerBase *bcontainer = container_of(listener, VFIOContainerBase,
+ listener);
+ void (*listener_commit)(VFIOContainerBase *bcontainer);
+
+ listener_commit = VFIO_IOMMU_GET_CLASS(bcontainer)->listener_begin;
+
+ if (listener_commit) {
+ listener_commit(bcontainer);
+ }
+}
+
static void vfio_listener_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -1378,6 +1404,8 @@ static void vfio_listener_log_sync(MemoryListener
*listener,
const MemoryListener vfio_memory_listener = {
.name = "vfio",
+ .begin = vfio_listener_begin,
+ .commit = vfio_listener_commit,
.region_add = vfio_listener_region_add,
.region_del = vfio_listener_region_del,
.log_global_start = vfio_listener_log_global_start,
diff --git a/include/hw/vfio/vfio-container-base.h
b/include/hw/vfio/vfio-container-base.h
index c9d339383e..0a863df0dc 100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -111,6 +111,8 @@ struct VFIOIOMMUClass {
/* basic feature */
bool (*setup)(VFIOContainerBase *bcontainer, Error **errp);
+ void (*listener_begin)(VFIOContainerBase *bcontainer);
+ void (*listener_commit)(VFIOContainerBase *bcontainer);
int (*dma_map)(const VFIOContainerBase *bcontainer,
hwaddr iova, ram_addr_t size,
void *vaddr, bool readonly, MemoryRegion *mrp);
--
2.34.1
- [v7 00/26] vfio-user client, John Levon, 2025/01/08
- [PATCH 10/26] vfio-user: add vfio-user class and container, John Levon, 2025/01/08
- [PATCH 02/26] vfio/container: pass listener_begin/commit callbacks,
John Levon <=
- [PATCH 08/26] vfio: add device IO ops vector, John Levon, 2025/01/08
- [PATCH 04/26] vfio: add vfio_attach_device_by_iommu_type(), John Levon, 2025/01/08
- [PATCH 05/26] vfio: add vfio_prepare_device(), John Levon, 2025/01/08
- [PATCH 09/26] vfio-user: introduce vfio-user protocol specification, John Levon, 2025/01/08
- [PATCH 11/26] vfio-user: connect vfio proxy to remote server, John Levon, 2025/01/08
- [PATCH 14/26] vfio-user: get device info, John Levon, 2025/01/08
- [PATCH 12/26] vfio-user: define socket receive functions, John Levon, 2025/01/08
- [PATCH 07/26] vfio: add VFIO base abstract class, John Levon, 2025/01/08
- [PATCH 13/26] vfio-user: define socket send functions, John Levon, 2025/01/08
- [PATCH 17/26] vfio-user: pci_user_realize PCI setup, John Levon, 2025/01/08