mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
secret: Alter FindByUUID to expect the formatted uuidstr
Since we're storing a virUUIDFormat'd string in our Hash Table, let's modify the Lookup API to receive a formatted string as well. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
836c40be53
commit
f9ccfd5962
@ -171,12 +171,8 @@ virSecretObjListDispose(void *obj)
|
|||||||
*/
|
*/
|
||||||
static virSecretObjPtr
|
static virSecretObjPtr
|
||||||
virSecretObjListFindByUUIDLocked(virSecretObjListPtr secrets,
|
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));
|
return virObjectRef(virHashLookup(secrets->objs, uuidstr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +180,7 @@ virSecretObjListFindByUUIDLocked(virSecretObjListPtr secrets,
|
|||||||
/**
|
/**
|
||||||
* virSecretObjFindByUUID:
|
* virSecretObjFindByUUID:
|
||||||
* @secrets: list of secret objects
|
* @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
|
* This function locks @secrets and finds the secret object which
|
||||||
* corresponds to @uuid.
|
* corresponds to @uuid.
|
||||||
@ -193,12 +189,12 @@ virSecretObjListFindByUUIDLocked(virSecretObjListPtr secrets,
|
|||||||
*/
|
*/
|
||||||
virSecretObjPtr
|
virSecretObjPtr
|
||||||
virSecretObjListFindByUUID(virSecretObjListPtr secrets,
|
virSecretObjListFindByUUID(virSecretObjListPtr secrets,
|
||||||
const unsigned char *uuid)
|
const char *uuidstr)
|
||||||
{
|
{
|
||||||
virSecretObjPtr obj;
|
virSecretObjPtr obj;
|
||||||
|
|
||||||
virObjectLock(secrets);
|
virObjectLock(secrets);
|
||||||
obj = virSecretObjListFindByUUIDLocked(secrets, uuid);
|
obj = virSecretObjListFindByUUIDLocked(secrets, uuidstr);
|
||||||
virObjectUnlock(secrets);
|
virObjectUnlock(secrets);
|
||||||
if (obj)
|
if (obj)
|
||||||
virObjectLock(obj);
|
virObjectLock(obj);
|
||||||
@ -346,13 +342,14 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
|
|||||||
if (oldDef)
|
if (oldDef)
|
||||||
*oldDef = NULL;
|
*oldDef = NULL;
|
||||||
|
|
||||||
|
virUUIDFormat(newdef->uuid, uuidstr);
|
||||||
|
|
||||||
/* Is there a secret already matching this UUID */
|
/* Is there a secret already matching this UUID */
|
||||||
if ((obj = virSecretObjListFindByUUIDLocked(secrets, newdef->uuid))) {
|
if ((obj = virSecretObjListFindByUUIDLocked(secrets, uuidstr))) {
|
||||||
virObjectLock(obj);
|
virObjectLock(obj);
|
||||||
def = obj->def;
|
def = obj->def;
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(def->usage_id, newdef->usage_id)) {
|
if (STRNEQ_NULLABLE(def->usage_id, newdef->usage_id)) {
|
||||||
virUUIDFormat(def->uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("a secret with UUID %s is already defined for "
|
_("a secret with UUID %s is already defined for "
|
||||||
"use with %s"),
|
"use with %s"),
|
||||||
@ -390,7 +387,6 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
|
|||||||
/* Generate the possible configFile and base64File strings
|
/* Generate the possible configFile and base64File strings
|
||||||
* using the configDir, uuidstr, and appropriate suffix
|
* using the configDir, uuidstr, and appropriate suffix
|
||||||
*/
|
*/
|
||||||
virUUIDFormat(newdef->uuid, uuidstr);
|
|
||||||
if (!(configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
|
if (!(configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
|
||||||
!(base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
|
!(base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -40,7 +40,7 @@ virSecretObjListNew(void);
|
|||||||
|
|
||||||
virSecretObjPtr
|
virSecretObjPtr
|
||||||
virSecretObjListFindByUUID(virSecretObjListPtr secrets,
|
virSecretObjListFindByUUID(virSecretObjListPtr secrets,
|
||||||
const unsigned char *uuid);
|
const char *uuidstr);
|
||||||
|
|
||||||
virSecretObjPtr
|
virSecretObjPtr
|
||||||
virSecretObjListFindByUsage(virSecretObjListPtr secrets,
|
virSecretObjListFindByUsage(virSecretObjListPtr secrets,
|
||||||
|
@ -86,8 +86,8 @@ secretObjFromSecret(virSecretPtr secret)
|
|||||||
virSecretObjPtr obj;
|
virSecretObjPtr obj;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
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,
|
virReportError(VIR_ERR_NO_SECRET,
|
||||||
_("no secret with matching uuid '%s'"), uuidstr);
|
_("no secret with matching uuid '%s'"), uuidstr);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -148,10 +148,10 @@ secretLookupByUUID(virConnectPtr conn,
|
|||||||
virSecretPtr ret = NULL;
|
virSecretPtr ret = NULL;
|
||||||
virSecretObjPtr obj;
|
virSecretObjPtr obj;
|
||||||
virSecretDefPtr def;
|
virSecretDefPtr def;
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
if (!(obj = virSecretObjListFindByUUID(driver->secrets, uuid))) {
|
virUUIDFormat(uuid, uuidstr);
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
if (!(obj = virSecretObjListFindByUUID(driver->secrets, uuidstr))) {
|
||||||
virUUIDFormat(uuid, uuidstr);
|
|
||||||
virReportError(VIR_ERR_NO_SECRET,
|
virReportError(VIR_ERR_NO_SECRET,
|
||||||
_("no secret with matching uuid '%s'"), uuidstr);
|
_("no secret with matching uuid '%s'"), uuidstr);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user