KVM: Device assignment permission checks
commitc4e7f9022e506c6635a5037713c37118e23193e4
authorAlex Williamson <alex.williamson@redhat.com>
Thu, 12 Jan 2012 10:39:54 +0000 (12 12:39 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 18 Jan 2012 15:31:54 +0000 (18 07:31 -0800)
tree02f95483e4fb2d7f05bdca533c02cb3fc4ccc957
parent4fd9e326e5001982747225f0f7bb462e34ae9215
KVM: Device assignment permission checks

(cherry picked from commit 3d27e23b17010c668db311140b17bbbb70c78fb9)

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Documentation/virtual/kvm/api.txt
virt/kvm/assigned-dev.c