static void dev_refresh(const char *udi) { const char *name = hal_name(udi); virNodeDeviceObjPtr dev; nodeDeviceLock(driverState); dev = virNodeDeviceFindByName(&driverState->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); } else VIR_DEBUG("no device named %s", name); nodeDeviceUnlock(driverState); if (dev) { dev_create(udi); } }
static void dev_create(const char *udi) { LibHalContext *ctx; char *parent_key = NULL; virNodeDeviceObjPtr dev = NULL; virNodeDeviceDefPtr def = NULL; const char *name = hal_name(udi); int rv; char *privData; char *devicePath = NULL; if (VIR_STRDUP(privData, udi) < 0) return; nodeDeviceLock(driverState); ctx = DRV_STATE_HAL_CTX(driverState); if (VIR_ALLOC(def) < 0) goto failure; if (VIR_STRDUP(def->name, name) < 0) goto failure; if (get_str_prop(ctx, udi, "info.parent", &parent_key) == 0) { if (VIR_STRDUP(def->parent, hal_name(parent_key)) < 0) { VIR_FREE(parent_key); goto failure; } VIR_FREE(parent_key); } rv = gather_capabilities(ctx, udi, &def->caps); if (rv != 0) goto failure; if (def->caps == NULL) goto cleanup; /* 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, def); if (!dev) { VIR_FREE(devicePath); goto failure; } dev->privateData = privData; dev->privateFree = free_udi; dev->def->sysfs_path = devicePath; virNodeDeviceObjUnlock(dev); nodeDeviceUnlock(driverState); return; failure: VIR_DEBUG("FAILED TO ADD dev %s", name); cleanup: VIR_FREE(privData); virNodeDeviceDefFree(def); nodeDeviceUnlock(driverState); }
*/ virNodeDeviceObjRemove(&driverState->devs, dev); } else VIR_DEBUG("no device named %s", name); nodeDeviceUnlock(driverState); if (dev) { dev_create(udi); } } static void device_added(LibHalContext *ctx ATTRIBUTE_UNUSED, const char *udi) { VIR_DEBUG("%s", hal_name(udi)); dev_create(udi); } static void device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED, const char *udi) { const char *name = hal_name(udi); virNodeDeviceObjPtr dev; nodeDeviceLock(driverState); dev = virNodeDeviceFindByName(&driverState->devs, name); VIR_DEBUG("%s", name); if (dev)