On 02/26/2016 12:16 PM, Daniel P. Berrange wrote:
On Thu, Feb 25, 2016 at 09:03:18AM -0500, John Ferlan wrote:
> This patch replaces the listInsert and listUnlink with the more commonly
> used VIR_APPEND_ELEMENT and VIR_REMOVE_ELEMENT macros used for list mgmt.
>
> Of course that does require any code walking the ->next list to instead
> use the ->count for loop
>
> Signed-off-by: John Ferlan <jferlan(a)redhat.com>
> ---
> src/secret/secret_driver.c | 244 +++++++++++++++++++++++----------------------
> 1 file changed, 124 insertions(+), 120 deletions(-)
>
> diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
> index fb24237..deb8c59 100644
> --- a/src/secret/secret_driver.c
> +++ b/src/secret/secret_driver.c
> @@ -55,7 +55,6 @@ enum { SECRET_MAX_XML_FILE = 10*1024*1024 };
> typedef struct _virSecretObj virSecretObj;
> typedef virSecretObj *virSecretObjPtr;
> struct _virSecretObj {
> - virSecretObjPtr next;
> char *configFile;
> char *base64File;
> virSecretDefPtr def;
> @@ -63,11 +62,18 @@ struct _virSecretObj {
> size_t value_size;
> };
>
> +typedef struct _virSecretObjList virSecretObjList;
> +typedef virSecretObjList *virSecretObjListPtr;
> +struct _virSecretObjList {
> + size_t count;
> + virSecretObjPtr *objs;
> +};
> +
> typedef struct _virSecretDriverState virSecretDriverState;
> typedef virSecretDriverState *virSecretDriverStatePtr;
> struct _virSecretDriverState {
> virMutex lock;
> - virSecretObj *secrets;
> + virSecretObjList secrets;
> char *configDir;
> };
No objections to using an array, but if we consider the possibility
of having many 100's of guests, all using encrypted disks, or network
disks needing auth, then we would probably be better having a hash
table indexed on uuid, like we do for domains.
Hmm.. Yeah - that's probably the better solution. Once this release
closes I'll push patches 1-13 and rework this change to use secret
objects similar to domain objects...
Even though patch 12 introduces secretAssignDef that could conceptually
go into secret_conf.c - I'll keep it in secret_driver.c for now and then
when implementing a secret obj like domain obj a virSecret[Obj]AssignDef
can be generated. It'll be temporary similar to listUnlinkSecret is/was.
Thanks -
John