KVM: Device assignment permission checks
authorAlex Williamson <alex.williamson@redhat.com>
Wed, 21 Dec 2011 04:59:09 +0000 (21:59 -0700)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Oct 2012 21:37:19 +0000 (23:37 +0200)
commite642da01ccb67c419a26b262a067db8e8bbdb04c
tree14159bf2edd3581c7cdf751fcab6e8704270e653
parent4d092c1fe004f512a70dbe66efd50cd8cf15e66c
KVM: Device assignment permission checks

commit 3d27e23b17010c668db311140b17bbbb70c78fb9 upstream

Only allow KVM device assignment to attach to devices which:

 - Are not bridges
 - Have BAR resources (assume others are special devices)
 - The user has permissions to use

Assigning a bridge is a configuration error, it's not supported, and
typically doesn't result in the behavior the user is expecting anyway.
Devices without BAR resources are typically chipset components that
also don't have host drivers.  We don't want users to hold such devices
captive or cause system problems by fencing them off into an iommu
domain.  We determine "permission to use" by testing whether the user
has access to the PCI sysfs resource files.  By default a normal user
will not have access to these files, so it provides a good indication
that an administration agent has granted the user access to the device.

[Yang Bai: add missing #include]
[avi: fix comment style]

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Yang Bai <hamo.by@gmail.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
[dannf: backported to Debian's 2.6.32]
Signed-off-by: Willy Tarreau <w@1wt.eu>
virt/kvm/kvm_main.c