mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
vz: save session uuid on login
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. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
90d506e3e5
commit
34075acf21
@ -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");
|
||||
|
||||
/*
|
||||
@ -268,24 +271,43 @@ prlsdkDeinit(void)
|
||||
int
|
||||
prlsdkConnect(vzDriverPtr driver)
|
||||
{
|
||||
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];
|
||||
|
||||
ret = PrlSrv_Create(&driver->server);
|
||||
if (PRL_FAILED(ret)) {
|
||||
logPrlError(ret);
|
||||
return -1;
|
||||
}
|
||||
pret = PrlSrv_Create(&driver->server);
|
||||
prlsdkCheckRetExit(pret, -1);
|
||||
|
||||
job = PrlSrv_LoginLocalEx(driver->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 = prlsdkGetStringParamBuf(PrlLoginResponse_GetSessionUuid,
|
||||
response, session_uuid, sizeof(session_uuid));
|
||||
prlsdkCheckRetGoto(pret, cleanup);
|
||||
|
||||
if (prlsdkUUIDParse(session_uuid, driver->session_uuid) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (ret < 0) {
|
||||
PrlHandle_Free(driver->server);
|
||||
return -1;
|
||||
driver->server = PRL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
PrlHandle_Free(result);
|
||||
PrlHandle_Free(response);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -66,7 +66,7 @@ struct _vzDriver {
|
||||
|
||||
/* Immutable pointer, self-locking APIs */
|
||||
virDomainObjListPtr domains;
|
||||
|
||||
unsigned char session_uuid[VIR_UUID_BUFLEN];
|
||||
PRL_HANDLE server;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLOptionPtr xmlopt;
|
||||
|
Loading…
Reference in New Issue
Block a user