Skip to contentSkip to conversation

VFIO: Fix vfio-kvm device group registration

GIT PULL Alex Williamson 2 participants 3 messages Dec 6, 2017

lore
Share & tools
lore
#0 lore raw

The following changes since commit 2babfe0c9241c239272a03fec785165a50e8288c:

Update version for v2.11.0-rc4 release (2017-12-05 16:36:46 +0000)

are available in the git repository at:

git://github.com/awilliam/qemu-vfio.git tags/vfio-fixes-20171206.0

for you to fetch changes up to 13e6ae741cc0848a1819f435e2251d6d0bfae3e1:

vfio: Fix vfio-kvm group registration (2017-12-05 13:22:45 -0700)

----------------------------------------------------------------
VFIO fix for v2.11-final

- Fix bug failing to register all but the first group attached to a container with kvm-vfio device (Alex Williamson)

----------------------------------------------------------------
Alex Williamson (1):
vfio: Fix vfio-kvm group registration

 hw/vfio/common.c | 1 +
 1 file changed, 1 insertion(+)
#1 lore raw

[Qemu-devel] [PULL for-2.11 1/1] vfio: Fix vfio-kvm group registration

Commit 8c37faa475f3 ("vfio-pci, ppc64/spapr: Reorder group-to-container attaching") moved registration of groups with the vfio-kvm device from vfio_get_group() to vfio_connect_container(), but it missed the case where a group is attached to an existing container and takes an early exit. Perhaps this is a less common case on ppc64/spapr, but on x86 (without viommu) all groups are connected to the same container and thus only the first group gets registered with the vfio-kvm device. This becomes a problem if we then hot-unplug the devices associated with that first group and we end up with KVM being misinformed about any vfio connections that might remain. Fix by including the call to vfio_kvm_device_add_group() in this early exit path.

Fixes 8c37faa475f3 ("vfio-pci, ppc64/spapr: Reorder group-to-container attaching")
Cc [email protected] # qemu-2.10+
---
 hw/vfio/common.c |    1 +
 1 file changed, 1 insertion(+)
hw/vfio/common.c +1 -0
index 7b2924c0ef19..7007878e345e 100644
@@ -968,6 +968,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
         if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) {
             group->container = container;
             QLIST_INSERT_HEAD(&container->group_list, group, container_next);
+            vfio_kvm_device_add_group(group);
             return 0;
         }
     }
#2 lore raw
In reply to Alex Williamson
Quoted 12 lines · Alex Williamson

The following changes since commit 2babfe0c9241c239272a03fec785165a50e8288c:

Update version for v2.11.0-rc4 release (2017-12-05 16:36:46 +0000)

are available in the git repository at:

git://github.com/awilliam/qemu-vfio.git tags/vfio-fixes-20171206.0

for you to fetch changes up to 13e6ae741cc0848a1819f435e2251d6d0bfae3e1:

vfio: Fix vfio-kvm group registration (2017-12-05 13:22:45 -0700)

Quoted 7 lines

----------------------------------------------------------------
VFIO fix for v2.11-final

- Fix bug failing to register all but the first group attached to a container with kvm-vfio device (Alex Williamson)

----------------------------------------------------------------

I'm afraid this has missed the boat for 2.11, since we've already cut what we think should be the final rc. It would have to be a really critical regression since 2.10...

thanks
-- PMM