]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: introduce virPCIDeviceConfigOpenTry
authorJán Tomko <jtomko@redhat.com>
Tue, 13 Aug 2019 13:14:05 +0000 (15:14 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 14 Aug 2019 14:28:34 +0000 (16:28 +0200)
For callers that only need read-only access and don't want
an error reported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virpci.c

index e45dfbc6315bce63252bf5deed8482e998a708ff..2758ee6f49aa72697efa84b125d279914950e2f1 100644 (file)
@@ -320,6 +320,12 @@ virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal)
     return virPCIDeviceConfigOpenInternal(dev, false, fatal);
 }
 
+static int
+virPCIDeviceConfigOpenTry(virPCIDevicePtr dev)
+{
+    return virPCIDeviceConfigOpenInternal(dev, true, false);
+}
+
 static int
 virPCIDeviceConfigOpenWrite(virPCIDevicePtr dev)
 {
@@ -692,7 +698,7 @@ virPCIDeviceIsParent(virPCIDevicePtr dev, virPCIDevicePtr check, void *data)
     if (dev->address.domain != check->address.domain)
         return 0;
 
-    if ((fd = virPCIDeviceConfigOpen(check, false)) < 0)
+    if ((fd = virPCIDeviceConfigOpenTry(check)) < 0)
         return 0;
 
     /* Is it a bridge? */
@@ -740,7 +746,7 @@ virPCIDeviceIsParent(virPCIDevicePtr dev, virPCIDevicePtr check, void *data)
             int bestfd;
             uint8_t best_secondary;
 
-            if ((bestfd = virPCIDeviceConfigOpen(*best, false)) < 0)
+            if ((bestfd = virPCIDeviceConfigOpenTry(*best)) < 0)
                 goto cleanup;
             best_secondary = virPCIDeviceRead8(*best, bestfd, PCI_SECONDARY_BUS);
             virPCIDeviceConfigClose(*best, bestfd);