[PATCH v2] vbox: Fix starting domains
Martin Kletzander
mkletzan at redhat.com
Mon Jan 23 15:13:35 UTC 2023
On Mon, Jan 23, 2023 at 02:59:28PM +0100, Michal Privoznik wrote:
>When starting a VirtualBox domain, we try to guess which frontend
>to use. While the whole algorithm looks a bit outdated, it may
>happen that we tell VirtualBox to use "gui" frontend, but not
>which DISPLAY= to use.
>
>I haven't found any documentation on the algorithm we use, but if
>I make us fallback onto DISPLAY=:0 when no other configuration is
>found then I'm able to start my guests just fine.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
Reviewed-by: Martin Kletzander <mkletzan at redhat.com>
>---
>
>I've experimented with introducing an enum for frontend since it can be
>one of gui, sdl, vrdp. But it turned out to be a huge mess and not worth
>the fix I'm trying to get in. If anybody else wants to do it, please.
>
> src/vbox/vbox_common.c | 41 +++++++++++++++++++++--------------------
> 1 file changed, 21 insertions(+), 20 deletions(-)
>
>diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
>index bd77641d39..30a85ce8b2 100644
>--- a/src/vbox/vbox_common.c
>+++ b/src/vbox/vbox_common.c
>@@ -2120,32 +2120,33 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIID *iid
> }
> VBOX_UTF8_FREE(valueDisplayUtf8);
>
>- if (guiPresent) {
>- if (guiDisplay) {
>- char *displayutf8;
>- displayutf8 = g_strdup_printf("DISPLAY=%s", guiDisplay);
>- VBOX_UTF8_TO_UTF16(displayutf8, &env);
>- VIR_FREE(displayutf8);
>- VIR_FREE(guiDisplay);
>- }
>+ if (guiPresent || sdlPresent) {
>+ const char *display = NULL;
>+ const char *sessType = NULL;
>+ char *displayutf8;
>
>- VBOX_UTF8_TO_UTF16("gui", &sessionType);
>- }
>+ if (guiPresent) {
>+ sessType = "gui";
>+ display = guiDisplay;
>+ } else {
>+ sessType = "sdl";
>+ display = sdlDisplay;
>+ }
>
>- if (sdlPresent) {
>- if (sdlDisplay) {
>- char *displayutf8;
>- displayutf8 = g_strdup_printf("DISPLAY=%s", sdlDisplay);
>- VBOX_UTF8_TO_UTF16(displayutf8, &env);
>- VIR_FREE(displayutf8);
>- VIR_FREE(sdlDisplay);
>+ if (!display) {
>+ /* Provide some sane default */
>+ display = ":0";
> }
>
>- VBOX_UTF8_TO_UTF16("sdl", &sessionType);
>- }
>+ displayutf8 = g_strdup_printf("DISPLAY=%s", display);
>+ VBOX_UTF8_TO_UTF16(displayutf8, &env);
>+ VIR_FREE(displayutf8);
>+ VIR_FREE(guiDisplay);
>
>- if (vrdpPresent)
>+ VBOX_UTF8_TO_UTF16(sessType, &sessionType);
>+ } else if (vrdpPresent) {
> VBOX_UTF8_TO_UTF16("vrdp", &sessionType);
>+ }
>
> rc = gVBoxAPI.UIMachine.LaunchVMProcess(data, machine, iid,
> sessionType, env,
>--
>2.39.1
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230123/8802a894/attachment.sig>
More information about the libvir-list
mailing list