/** * virIdentityGetCurrent: * * Get the current identity associated with this thread. The * caller will own a reference to the returned identity, but * must not modify the object in any way, other than to * release the reference when done with virObjectUnref * * Returns: a reference to the current identity, or NULL */ virIdentityPtr virIdentityGetCurrent(void) { virIdentityPtr ident; if (virIdentityInitialize() < 0) return NULL; ident = virThreadLocalGet(&virIdentityCurrent); return virObjectRef(ident); }
/** * virIdentityNew: * * Creates a new empty identity object. After creating, one or * more identifying attributes should be set on the identity. * * Returns: a new empty identity */ virIdentityPtr virIdentityNew(void) { virIdentityPtr ident; if (virIdentityInitialize() < 0) return NULL; if (!(ident = virObjectNew(virIdentityClass))) return NULL; return ident; }
/** * virIdentitySetCurrent: * * Set the new identity to be associated with this thread. * The caller should not modify the passed identity after * it has been set, other than to release its own reference. * * Returns 0 on success, or -1 on error */ int virIdentitySetCurrent(virIdentityPtr ident) { virIdentityPtr old; if (virIdentityInitialize() < 0) return -1; old = virThreadLocalGet(&virIdentityCurrent); virObjectUnref(old); if (virThreadLocalSet(&virIdentityCurrent, virObjectRef(ident)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to set thread local identity")); return -1; } return 0; }