mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
nodedev: Cleanup driver code and prototypes
Alter the node_device_driver source and prototypes to follow more recent code style guidelines w/r/t spacing between functions, format of the function, and the prototype definitions. While the new names for nodeDeviceUpdateCaps, nodeDeviceUpdateDriverName, and nodeDeviceGetTime don't follow exactly w/r/t a "vir" prefix, they do follow other driver nomenclature style. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
944b8de83e
commit
18c551f378
@ -47,7 +47,9 @@
|
|||||||
|
|
||||||
virNodeDeviceDriverStatePtr driver;
|
virNodeDeviceDriverStatePtr driver;
|
||||||
|
|
||||||
static int update_caps(virNodeDeviceObjPtr dev)
|
|
||||||
|
static int
|
||||||
|
nodeDeviceUpdateCaps(virNodeDeviceObjPtr dev)
|
||||||
{
|
{
|
||||||
virNodeDevCapsDefPtr cap = dev->def->caps;
|
virNodeDevCapsDefPtr cap = dev->def->caps;
|
||||||
|
|
||||||
@ -107,7 +109,8 @@ static int update_caps(virNodeDeviceObjPtr dev)
|
|||||||
* the driver name for a device each time its entry is used, both for
|
* the driver name for a device each time its entry is used, both for
|
||||||
* udev *and* HAL backends.
|
* udev *and* HAL backends.
|
||||||
*/
|
*/
|
||||||
static int update_driver_name(virNodeDeviceObjPtr dev)
|
static int
|
||||||
|
nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
|
||||||
{
|
{
|
||||||
char *driver_link = NULL;
|
char *driver_link = NULL;
|
||||||
char *devpath = NULL;
|
char *devpath = NULL;
|
||||||
@ -144,22 +147,28 @@ static int update_driver_name(virNodeDeviceObjPtr dev)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* XXX: Implement me for non-linux */
|
/* XXX: Implement me for non-linux */
|
||||||
static int update_driver_name(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED)
|
static int
|
||||||
|
nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void nodeDeviceLock(void)
|
void
|
||||||
|
nodeDeviceLock(void)
|
||||||
{
|
{
|
||||||
virMutexLock(&driver->lock);
|
virMutexLock(&driver->lock);
|
||||||
}
|
}
|
||||||
void nodeDeviceUnlock(void)
|
|
||||||
|
|
||||||
|
void
|
||||||
|
nodeDeviceUnlock(void)
|
||||||
{
|
{
|
||||||
virMutexUnlock(&driver->lock);
|
virMutexUnlock(&driver->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeNumOfDevices(virConnectPtr conn,
|
nodeNumOfDevices(virConnectPtr conn,
|
||||||
const char *cap,
|
const char *cap,
|
||||||
@ -204,6 +213,7 @@ nodeListDevices(virConnectPtr conn,
|
|||||||
return nnames;
|
return nnames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeConnectListAllNodeDevices(virConnectPtr conn,
|
nodeConnectListAllNodeDevices(virConnectPtr conn,
|
||||||
virNodeDevicePtr **devices,
|
virNodeDevicePtr **devices,
|
||||||
@ -224,8 +234,10 @@ nodeConnectListAllNodeDevices(virConnectPtr conn,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virNodeDevicePtr
|
virNodeDevicePtr
|
||||||
nodeDeviceLookupByName(virConnectPtr conn, const char *name)
|
nodeDeviceLookupByName(virConnectPtr conn,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
virNodeDeviceObjPtr obj;
|
virNodeDeviceObjPtr obj;
|
||||||
virNodeDevicePtr ret = NULL;
|
virNodeDevicePtr ret = NULL;
|
||||||
@ -340,8 +352,8 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
|
|||||||
if (virNodeDeviceGetXMLDescEnsureACL(dev->conn, obj->def) < 0)
|
if (virNodeDeviceGetXMLDescEnsureACL(dev->conn, obj->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
update_driver_name(obj);
|
nodeDeviceUpdateDriverName(obj);
|
||||||
if (update_caps(obj) < 0)
|
if (nodeDeviceUpdateCaps(obj) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = virNodeDeviceDefFormat(obj->def);
|
ret = virNodeDeviceDefFormat(obj->def);
|
||||||
@ -433,8 +445,11 @@ nodeDeviceNumOfCaps(virNodeDevicePtr dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
|
nodeDeviceListCaps(virNodeDevicePtr dev,
|
||||||
|
char **const names,
|
||||||
|
int maxnames)
|
||||||
{
|
{
|
||||||
virNodeDeviceObjPtr obj;
|
virNodeDeviceObjPtr obj;
|
||||||
virNodeDevCapsDefPtr caps;
|
virNodeDevCapsDefPtr caps;
|
||||||
@ -490,8 +505,9 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_time(time_t *t)
|
nodeDeviceGetTime(time_t *t)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -522,7 +538,9 @@ get_time(time_t *t)
|
|||||||
* it's probably safe to assume it's not going to appear.
|
* it's probably safe to assume it's not going to appear.
|
||||||
*/
|
*/
|
||||||
static virNodeDevicePtr
|
static virNodeDevicePtr
|
||||||
find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
|
nodeDeviceFindNewDevice(virConnectPtr conn,
|
||||||
|
const char *wwnn,
|
||||||
|
const char *wwpn)
|
||||||
{
|
{
|
||||||
virNodeDevicePtr dev = NULL;
|
virNodeDevicePtr dev = NULL;
|
||||||
time_t start = 0, now = 0;
|
time_t start = 0, now = 0;
|
||||||
@ -534,7 +552,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
|
|||||||
* doesn't become invalid. */
|
* doesn't become invalid. */
|
||||||
nodeDeviceUnlock();
|
nodeDeviceUnlock();
|
||||||
|
|
||||||
get_time(&start);
|
nodeDeviceGetTime(&start);
|
||||||
|
|
||||||
while ((now - start) < LINUX_NEW_DEVICE_WAIT_TIME) {
|
while ((now - start) < LINUX_NEW_DEVICE_WAIT_TIME) {
|
||||||
|
|
||||||
@ -546,7 +564,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
sleep(5);
|
sleep(5);
|
||||||
if (get_time(&now) == -1)
|
if (nodeDeviceGetTime(&now) == -1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,6 +573,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
|
|||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virNodeDevicePtr
|
virNodeDevicePtr
|
||||||
nodeDeviceCreateXML(virConnectPtr conn,
|
nodeDeviceCreateXML(virConnectPtr conn,
|
||||||
const char *xmlDesc,
|
const char *xmlDesc,
|
||||||
@ -587,7 +606,7 @@ nodeDeviceCreateXML(virConnectPtr conn,
|
|||||||
if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_CREATE) < 0)
|
if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_CREATE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
dev = find_new_device(conn, wwnn, wwpn);
|
dev = nodeDeviceFindNewDevice(conn, wwnn, wwpn);
|
||||||
/* We don't check the return value, because one way or another,
|
/* We don't check the return value, because one way or another,
|
||||||
* we're returning what we get... */
|
* we're returning what we get... */
|
||||||
|
|
||||||
@ -653,6 +672,7 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
|
nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
|
||||||
virNodeDevicePtr dev,
|
virNodeDevicePtr dev,
|
||||||
@ -674,6 +694,7 @@ nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
|
|||||||
return callbackID;
|
return callbackID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
||||||
int callbackID)
|
int callbackID)
|
||||||
@ -694,7 +715,9 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nodedevRegister(void)
|
|
||||||
|
int
|
||||||
|
nodedevRegister(void)
|
||||||
{
|
{
|
||||||
#ifdef WITH_UDEV
|
#ifdef WITH_UDEV
|
||||||
return udevNodeRegister();
|
return udevNodeRegister();
|
||||||
|
@ -31,37 +31,74 @@
|
|||||||
# define LINUX_NEW_DEVICE_WAIT_TIME 60
|
# define LINUX_NEW_DEVICE_WAIT_TIME 60
|
||||||
|
|
||||||
# ifdef WITH_HAL
|
# ifdef WITH_HAL
|
||||||
int halNodeRegister(void);
|
int
|
||||||
# endif
|
halNodeRegister(void);
|
||||||
# ifdef WITH_UDEV
|
|
||||||
int udevNodeRegister(void);
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
void nodeDeviceLock(void);
|
# ifdef WITH_UDEV
|
||||||
void nodeDeviceUnlock(void);
|
int
|
||||||
|
udevNodeRegister(void);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
void
|
||||||
|
nodeDeviceLock(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
nodeDeviceUnlock(void);
|
||||||
|
|
||||||
extern virNodeDeviceDriverStatePtr driver;
|
extern virNodeDeviceDriverStatePtr driver;
|
||||||
|
|
||||||
int nodedevRegister(void);
|
int
|
||||||
|
nodedevRegister(void);
|
||||||
|
|
||||||
int nodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags);
|
int
|
||||||
int nodeListDevices(virConnectPtr conn, const char *cap, char **const names,
|
nodeNumOfDevices(virConnectPtr conn,
|
||||||
int maxnames, unsigned int flags);
|
const char *cap,
|
||||||
int nodeConnectListAllNodeDevices(virConnectPtr conn,
|
unsigned int flags);
|
||||||
|
|
||||||
|
int nodeListDevices(virConnectPtr conn,
|
||||||
|
const char *cap,
|
||||||
|
char **const names,
|
||||||
|
int maxnames,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
|
int
|
||||||
|
nodeConnectListAllNodeDevices(virConnectPtr conn,
|
||||||
virNodeDevicePtr **devices,
|
virNodeDevicePtr **devices,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
virNodeDevicePtr nodeDeviceLookupByName(virConnectPtr conn, const char *name);
|
|
||||||
virNodeDevicePtr nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
|
virNodeDevicePtr
|
||||||
|
nodeDeviceLookupByName(virConnectPtr conn,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
virNodeDevicePtr
|
||||||
|
nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
|
||||||
const char *wwnn,
|
const char *wwnn,
|
||||||
const char *wwpn,
|
const char *wwpn,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
char *nodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags);
|
|
||||||
char *nodeDeviceGetParent(virNodeDevicePtr dev);
|
char *
|
||||||
int nodeDeviceNumOfCaps(virNodeDevicePtr dev);
|
nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
|
||||||
int nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames);
|
unsigned int flags);
|
||||||
virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn,
|
|
||||||
const char *xmlDesc, unsigned int flags);
|
char *
|
||||||
int nodeDeviceDestroy(virNodeDevicePtr dev);
|
nodeDeviceGetParent(virNodeDevicePtr dev);
|
||||||
|
|
||||||
|
int
|
||||||
|
nodeDeviceNumOfCaps(virNodeDevicePtr dev);
|
||||||
|
|
||||||
|
int
|
||||||
|
nodeDeviceListCaps(virNodeDevicePtr dev,
|
||||||
|
char **const names,
|
||||||
|
int maxnames);
|
||||||
|
|
||||||
|
virNodeDevicePtr
|
||||||
|
nodeDeviceCreateXML(virConnectPtr conn,
|
||||||
|
const char *xmlDesc,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
|
int
|
||||||
|
nodeDeviceDestroy(virNodeDevicePtr dev);
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
|
nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
|
||||||
@ -73,4 +110,5 @@ nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
|
|||||||
int
|
int
|
||||||
nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
||||||
int callbackID);
|
int callbackID);
|
||||||
|
|
||||||
#endif /* __VIR_NODE_DEVICE_H__ */
|
#endif /* __VIR_NODE_DEVICE_H__ */
|
||||||
|
@ -71,7 +71,8 @@ udevHasDeviceProperty(struct udev_device *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *udevGetDeviceProperty(struct udev_device *udev_device,
|
static const char *
|
||||||
|
udevGetDeviceProperty(struct udev_device *udev_device,
|
||||||
const char *property_key)
|
const char *property_key)
|
||||||
{
|
{
|
||||||
const char *ret = NULL;
|
const char *ret = NULL;
|
||||||
@ -85,7 +86,8 @@ static const char *udevGetDeviceProperty(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetStringProperty(struct udev_device *udev_device,
|
static int
|
||||||
|
udevGetStringProperty(struct udev_device *udev_device,
|
||||||
const char *property_key,
|
const char *property_key,
|
||||||
char **value)
|
char **value)
|
||||||
{
|
{
|
||||||
@ -97,7 +99,8 @@ static int udevGetStringProperty(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetIntProperty(struct udev_device *udev_device,
|
static int
|
||||||
|
udevGetIntProperty(struct udev_device *udev_device,
|
||||||
const char *property_key,
|
const char *property_key,
|
||||||
int *value,
|
int *value,
|
||||||
int base)
|
int base)
|
||||||
@ -115,7 +118,8 @@ static int udevGetIntProperty(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetUintProperty(struct udev_device *udev_device,
|
static int
|
||||||
|
udevGetUintProperty(struct udev_device *udev_device,
|
||||||
const char *property_key,
|
const char *property_key,
|
||||||
unsigned int *value,
|
unsigned int *value,
|
||||||
int base)
|
int base)
|
||||||
@ -133,7 +137,8 @@ static int udevGetUintProperty(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *udevGetDeviceSysfsAttr(struct udev_device *udev_device,
|
static const char *
|
||||||
|
udevGetDeviceSysfsAttr(struct udev_device *udev_device,
|
||||||
const char *attr_name)
|
const char *attr_name)
|
||||||
{
|
{
|
||||||
const char *ret = NULL;
|
const char *ret = NULL;
|
||||||
@ -148,7 +153,8 @@ static const char *udevGetDeviceSysfsAttr(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetStringSysfsAttr(struct udev_device *udev_device,
|
static int
|
||||||
|
udevGetStringSysfsAttr(struct udev_device *udev_device,
|
||||||
const char *attr_name,
|
const char *attr_name,
|
||||||
char **value)
|
char **value)
|
||||||
{
|
{
|
||||||
@ -164,7 +170,8 @@ static int udevGetStringSysfsAttr(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetIntSysfsAttr(struct udev_device *udev_device,
|
static int
|
||||||
|
udevGetIntSysfsAttr(struct udev_device *udev_device,
|
||||||
const char *attr_name,
|
const char *attr_name,
|
||||||
int *value,
|
int *value,
|
||||||
int base)
|
int base)
|
||||||
@ -183,7 +190,8 @@ static int udevGetIntSysfsAttr(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetUintSysfsAttr(struct udev_device *udev_device,
|
static int
|
||||||
|
udevGetUintSysfsAttr(struct udev_device *udev_device,
|
||||||
const char *attr_name,
|
const char *attr_name,
|
||||||
unsigned int *value,
|
unsigned int *value,
|
||||||
int base)
|
int base)
|
||||||
@ -202,7 +210,8 @@ static int udevGetUintSysfsAttr(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetUint64SysfsAttr(struct udev_device *udev_device,
|
static int
|
||||||
|
udevGetUint64SysfsAttr(struct udev_device *udev_device,
|
||||||
const char *attr_name,
|
const char *attr_name,
|
||||||
unsigned long long *value)
|
unsigned long long *value)
|
||||||
{
|
{
|
||||||
@ -220,7 +229,8 @@ static int udevGetUint64SysfsAttr(struct udev_device *udev_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGenerateDeviceName(struct udev_device *device,
|
static int
|
||||||
|
udevGenerateDeviceName(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def,
|
virNodeDeviceDefPtr def,
|
||||||
const char *s)
|
const char *s)
|
||||||
{
|
{
|
||||||
@ -247,8 +257,10 @@ static int udevGenerateDeviceName(struct udev_device *device,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if HAVE_UDEV_LOGGING
|
#if HAVE_UDEV_LOGGING
|
||||||
typedef void (*udevLogFunctionPtr)(struct udev *udev,
|
typedef void
|
||||||
|
(*udevLogFunctionPtr)(struct udev *udev,
|
||||||
int priority,
|
int priority,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
@ -283,7 +295,8 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int udevTranslatePCIIds(unsigned int vendor,
|
static int
|
||||||
|
udevTranslatePCIIds(unsigned int vendor,
|
||||||
unsigned int product,
|
unsigned int product,
|
||||||
char **vendor_string,
|
char **vendor_string,
|
||||||
char **product_string)
|
char **product_string)
|
||||||
@ -427,7 +440,8 @@ udevPCIGetMdevTypesCap(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessPCI(struct udev_device *device,
|
static int
|
||||||
|
udevProcessPCI(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapPCIDevPtr pci_dev = &def->caps->data.pci_dev;
|
virNodeDevCapPCIDevPtr pci_dev = &def->caps->data.pci_dev;
|
||||||
@ -527,7 +541,9 @@ static int udevProcessPCI(struct udev_device *device,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int drmGetMinorType(int minor)
|
|
||||||
|
static int
|
||||||
|
drmGetMinorType(int minor)
|
||||||
{
|
{
|
||||||
int type = minor >> 6;
|
int type = minor >> 6;
|
||||||
|
|
||||||
@ -544,7 +560,9 @@ static int drmGetMinorType(int minor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udevProcessDRMDevice(struct udev_device *device,
|
|
||||||
|
static int
|
||||||
|
udevProcessDRMDevice(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapDRMPtr drm = &def->caps->data.drm;
|
virNodeDevCapDRMPtr drm = &def->caps->data.drm;
|
||||||
@ -564,7 +582,9 @@ static int udevProcessDRMDevice(struct udev_device *device,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udevProcessUSBDevice(struct udev_device *device,
|
|
||||||
|
static int
|
||||||
|
udevProcessUSBDevice(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapUSBDevPtr usb_dev = &def->caps->data.usb_dev;
|
virNodeDevCapUSBDevPtr usb_dev = &def->caps->data.usb_dev;
|
||||||
@ -606,7 +626,8 @@ static int udevProcessUSBDevice(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessUSBInterface(struct udev_device *device,
|
static int
|
||||||
|
udevProcessUSBInterface(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapUSBIfPtr usb_if = &def->caps->data.usb_if;
|
virNodeDevCapUSBIfPtr usb_if = &def->caps->data.usb_if;
|
||||||
@ -634,7 +655,8 @@ static int udevProcessUSBInterface(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessNetworkInterface(struct udev_device *device,
|
static int
|
||||||
|
udevProcessNetworkInterface(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
const char *devtype = udev_device_get_devtype(device);
|
const char *devtype = udev_device_get_devtype(device);
|
||||||
@ -671,7 +693,8 @@ static int udevProcessNetworkInterface(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
|
static int
|
||||||
|
udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapSCSIHostPtr scsi_host = &def->caps->data.scsi_host;
|
virNodeDevCapSCSIHostPtr scsi_host = &def->caps->data.scsi_host;
|
||||||
@ -697,7 +720,8 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessSCSITarget(struct udev_device *device,
|
static int
|
||||||
|
udevProcessSCSITarget(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
const char *sysname = NULL;
|
const char *sysname = NULL;
|
||||||
@ -717,8 +741,10 @@ static int udevProcessSCSITarget(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED,
|
static int
|
||||||
unsigned int type, char **typestring)
|
udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int type,
|
||||||
|
char **typestring)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int foundtype = 1;
|
int foundtype = 1;
|
||||||
@ -775,7 +801,8 @@ static int udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
|
static int
|
||||||
|
udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -818,7 +845,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessDisk(struct udev_device *device,
|
static int
|
||||||
|
udevProcessDisk(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapStoragePtr storage = &def->caps->data.storage;
|
virNodeDevCapStoragePtr storage = &def->caps->data.storage;
|
||||||
@ -836,7 +864,8 @@ static int udevProcessDisk(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessRemoveableMedia(struct udev_device *device,
|
static int
|
||||||
|
udevProcessRemoveableMedia(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def,
|
virNodeDeviceDefPtr def,
|
||||||
int has_media)
|
int has_media)
|
||||||
{
|
{
|
||||||
@ -877,7 +906,9 @@ static int udevProcessRemoveableMedia(struct udev_device *device,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udevProcessCDROM(struct udev_device *device,
|
|
||||||
|
static int
|
||||||
|
udevProcessCDROM(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
int has_media = 0;
|
int has_media = 0;
|
||||||
@ -897,7 +928,9 @@ static int udevProcessCDROM(struct udev_device *device,
|
|||||||
return udevProcessRemoveableMedia(device, def, has_media);
|
return udevProcessRemoveableMedia(device, def, has_media);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udevProcessFloppy(struct udev_device *device,
|
|
||||||
|
static int
|
||||||
|
udevProcessFloppy(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
int has_media = 0;
|
int has_media = 0;
|
||||||
@ -915,7 +948,8 @@ static int udevProcessFloppy(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessSD(struct udev_device *device,
|
static int
|
||||||
|
udevProcessSD(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapStoragePtr storage = &def->caps->data.storage;
|
virNodeDevCapStoragePtr storage = &def->caps->data.storage;
|
||||||
@ -934,12 +968,12 @@ static int udevProcessSD(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* This function exists to deal with the case in which a driver does
|
/* This function exists to deal with the case in which a driver does
|
||||||
* not provide a device type in the usual place, but udev told us it's
|
* not provide a device type in the usual place, but udev told us it's
|
||||||
* a storage device, and we can make a good guess at what kind of
|
* a storage device, and we can make a good guess at what kind of
|
||||||
* storage device it is from other information that is provided. */
|
* storage device it is from other information that is provided. */
|
||||||
static int udevKludgeStorageType(virNodeDeviceDefPtr def)
|
static int
|
||||||
|
udevKludgeStorageType(virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("Could not find definitive storage type for device "
|
VIR_DEBUG("Could not find definitive storage type for device "
|
||||||
"with sysfs path '%s', trying to guess it",
|
"with sysfs path '%s', trying to guess it",
|
||||||
@ -960,7 +994,8 @@ static int udevKludgeStorageType(virNodeDeviceDefPtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessStorage(struct udev_device *device,
|
static int
|
||||||
|
udevProcessStorage(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
virNodeDevCapStoragePtr storage = &def->caps->data.storage;
|
virNodeDevCapStoragePtr storage = &def->caps->data.storage;
|
||||||
@ -1056,6 +1091,7 @@ static int udevProcessStorage(struct udev_device *device,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
udevProcessSCSIGeneric(struct udev_device *dev,
|
udevProcessSCSIGeneric(struct udev_device *dev,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
@ -1070,6 +1106,7 @@ udevProcessSCSIGeneric(struct udev_device *dev,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
udevProcessMediatedDevice(struct udev_device *dev,
|
udevProcessMediatedDevice(struct udev_device *dev,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
@ -1164,6 +1201,7 @@ udevGetDeviceNodes(struct udev_device *device,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
udevGetDeviceType(struct udev_device *device,
|
udevGetDeviceType(struct udev_device *device,
|
||||||
virNodeDevCapType *type)
|
virNodeDevCapType *type)
|
||||||
@ -1230,7 +1268,8 @@ udevGetDeviceType(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevGetDeviceDetails(struct udev_device *device,
|
static int
|
||||||
|
udevGetDeviceDetails(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
switch (def->caps->data.type) {
|
switch (def->caps->data.type) {
|
||||||
@ -1270,7 +1309,8 @@ static int udevGetDeviceDetails(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevRemoveOneDevice(struct udev_device *device)
|
static int
|
||||||
|
udevRemoveOneDevice(struct udev_device *device)
|
||||||
{
|
{
|
||||||
virNodeDeviceObjPtr dev = NULL;
|
virNodeDeviceObjPtr dev = NULL;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
@ -1302,7 +1342,8 @@ static int udevRemoveOneDevice(struct udev_device *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevSetParent(struct udev_device *device,
|
static int
|
||||||
|
udevSetParent(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
struct udev_device *parent_device = NULL;
|
struct udev_device *parent_device = NULL;
|
||||||
@ -1350,7 +1391,8 @@ static int udevSetParent(struct udev_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevAddOneDevice(struct udev_device *device)
|
static int
|
||||||
|
udevAddOneDevice(struct udev_device *device)
|
||||||
{
|
{
|
||||||
virNodeDeviceDefPtr def = NULL;
|
virNodeDeviceDefPtr def = NULL;
|
||||||
virNodeDeviceObjPtr dev = NULL;
|
virNodeDeviceObjPtr dev = NULL;
|
||||||
@ -1419,7 +1461,8 @@ static int udevAddOneDevice(struct udev_device *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevProcessDeviceListEntry(struct udev *udev,
|
static int
|
||||||
|
udevProcessDeviceListEntry(struct udev *udev,
|
||||||
struct udev_list_entry *list_entry)
|
struct udev_list_entry *list_entry)
|
||||||
{
|
{
|
||||||
struct udev_device *device;
|
struct udev_device *device;
|
||||||
@ -1452,7 +1495,8 @@ const char *subsystem_blacklist[] = {
|
|||||||
"acpi", "tty", "vc", "i2c",
|
"acpi", "tty", "vc", "i2c",
|
||||||
};
|
};
|
||||||
|
|
||||||
static int udevEnumerateAddMatches(struct udev_enumerate *udev_enumerate)
|
static int
|
||||||
|
udevEnumerateAddMatches(struct udev_enumerate *udev_enumerate)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -1467,7 +1511,8 @@ static int udevEnumerateAddMatches(struct udev_enumerate *udev_enumerate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int udevEnumerateDevices(struct udev *udev)
|
static int
|
||||||
|
udevEnumerateDevices(struct udev *udev)
|
||||||
{
|
{
|
||||||
struct udev_enumerate *udev_enumerate = NULL;
|
struct udev_enumerate *udev_enumerate = NULL;
|
||||||
struct udev_list_entry *list_entry = NULL;
|
struct udev_list_entry *list_entry = NULL;
|
||||||
@ -1497,7 +1542,8 @@ static int udevEnumerateDevices(struct udev *udev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void udevPCITranslateDeinit(void)
|
static void
|
||||||
|
udevPCITranslateDeinit(void)
|
||||||
{
|
{
|
||||||
#if defined __s390__ || defined __s390x_
|
#if defined __s390__ || defined __s390x_
|
||||||
/* Nothing was initialized, nothing needs to be cleaned up */
|
/* Nothing was initialized, nothing needs to be cleaned up */
|
||||||
@ -1509,7 +1555,8 @@ static void udevPCITranslateDeinit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int nodeStateCleanup(void)
|
static int
|
||||||
|
nodeStateCleanup(void)
|
||||||
{
|
{
|
||||||
udevPrivate *priv = NULL;
|
udevPrivate *priv = NULL;
|
||||||
struct udev_monitor *udev_monitor = NULL;
|
struct udev_monitor *udev_monitor = NULL;
|
||||||
@ -1550,7 +1597,8 @@ static int nodeStateCleanup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
|
static void
|
||||||
|
udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
|
||||||
int fd,
|
int fd,
|
||||||
int events ATTRIBUTE_UNUSED,
|
int events ATTRIBUTE_UNUSED,
|
||||||
void *data ATTRIBUTE_UNUSED)
|
void *data ATTRIBUTE_UNUSED)
|
||||||
@ -1654,7 +1702,8 @@ udevGetDMIData(virNodeDevCapSystemPtr syscap)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int udevSetupSystemDev(void)
|
static int
|
||||||
|
udevSetupSystemDev(void)
|
||||||
{
|
{
|
||||||
virNodeDeviceDefPtr def = NULL;
|
virNodeDeviceDefPtr def = NULL;
|
||||||
virNodeDeviceObjPtr dev = NULL;
|
virNodeDeviceObjPtr dev = NULL;
|
||||||
@ -1688,7 +1737,9 @@ static int udevSetupSystemDev(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED)
|
|
||||||
|
static int
|
||||||
|
udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
#if defined __s390__ || defined __s390x_
|
#if defined __s390__ || defined __s390x_
|
||||||
/* On s390(x) system there is no PCI bus.
|
/* On s390(x) system there is no PCI bus.
|
||||||
@ -1710,7 +1761,9 @@ static int udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nodeStateInitialize(bool privileged,
|
|
||||||
|
static int
|
||||||
|
nodeStateInitialize(bool privileged,
|
||||||
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
@ -1807,7 +1860,8 @@ static int nodeStateInitialize(bool privileged,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int nodeStateReload(void)
|
static int
|
||||||
|
nodeStateReload(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1837,7 +1891,9 @@ static virStateDriver udevStateDriver = {
|
|||||||
.stateReload = nodeStateReload, /* 0.7.3 */
|
.stateReload = nodeStateReload, /* 0.7.3 */
|
||||||
};
|
};
|
||||||
|
|
||||||
int udevNodeRegister(void)
|
|
||||||
|
int
|
||||||
|
udevNodeRegister(void)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("Registering udev node device backend");
|
VIR_DEBUG("Registering udev node device backend");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user