mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
nodedev: Move privileged flag from udev private data to driver's state
Even though hal doesn't make use of it, the privileged flag is related to the daemon/driver rather than the backend actually used. While at it, get rid of some tab indentation in the driver state struct. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
b3aaff56db
commit
643c74abff
@ -40,6 +40,7 @@ struct _virNodeDeviceDriverState {
|
|||||||
|
|
||||||
virNodeDeviceObjListPtr devs; /* currently-known devices */
|
virNodeDeviceObjListPtr devs; /* currently-known devices */
|
||||||
void *privateData; /* driver-specific private data */
|
void *privateData; /* driver-specific private data */
|
||||||
|
bool privileged; /* whether we run in privileged mode */
|
||||||
|
|
||||||
/* Immutable pointer, self-locking APIs */
|
/* Immutable pointer, self-locking APIs */
|
||||||
virObjectEventStatePtr nodeDeviceEventState;
|
virObjectEventStatePtr nodeDeviceEventState;
|
||||||
|
@ -56,7 +56,6 @@ VIR_LOG_INIT("node_device.node_device_udev");
|
|||||||
struct _udevPrivate {
|
struct _udevPrivate {
|
||||||
struct udev_monitor *udev_monitor;
|
struct udev_monitor *udev_monitor;
|
||||||
int watch;
|
int watch;
|
||||||
bool privileged;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -447,9 +446,13 @@ udevProcessPCI(struct udev_device *device,
|
|||||||
virNodeDevCapPCIDevPtr pci_dev = &def->caps->data.pci_dev;
|
virNodeDevCapPCIDevPtr pci_dev = &def->caps->data.pci_dev;
|
||||||
virPCIEDeviceInfoPtr pci_express = NULL;
|
virPCIEDeviceInfoPtr pci_express = NULL;
|
||||||
virPCIDevicePtr pciDev = NULL;
|
virPCIDevicePtr pciDev = NULL;
|
||||||
udevPrivate *priv = driver->privateData;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *p;
|
char *p;
|
||||||
|
bool privileged;
|
||||||
|
|
||||||
|
nodeDeviceLock();
|
||||||
|
privileged = driver->privileged;
|
||||||
|
nodeDeviceUnlock();
|
||||||
|
|
||||||
if (udevGetUintProperty(device, "PCI_CLASS", &pci_dev->class, 16) < 0)
|
if (udevGetUintProperty(device, "PCI_CLASS", &pci_dev->class, 16) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -498,7 +501,7 @@ udevProcessPCI(struct udev_device *device,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* We need to be root to read PCI device configs */
|
/* We need to be root to read PCI device configs */
|
||||||
if (priv->privileged) {
|
if (privileged) {
|
||||||
if (virPCIGetHeaderType(pciDev, &pci_dev->hdrType) < 0)
|
if (virPCIGetHeaderType(pciDev, &pci_dev->hdrType) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -1787,7 +1790,6 @@ nodeStateInitialize(bool privileged,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
priv->watch = -1;
|
priv->watch = -1;
|
||||||
priv->privileged = privileged;
|
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0) {
|
if (VIR_ALLOC(driver) < 0) {
|
||||||
VIR_FREE(priv);
|
VIR_FREE(priv);
|
||||||
@ -1802,6 +1804,7 @@ nodeStateInitialize(bool privileged,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
driver->privileged = privileged;
|
||||||
driver->privateData = priv;
|
driver->privateData = priv;
|
||||||
nodeDeviceLock();
|
nodeDeviceLock();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user