[libvirt] [PATCH v2] util: disallow assigning or resetting a pci-bridge device
Martin Kletzander
mkletzan at redhat.com
Wed Jan 18 16:10:05 UTC 2017
On Wed, Jan 18, 2017 at 07:29:29PM +0530, Shivaprasad G Bhat wrote:
>It is destructive to attempt reset on a pci-bridge, the host can crash.
>The bridges won't contain any guest data and neither they can be
>passed through using vfio/stub. So, no point in allowing a reset on them.
>
Wasn't resetting non-endpoint the only way in some cases when you needed
to passthrough 2 endpoint devices when none of them could be reset? I
might be very easily wrong, though.
>Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
>---
> src/util/virhostdev.c | 10 ++++++++++
> src/util/virpci.c | 11 +++++++++++
> 2 files changed, 21 insertions(+)
>
>diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
>index 0673afb..16b96f3 100644
>--- a/src/util/virhostdev.c
>+++ b/src/util/virhostdev.c
>@@ -532,6 +532,16 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
> bool strict_acs_check = !!(flags & VIR_HOSTDEV_STRICT_ACS_CHECK);
> bool usesVFIO = (virPCIDeviceGetStubDriver(pci) == VIR_PCI_STUB_DRIVER_VFIO);
> struct virHostdevIsPCINodeDeviceUsedData data = { mgr, dom_name, usesVFIO };
>+ int hdrType = -1;
>+
>+ if (virPCIGetHeaderType(pci, &hdrType) < 0)
>+ goto cleanup;
>+
>+ if (hdrType == VIR_PCI_HEADER_PCI_BRIDGE) {
>+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PCI bridge devices"
>+ " cannot be assigned to guests"));
>+ goto cleanup;
>+ }
>
> if (!usesVFIO && !virPCIDeviceIsAssignable(pci, strict_acs_check)) {
> virReportError(VIR_ERR_OPERATION_INVALID,
>diff --git a/src/util/virpci.c b/src/util/virpci.c
>index 0601f49..f205abf 100644
>--- a/src/util/virpci.c
>+++ b/src/util/virpci.c
>@@ -933,6 +933,17 @@ virPCIDeviceReset(virPCIDevicePtr dev,
> char *drvName = NULL;
> int ret = -1;
> int fd = -1;
>+ int hdrType = -1;
>+
>+ if (virPCIGetHeaderType(dev, &hdrType) < 0)
>+ return -1;
>+
>+ if (hdrType != VIR_PCI_HEADER_ENDPOINT) {
>+ virReportError(VIR_ERR_INTERNAL_ERROR,
>+ _("Invalid attempt to reset non-endpoint PCI device %s."
>+ " Only PCI endpoint devices can be reset"), dev->name);
>+ return -1;
>+ }
>
> if (activeDevs && virPCIDeviceListFind(activeDevs, dev)) {
> virReportError(VIR_ERR_INTERNAL_ERROR,
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170118/5427cdba/attachment-0001.sig>
More information about the libvir-list
mailing list