Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/vz/vz_sdk.c | 62 ++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 25 deletions(-)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 6b9c10d..9ffcc70 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -457,7 +457,33 @@ prlsdkDomObjFreePrivate(void *p)
};
static int
-prlsdkAddDomainVideoInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
+prlsdkAddDomainVideoInfoCt(virDomainDefPtr def)
+{
+ virDomainVideoDefPtr video = NULL;
+ int ret = -1;
+
+ if (def->ngraphics == 0)
+ return 0;
+
+ if (VIR_ALLOC(video) < 0)
+ goto cleanup;
+
+ video->type = VIR_DOMAIN_VIDEO_TYPE_PARALLELS;
+ video->vram = 0;
+ video->heads = 1;
+
+ if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0)
+ goto cleanup;
+
+ ret = 0;
+ cleanup:
+ virDomainVideoDefFree(video);
+
+ return ret;
+}
+
+static int
+prlsdkAddDomainVideoInfoVm(PRL_HANDLE sdkdom, virDomainDefPtr def)
{
virDomainVideoDefPtr video = NULL;
virDomainVideoAccelDefPtr accel = NULL;
@@ -1099,9 +1125,13 @@ prlsdkAddSerialInfo(PRL_HANDLE sdkdom,
static int
prlsdkAddDomainHardware(vzDriverPtr driver, PRL_HANDLE sdkdom, virDomainDefPtr def)
{
- if (!IS_CT(def))
- if (prlsdkAddDomainVideoInfo(sdkdom, def) < 0)
+ if (IS_CT(def)) {
+ if (prlsdkAddDomainVideoInfoCt(def) < 0)
goto error;
+ } else {
+ if (prlsdkAddDomainVideoInfoVm(sdkdom, def) < 0)
+ goto error;
+ }
if (prlsdkAddDomainHardDisksInfo(driver, sdkdom, def) < 0)
goto error;
@@ -1166,25 +1196,6 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, gr) < 0)
goto error;
- if (IS_CT(def)) {
- virDomainVideoDefPtr video;
- if (VIR_ALLOC(video) < 0)
- goto error;
- video->type = virDomainVideoDefaultType(def);
- if (video->type < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("cannot determine default video type"));
- VIR_FREE(video);
- goto error;
- }
- video->vram = virDomainVideoDefaultRAM(def, video->type);
- video->heads = 1;
- if (VIR_ALLOC_N(def->videos, 1) < 0) {
- virDomainVideoDefFree(video);
- goto error;
- }
- def->videos[def->nvideos++] = video;
- }
return 0;
error:
@@ -1678,6 +1689,10 @@ prlsdkLoadDomain(vzDriverPtr driver, virDomainObjPtr dom)
if (prlsdkConvertDomainType(sdkdom, def) < 0)
goto error;
+ if (prlsdkAddVNCInfo(sdkdom, def) < 0)
+ goto error;
+
+ /* depends on prlsdkAddVNCInfo */
if (prlsdkAddDomainHardware(driver, sdkdom, def) < 0)
goto error;
@@ -1685,9 +1700,6 @@ prlsdkLoadDomain(vzDriverPtr driver, virDomainObjPtr dom)
if (prlsdkConvertBootOrder(sdkdom, def) < 0)
goto error;
- if (prlsdkAddVNCInfo(sdkdom, def) < 0)
- goto error;
-
pret = PrlVmCfg_GetEnvId(sdkdom, &envId);
prlsdkCheckRetGoto(pret, error);
--
1.8.3.1