mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-15 06:01:58 -06:00
vfio: Rename VFIOContainer related services
Rename these routines : vfio_put_group -> vfio_group_put vfio_get_group -> vfio_group_get vfio_kvm_device_del_group -> vfio_group_del_kvm_device vfio_kvm_device_add_group -> vfio_group_add_kvm_device vfio_get_device -> vfio_device_get vfio_put_base_device -> vfio_device_put vfio_device_groupid -> vfio_device_get_groupid vfio_connect_container -> vfio_container_connect vfio_disconnect_container -> vfio_container_disconnect to better reflect the namespace they belong to. Reviewed-by: John Levon <john.levon@nutanix.com> Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-30-clg@redhat.com Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-38-clg@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
e218ccf0c9
commit
7d810bb166
2 changed files with 33 additions and 31 deletions
|
@ -306,7 +306,7 @@ static bool vfio_get_info_iova_range(struct vfio_iommu_type1_info *info,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_kvm_device_add_group(VFIOGroup *group)
|
static void vfio_group_add_kvm_device(VFIOGroup *group)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ static void vfio_kvm_device_add_group(VFIOGroup *group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_kvm_device_del_group(VFIOGroup *group)
|
static void vfio_group_del_kvm_device(VFIOGroup *group)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ static bool vfio_legacy_setup(VFIOContainerBase *bcontainer, Error **errp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
VFIOContainer *container;
|
VFIOContainer *container;
|
||||||
|
@ -569,7 +569,7 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
}
|
}
|
||||||
group->container = container;
|
group->container = container;
|
||||||
QLIST_INSERT_HEAD(&container->group_list, group, container_next);
|
QLIST_INSERT_HEAD(&container->group_list, group, container_next);
|
||||||
vfio_kvm_device_add_group(group);
|
vfio_group_add_kvm_device(group);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,7 +609,7 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
goto enable_discards_exit;
|
goto enable_discards_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfio_kvm_device_add_group(group);
|
vfio_group_add_kvm_device(group);
|
||||||
|
|
||||||
vfio_address_space_insert(space, bcontainer);
|
vfio_address_space_insert(space, bcontainer);
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
||||||
return true;
|
return true;
|
||||||
listener_release_exit:
|
listener_release_exit:
|
||||||
QLIST_REMOVE(group, container_next);
|
QLIST_REMOVE(group, container_next);
|
||||||
vfio_kvm_device_del_group(group);
|
vfio_group_del_kvm_device(group);
|
||||||
vfio_listener_unregister(bcontainer);
|
vfio_listener_unregister(bcontainer);
|
||||||
if (vioc->release) {
|
if (vioc->release) {
|
||||||
vioc->release(bcontainer);
|
vioc->release(bcontainer);
|
||||||
|
@ -649,7 +649,7 @@ put_space_exit:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_disconnect_container(VFIOGroup *group)
|
static void vfio_container_disconnect(VFIOGroup *group)
|
||||||
{
|
{
|
||||||
VFIOContainer *container = group->container;
|
VFIOContainer *container = group->container;
|
||||||
VFIOContainerBase *bcontainer = &container->bcontainer;
|
VFIOContainerBase *bcontainer = &container->bcontainer;
|
||||||
|
@ -678,7 +678,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
|
||||||
if (QLIST_EMPTY(&container->group_list)) {
|
if (QLIST_EMPTY(&container->group_list)) {
|
||||||
VFIOAddressSpace *space = bcontainer->space;
|
VFIOAddressSpace *space = bcontainer->space;
|
||||||
|
|
||||||
trace_vfio_disconnect_container(container->fd);
|
trace_vfio_container_disconnect(container->fd);
|
||||||
vfio_cpr_unregister_container(bcontainer);
|
vfio_cpr_unregister_container(bcontainer);
|
||||||
close(container->fd);
|
close(container->fd);
|
||||||
object_unref(container);
|
object_unref(container);
|
||||||
|
@ -687,7 +687,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp)
|
static VFIOGroup *vfio_group_get(int groupid, AddressSpace *as, Error **errp)
|
||||||
{
|
{
|
||||||
ERRP_GUARD();
|
ERRP_GUARD();
|
||||||
VFIOGroup *group;
|
VFIOGroup *group;
|
||||||
|
@ -731,7 +731,7 @@ static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp)
|
||||||
group->groupid = groupid;
|
group->groupid = groupid;
|
||||||
QLIST_INIT(&group->device_list);
|
QLIST_INIT(&group->device_list);
|
||||||
|
|
||||||
if (!vfio_connect_container(group, as, errp)) {
|
if (!vfio_container_connect(group, as, errp)) {
|
||||||
error_prepend(errp, "failed to setup container for group %d: ",
|
error_prepend(errp, "failed to setup container for group %d: ",
|
||||||
groupid);
|
groupid);
|
||||||
goto close_fd_exit;
|
goto close_fd_exit;
|
||||||
|
@ -750,7 +750,7 @@ free_group_exit:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_put_group(VFIOGroup *group)
|
static void vfio_group_put(VFIOGroup *group)
|
||||||
{
|
{
|
||||||
if (!group || !QLIST_EMPTY(&group->device_list)) {
|
if (!group || !QLIST_EMPTY(&group->device_list)) {
|
||||||
return;
|
return;
|
||||||
|
@ -759,15 +759,15 @@ static void vfio_put_group(VFIOGroup *group)
|
||||||
if (!group->ram_block_discard_allowed) {
|
if (!group->ram_block_discard_allowed) {
|
||||||
vfio_ram_block_discard_disable(group->container, false);
|
vfio_ram_block_discard_disable(group->container, false);
|
||||||
}
|
}
|
||||||
vfio_kvm_device_del_group(group);
|
vfio_group_del_kvm_device(group);
|
||||||
vfio_disconnect_container(group);
|
vfio_container_disconnect(group);
|
||||||
QLIST_REMOVE(group, next);
|
QLIST_REMOVE(group, next);
|
||||||
trace_vfio_put_group(group->fd);
|
trace_vfio_group_put(group->fd);
|
||||||
close(group->fd);
|
close(group->fd);
|
||||||
g_free(group);
|
g_free(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vfio_get_device(VFIOGroup *group, const char *name,
|
static bool vfio_device_get(VFIOGroup *group, const char *name,
|
||||||
VFIODevice *vbasedev, Error **errp)
|
VFIODevice *vbasedev, Error **errp)
|
||||||
{
|
{
|
||||||
g_autofree struct vfio_device_info *info = NULL;
|
g_autofree struct vfio_device_info *info = NULL;
|
||||||
|
@ -819,25 +819,25 @@ static bool vfio_get_device(VFIOGroup *group, const char *name,
|
||||||
vbasedev->num_regions = info->num_regions;
|
vbasedev->num_regions = info->num_regions;
|
||||||
vbasedev->flags = info->flags;
|
vbasedev->flags = info->flags;
|
||||||
|
|
||||||
trace_vfio_get_device(name, info->flags, info->num_regions, info->num_irqs);
|
trace_vfio_device_get(name, info->flags, info->num_regions, info->num_irqs);
|
||||||
|
|
||||||
vbasedev->reset_works = !!(info->flags & VFIO_DEVICE_FLAGS_RESET);
|
vbasedev->reset_works = !!(info->flags & VFIO_DEVICE_FLAGS_RESET);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_put_base_device(VFIODevice *vbasedev)
|
static void vfio_device_put(VFIODevice *vbasedev)
|
||||||
{
|
{
|
||||||
if (!vbasedev->group) {
|
if (!vbasedev->group) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QLIST_REMOVE(vbasedev, next);
|
QLIST_REMOVE(vbasedev, next);
|
||||||
vbasedev->group = NULL;
|
vbasedev->group = NULL;
|
||||||
trace_vfio_put_base_device(vbasedev->fd);
|
trace_vfio_device_put(vbasedev->fd);
|
||||||
close(vbasedev->fd);
|
close(vbasedev->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp)
|
static int vfio_device_get_groupid(VFIODevice *vbasedev, Error **errp)
|
||||||
{
|
{
|
||||||
char *tmp, group_path[PATH_MAX];
|
char *tmp, group_path[PATH_MAX];
|
||||||
g_autofree char *group_name = NULL;
|
g_autofree char *group_name = NULL;
|
||||||
|
@ -872,7 +872,7 @@ static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp)
|
||||||
static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,
|
static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,
|
||||||
AddressSpace *as, Error **errp)
|
AddressSpace *as, Error **errp)
|
||||||
{
|
{
|
||||||
int groupid = vfio_device_groupid(vbasedev, errp);
|
int groupid = vfio_device_get_groupid(vbasedev, errp);
|
||||||
VFIODevice *vbasedev_iter;
|
VFIODevice *vbasedev_iter;
|
||||||
VFIOGroup *group;
|
VFIOGroup *group;
|
||||||
VFIOContainerBase *bcontainer;
|
VFIOContainerBase *bcontainer;
|
||||||
|
@ -887,7 +887,7 @@ static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
group = vfio_get_group(groupid, as, errp);
|
group = vfio_group_get(groupid, as, errp);
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -895,12 +895,12 @@ static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbasedev,
|
||||||
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
|
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
|
||||||
if (strcmp(vbasedev_iter->name, vbasedev->name) == 0) {
|
if (strcmp(vbasedev_iter->name, vbasedev->name) == 0) {
|
||||||
error_setg(errp, "device is already attached");
|
error_setg(errp, "device is already attached");
|
||||||
vfio_put_group(group);
|
vfio_group_put(group);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!vfio_get_device(group, name, vbasedev, errp)) {
|
if (!vfio_device_get(group, name, vbasedev, errp)) {
|
||||||
vfio_put_group(group);
|
vfio_group_put(group);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,8 +920,8 @@ static void vfio_legacy_detach_device(VFIODevice *vbasedev)
|
||||||
QLIST_REMOVE(vbasedev, container_next);
|
QLIST_REMOVE(vbasedev, container_next);
|
||||||
vbasedev->bcontainer = NULL;
|
vbasedev->bcontainer = NULL;
|
||||||
trace_vfio_device_detach(vbasedev->name, group->groupid);
|
trace_vfio_device_detach(vbasedev->name, group->groupid);
|
||||||
vfio_put_base_device(vbasedev);
|
vfio_device_put(vbasedev);
|
||||||
vfio_put_group(group);
|
vfio_group_put(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_legacy_pci_hot_reset(VFIODevice *vbasedev, bool single)
|
static int vfio_legacy_pci_hot_reset(VFIODevice *vbasedev, bool single)
|
||||||
|
|
|
@ -99,16 +99,18 @@ vfio_listener_region_add_no_dma_map(const char *name, uint64_t iova, uint64_t si
|
||||||
vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
|
vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
|
||||||
vfio_device_dirty_tracking_update(uint64_t start, uint64_t end, uint64_t min, uint64_t max) "section 0x%"PRIx64" - 0x%"PRIx64" -> update [0x%"PRIx64" - 0x%"PRIx64"]"
|
vfio_device_dirty_tracking_update(uint64_t start, uint64_t end, uint64_t min, uint64_t max) "section 0x%"PRIx64" - 0x%"PRIx64" -> update [0x%"PRIx64" - 0x%"PRIx64"]"
|
||||||
vfio_device_dirty_tracking_start(int nr_ranges, uint64_t min32, uint64_t max32, uint64_t min64, uint64_t max64, uint64_t minpci, uint64_t maxpci) "nr_ranges %d 32:[0x%"PRIx64" - 0x%"PRIx64"], 64:[0x%"PRIx64" - 0x%"PRIx64"], pci64:[0x%"PRIx64" - 0x%"PRIx64"]"
|
vfio_device_dirty_tracking_start(int nr_ranges, uint64_t min32, uint64_t max32, uint64_t min64, uint64_t max64, uint64_t minpci, uint64_t maxpci) "nr_ranges %d 32:[0x%"PRIx64" - 0x%"PRIx64"], 64:[0x%"PRIx64" - 0x%"PRIx64"], pci64:[0x%"PRIx64" - 0x%"PRIx64"]"
|
||||||
vfio_disconnect_container(int fd) "close container->fd=%d"
|
|
||||||
vfio_put_group(int fd) "close group->fd=%d"
|
|
||||||
vfio_get_device(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u"
|
|
||||||
vfio_put_base_device(int fd) "close vdev->fd=%d"
|
|
||||||
vfio_legacy_dma_unmap_overflow_workaround(void) ""
|
|
||||||
vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64
|
vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64
|
||||||
|
|
||||||
# container-base.c
|
# container-base.c
|
||||||
vfio_container_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64
|
vfio_container_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64
|
||||||
|
|
||||||
|
# container.c
|
||||||
|
vfio_container_disconnect(int fd) "close container->fd=%d"
|
||||||
|
vfio_group_put(int fd) "close group->fd=%d"
|
||||||
|
vfio_device_get(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u"
|
||||||
|
vfio_device_put(int fd) "close vdev->fd=%d"
|
||||||
|
vfio_legacy_dma_unmap_overflow_workaround(void) ""
|
||||||
|
|
||||||
# region.c
|
# region.c
|
||||||
vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)"
|
vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)"
|
||||||
vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t data) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64
|
vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t data) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue