mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 06:43:53 -06:00
vfio/container: pass listener_begin/commit callbacks
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. Reviewed-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: John Levon <john.levon@nutanix.com> Link: https://lore.kernel.org/qemu-devel/20250507152020.1254632-15-john.levon@nutanix.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
d4e392d0a9
commit
d9b7d8b699
2 changed files with 30 additions and 0 deletions
|
@ -411,6 +411,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_device_error_append(VFIODevice *vbasedev, Error **errp)
|
||||
{
|
||||
/*
|
||||
|
@ -1161,6 +1187,8 @@ static void vfio_listener_log_sync(MemoryListener *listener,
|
|||
|
||||
static 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,
|
||||
|
|
|
@ -117,6 +117,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue