mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
nodedev: Convert virNodeDeviceObj to use virObjectLockable
Now that we have a bit more control, let's convert our object into a lockable object and let that magic handle the create and lock/unlock. This also involves creating a virNodeDeviceEndAPI in order to handle the object cleanup for API's that use the Add or Find API's in order to get a locked/reffed object. The EndAPI will unlock and unref the object returning NULL to indicate to the caller to not use the obj. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
960d665c1e
commit
dae23ec345
@ -33,7 +33,7 @@
|
|||||||
VIR_LOG_INIT("conf.virnodedeviceobj");
|
VIR_LOG_INIT("conf.virnodedeviceobj");
|
||||||
|
|
||||||
struct _virNodeDeviceObj {
|
struct _virNodeDeviceObj {
|
||||||
virMutex lock;
|
virObjectLockable parent;
|
||||||
|
|
||||||
virNodeDeviceDefPtr def; /* device definition */
|
virNodeDeviceDefPtr def; /* device definition */
|
||||||
};
|
};
|
||||||
@ -44,26 +44,62 @@ struct _virNodeDeviceObjList {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static virClassPtr virNodeDeviceObjClass;
|
||||||
|
static void virNodeDeviceObjDispose(void *opaque);
|
||||||
|
|
||||||
|
static int
|
||||||
|
virNodeDeviceObjOnceInit(void)
|
||||||
|
{
|
||||||
|
if (!(virNodeDeviceObjClass = virClassNew(virClassForObjectLockable(),
|
||||||
|
"virNodeDeviceObj",
|
||||||
|
sizeof(virNodeDeviceObj),
|
||||||
|
virNodeDeviceObjDispose)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_ONCE_GLOBAL_INIT(virNodeDeviceObj)
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virNodeDeviceObjDispose(void *opaque)
|
||||||
|
{
|
||||||
|
virNodeDeviceObjPtr obj = opaque;
|
||||||
|
|
||||||
|
virNodeDeviceDefFree(obj->def);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virNodeDeviceObjPtr
|
static virNodeDeviceObjPtr
|
||||||
virNodeDeviceObjNew(void)
|
virNodeDeviceObjNew(void)
|
||||||
{
|
{
|
||||||
virNodeDeviceObjPtr obj;
|
virNodeDeviceObjPtr obj;
|
||||||
|
|
||||||
if (VIR_ALLOC(obj) < 0)
|
if (virNodeDeviceObjInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virMutexInit(&obj->lock) < 0) {
|
if (!(obj = virObjectLockableNew(virNodeDeviceObjClass)))
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
"%s", _("cannot initialize mutex"));
|
|
||||||
VIR_FREE(obj);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virNodeDeviceObjEndAPI(virNodeDeviceObjPtr *obj)
|
||||||
|
{
|
||||||
|
if (!*obj)
|
||||||
|
return;
|
||||||
|
|
||||||
|
virObjectUnlock(*obj);
|
||||||
|
virObjectUnref(*obj);
|
||||||
|
*obj = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virNodeDeviceDefPtr
|
virNodeDeviceDefPtr
|
||||||
virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj)
|
virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj)
|
||||||
{
|
{
|
||||||
@ -185,13 +221,13 @@ virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
|
|||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDeviceDefPtr def;
|
virNodeDeviceDefPtr def;
|
||||||
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
def = obj->def;
|
def = obj->def;
|
||||||
if ((def->sysfs_path != NULL) &&
|
if ((def->sysfs_path != NULL) &&
|
||||||
(STREQ(def->sysfs_path, sysfs_path))) {
|
(STREQ(def->sysfs_path, sysfs_path))) {
|
||||||
return obj;
|
return virObjectRef(obj);
|
||||||
}
|
}
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -208,11 +244,11 @@ virNodeDeviceObjListFindByName(virNodeDeviceObjListPtr devs,
|
|||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDeviceDefPtr def;
|
virNodeDeviceDefPtr def;
|
||||||
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
def = obj->def;
|
def = obj->def;
|
||||||
if (STREQ(def->name, name))
|
if (STREQ(def->name, name))
|
||||||
return obj;
|
return virObjectRef(obj);
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -230,13 +266,13 @@ virNodeDeviceObjListFindByWWNs(virNodeDeviceObjListPtr devs,
|
|||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDevCapsDefPtr cap;
|
virNodeDevCapsDefPtr cap;
|
||||||
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
if ((cap = virNodeDeviceFindFCCapDef(obj)) &&
|
if ((cap = virNodeDeviceFindFCCapDef(obj)) &&
|
||||||
STREQ_NULLABLE(cap->data.scsi_host.wwnn, parent_wwnn) &&
|
STREQ_NULLABLE(cap->data.scsi_host.wwnn, parent_wwnn) &&
|
||||||
STREQ_NULLABLE(cap->data.scsi_host.wwpn, parent_wwpn) &&
|
STREQ_NULLABLE(cap->data.scsi_host.wwpn, parent_wwpn) &&
|
||||||
virNodeDeviceFindVPORTCapDef(obj))
|
virNodeDeviceFindVPORTCapDef(obj))
|
||||||
return obj;
|
return virObjectRef(obj);
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -253,12 +289,12 @@ virNodeDeviceObjListFindByFabricWWN(virNodeDeviceObjListPtr devs,
|
|||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDevCapsDefPtr cap;
|
virNodeDevCapsDefPtr cap;
|
||||||
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
if ((cap = virNodeDeviceFindFCCapDef(obj)) &&
|
if ((cap = virNodeDeviceFindFCCapDef(obj)) &&
|
||||||
STREQ_NULLABLE(cap->data.scsi_host.fabric_wwn, parent_fabric_wwn) &&
|
STREQ_NULLABLE(cap->data.scsi_host.fabric_wwn, parent_fabric_wwn) &&
|
||||||
virNodeDeviceFindVPORTCapDef(obj))
|
virNodeDeviceFindVPORTCapDef(obj))
|
||||||
return obj;
|
return virObjectRef(obj);
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -274,10 +310,10 @@ virNodeDeviceObjListFindByCap(virNodeDeviceObjListPtr devs,
|
|||||||
for (i = 0; i < devs->count; i++) {
|
for (i = 0; i < devs->count; i++) {
|
||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
if (virNodeDeviceObjHasCap(obj, cap))
|
if (virNodeDeviceObjHasCap(obj, cap))
|
||||||
return obj;
|
return virObjectRef(obj);
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -295,7 +331,7 @@ virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceObjListPtr devs,
|
|||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDevCapsDefPtr cap;
|
virNodeDevCapsDefPtr cap;
|
||||||
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
cap = obj->def->caps;
|
cap = obj->def->caps;
|
||||||
|
|
||||||
while (cap) {
|
while (cap) {
|
||||||
@ -305,32 +341,18 @@ virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceObjListPtr devs,
|
|||||||
VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
|
VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
|
||||||
if (STREQ(cap->data.scsi_host.wwnn, wwnn) &&
|
if (STREQ(cap->data.scsi_host.wwnn, wwnn) &&
|
||||||
STREQ(cap->data.scsi_host.wwpn, wwpn))
|
STREQ(cap->data.scsi_host.wwpn, wwpn))
|
||||||
return obj;
|
return virObjectRef(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cap = cap->next;
|
cap = cap->next;
|
||||||
}
|
}
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
virNodeDeviceObjFree(virNodeDeviceObjPtr obj)
|
|
||||||
{
|
|
||||||
if (!obj)
|
|
||||||
return;
|
|
||||||
|
|
||||||
virNodeDeviceDefFree(obj->def);
|
|
||||||
|
|
||||||
virMutexDestroy(&obj->lock);
|
|
||||||
|
|
||||||
VIR_FREE(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virNodeDeviceObjListPtr
|
virNodeDeviceObjListPtr
|
||||||
virNodeDeviceObjListNew(void)
|
virNodeDeviceObjListNew(void)
|
||||||
{
|
{
|
||||||
@ -347,7 +369,7 @@ virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < devs->count; i++)
|
for (i = 0; i < devs->count; i++)
|
||||||
virNodeDeviceObjFree(devs->objs[i]);
|
virObjectUnref(devs->objs[i]);
|
||||||
VIR_FREE(devs->objs);
|
VIR_FREE(devs->objs);
|
||||||
VIR_FREE(devs);
|
VIR_FREE(devs);
|
||||||
}
|
}
|
||||||
@ -369,13 +391,12 @@ virNodeDeviceObjListAssignDef(virNodeDeviceObjListPtr devs,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_APPEND_ELEMENT_COPY(devs->objs, devs->count, obj) < 0) {
|
if (VIR_APPEND_ELEMENT_COPY(devs->objs, devs->count, obj) < 0) {
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
virNodeDeviceObjFree(obj);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
obj->def = def;
|
obj->def = def;
|
||||||
|
|
||||||
return obj;
|
return virObjectRef(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -385,17 +406,18 @@ virNodeDeviceObjListRemove(virNodeDeviceObjListPtr devs,
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
|
|
||||||
for (i = 0; i < devs->count; i++) {
|
for (i = 0; i < devs->count; i++) {
|
||||||
virNodeDeviceObjLock(devs->objs[i]);
|
virObjectLock(devs->objs[i]);
|
||||||
if (devs->objs[i] == obj) {
|
if (devs->objs[i] == obj) {
|
||||||
virNodeDeviceObjUnlock(devs->objs[i]);
|
virObjectUnlock(devs->objs[i]);
|
||||||
|
virObjectUnref(devs->objs[i]);
|
||||||
|
|
||||||
VIR_DELETE_ELEMENT(devs->objs, i, devs->count);
|
VIR_DELETE_ELEMENT(devs->objs, i, devs->count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
virNodeDeviceObjUnlock(devs->objs[i]);
|
virObjectUnlock(devs->objs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +468,7 @@ virNodeDeviceObjListGetParentHostByParent(virNodeDeviceObjListPtr devs,
|
|||||||
|
|
||||||
ret = virNodeDeviceFindFCParentHost(obj);
|
ret = virNodeDeviceFindFCParentHost(obj);
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -471,7 +493,7 @@ virNodeDeviceObjListGetParentHostByWWNs(virNodeDeviceObjListPtr devs,
|
|||||||
|
|
||||||
ret = virNodeDeviceFindFCParentHost(obj);
|
ret = virNodeDeviceFindFCParentHost(obj);
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -494,7 +516,7 @@ virNodeDeviceObjListGetParentHostByFabricWWN(virNodeDeviceObjListPtr devs,
|
|||||||
|
|
||||||
ret = virNodeDeviceFindFCParentHost(obj);
|
ret = virNodeDeviceFindFCParentHost(obj);
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -515,7 +537,7 @@ virNodeDeviceObjListFindVportParentHost(virNodeDeviceObjListPtr devs)
|
|||||||
|
|
||||||
ret = virNodeDeviceFindFCParentHost(obj);
|
ret = virNodeDeviceFindFCParentHost(obj);
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -548,20 +570,6 @@ virNodeDeviceObjListGetParentHost(virNodeDeviceObjListPtr devs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
virNodeDeviceObjLock(virNodeDeviceObjPtr obj)
|
|
||||||
{
|
|
||||||
virMutexLock(&obj->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj)
|
|
||||||
{
|
|
||||||
virMutexUnlock(&obj->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
virNodeDeviceCapMatch(virNodeDeviceObjPtr obj,
|
virNodeDeviceCapMatch(virNodeDeviceObjPtr obj,
|
||||||
int type)
|
int type)
|
||||||
@ -623,11 +631,11 @@ virNodeDeviceObjListNumOfDevices(virNodeDeviceObjListPtr devs,
|
|||||||
|
|
||||||
for (i = 0; i < devs->count; i++) {
|
for (i = 0; i < devs->count; i++) {
|
||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
if ((!aclfilter || aclfilter(conn, obj->def)) &&
|
if ((!aclfilter || aclfilter(conn, obj->def)) &&
|
||||||
(!cap || virNodeDeviceObjHasCap(obj, cap)))
|
(!cap || virNodeDeviceObjHasCap(obj, cap)))
|
||||||
++ndevs;
|
++ndevs;
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ndevs;
|
return ndevs;
|
||||||
@ -647,16 +655,16 @@ virNodeDeviceObjListGetNames(virNodeDeviceObjListPtr devs,
|
|||||||
|
|
||||||
for (i = 0; i < devs->count && nnames < maxnames; i++) {
|
for (i = 0; i < devs->count && nnames < maxnames; i++) {
|
||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
if ((!aclfilter || aclfilter(conn, obj->def)) &&
|
if ((!aclfilter || aclfilter(conn, obj->def)) &&
|
||||||
(!cap || virNodeDeviceObjHasCap(obj, cap))) {
|
(!cap || virNodeDeviceObjHasCap(obj, cap))) {
|
||||||
if (VIR_STRDUP(names[nnames], obj->def->name) < 0) {
|
if (VIR_STRDUP(names[nnames], obj->def->name) < 0) {
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
nnames++;
|
nnames++;
|
||||||
}
|
}
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nnames;
|
return nnames;
|
||||||
@ -718,21 +726,21 @@ virNodeDeviceObjListExport(virConnectPtr conn,
|
|||||||
|
|
||||||
for (i = 0; i < devs->count; i++) {
|
for (i = 0; i < devs->count; i++) {
|
||||||
virNodeDeviceObjPtr obj = devs->objs[i];
|
virNodeDeviceObjPtr obj = devs->objs[i];
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
if ((!aclfilter || aclfilter(conn, obj->def)) &&
|
if ((!aclfilter || aclfilter(conn, obj->def)) &&
|
||||||
virNodeDeviceMatch(obj, flags)) {
|
virNodeDeviceMatch(obj, flags)) {
|
||||||
if (devices) {
|
if (devices) {
|
||||||
if (!(device = virGetNodeDevice(conn, obj->def->name)) ||
|
if (!(device = virGetNodeDevice(conn, obj->def->name)) ||
|
||||||
VIR_STRDUP(device->parent, obj->def->parent) < 0) {
|
VIR_STRDUP(device->parent, obj->def->parent) < 0) {
|
||||||
virObjectUnref(device);
|
virObjectUnref(device);
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
tmp_devices[ndevices] = device;
|
tmp_devices[ndevices] = device;
|
||||||
}
|
}
|
||||||
ndevices++;
|
ndevices++;
|
||||||
}
|
}
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp_devices) {
|
if (tmp_devices) {
|
||||||
|
@ -45,6 +45,8 @@ struct _virNodeDeviceDriverState {
|
|||||||
virObjectEventStatePtr nodeDeviceEventState;
|
virObjectEventStatePtr nodeDeviceEventState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
virNodeDeviceObjEndAPI(virNodeDeviceObjPtr *obj);
|
||||||
|
|
||||||
virNodeDeviceDefPtr
|
virNodeDeviceDefPtr
|
||||||
virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj);
|
virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj);
|
||||||
@ -76,21 +78,12 @@ virNodeDeviceObjListGetParentHost(virNodeDeviceObjListPtr devs,
|
|||||||
virNodeDeviceDefPtr def,
|
virNodeDeviceDefPtr def,
|
||||||
int create);
|
int create);
|
||||||
|
|
||||||
void
|
|
||||||
virNodeDeviceObjFree(virNodeDeviceObjPtr dev);
|
|
||||||
|
|
||||||
virNodeDeviceObjListPtr
|
virNodeDeviceObjListPtr
|
||||||
virNodeDeviceObjListNew(void);
|
virNodeDeviceObjListNew(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs);
|
virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs);
|
||||||
|
|
||||||
void
|
|
||||||
virNodeDeviceObjLock(virNodeDeviceObjPtr obj);
|
|
||||||
|
|
||||||
void
|
|
||||||
virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj);
|
|
||||||
|
|
||||||
typedef bool
|
typedef bool
|
||||||
(*virNodeDeviceObjListFilter)(virConnectPtr conn,
|
(*virNodeDeviceObjListFilter)(virConnectPtr conn,
|
||||||
virNodeDeviceDefPtr def);
|
virNodeDeviceDefPtr def);
|
||||||
|
@ -964,7 +964,7 @@ virNetworkObjUpdateAssignDef;
|
|||||||
|
|
||||||
|
|
||||||
# conf/virnodedeviceobj.h
|
# conf/virnodedeviceobj.h
|
||||||
virNodeDeviceObjFree;
|
virNodeDeviceObjEndAPI;
|
||||||
virNodeDeviceObjGetDef;
|
virNodeDeviceObjGetDef;
|
||||||
virNodeDeviceObjListAssignDef;
|
virNodeDeviceObjListAssignDef;
|
||||||
virNodeDeviceObjListExport;
|
virNodeDeviceObjListExport;
|
||||||
@ -977,8 +977,6 @@ virNodeDeviceObjListGetParentHost;
|
|||||||
virNodeDeviceObjListNew;
|
virNodeDeviceObjListNew;
|
||||||
virNodeDeviceObjListNumOfDevices;
|
virNodeDeviceObjListNumOfDevices;
|
||||||
virNodeDeviceObjListRemove;
|
virNodeDeviceObjListRemove;
|
||||||
virNodeDeviceObjLock;
|
|
||||||
virNodeDeviceObjUnlock;
|
|
||||||
|
|
||||||
|
|
||||||
# conf/virnwfilterobj.h
|
# conf/virnwfilterobj.h
|
||||||
|
@ -277,7 +277,7 @@ nodeDeviceLookupByName(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr device,
|
|||||||
ret = virNodeDeviceDefFormat(def);
|
ret = virNodeDeviceDefFormat(def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ nodeDeviceGetParent(virNodeDevicePtr device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ nodeDeviceNumOfCaps(virNodeDevicePtr device)
|
|||||||
ret = ncaps;
|
ret = ncaps;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ nodeDeviceListCaps(virNodeDevicePtr device,
|
|||||||
ret = ncaps;
|
ret = ncaps;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
--ncaps;
|
--ncaps;
|
||||||
while (--ncaps >= 0)
|
while (--ncaps >= 0)
|
||||||
@ -613,8 +613,7 @@ nodeDeviceDestroy(virNodeDevicePtr device)
|
|||||||
* to be taken, so grab the object def which will have the various
|
* to be taken, so grab the object def which will have the various
|
||||||
* fields used to search (name, parent, parent_wwnn, parent_wwpn,
|
* fields used to search (name, parent, parent_wwnn, parent_wwpn,
|
||||||
* or parent_fabric_wwn) and drop the object lock. */
|
* or parent_fabric_wwn) and drop the object lock. */
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
obj = NULL;
|
|
||||||
if ((parent_host = virNodeDeviceObjListGetParentHost(driver->devs, def,
|
if ((parent_host = virNodeDeviceObjListGetParentHost(driver->devs, def,
|
||||||
EXISTING_DEVICE)) < 0)
|
EXISTING_DEVICE)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -626,8 +625,7 @@ nodeDeviceDestroy(virNodeDevicePtr device)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
nodeDeviceUnlock();
|
nodeDeviceUnlock();
|
||||||
if (obj)
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
virNodeDeviceObjUnlock(obj);
|
|
||||||
VIR_FREE(wwnn);
|
VIR_FREE(wwnn);
|
||||||
VIR_FREE(wwpn);
|
VIR_FREE(wwpn);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -490,7 +490,7 @@ dev_create(const char *udi)
|
|||||||
|
|
||||||
objdef->sysfs_path = devicePath;
|
objdef->sysfs_path = devicePath;
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
nodeDeviceUnlock();
|
nodeDeviceUnlock();
|
||||||
return;
|
return;
|
||||||
@ -520,7 +520,7 @@ dev_refresh(const char *udi)
|
|||||||
nodeDeviceUnlock();
|
nodeDeviceUnlock();
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
virNodeDeviceObjFree(obj);
|
virObjectUnref(obj);
|
||||||
dev_create(udi);
|
dev_create(udi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,7 +549,7 @@ device_removed(LibHalContext *ctx ATTRIBUTE_UNUSED,
|
|||||||
else
|
else
|
||||||
VIR_DEBUG("no device named %s", name);
|
VIR_DEBUG("no device named %s", name);
|
||||||
nodeDeviceUnlock();
|
nodeDeviceUnlock();
|
||||||
virNodeDeviceObjFree(obj);
|
virObjectUnref(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -568,7 +568,7 @@ device_cap_added(LibHalContext *ctx,
|
|||||||
if (obj) {
|
if (obj) {
|
||||||
def = virNodeDeviceObjGetDef(obj);
|
def = virNodeDeviceObjGetDef(obj);
|
||||||
(void)gather_capability(ctx, udi, cap, &def->caps);
|
(void)gather_capability(ctx, udi, cap, &def->caps);
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
} else {
|
} else {
|
||||||
VIR_DEBUG("no device named %s", name);
|
VIR_DEBUG("no device named %s", name);
|
||||||
}
|
}
|
||||||
|
@ -1332,7 +1332,7 @@ udevRemoveOneDevice(struct udev_device *device)
|
|||||||
VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
|
VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
|
||||||
def->name, name);
|
def->name, name);
|
||||||
virNodeDeviceObjListRemove(driver->devs, obj);
|
virNodeDeviceObjListRemove(driver->devs, obj);
|
||||||
virNodeDeviceObjFree(obj);
|
virObjectUnref(obj);
|
||||||
|
|
||||||
if (event)
|
if (event)
|
||||||
virObjectEventStateQueue(driver->nodeDeviceEventState, event);
|
virObjectEventStateQueue(driver->nodeDeviceEventState, event);
|
||||||
@ -1369,10 +1369,10 @@ udevSetParent(struct udev_device *device,
|
|||||||
parent_sysfs_path))) {
|
parent_sysfs_path))) {
|
||||||
objdef = virNodeDeviceObjGetDef(obj);
|
objdef = virNodeDeviceObjGetDef(obj);
|
||||||
if (VIR_STRDUP(def->parent, objdef->name) < 0) {
|
if (VIR_STRDUP(def->parent, objdef->name) < 0) {
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
if (VIR_STRDUP(def->parent_sysfs_path, parent_sysfs_path) < 0)
|
if (VIR_STRDUP(def->parent_sysfs_path, parent_sysfs_path) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1425,7 +1425,7 @@ udevAddOneDevice(struct udev_device *device)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((obj = virNodeDeviceObjListFindByName(driver->devs, def->name))) {
|
if ((obj = virNodeDeviceObjListFindByName(driver->devs, def->name))) {
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
new_device = false;
|
new_device = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1442,7 +1442,7 @@ udevAddOneDevice(struct udev_device *device)
|
|||||||
else
|
else
|
||||||
event = virNodeDeviceEventUpdateNew(objdef->name);
|
event = virNodeDeviceEventUpdateNew(objdef->name);
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -1724,7 +1724,7 @@ udevSetupSystemDev(void)
|
|||||||
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
|
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -1177,7 +1177,7 @@ testParseNodedevs(testDriverPtr privconn,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -4361,7 +4361,7 @@ testCreateVport(testDriverPtr driver,
|
|||||||
* create the vHBA. In the long run the result is the same. */
|
* create the vHBA. In the long run the result is the same. */
|
||||||
if (!(obj = testNodeDeviceMockCreateVport(driver, wwnn, wwpn)))
|
if (!(obj = testNodeDeviceMockCreateVport(driver, wwnn, wwpn)))
|
||||||
return -1;
|
return -1;
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -4573,7 +4573,7 @@ testDestroyVport(testDriverPtr privconn,
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
virNodeDeviceObjListRemove(privconn->devs, obj);
|
virNodeDeviceObjListRemove(privconn->devs, obj);
|
||||||
virNodeDeviceObjFree(obj);
|
virObjectUnref(obj);
|
||||||
|
|
||||||
testObjectEventQueue(privconn, event);
|
testObjectEventQueue(privconn, event);
|
||||||
return 0;
|
return 0;
|
||||||
@ -5374,7 +5374,7 @@ testNodeDeviceLookupByName(virConnectPtr conn, const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5393,7 +5393,7 @@ testNodeDeviceGetXMLDesc(virNodeDevicePtr dev,
|
|||||||
|
|
||||||
ret = virNodeDeviceDefFormat(virNodeDeviceObjGetDef(obj));
|
ret = virNodeDeviceDefFormat(virNodeDeviceObjGetDef(obj));
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5416,7 +5416,7 @@ testNodeDeviceGetParent(virNodeDevicePtr dev)
|
|||||||
"%s", _("no parent for this device"));
|
"%s", _("no parent for this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5437,7 +5437,7 @@ testNodeDeviceNumOfCaps(virNodeDevicePtr dev)
|
|||||||
for (caps = def->caps; caps; caps = caps->next)
|
for (caps = def->caps; caps; caps = caps->next)
|
||||||
++ncaps;
|
++ncaps;
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ncaps;
|
return ncaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5462,13 +5462,13 @@ testNodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
|
|||||||
ncaps++;
|
ncaps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ncaps;
|
return ncaps;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
while (--ncaps >= 0)
|
while (--ncaps >= 0)
|
||||||
VIR_FREE(names[ncaps]);
|
VIR_FREE(names[ncaps]);
|
||||||
virNodeDeviceObjUnlock(obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5499,7 +5499,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = virNodeDeviceDefFormat(virNodeDeviceObjGetDef(objcopy));
|
xml = virNodeDeviceDefFormat(virNodeDeviceObjGetDef(objcopy));
|
||||||
virNodeDeviceObjUnlock(objcopy);
|
virNodeDeviceObjEndAPI(&objcopy);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -5603,8 +5603,7 @@ testNodeDeviceCreateXML(virConnectPtr conn,
|
|||||||
dev = NULL;
|
dev = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (obj)
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
virNodeDeviceObjUnlock(obj);
|
|
||||||
testDriverUnlock(driver);
|
testDriverUnlock(driver);
|
||||||
virNodeDeviceDefFree(def);
|
virNodeDeviceDefFree(def);
|
||||||
virObjectUnref(dev);
|
virObjectUnref(dev);
|
||||||
@ -5637,13 +5636,13 @@ testNodeDeviceDestroy(virNodeDevicePtr dev)
|
|||||||
* taken, so we have to dup the parent's name and drop the lock
|
* taken, so we have to dup the parent's name and drop the lock
|
||||||
* before calling it. We don't need the reference to the object
|
* before calling it. We don't need the reference to the object
|
||||||
* any more once we have the parent's name. */
|
* any more once we have the parent's name. */
|
||||||
virNodeDeviceObjUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
|
|
||||||
/* We do this just for basic validation, but also avoid finding a
|
/* We do this just for basic validation, but also avoid finding a
|
||||||
* vport capable HBA if for some reason our vHBA doesn't exist */
|
* vport capable HBA if for some reason our vHBA doesn't exist */
|
||||||
if (virNodeDeviceObjListGetParentHost(driver->devs, def,
|
if (virNodeDeviceObjListGetParentHost(driver->devs, def,
|
||||||
EXISTING_DEVICE) < 0) {
|
EXISTING_DEVICE) < 0) {
|
||||||
obj = NULL;
|
virObjectLock(obj);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5651,14 +5650,13 @@ testNodeDeviceDestroy(virNodeDevicePtr dev)
|
|||||||
VIR_NODE_DEVICE_EVENT_DELETED,
|
VIR_NODE_DEVICE_EVENT_DELETED,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
virNodeDeviceObjLock(obj);
|
virObjectLock(obj);
|
||||||
virNodeDeviceObjListRemove(driver->devs, obj);
|
virNodeDeviceObjListRemove(driver->devs, obj);
|
||||||
virNodeDeviceObjFree(obj);
|
virObjectUnref(obj);
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (obj)
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
virNodeDeviceObjUnlock(obj);
|
|
||||||
testObjectEventQueue(driver, event);
|
testObjectEventQueue(driver, event);
|
||||||
VIR_FREE(parent_name);
|
VIR_FREE(parent_name);
|
||||||
VIR_FREE(wwnn);
|
VIR_FREE(wwnn);
|
||||||
|
Loading…
Reference in New Issue
Block a user