Hi All, [PATCH 2/3]: contains support for vrdp/sdl/gui while dumping xml [PATCH 3/3]: contains support for vrdp/sdl/gui while starting the machine Pritesh |
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 223009a..97a686f 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2322,20 +2322,12 @@ static int vboxDomainCreate(virDomainPtr dom) { IProgress *progress = NULL; PRUint32 machineCnt = 0; PRUnichar *env = NULL; - const char *display = getenv("DISPLAY"); PRUnichar *sessionType = NULL; char displayutf8[32] = {0}; unsigned char iidl[VIR_UUID_BUFLEN] = {0}; int i, ret = -1; - if (display) { - sprintf(displayutf8, "DISPLAY=%s", display); - data->pFuncs->pfnUtf8ToUtf16(displayutf8, &env); - } - - data->pFuncs->pfnUtf8ToUtf16("gui", &sessionType); - if (!dom->name) { vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s", "Error while reading the domain name"); @@ -2373,6 +2365,92 @@ static int vboxDomainCreate(virDomainPtr dom) { if ( (state == MachineState_PoweredOff) || (state == MachineState_Saved) || (state == MachineState_Aborted) ) { + int vrdpPresent = 0; + int sdlPresent = 0; + int guiPresent = 0; + char *guiDisplay = NULL; + char *sdlDisplay = NULL; + PRUnichar *keyTypeUtf16 = NULL; + PRUnichar *valueTypeUtf16 = NULL; + char *valueTypeUtf8 = NULL; + PRUnichar *keyDislpayUtf16 = NULL; + PRUnichar *valueDisplayUtf16 = NULL; + char *valueDisplayUtf8 = NULL; + int valueDisplayFree = 1; + + data->pFuncs->pfnUtf8ToUtf16("FRONTEND/Type", &keyTypeUtf16); + machine->vtbl->GetExtraData(machine, keyTypeUtf16, &valueTypeUtf16); + data->pFuncs->pfnUtf16Free(keyTypeUtf16); + + if (valueTypeUtf16) { + data->pFuncs->pfnUtf16ToUtf8(valueTypeUtf16, &valueTypeUtf8); + data->pFuncs->pfnUtf16Free(valueTypeUtf16); + + if ( STREQ(valueTypeUtf8, "sdl") || STREQ(valueTypeUtf8, "gui") ) { + + data->pFuncs->pfnUtf8ToUtf16("FRONTEND/Display", &keyDislpayUtf16); + machine->vtbl->GetExtraData(machine, keyDislpayUtf16, &valueDisplayUtf16); + data->pFuncs->pfnUtf16Free(keyDislpayUtf16); + + if (valueDisplayUtf16) { + data->pFuncs->pfnUtf16ToUtf8(valueDisplayUtf16, &valueDisplayUtf8); + data->pFuncs->pfnUtf16Free(valueDisplayUtf16); + + if (strlen(valueDisplayUtf8) <= 0) { + data->pFuncs->pfnUtf8Free(valueDisplayUtf8); + valueDisplayUtf8 = getenv("DISPLAY"); + valueDisplayFree = 0; + } + } else { + valueDisplayUtf8 = getenv("DISPLAY"); + valueDisplayFree = 0; + } + + if (STREQ(valueTypeUtf8, "sdl")) { + sdlPresent = 1; + sdlDisplay = strdup(valueDisplayUtf8); + } + + if (STREQ(valueTypeUtf8, "gui")) { + guiPresent = 1; + guiDisplay = strdup(valueDisplayUtf8); + } + } + + if (STREQ(valueTypeUtf8, "vrdp")) { + vrdpPresent = 1; + } + + data->pFuncs->pfnUtf8Free(valueTypeUtf8); + + } else { + guiPresent = 1; + guiDisplay = strdup(getenv("DISPLAY")); + } + if (valueDisplayFree) + data->pFuncs->pfnUtf8Free(valueDisplayUtf8); + + if (guiPresent) { + sprintf(displayutf8, "DISPLAY=%.24s", guiDisplay); + data->pFuncs->pfnUtf8ToUtf16(displayutf8, &env); + + data->pFuncs->pfnUtf8ToUtf16("gui", &sessionType); + + VIR_FREE(guiDisplay); + } + + if (sdlPresent) { + sprintf(displayutf8, "DISPLAY=%.24s", sdlDisplay); + data->pFuncs->pfnUtf8ToUtf16(displayutf8, &env); + + data->pFuncs->pfnUtf8ToUtf16("sdl", &sessionType); + + VIR_FREE(sdlDisplay); + } + + if (vrdpPresent) { + data->pFuncs->pfnUtf8ToUtf16("vrdp", &sessionType); + } data->vboxObj->vtbl->OpenRemoteSession(data->vboxObj, data->vboxSession,
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list