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

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Tom79
Posts: 7
Joined: 6. Dec 2018, 14:53

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

Post 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.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

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

Post 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.
Tom79
Posts: 7
Joined: 6. Dec 2018, 14:53

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

Post 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
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

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

Post 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:
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

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

Post 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.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

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

Post by noteirak »

Relocated topic to the right forum.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

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

Post by mpack »

NEM is Windows Host only, so it belongs better in Windows Hosts.
Post Reply