*/
static virSecretObjPtr
virSecretObjListFindByUUIDLocked(virSecretObjListPtr secrets,
- const unsigned char *uuid)
+ const char *uuidstr)
{
- char uuidstr[VIR_UUID_STRING_BUFLEN];
-
- virUUIDFormat(uuid, uuidstr);
-
return virObjectRef(virHashLookup(secrets->objs, uuidstr));
}
/**
* virSecretObjFindByUUID:
* @secrets: list of secret objects
- * @uuid: secret uuid to find
+ * @uuidstr: secret uuid to find
*
* This function locks @secrets and finds the secret object which
* corresponds to @uuid.
*/
virSecretObjPtr
virSecretObjListFindByUUID(virSecretObjListPtr secrets,
- const unsigned char *uuid)
+ const char *uuidstr)
{
virSecretObjPtr obj;
virObjectLock(secrets);
- obj = virSecretObjListFindByUUIDLocked(secrets, uuid);
+ obj = virSecretObjListFindByUUIDLocked(secrets, uuidstr);
virObjectUnlock(secrets);
if (obj)
virObjectLock(obj);
if (oldDef)
*oldDef = NULL;
+ virUUIDFormat(newdef->uuid, uuidstr);
+
/* Is there a secret already matching this UUID */
- if ((obj = virSecretObjListFindByUUIDLocked(secrets, newdef->uuid))) {
+ if ((obj = virSecretObjListFindByUUIDLocked(secrets, uuidstr))) {
virObjectLock(obj);
def = obj->def;
if (STRNEQ_NULLABLE(def->usage_id, newdef->usage_id)) {
- virUUIDFormat(def->uuid, uuidstr);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("a secret with UUID %s is already defined for "
"use with %s"),
/* Generate the possible configFile and base64File strings
* using the configDir, uuidstr, and appropriate suffix
*/
- virUUIDFormat(newdef->uuid, uuidstr);
if (!(configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
!(base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
goto cleanup;
virSecretObjPtr obj;
char uuidstr[VIR_UUID_STRING_BUFLEN];
- if (!(obj = virSecretObjListFindByUUID(driver->secrets, secret->uuid))) {
- virUUIDFormat(secret->uuid, uuidstr);
+ virUUIDFormat(secret->uuid, uuidstr);
+ if (!(obj = virSecretObjListFindByUUID(driver->secrets, uuidstr))) {
virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr);
return NULL;
virSecretPtr ret = NULL;
virSecretObjPtr obj;
virSecretDefPtr def;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
- if (!(obj = virSecretObjListFindByUUID(driver->secrets, uuid))) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(uuid, uuidstr);
+ virUUIDFormat(uuid, uuidstr);
+ if (!(obj = virSecretObjListFindByUUID(driver->secrets, uuidstr))) {
virReportError(VIR_ERR_NO_SECRET,
_("no secret with matching uuid '%s'"), uuidstr);
goto cleanup;