[libvirt] [PATCH v2 1/7] vz: save session uuid on login

Dmitry Guryanov dguryanov at virtuozzo.com
Thu Jul 23 16:16:37 UTC 2015


On 07/17/2015 03:55 PM, nshirokovskiy at virtuozzo.com wrote:
> From: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
>
> This session uuid acts as authN token for different multihost vz operations one
> of which is migration. Unfortunately we can't get it from server at any time
> thus we need to save it at login.

ACK

>
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
> ---
>   src/vz/vz_sdk.c   |   39 +++++++++++++++++++++++++++++----------
>   src/vz/vz_utils.h |    2 +-
>   2 files changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index 744b58a..f7253de 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -37,6 +37,9 @@
>   #define VIR_FROM_THIS VIR_FROM_PARALLELS
>   #define JOB_INFINIT_WAIT_TIMEOUT UINT_MAX
>   
> +static int
> +prlsdkUUIDParse(const char *uuidstr, unsigned char *uuid);
> +
>   VIR_LOG_INIT("parallels.sdk");
>   
>   /*
> @@ -228,24 +231,40 @@ prlsdkDeinit(void)
>   int
>   prlsdkConnect(vzConnPtr privconn)
>   {
> -    PRL_RESULT ret;
> +    int ret = -1;
> +    PRL_RESULT pret;
>       PRL_HANDLE job = PRL_INVALID_HANDLE;
> +    PRL_HANDLE result = PRL_INVALID_HANDLE;
> +    PRL_HANDLE response = PRL_INVALID_HANDLE;
> +    char session_uuid[VIR_UUID_STRING_BUFLEN + 2];
> +    PRL_UINT32 buflen = ARRAY_CARDINALITY(session_uuid);
>   
> -    ret = PrlSrv_Create(&privconn->server);
> -    if (PRL_FAILED(ret)) {
> -        logPrlError(ret);
> -        return -1;
> -    }
> +    pret = PrlSrv_Create(&privconn->server);
> +    prlsdkCheckRetGoto(pret, cleanup);
>   
>       job = PrlSrv_LoginLocalEx(privconn->server, NULL, 0,
>                                 PSL_HIGH_SECURITY, PACF_NON_INTERACTIVE_MODE);
> +    if (PRL_FAILED(getJobResult(job, &result)))
> +        goto cleanup;
>   
> -    if (waitJob(job)) {
> +    pret = PrlResult_GetParam(result, &response);
> +    prlsdkCheckRetGoto(pret, cleanup);
> +
> +    pret = PrlLoginResponse_GetSessionUuid(response, session_uuid, &buflen);
> +    prlsdkCheckRetGoto(pret, cleanup);
> +
> +    if (prlsdkUUIDParse(session_uuid, privconn->session_uuid) < 0)
> +        goto cleanup;
> +
> +    ret = 0;
> +
> + cleanup:
> +    if (ret < 0)
>           PrlHandle_Free(privconn->server);
> -        return -1;
> -    }
> +    PrlHandle_Free(result);
> +    PrlHandle_Free(response);
>   
> -    return 0;
> +    return ret;
>   }
>   
>   void
> diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
> index db09647..fe54b25 100644
> --- a/src/vz/vz_utils.h
> +++ b/src/vz/vz_utils.h
> @@ -60,7 +60,7 @@ struct _vzConn {
>   
>       /* Immutable pointer, self-locking APIs */
>       virDomainObjListPtr domains;
> -
> +    unsigned char session_uuid[VIR_UUID_BUFLEN];
>       PRL_HANDLE server;
>       virStoragePoolObjList pools;
>       virNetworkObjListPtr networks;




More information about the libvir-list mailing list