1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

util: introduce virPCIDeviceConfigOpenTry

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>
This commit is contained in:
Ján Tomko 2019-08-13 15:14:05 +02:00
parent 801ebb5edb
commit 17317a4bc6

View 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);