[PATCH v2 2/2] util: disallow resetting a pci-bridge device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
---
 src/util/virpci.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 0601f49..ae72587 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux