[libvirt] [PATCH] storage: Fix incorrect format for <disk> <auth> XML

Michal Privoznik mprivozn at redhat.com
Tue Oct 6 13:19:48 UTC 2015


On 23.09.2015 22:54, John Ferlan wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1256999
> 
> When creating a copy of the 'authdef', need to take into account the
> slight variation between <disk> and <pool> before blindly copying
> the 'authType' field. This ensures virStorageAuthDefFormat will
> properly format the <auth> XML for a <disk>.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/util/virstoragefile.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
> index 2aa1d90..0b72cb3 100644
> --- a/src/util/virstoragefile.c
> +++ b/src/util/virstoragefile.c
> @@ -1522,7 +1522,12 @@ virStorageAuthDefCopy(const virStorageAuthDef *src)
>      /* Not present for storage pool, but used for disk source */
>      if (VIR_STRDUP(ret->secrettype, src->secrettype) < 0)
>          goto error;
> -    ret->authType = src->authType;
> +    /* A <disk> uses secrettype, while a <pool> uses authType, so
> +     * if we have a secrettype, then don't copy authType; otherwise,
> +     * we will format the authType in <disk>
> +     */
> +    if (!ret->secrettype)
> +        ret->authType = src->authType;
>      ret->secretType = src->secretType;

This seems like we have a bug somewhere if authType and secretType are
both set at the same time. Because the way I understand the code is that
only one from the pair can be non-null at the time. If so, I think we
should fix the bug and drop this if() here. Moreover, I'd expect a copy
function to create the exact copy of the original image instead of
masking a bug somewhere.
BTW isn't authType set to VIR_STORAGE_AUTH_TYPE_NONE by default?
And secretType to VIR_STORAGE_SECRET_TYPE_NONE?

Michal




More information about the libvir-list mailing list