mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
util: Introduce virPCIDeviceConfigOpenWrite
Only a handful of function need write access to the PCI config space. Create a wrapper function for those so that we can open it read only by default. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
fc16c69987
commit
fabb743050
@ -320,6 +320,12 @@ virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal)
|
|||||||
return virPCIDeviceConfigOpenInternal(dev, fatal);
|
return virPCIDeviceConfigOpenInternal(dev, fatal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
virPCIDeviceConfigOpenWrite(virPCIDevicePtr dev)
|
||||||
|
{
|
||||||
|
return virPCIDeviceConfigOpenInternal(dev, true);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virPCIDeviceConfigClose(virPCIDevicePtr dev, int cfgfd)
|
virPCIDeviceConfigClose(virPCIDevicePtr dev, int cfgfd)
|
||||||
{
|
{
|
||||||
@ -808,7 +814,7 @@ virPCIDeviceTrySecondaryBusReset(virPCIDevicePtr dev,
|
|||||||
dev->name);
|
dev->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((parentfd = virPCIDeviceConfigOpen(parent, true)) < 0)
|
if ((parentfd = virPCIDeviceConfigOpenWrite(parent)) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
VIR_DEBUG("%s %s: doing a secondary bus reset", dev->id, dev->name);
|
VIR_DEBUG("%s %s: doing a secondary bus reset", dev->id, dev->name);
|
||||||
@ -957,7 +963,7 @@ virPCIDeviceReset(virPCIDevicePtr dev,
|
|||||||
}
|
}
|
||||||
VIR_DEBUG("Resetting device %s", dev->name);
|
VIR_DEBUG("Resetting device %s", dev->name);
|
||||||
|
|
||||||
if ((fd = virPCIDeviceConfigOpen(dev, true)) < 0)
|
if ((fd = virPCIDeviceConfigOpenWrite(dev)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virPCIDeviceInit(dev, fd) < 0)
|
if (virPCIDeviceInit(dev, fd) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user