Page 1 of 1

Interface to get info if VM runs with HW-Virtualization or in NEM mode

Posted: 20. Jun 2022, 12:00
by Tom79
Is there an interface to get information whether a VM runs with HW-Virtualization (blue "V" in status bar") or in NEM mode ("green turtle with V" in status bar)?
I run VirtualBox VMs in headless mode and therefore I need a possibility to detect that mode, eg. by means of VBoxManage.exe.

Re: Interface to get info if VM runs with HW-Virtualization or in NEM mode

Posted: 20. Jun 2022, 14:00
by scottgus1
This is a really good question! The only method I know of is to read through the VM's log for a line containing these words:

Attempting fall back to NEM

These words show up within a few seconds of the VM starting. If they are present, the green turtle is showing. Notepad is able to open a VM log while the VM is running, but VBscript cannot. Other programming languages might be able to.

Also possibly check these lines in vboxmanage showvminfo "VM name"
Hardware Virtualization:
VT-x VPID:
VT-x Unrestricted Exec.:
I don't know what they might read on a green turtle host, but they're all 'enabled' on a blue V host.

Re: Interface to get info if VM runs with HW-Virtualization or in NEM mode

Posted: 20. Jun 2022, 16:06
by Tom79
Yes, I know that VBox.log file contains some extra output ("Attempting fall back to NEM") in case of "green-turtle" mode. But I would like to avoid parsing the VBox.log file for that information.

Now I also checked the output of vboxmanage showvminfo "VM name" command. Unfortunately there is no difference in command output in case of "green-turtle" mode, it also contains:
VT-x VPID: enabled
VT-x Unrestricted Exec.: enabled

Re: Interface to get info if VM runs with HW-Virtualization or in NEM mode

Posted: 20. Jun 2022, 16:25
by scottgus1
FWIW, parsing the vbox.log file is not hard

basic pseudocode:

Code: Select all

turtlefound = false
do while not vboxlog.atendofstream
linein = vboxlog.readline
if instr(linein,"Attempting fall back to NEM")<>0 then 
turtlefound  = true
exit do
end if
loop
or

DOS batch file:
find /i /n "Attempting fall back to NEM" vbox.log > nul
rem errorlevel from find: 0, text found; 1, text missing
if "%Errorlevel%"=="0" goto handleturtle
But I'm sure there's something somewhere. Will have to wait for the gurus to show us.

BTW, regarding this:
Tom79 wrote:in case of "green-turtle" mode, it also contains:
VT-x VPID: enabled
VT-x Unrestricted Exec.: enabled
what does this show:
scottgus1 wrote:possibly check these lines
Hardware Virtualization:

Re: Interface to get info if VM runs with HW-Virtualization or in NEM mode

Posted: 20. Jun 2022, 19:41
by fth0
Tom79 wrote:Is there an interface to get information whether a VM runs with HW-Virtualization (blue "V" in status bar") or in NEM mode ("green turtle with V" in status bar)?
Unfortunately, the VM Execution Engine seems to be only available programmatically and visually (in the VM window > Machine > Session Information... > Runtime information dialog and in the status line icon).

Fortunately, that cannot stop a Linux hacker from obtaining it with a quick and dirty one-liner: ;)

Code: Select all

python2 /usr/lib/virtualbox/vboxshell.py -c "guest 'Linux Mint' 'print(\"VM Execution Engine: \" + {0: \"Not set\", 1: \"Raw mode\", 2: \"VT-x/AMD-V\", 3: \"Native API\"}.get(console.debugger.executionEngine))'" | grep "VM Execution Engine: " | sed "s/VM Execution Engine: //"
One could argue that parsing the VBox.log file is easier, though: ;)

Code: Select all

grep -c "NEM: NEMR3Init: Active." VBox.log
PS: The examples are for demonstration purposes, using programs pre-installed on most Linux desktop installations (e.g. python, grep, sed) but not readily available on Windows installations.

Re: Interface to get info if VM runs with HW-Virtualization or in NEM mode

Posted: 22. Jun 2022, 20:08
by noteirak
Relocated topic to the right forum.

Re: Interface to get info if VM runs with HW-Virtualization or in NEM mode

Posted: 23. Jun 2022, 10:31
by mpack
NEM is Windows Host only, so it belongs better in Windows Hosts.