What OS resolution is under VirtualBox.

This is for discussing general topics about how to use VirtualBox.

What OS resolution is under VirtualBox.

Postby Sandman192 » 26. Jul 2021, 02:52

Is there a way to have VirtualBox tell you on what resolution the OS is running at under VirtualBox?
Software: Win 10 Pro 64 bit, Video Drivers v471.11, CUDA v11.4, V-Box 6.1.22
Hardware: ASUS X-99 Deluxe-i7 5930K Extreme Edition 3.50Ghz to 4.10, 12 core-32GB of Ram, EVGA GTX 1080Ti 11GBs, EVGA GTX 980 GTX 4GBs, 512GB M.2 for BOINC Program and 3TB
Sandman192
 
Posts: 3
Joined: 11. Sep 2010, 17:16
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Linux

Re: What OS resolution is under VirtualBox.

Postby towo2099 » 28. Jul 2021, 08:56

You have to set the resolution in the guest, like on a real system too.
towo2099
Volunteer
 
Posts: 338
Joined: 18. Aug 2014, 21:53
Primary OS: Debian Sid
VBox Version: PUEL
Guest OSses: Android, Linux

Re: What OS resolution is under VirtualBox.

Postby scottgus1 » 28. Jul 2021, 16:41

Been pondering this one for a couple days. If you are trying to know what screen size the VM is using from the host OS, there may be a way.

This command:

vboxmanage getextradata "vm name" GUI/LastGuestSizeHint

will respond with:

Value: xxx,yyy

where xxx and yyy are the width and height of the VM OS screen size. The values from the command change as the screen size is changed, either by orders from the VM OS, the VM View menu, or dragging the VM window. The command also works without the VM running, so it will show what size the OS shut down with.

FWIW before you start the VM you can force what size the VM will start with using this command:

vboxmanage setextradata "vm name" GUI/LastGuestSizeHint xxx,yyy

(This last command apparently does not work to force a screen size change while the VM is running. The View menu can force a change, though.)
scottgus1
Site Moderator
 
Posts: 13020
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What OS resolution is under VirtualBox.

Postby fth0 » 28. Jul 2021, 17:51

scottgus1 wrote:The values from the command change as the screen size is changed

Can you do me a favor and test if this works for you on a Linux VM?

From my own experience, VirtualBox never created this setting in "Linux Mint.vbox" files on its own (*). Only after I created it myself, it was updated by VirtualBox in the past. Today, even the latter didn't work for me.

(*) Only using the VBoxManage commands worked for me (and the discouraged manual editing, of course ;)).
Last edited by fth0 on 28. Jul 2021, 18:15, edited 1 time in total.
fth0
Volunteer
 
Posts: 2385
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: What OS resolution is under VirtualBox.

Postby scottgus1 » 28. Jul 2021, 20:12

OK, I got Linux Mint installed on a 6.1.18 Windows host, and got GAs 6.1.18 installed.

The first boot after GAs install did not have the "GUI/LastGuestSizeHint" extradata value in the VM's .vbox file. After I used the View menu to ask for a different screen size, the extradata value appeared by itself in the .vbox file. The getextradata command works, and continued screen size changes via dragging the window also appear in the getextradata command output.
scottgus1
Site Moderator
 
Posts: 13020
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What OS resolution is under VirtualBox.

Postby fth0 » 29. Jul 2021, 12:43

@scottgus1: Thanks for testing. :) Looks like there are different sequences of events possible, so it may be worth to further investigate at some time in the future. klaus called it "complicated, messy stuff :D", BTW. ;)

scottgus1 wrote:The first boot after GAs install [...]

After a reboot or a shutdown?

scottgus1 wrote:[...] did not have the "GUI/LastGuestSizeHint" extradata value in the VM's .vbox file.

During the VM run or after the next shut down?

scottgus1 wrote:After I used the View menu to ask for a different screen size, the extradata value appeared by itself in the .vbox file.

During the VM run or after the next shut down?
fth0
Volunteer
 
Posts: 2385
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: What OS resolution is under VirtualBox.

Postby scottgus1 » 29. Jul 2021, 18:39

fth0 wrote:
scottgus1 wrote:The first boot after GAs install

After a reboot or a shutdown?

This would have been a full shutdown. After the OS install & reboot, I got the GAs installed, then fully shut down. I then enabled 3D acceleration and started again.

fth0 wrote:
scottgus1 wrote:[...] did not have the "GUI/LastGuestSizeHint" extradata value in the VM's .vbox file.

During the VM run or after the next shut down?

This and the next:
scottgus1 wrote:After I used the View menu to ask for a different screen size, the extradata value appeared by itself in the .vbox file.

were during the one VM run after enabling 3D and starting the VM. No reboot happened for these results.

It went like this:
  1. install OS
  2. reboot
  3. install GAs
  4. shut down completely
  5. enable 3D acceleration
  6. start again
  7. no GUI//LastGuestSizeHint in .vbox file
  8. View menu screen size change
  9. GUI//LastGuestSizeHint is now in .vbox file and responsive to further size changes
scottgus1
Site Moderator
 
Posts: 13020
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What OS resolution is under VirtualBox.

Postby fth0 » 29. Jul 2021, 19:54

Thanks for the details, they will come in handy for my own experiments. :)

BTW, I explicitly asked about shutdowns, because the .vbox file is always updated after a VM's shutdown, but only sometimes during a VM run (which can include guest OS reboots), and I'm not sure what settings can get updated during a VM run. On the other hand, I just realized (again) that some VBoxManage commands effect changes in the .vbox file, some effects changes in the (live) VM configuration inside the VBoxSVC process and/or the VirtualBoxVM process, and some do all three, possibly at different times, so there is some decoupling to consider per command. I'm beginning to comprehend klaus' comments. ;)
fth0
Volunteer
 
Posts: 2385
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: What OS resolution is under VirtualBox.

Postby scottgus1 » 29. Jul 2021, 20:01

Does sound complicated... FWIW, I did see the screen size update in the .vbox file at each size change, live while the VM was running.
scottgus1
Site Moderator
 
Posts: 13020
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What OS resolution is under VirtualBox.

Postby fth0 » 2. Aug 2021, 20:07

Starting with your recipe, I made some interesting (*) discoveries:

On my ThinkPad T590 with a Full HD display (1920x1080), the LastGuestSizeHint is written/updated if I use the VM menu to resize the VM window to a resolution that does not fit on the display (1920x1200, 1920x1080, 1680x1050), or if I change the VM window size by dragging its edges/corners. The LastGuestSizeHint is not written/updated if I use the VM menu to resize the VM window to a resolution that does fit on the display (1600x900 or smaller) or if I change the VM window from within the guest OS display settings. I normally use 1600x900 from the VM menu for my testing VMs, which explains why it never worked for me.

On my macOS host with Retina display (5120x2440), none of the offered resolutions fits the display, so only dragging works for me. In consequence, the behavior of my guests seems to be OS agnostic. It must be me. ;)

The corresponding messages in the VBox.log file show that when selecting 1920x1080 for example, the display resolution is first changed to 1920x1080, and then immediately changed again to 1920x979, which somehow fits in the real screen estate available. LastGuestSizeHint is set to "1920,979" accordingly. Additionally, LastNormalWindowPosition is set to "-2,21,1903,1004" then. The latter seems to indicate some calculation problems. The quest continues ...

(*) Mr. Spock would have said: "Fascinating" ;)
fth0
Volunteer
 
Posts: 2385
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: What OS resolution is under VirtualBox.

Postby fth0 » 4. Aug 2021, 01:15

@scottgus1: Can you do me another favor and provide a VBox.log file of a VM run of the Linux VM? TIA.

If yes, please start the VM and wait a minute or two, so that all VirtualBox GA components are running. Then change the display resolution via the VM's menu, wait a second, change the display resolution via dragging the edge/corner of the VM's window, wait a second, change the display resolution from inside the guest OS, wait a second, and shut down the VM.
fth0
Volunteer
 
Posts: 2385
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: What OS resolution is under VirtualBox.

Postby scottgus1 » 8. Aug 2021, 01:16

Okeedoke, fth0, here is the log from the Mint VM, using the environment variables and a command-line start that you asked for in the PM:
cd "C:\Program Files\Oracle\VirtualBox"
set VBOX_RELEASE_LOG_FLAGS="thread group flag"
set VBOX_RELEASE_LOG="+GUI.e.l.f.l3+MAIN_DISPLAY.e.l.f"
VirtualBoxVM --startvm "VM name"


I followed the procedure above:
Boot & stabilize the VM
change size with VM View menu
chnage by dragging the window
change inside the VM's OS
shut down the VM

Linux Mint-2021-08-07-19-10-30.zip
(153.76 KiB) Downloaded 1 time
scottgus1
Site Moderator
 
Posts: 13020
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What OS resolution is under VirtualBox.

Postby fth0 » 8. Aug 2021, 12:24

Linux Mint-2021-08-07-19-10-30.log wrote:
00:03:25.598778 main     GUI      level 1  GUI: UIMachineLogic: Host-screen count changed
00:03:25.601904 main DEFAULT level 1 GUI: UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized: Screen 0 work area is formally resized to: 0x0 x 1366x768
00:03:25.601952 main GUI level 1 GUI: UIMachineLogic: Host-screen available-area changed
00:03:25.817794 main DEFAULT level 1 GUI: UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized: Screen 0 work area is formally resized to: 74x0 x 1292x768
00:03:25.817845 main GUI level 1 GUI: UIMachineLogic: Host-screen available-area changed

This probably doesn't matter, but do you have a left-hand side menu on your host OS? Has your host screen a resolution of 1366x768? The latter question may seem unnecessary and the answer obvious, but you'll see the reason for it later on ...

Linux Mint-2021-08-07-19-10-30.log wrote:
00:04:38.601853 main     DEV_VMM  level 1  VMMDev: SetVideoModeHint: Got a video mode hint (1280x720x32)@(0x0),(1;0) at 0
00:04:38.619970 VMSVGA FIFO MAIN_DISPLAY level 1 Display::i_handleDisplayResize: uScreenId=0 pvVRAM=0000000000000000 w=800 h=600 bpp=0 cbLine=0x0 flags=0x2 origin=0,0
00:04:38.633742 VMSVGA FIFO MAIN_DISPLAY level 1 Display::i_handleDisplayResize: uScreenId=0 pvVRAM=000000000df6a000 w=1280 h=720 bpp=32 cbLine=0x1400 flags=0x1 origin=0,0
00:04:38.661252 main GUI level 1 GUI: UIMachineLogic: Guest-screen count changed
00:04:38.946873 main GUI level 1 GUI: UIMachineView::sltPerformGuestResize: Sending guest size-hint to screen 0 as 1280x707 if necessary
00:04:39.002268 main DEV_VMM level 1 VMMDev: SetVideoModeHint: Got a video mode hint (1280x707x32)@(0x0),(1;0) at 0
00:04:39.018754 main GUI level 1 GUI: UIMediumEnumerator: Medium-enumeration finished!
00:04:39.023959 VMSVGA FIFO MAIN_DISPLAY level 1 Display::i_handleDisplayResize: uScreenId=0 pvVRAM=0000000000000000 w=1280 h=720 bpp=0 cbLine=0x0 flags=0x2 origin=0,0
00:04:39.047642 VMSVGA FIFO MAIN_DISPLAY level 1 Display::i_handleDisplayResize: uScreenId=0 pvVRAM=000000000df6a000 w=1280 h=707 bpp=32 cbLine=0x1400 flags=0x1 origin=0,0
00:04:39.050122 main GUI level 1 GUI: UIMachineLogic: Guest-screen count changed

This is where you selected the display resolution from the VM menu. Here you see the behavior that I described as "does not fit" in an earlier post. The automatic height reduction is the reason that the change is written to the LastGuestSizeHint (it was written as "1280,707", wasn't it?). If you select 800x600 or 640x480 from the VM menu, is the LastGuestSizeHint re-written then? ;)

Linux Mint-2021-08-07-19-10-30.log wrote:
00:04:52.780262 main     GUI      level 1  GUI: UIMachineView::sltPerformGuestResize: Sending guest size-hint to screen 0 as 911x851 if necessary
[...]
00:04:53.637711 main GUI level 1 GUI: UIMachineView::sltPerformGuestResize: Sending guest size-hint to screen 0 as 906x707 if necessary

This is where you dragged the window. ... I don't understand why VirtualBox thought that you dragged the height to 851, if your screen height was only 768 pixels.
fth0
Volunteer
 
Posts: 2385
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: What OS resolution is under VirtualBox.

Postby scottgus1 » 8. Aug 2021, 16:16

fth0 wrote:do you have a left-hand side menu on your host OS? Has your host screen a resolution of 1366x768?

Correct on both. I also have a 1920x1080 second monitor, which I moved the VM to, after it loaded and stabilized.

fth0 wrote:is the LastGuestSizeHint re-written then?

I regret I didn't check on this for this test. I'll re-run it and monitor for the LastGuestSizeHint changes.

fth0 wrote:I don't understand why VirtualBox thought that you dragged the height to 851, if your screen height was only 768 pixels.

I have a magic mouse. :lol:
I had moved the VM to the 1920x1080 screen so I'd have some more room.

I tried another fresh install of the Mint OS in a new VM. I also 'standardized' my host using only the 1366x768 monitor and the Taskbar on the bottom, and checked for GUI/LastGuestSizeHint while the VM was being used.

I had updated the host to 6.1.26 before this, and I did not get the GUI/LastGuestSizeHint appearing automatically as I reported above. I don't know if it's a difference between 6.1.18 and 6.1.26, or if I did something I didn't recognize in the earlier test.

Here's the logs of the new VM and a list of test steps with what I saw in the .vbox file for GUI/LastGuestSizeHint.
I just noticed that for some reason the extra logging lines did not come through even though I started the VM from vboxmanage with the environment variables set. I'll try again later if it is necessary. I did seem to notice that the LastGuestSizeHint only seemed to update if the VM window was made bigger from the View menu or if the window was dragged.
Attachments
Logs.zip
(137.33 KiB) Downloaded 3 times
scottgus1
Site Moderator
 
Posts: 13020
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What OS resolution is under VirtualBox.

Postby fth0 » 8. Aug 2021, 21:35

First of all: Thanks a lot for your additional tests hard work! :)

scottgus1 wrote:I also have a 1920x1080 second monitor, which I moved the VM to, after it loaded and stabilized.

You even tried to trick me, but it didn't work. :lol:

I can explain now what happens. There are two functions in the VirtualBox work flow that can trigger writing/updating GUI/LastGuestSizeHint to/in the VM configuration file:

The first function UIMachineView::sltHandleNotifyChange(), which only outputs a level 2 and a flow log message and therefore cannot be seen in typical VBox.log files, deliberately does not write/update the hint when VMSVGA is used. Next, the frame buffer is resized to the new resolution. The second function UIMachineView::sltPerformGuestResize() checks if the new resolution is possible, adapts the resolution if necessary, and only writes the hint if the frame buffer size and the new size are different.

In consequence, for Linux guests GUI/LastGuestSizeHint gets only written/updated to/in the VM configuration file, if the resolution selected in the VM View menu is too large for the screen (or if VBox(S)VGA is used). The same holds true for resolution changes from within the guest OS, which use the same VirtualBox workflow. When dragging the VM window's edges/corners, UIMachineView::sltPerformGuestResize() gets called before the frame buffer is resized, so that the hint is always written/updated.

AFAICS, this explains everything I saw from your and my own experiments, except the "why". Time to ask the VirtualBox developers ...

Please feel free to ask if my ramblings are not understandable or you think I'm missing something. ;)
fth0
Volunteer
 
Posts: 2385
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Next

Return to Using VirtualBox

Who is online

Users browsing this forum: scottgus1 and 11 guests