> > [PATCH 1/3]: contains support for vrdp/sdl/gui while defining a machine. > > + guiDisplay = > > strdup(def->graphics[i]->data.desktop.display); + } > > + > > + if ((def->graphics[i]->type == > > VIR_DOMAIN_GRAPHICS_TYPE_SDL) && (sdlPresent == 0)) { + > > sdlPresent = 1; > > + sdlDisplay = > > strdup(def->graphics[i]->data.sdl.display); + } > > + } > > Need to check for OOM failure here. Done and reposting the patch Regards, Pritesh
commit 7f23240a48f1f46e0aa4aaaf7f4fde63723e6b98 Author: pk221555 <pk221555@krishna.(none)> Date: Mon May 11 14:45:09 2009 +0200 libvirt: added support for vrdp/sdl/gui while defining a machine diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 8e42958..4ef1488 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -3041,24 +3041,29 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { } } /* Finished:Block to attach the Parallel Port to the VM */ -#if 0 { /* Started:Block to attach the Remote Display to VM */ - if (def->graphics) { + int vrdpPresent = 0; + int sdlPresent = 0; + int guiPresent = 0; + char *guiDisplay = NULL; + char *sdlDisplay = NULL; + int i = 0; + + for (i = 0; i < def->ngraphics; i++) { IVRDPServer *VRDPServer = NULL; - /* TODO: include the support for headless stuff - */ + if ((def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) && (vrdpPresent == 0)) { - if (def->graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) { + vrdpPresent = 1; machine->vtbl->GetVRDPServer(machine, &VRDPServer); if (VRDPServer) { VRDPServer->vtbl->SetEnabled(VRDPServer, PR_TRUE); DEBUG0("VRDP Support turned ON on port: 3389"); - if (def->graphics->data.rdp.port) { - VRDPServer->vtbl->SetPort(VRDPServer, def->graphics->data.rdp.port); - DEBUG("VRDP Port changed to: %d", def->graphics->data.rdp.port); - } else if (def->graphics->data.rdp.autoport) { + if (def->graphics[i]->data.rdp.port) { + VRDPServer->vtbl->SetPort(VRDPServer, def->graphics[i]->data.rdp.port); + DEBUG("VRDP Port changed to: %d", def->graphics[i]->data.rdp.port); + } else if (def->graphics[i]->data.rdp.autoport) { /* Setting the port to 0 will reset its value to * the default one which is 3389 currently */ @@ -3066,37 +3071,22 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { DEBUG0("VRDP Port changed to default, which is 3389 currently"); } - if (def->graphics->data.rdp.reuseconnection) { + if (def->graphics[i]->data.rdp.replaceUser) { VRDPServer->vtbl->SetReuseSingleConnection(VRDPServer, PR_TRUE); DEBUG0("VRDP set to reuse single connection"); } - if (def->graphics->data.rdp.multiconnections) { + if (def->graphics[i]->data.rdp.multiUser) { VRDPServer->vtbl->SetAllowMultiConnection(VRDPServer, PR_TRUE); DEBUG0("VRDP set to allow multiple connection"); } - if (def->graphics->data.rdp.auth) { - if (STREQ(def->graphics->data.rdp.auth, "guest")) { - VRDPServer->vtbl->SetAuthType(VRDPServer, VRDPAuthType_Guest); - DEBUG0("VRDP authentication method set to Guest"); - } else if (STREQ(def->graphics->data.rdp.auth, "external")) { - VRDPServer->vtbl->SetAuthType(VRDPServer, VRDPAuthType_External); - DEBUG0("VRDP authentication method set to External"); - } - - if (def->graphics->data.rdp.authtimeout) { - VRDPServer->vtbl->SetAuthTimeout(VRDPServer, def->graphics->data.rdp.authtimeout); - DEBUG("VRDP authentication timeout is set to %llu", def->graphics->data.rdp.authtimeout); - } - } - - if (def->graphics->data.rdp.listenAddr) { + if (def->graphics[i]->data.rdp.listenAddr) { PRUnichar *netAddressUtf16 = NULL; - data->pFuncs->pfnUtf8ToUtf16(def->graphics->data.rdp.listenAddr, &netAddressUtf16); + data->pFuncs->pfnUtf8ToUtf16(def->graphics[i]->data.rdp.listenAddr, &netAddressUtf16); VRDPServer->vtbl->SetNetAddress(VRDPServer, netAddressUtf16); - DEBUG("VRDP listen address is set to: %s", def->graphics->data.rdp.listenAddr); + DEBUG("VRDP listen address is set to: %s", def->graphics[i]->data.rdp.listenAddr); data->pFuncs->pfnUtf16Free(netAddressUtf16); } @@ -3104,9 +3094,100 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { VRDPServer->vtbl->nsisupports.Release((nsISupports *)VRDPServer); } } + + if ((def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP) && (guiPresent == 0)) { + guiPresent = 1; + guiDisplay = strdup(def->graphics[i]->data.desktop.display); + if (guiDisplay == NULL) { + vboxError(conn, VIR_ERR_SYSTEM_ERROR, "%s", "strdup failed"); + /* just don't go to cleanup yet as it is ok to have + * guiDisplay as NULL and we check it below if it + * exist and then only use it there + */ + } + } + + if ((def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) && (sdlPresent == 0)) { + sdlPresent = 1; + sdlDisplay = strdup(def->graphics[i]->data.sdl.display); + if (sdlDisplay == NULL) { + vboxError(conn, VIR_ERR_SYSTEM_ERROR, "%s", "strdup failed"); + /* just don't go to cleanup yet as it is ok to have + * sdlDisplay as NULL and we check it below if it + * exist and then only use it there + */ + } + } + } + + if ((vrdpPresent == 1) && (guiPresent == 0) && (sdlPresent == 0)) { + /* store extradata key that frontend is set to vrdp */ + PRUnichar *keyTypeUtf16 = NULL; + PRUnichar *valueTypeUtf16 = NULL; + + data->pFuncs->pfnUtf8ToUtf16("FRONTEND/Type", &keyTypeUtf16); + data->pFuncs->pfnUtf8ToUtf16("vrdp", &valueTypeUtf16); + + machine->vtbl->SetExtraData(machine, keyTypeUtf16, valueTypeUtf16); + + data->pFuncs->pfnUtf16Free(keyTypeUtf16); + data->pFuncs->pfnUtf16Free(valueTypeUtf16); + + } else if ((guiPresent == 0) && (sdlPresent == 1)) { + /* store extradata key that frontend is set to sdl */ + PRUnichar *keyTypeUtf16 = NULL; + PRUnichar *valueTypeUtf16 = NULL; + PRUnichar *keyDislpayUtf16 = NULL; + PRUnichar *valueDisplayUtf16 = NULL; + + data->pFuncs->pfnUtf8ToUtf16("FRONTEND/Type", &keyTypeUtf16); + data->pFuncs->pfnUtf8ToUtf16("sdl", &valueTypeUtf16); + + machine->vtbl->SetExtraData(machine, keyTypeUtf16, valueTypeUtf16); + + data->pFuncs->pfnUtf16Free(keyTypeUtf16); + data->pFuncs->pfnUtf16Free(valueTypeUtf16); + + if (sdlDisplay) { + data->pFuncs->pfnUtf8ToUtf16("FRONTEND/Display", &keyDislpayUtf16); + data->pFuncs->pfnUtf8ToUtf16(sdlDisplay, &valueDisplayUtf16); + + machine->vtbl->SetExtraData(machine, keyDislpayUtf16, valueDisplayUtf16); + + data->pFuncs->pfnUtf16Free(keyDislpayUtf16); + data->pFuncs->pfnUtf16Free(valueDisplayUtf16); + } + + } else { + /* if all are set then default is gui, with vrdp turned on */ + PRUnichar *keyTypeUtf16 = NULL; + PRUnichar *valueTypeUtf16 = NULL; + PRUnichar *keyDislpayUtf16 = NULL; + PRUnichar *valueDisplayUtf16 = NULL; + + data->pFuncs->pfnUtf8ToUtf16("FRONTEND/Type", &keyTypeUtf16); + data->pFuncs->pfnUtf8ToUtf16("gui", &valueTypeUtf16); + + machine->vtbl->SetExtraData(machine, keyTypeUtf16, valueTypeUtf16); + + data->pFuncs->pfnUtf16Free(keyTypeUtf16); + data->pFuncs->pfnUtf16Free(valueTypeUtf16); + + if (guiDisplay) { + data->pFuncs->pfnUtf8ToUtf16("FRONTEND/Display", &keyDislpayUtf16); + data->pFuncs->pfnUtf8ToUtf16(guiDisplay, &valueDisplayUtf16); + + machine->vtbl->SetExtraData(machine, keyDislpayUtf16, valueDisplayUtf16); + + data->pFuncs->pfnUtf16Free(keyDislpayUtf16); + data->pFuncs->pfnUtf16Free(valueDisplayUtf16); + } } + + VIR_FREE(guiDisplay); + VIR_FREE(sdlDisplay); + } /* Finished:Block to attach the Remote Display to VM */ -#endif { /* Started:Block to attach USB Devices to VM */ if (def->nhostdevs > 0) {
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list