[PATCH 4/8] Remove use of nodeDevicePrivateData from nodeDev driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The node device driver can rely on its global state instead
of the connect private data.
---
 src/node_device/node_device_driver.c | 68 +++++++++++++----------------
 src/node_device/node_device_driver.h |  6 ++-
 src/node_device/node_device_hal.c    | 84 ++++++++++++++++--------------------
 src/node_device/node_device_udev.c   | 61 ++++++++++++--------------
 4 files changed, 99 insertions(+), 120 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 5d0efb4..b1f17f4 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -43,6 +43,8 @@
 
 #define VIR_FROM_THIS VIR_FROM_NODEDEV
 
+virNodeDeviceDriverStatePtr driver;
+
 static int update_caps(virNodeDeviceObjPtr dev)
 {
     virNodeDevCapsDefPtr cap = dev->def->caps;
@@ -114,11 +116,11 @@ static int update_driver_name(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED)
 #endif
 
 
-void nodeDeviceLock(virNodeDeviceDriverStatePtr driver)
+void nodeDeviceLock(void)
 {
     virMutexLock(&driver->lock);
 }
-void nodeDeviceUnlock(virNodeDeviceDriverStatePtr driver)
+void nodeDeviceUnlock(void)
 {
     virMutexUnlock(&driver->lock);
 }
@@ -128,7 +130,6 @@ nodeNumOfDevices(virConnectPtr conn,
                  const char *cap,
                  unsigned int flags)
 {
-    virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
     int ndevs = 0;
     size_t i;
 
@@ -137,7 +138,7 @@ nodeNumOfDevices(virConnectPtr conn,
 
     virCheckFlags(0, -1);
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     for (i = 0; i < driver->devs.count; i++) {
         virNodeDeviceObjPtr obj = driver->devs.objs[i];
         virNodeDeviceObjLock(obj);
@@ -147,7 +148,7 @@ nodeNumOfDevices(virConnectPtr conn,
             ++ndevs;
         virNodeDeviceObjUnlock(obj);
     }
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     return ndevs;
 }
@@ -158,7 +159,6 @@ nodeListDevices(virConnectPtr conn,
                 char **const names, int maxnames,
                 unsigned int flags)
 {
-    virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
     int ndevs = 0;
     size_t i;
 
@@ -167,7 +167,7 @@ nodeListDevices(virConnectPtr conn,
 
     virCheckFlags(0, -1);
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     for (i = 0; i < driver->devs.count && ndevs < maxnames; i++) {
         virNodeDeviceObjPtr obj = driver->devs.objs[i];
         virNodeDeviceObjLock(obj);
@@ -181,12 +181,12 @@ nodeListDevices(virConnectPtr conn,
         }
         virNodeDeviceObjUnlock(obj);
     }
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     return ndevs;
 
  failure:
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
     --ndevs;
     while (--ndevs >= 0)
         VIR_FREE(names[ndevs]);
@@ -198,7 +198,6 @@ nodeConnectListAllNodeDevices(virConnectPtr conn,
                               virNodeDevicePtr **devices,
                               unsigned int flags)
 {
-    virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
     int ret = -1;
 
     virCheckFlags(VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP, -1);
@@ -206,24 +205,23 @@ nodeConnectListAllNodeDevices(virConnectPtr conn,
     if (virConnectListAllNodeDevicesEnsureACL(conn) < 0)
         return -1;
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     ret = virNodeDeviceObjListExport(conn, driver->devs, devices,
                                      virConnectListAllNodeDevicesCheckACL,
                                      flags);
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
     return ret;
 }
 
 virNodeDevicePtr
 nodeDeviceLookupByName(virConnectPtr conn, const char *name)
 {
-    virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
     virNodeDeviceObjPtr obj;
     virNodeDevicePtr ret = NULL;
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     obj = virNodeDeviceFindByName(&driver->devs, name);
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     if (!obj) {
         virReportError(VIR_ERR_NO_NODE_DEVICE, NULL);
@@ -249,7 +247,6 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
                               unsigned int flags)
 {
     size_t i;
-    virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
     virNodeDeviceObjListPtr devs = &driver->devs;
     virNodeDevCapsDefPtr cap = NULL;
     virNodeDeviceObjPtr obj = NULL;
@@ -257,7 +254,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
 
     virCheckFlags(0, NULL);
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
 
     for (i = 0; i < devs->count; i++) {
         obj = devs->objs[i];
@@ -288,7 +285,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
     }
 
  out:
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
     return dev;
 }
 
@@ -297,15 +294,14 @@ char *
 nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
                      unsigned int flags)
 {
-    virNodeDeviceDriverStatePtr driver = dev->conn->nodeDevicePrivateData;
     virNodeDeviceObjPtr obj;
     char *ret = NULL;
 
     virCheckFlags(0, NULL);
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     obj = virNodeDeviceFindByName(&driver->devs, dev->name);
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     if (!obj) {
         virReportError(VIR_ERR_NO_NODE_DEVICE,
@@ -333,13 +329,12 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
 char *
 nodeDeviceGetParent(virNodeDevicePtr dev)
 {
-    virNodeDeviceDriverStatePtr driver = dev->conn->nodeDevicePrivateData;
     virNodeDeviceObjPtr obj;
     char *ret = NULL;
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     obj = virNodeDeviceFindByName(&driver->devs, dev->name);
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     if (!obj) {
         virReportError(VIR_ERR_NO_NODE_DEVICE,
@@ -369,15 +364,14 @@ nodeDeviceGetParent(virNodeDevicePtr dev)
 int
 nodeDeviceNumOfCaps(virNodeDevicePtr dev)
 {
-    virNodeDeviceDriverStatePtr driver = dev->conn->nodeDevicePrivateData;
     virNodeDeviceObjPtr obj;
     virNodeDevCapsDefPtr caps;
     int ncaps = 0;
     int ret = -1;
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     obj = virNodeDeviceFindByName(&driver->devs, dev->name);
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     if (!obj) {
         virReportError(VIR_ERR_NO_NODE_DEVICE,
@@ -403,15 +397,14 @@ nodeDeviceNumOfCaps(virNodeDevicePtr dev)
 int
 nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
 {
-    virNodeDeviceDriverStatePtr driver = dev->conn->nodeDevicePrivateData;
     virNodeDeviceObjPtr obj;
     virNodeDevCapsDefPtr caps;
     int ncaps = 0;
     int ret = -1;
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     obj = virNodeDeviceFindByName(&driver->devs, dev->name);
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     if (!obj) {
         virReportError(VIR_ERR_NO_NODE_DEVICE,
@@ -474,7 +467,6 @@ get_time(time_t *t)
 static virNodeDevicePtr
 find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
 {
-    virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
     virNodeDevicePtr dev = NULL;
     time_t start = 0, now = 0;
 
@@ -483,7 +475,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
      * We're not doing anything with the driver pointer at this point,
      * so it's safe to release it, assuming that the pointer itself
      * doesn't become invalid.  */
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     get_time(&start);
 
@@ -501,7 +493,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
             break;
     }
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
 
     return dev;
 }
@@ -511,7 +503,6 @@ nodeDeviceCreateXML(virConnectPtr conn,
                     const char *xmlDesc,
                     unsigned int flags)
 {
-    virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
     virNodeDeviceDefPtr def = NULL;
     char *wwnn = NULL, *wwpn = NULL;
     int parent_host = -1;
@@ -521,7 +512,7 @@ nodeDeviceCreateXML(virConnectPtr conn,
     virCheckFlags(0, NULL);
     virt_type  = virConnectGetType(conn);
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
 
     def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE, virt_type);
     if (def == NULL)
@@ -555,7 +546,7 @@ nodeDeviceCreateXML(virConnectPtr conn,
         virReportError(VIR_ERR_NO_NODE_DEVICE, NULL);
 
  cleanup:
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
     virNodeDeviceDefFree(def);
     VIR_FREE(wwnn);
     VIR_FREE(wwpn);
@@ -567,14 +558,13 @@ int
 nodeDeviceDestroy(virNodeDevicePtr dev)
 {
     int ret = -1;
-    virNodeDeviceDriverStatePtr driver = dev->conn->nodeDevicePrivateData;
     virNodeDeviceObjPtr obj = NULL;
     char *parent_name = NULL, *wwnn = NULL, *wwpn = NULL;
     int parent_host = -1;
 
-    nodeDeviceLock(driver);
+    nodeDeviceLock();
     obj = virNodeDeviceFindByName(&driver->devs, dev->name);
-    nodeDeviceUnlock(driver);
+    nodeDeviceUnlock();
 
     if (!obj) {
         virReportError(VIR_ERR_NO_NODE_DEVICE, NULL);
diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h
index e238ff8..79583cd 100644
--- a/src/node_device/node_device_driver.h
+++ b/src/node_device/node_device_driver.h
@@ -37,8 +37,10 @@ int halNodeRegister(void);
 int udevNodeRegister(void);
 # endif
 
-void nodeDeviceLock(virNodeDeviceDriverStatePtr driver);
-void nodeDeviceUnlock(virNodeDeviceDriverStatePtr driver);
+void nodeDeviceLock(void);
+void nodeDeviceUnlock(void);
+
+extern virNodeDeviceDriverStatePtr driver;
 
 int nodedevRegister(void);
 
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index c32b1fe..2885bd3 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -49,12 +49,7 @@ VIR_LOG_INIT("node_device.node_device_hal");
  * Host device enumeration (HAL implementation)
  */
 
-static virNodeDeviceDriverStatePtr driverState;
-
-#define CONN_DRV_STATE(conn) \
-        ((virNodeDeviceDriverStatePtr)((conn)->nodeDevicePrivateData))
 #define DRV_STATE_HAL_CTX(ds) ((LibHalContext *)((ds)->privateData))
-#define CONN_HAL_CTX(conn) DRV_STATE_HAL_CTX(CONN_DRV_STATE(conn))
 
 #define NODE_DEV_UDI(obj) ((const char *)((obj)->privateData)
 
@@ -481,8 +476,8 @@ dev_create(const char *udi)
     if (VIR_STRDUP(privData, udi) < 0)
         return;
 
-    nodeDeviceLock(driverState);
-    ctx = DRV_STATE_HAL_CTX(driverState);
+    nodeDeviceLock();
+    ctx = DRV_STATE_HAL_CTX(driver);
 
     if (VIR_ALLOC(def) < 0)
         goto failure;
@@ -507,7 +502,7 @@ dev_create(const char *udi)
     /* Some devices don't have a path in sysfs, so ignore failure */
     (void)get_str_prop(ctx, udi, "linux.sysfs_path", &devicePath);
 
-    dev = virNodeDeviceAssignDef(&driverState->devs,
+    dev = virNodeDeviceAssignDef(&driver->devs,
                                  def);
 
     if (!dev) {
@@ -521,7 +516,7 @@ dev_create(const char *udi)
 
     virNodeDeviceObjUnlock(dev);
 
-    nodeDeviceUnlock(driverState);
+    nodeDeviceUnlock();
     return;
 
  failure:
@@ -529,7 +524,7 @@ dev_create(const char *udi)
  cleanup:
     VIR_FREE(privData);
     virNodeDeviceDefFree(def);
-    nodeDeviceUnlock(driverState);
+    nodeDeviceUnlock();
 }
 
 static void
@@ -538,17 +533,17 @@ dev_refresh(const char *udi)
     const char *name = hal_name(udi);
     virNodeDeviceObjPtr dev;
 
-    nodeDeviceLock(driverState);
-    dev = virNodeDeviceFindByName(&driverState->devs, name);
+    nodeDeviceLock();
+    dev = virNodeDeviceFindByName(&driver->devs, name);
     if (dev) {
         /* Simply "rediscover" device -- incrementally handling changes
          * to sub-capabilities (like net.80203) is nasty ... so avoid it.
          */
-        virNodeDeviceObjRemove(&driverState->devs, dev);
+        virNodeDeviceObjRemove(&driver->devs, dev);
     } else {
         VIR_DEBUG("no device named %s", name);
     }
-    nodeDeviceUnlock(driverState);
+    nodeDeviceUnlock();
 
     if (dev)
         dev_create(udi);
@@ -570,14 +565,14 @@ device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED,
     const char *name = hal_name(udi);
     virNodeDeviceObjPtr dev;
 
-    nodeDeviceLock(driverState);
-    dev = virNodeDeviceFindByName(&driverState->devs, name);
+    nodeDeviceLock();
+    dev = virNodeDeviceFindByName(&driver->devs, name);
     VIR_DEBUG("%s", name);
     if (dev)
-        virNodeDeviceObjRemove(&driverState->devs, dev);
+        virNodeDeviceObjRemove(&driver->devs, dev);
     else
         VIR_DEBUG("no device named %s", name);
-    nodeDeviceUnlock(driverState);
+    nodeDeviceUnlock();
 }
 
 
@@ -588,9 +583,9 @@ device_cap_added(LibHalContext *ctx,
     const char *name = hal_name(udi);
     virNodeDeviceObjPtr dev;
 
-    nodeDeviceLock(driverState);
-    dev = virNodeDeviceFindByName(&driverState->devs, name);
-    nodeDeviceUnlock(driverState);
+    nodeDeviceLock();
+    dev = virNodeDeviceFindByName(&driver->devs, name);
+    nodeDeviceUnlock();
     VIR_DEBUG("%s %s", cap, name);
     if (dev) {
         (void)gather_capability(ctx, udi, cap, &dev->def->caps);
@@ -644,14 +639,14 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
     qsort(caps_tbl, ARRAY_CARDINALITY(caps_tbl), sizeof(caps_tbl[0]),
           cmpstringp);
 
-    if (VIR_ALLOC(driverState) < 0)
+    if (VIR_ALLOC(driver) < 0)
         return -1;
 
-    if (virMutexInit(&driverState->lock) < 0) {
-        VIR_FREE(driverState);
+    if (virMutexInit(&driver->lock) < 0) {
+        VIR_FREE(driver);
         return -1;
     }
-    nodeDeviceLock(driverState);
+    nodeDeviceLock();
 
     dbus_error_init(&err);
     if (!(sysbus = virDBusGetSystemBus())) {
@@ -682,14 +677,14 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
     }
 
     /* Populate with known devices */
-    driverState->privateData = hal_ctx;
+    driver->privateData = hal_ctx;
 
     /* We need to unlock state now, since setting these callbacks cause
      * a dbus RPC call, and while this call is waiting for the reply,
      * a signal may already arrive, triggering the callback and thus
      * requiring the lock !
      */
-    nodeDeviceUnlock(driverState);
+    nodeDeviceUnlock();
 
     /* Register HAL event callbacks */
     if (!libhal_ctx_set_device_added(hal_ctx, device_added) ||
@@ -720,11 +715,11 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
         VIR_ERROR(_("%s: %s"), err.name, err.message);
         dbus_error_free(&err);
     }
-    virNodeDeviceObjListFree(&driverState->devs);
+    virNodeDeviceObjListFree(&driver->devs);
     if (hal_ctx)
         (void)libhal_ctx_free(hal_ctx);
-    nodeDeviceUnlock(driverState);
-    VIR_FREE(driverState);
+    nodeDeviceUnlock();
+    VIR_FREE(driver);
 
     return ret;
 }
@@ -733,15 +728,15 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
 static int
 nodeStateCleanup(void)
 {
-    if (driverState) {
-        nodeDeviceLock(driverState);
-        LibHalContext *hal_ctx = DRV_STATE_HAL_CTX(driverState);
-        virNodeDeviceObjListFree(&driverState->devs);
+    if (driver) {
+        nodeDeviceLock();
+        LibHalContext *hal_ctx = DRV_STATE_HAL_CTX(driver);
+        virNodeDeviceObjListFree(&driver->devs);
         (void)libhal_ctx_shutdown(hal_ctx, NULL);
         (void)libhal_ctx_free(hal_ctx);
-        nodeDeviceUnlock(driverState);
-        virMutexDestroy(&driverState->lock);
-        VIR_FREE(driverState);
+        nodeDeviceUnlock();
+        virMutexDestroy(&driver->lock);
+        VIR_FREE(driver);
         return 0;
     }
     return -1;
@@ -758,12 +753,12 @@ nodeStateReload(void)
     LibHalContext *hal_ctx;
 
     VIR_INFO("Reloading HAL device state");
-    nodeDeviceLock(driverState);
+    nodeDeviceLock();
     VIR_INFO("Removing existing objects");
-    virNodeDeviceObjListFree(&driverState->devs);
-    nodeDeviceUnlock(driverState);
+    virNodeDeviceObjListFree(&driver->devs);
+    nodeDeviceUnlock();
 
-    hal_ctx = DRV_STATE_HAL_CTX(driverState);
+    hal_ctx = DRV_STATE_HAL_CTX(driver);
     VIR_INFO("Creating new objects");
     dbus_error_init(&err);
     udi = libhal_get_all_devices(hal_ctx, &num_devs, &err);
@@ -783,24 +778,21 @@ nodeStateReload(void)
 
 
 static virDrvOpenStatus
-nodeDeviceOpen(virConnectPtr conn,
+nodeDeviceOpen(virConnectPtr conn ATTRIBUTE_UNUSED,
                virConnectAuthPtr auth ATTRIBUTE_UNUSED,
                unsigned int flags)
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (driverState == NULL)
+    if (driver == NULL)
         return VIR_DRV_OPEN_DECLINED;
 
-    conn->nodeDevicePrivateData = driverState;
-
     return VIR_DRV_OPEN_SUCCESS;
 }
 
 static int
 nodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED)
 {
-    conn->nodeDevicePrivateData = NULL;
     return 0;
 }
 
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 1a35c07..115a92b 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -56,8 +56,6 @@ struct _udevPrivate {
     bool privileged;
 };
 
-static virNodeDeviceDriverStatePtr driverState;
-
 static int udevStrToLong_ull(char const *s,
                              char **end_ptr,
                              int base,
@@ -419,7 +417,7 @@ static int udevProcessPCI(struct udev_device *device,
     virPCIDeviceAddress addr;
     virPCIEDeviceInfoPtr pci_express = NULL;
     virPCIDevicePtr pciDev = NULL;
-    udevPrivate *priv = driverState->privateData;
+    udevPrivate *priv = driver->privateData;
     int tmpGroup, ret = -1;
     char *p;
     int rc;
@@ -1330,12 +1328,12 @@ static int udevRemoveOneDevice(struct udev_device *device)
     int ret = 0;
 
     name = udev_device_get_syspath(device);
-    dev = virNodeDeviceFindBySysfsPath(&driverState->devs, name);
+    dev = virNodeDeviceFindBySysfsPath(&driver->devs, name);
 
     if (dev != NULL) {
         VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
                   dev->def->name, name);
-        virNodeDeviceObjRemove(&driverState->devs, dev);
+        virNodeDeviceObjRemove(&driver->devs, dev);
     } else {
         VIR_DEBUG("Failed to find device to remove that has udev name '%s'",
                   name);
@@ -1369,7 +1367,7 @@ static int udevSetParent(struct udev_device *device,
             goto out;
         }
 
-        dev = virNodeDeviceFindBySysfsPath(&driverState->devs,
+        dev = virNodeDeviceFindBySysfsPath(&driver->devs,
                                            parent_sysfs_path);
         if (dev != NULL) {
             if (VIR_STRDUP(def->parent, dev->def->name) < 0) {
@@ -1426,7 +1424,7 @@ static int udevAddOneDevice(struct udev_device *device)
 
     /* If this is a device change, the old definition will be freed
      * and the current definition will take its place. */
-    dev = virNodeDeviceAssignDef(&driverState->devs, def);
+    dev = virNodeDeviceAssignDef(&driver->devs, def);
 
     if (dev == NULL) {
         VIR_ERROR(_("Failed to create device for '%s'"), def->name);
@@ -1507,15 +1505,15 @@ static int nodeStateCleanup(void)
     struct udev_monitor *udev_monitor = NULL;
     struct udev *udev = NULL;
 
-    if (driverState) {
-        nodeDeviceLock(driverState);
+    if (driver) {
+        nodeDeviceLock();
 
-        priv = driverState->privateData;
+        priv = driver->privateData;
 
         if (priv->watch != -1)
             virEventRemoveHandle(priv->watch);
 
-        udev_monitor = DRV_STATE_UDEV_MONITOR(driverState);
+        udev_monitor = DRV_STATE_UDEV_MONITOR(driver);
 
         if (udev_monitor != NULL) {
             udev = udev_monitor_get_udev(udev_monitor);
@@ -1525,10 +1523,10 @@ static int nodeStateCleanup(void)
         if (udev != NULL)
             udev_unref(udev);
 
-        virNodeDeviceObjListFree(&driverState->devs);
-        nodeDeviceUnlock(driverState);
-        virMutexDestroy(&driverState->lock);
-        VIR_FREE(driverState);
+        virNodeDeviceObjListFree(&driver->devs);
+        nodeDeviceUnlock();
+        virMutexDestroy(&driver->lock);
+        VIR_FREE(driver);
         VIR_FREE(priv);
     } else {
         ret = -1;
@@ -1551,11 +1549,11 @@ static void udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
                                     void *data ATTRIBUTE_UNUSED)
 {
     struct udev_device *device = NULL;
-    struct udev_monitor *udev_monitor = DRV_STATE_UDEV_MONITOR(driverState);
+    struct udev_monitor *udev_monitor = DRV_STATE_UDEV_MONITOR(driver);
     const char *action = NULL;
     int udev_fd = -1;
 
-    nodeDeviceLock(driverState);
+    nodeDeviceLock();
     udev_fd = udev_monitor_get_fd(udev_monitor);
     if (fd != udev_fd) {
         VIR_ERROR(_("File descriptor returned by udev %d does not "
@@ -1584,7 +1582,7 @@ static void udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
 
  out:
     udev_device_unref(device);
-    nodeDeviceUnlock(driverState);
+    nodeDeviceUnlock();
     return;
 }
 
@@ -1598,7 +1596,7 @@ udevGetDMIData(union _virNodeDevCapData *data)
     struct udev_device *device = NULL;
     char *tmp = NULL;
 
-    udev = udev_monitor_get_udev(DRV_STATE_UDEV_MONITOR(driverState));
+    udev = udev_monitor_get_udev(DRV_STATE_UDEV_MONITOR(driver));
 
     device = udev_device_new_from_syspath(udev, DMI_DEVPATH);
     if (device == NULL) {
@@ -1684,7 +1682,7 @@ static int udevSetupSystemDev(void)
     udevGetDMIData(&def->caps->data);
 #endif
 
-    dev = virNodeDeviceAssignDef(&driverState->devs, def);
+    dev = virNodeDeviceAssignDef(&driver->devs, def);
     if (dev == NULL) {
         VIR_ERROR(_("Failed to create device for '%s'"), def->name);
         goto out;
@@ -1737,21 +1735,21 @@ static int nodeStateInitialize(bool privileged,
     priv->watch = -1;
     priv->privileged = privileged;
 
-    if (VIR_ALLOC(driverState) < 0) {
+    if (VIR_ALLOC(driver) < 0) {
         VIR_FREE(priv);
         ret = -1;
         goto out;
     }
 
-    if (virMutexInit(&driverState->lock) < 0) {
-        VIR_ERROR(_("Failed to initialize mutex for driverState"));
+    if (virMutexInit(&driver->lock) < 0) {
+        VIR_ERROR(_("Failed to initialize mutex for driver"));
         VIR_FREE(priv);
-        VIR_FREE(driverState);
+        VIR_FREE(driver);
         ret = -1;
         goto out;
     }
 
-    nodeDeviceLock(driverState);
+    nodeDeviceLock();
 
     /*
      * http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev.html#udev-new
@@ -1776,7 +1774,7 @@ static int nodeStateInitialize(bool privileged,
     udev_monitor_enable_receiving(priv->udev_monitor);
 
     /* udev can be retrieved from udev_monitor */
-    driverState->privateData = priv;
+    driver->privateData = priv;
 
     /* We register the monitor with the event callback so we are
      * notified by udev of device changes before we enumerate existing
@@ -1808,7 +1806,7 @@ static int nodeStateInitialize(bool privileged,
     }
 
  out_unlock:
-    nodeDeviceUnlock(driverState);
+    nodeDeviceUnlock();
 
  out:
     if (ret == -1)
@@ -1823,23 +1821,20 @@ static int nodeStateReload(void)
 }
 
 
-static virDrvOpenStatus nodeDeviceOpen(virConnectPtr conn,
+static virDrvOpenStatus nodeDeviceOpen(virConnectPtr conn ATTRIBUTE_UNUSED,
                                        virConnectAuthPtr auth ATTRIBUTE_UNUSED,
                                        unsigned int flags)
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
-    if (driverState == NULL)
+    if (driver == NULL)
         return VIR_DRV_OPEN_DECLINED;
 
-    conn->nodeDevicePrivateData = driverState;
-
     return VIR_DRV_OPEN_SUCCESS;
 }
 
-static int nodeDeviceClose(virConnectPtr conn)
+static int nodeDeviceClose(virConnectPtr conn ATTRIBUTE_UNUSED)
 {
-    conn->nodeDevicePrivateData = NULL;
     return 0;
 }
 
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]