提交 34075acf 编写于 作者: N Nikolay Shirokovskiy 提交者: Maxim Nestratov

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: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 90d506e3
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册