[libvirt] [PATCH] util: disallow resetting a pci-bridge device

Shivaprasad G Bhat sbhat at linux.vnet.ibm.com
Tue Jan 17 14:51:53 UTC 2017


It is distructive to attempt a reset on 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 for them.

Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
---
 src/util/virpci.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 0601f49..860f7aa 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -933,6 +933,16 @@ 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_PCI_BRIDGE) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Resetting a pci-bridge device is not allowed"));
+        return -1;
+    }
 
     if (activeDevs && virPCIDeviceListFind(activeDevs, dev)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,




More information about the libvir-list mailing list