8

I know that kvm-qemu supports nested virtualization for Intel (VT-x) on Linux, since I have this working. I don't have this working on my mac with os x as a host though.

My Macbook Air with Dual-Core Intel i5 supports VT-x virtualization. I know this because this command shows 'VMX':

$ sysctl -a | grep machdep.cpu.features

I start qemu (qemu-system-x86_64, version 4.2.0) with this command:

$ qemu-system-x86_64 -m 2048 -vga virtio -usb -device usb-tablet -show-cursor -enable-kvm -drive file=~/vms-qemu/lmde.qcow2 -accel hvf -cpu host,vmx

This gives me a warning: 'host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]'.

Within the virtual machine, the guest running Linux Mint Debian Edition, virtualization is not available, as expected given the warning. This is shown by the command virt-host-validate from the libvirt-clients package. Also the command lscpu does not show:

Virtualization: VT-x

Hypervisor vendor: KVM

Virtualization type: full

Why does Qemu warn that the host does not support VMX? I ask because the host /does/ support this feature. And it's enabled by default by Apple since many years (https://support.apple.com/en-us/HT203296).

I successfully enabled nested virtualization on a Linux host with a Linux guest in qemu (2.8.1). For this I had to set the option 'options kvm-intel nested=Y' in /etc/modprobe.d/kvm-intel.conf. Is there perhaps something like this required on Mac OSX to make VT-x hardware assisted virtualization available for the guest?

1 Answer 1

-1
#!/bin/bash

# Check if VT-x (VMX) is supported by the CPU
cpu_features=$(sysctl -a | grep machdep.cpu.features)
if [[ $cpu_features == *"VMX"* ]]; then
    echo "VT-x (VMX) is supported by the CPU"
else
    echo "VT-x (VMX) is not supported by the CPU"
fi

# Check if nested virtualization is enabled on the host
nested=$(sysctl -a | grep machdep.cpu.extfeatures)
if [[ $nested == *"VMX"* ]]; then
    echo "Nested virtualization is enabled on the host"
else
    echo "Nested virtualization is not enabled on the host"
fi

# Check if HVF (Apple Hypervisor Framework) is being used
hypervisor=$(sysctl -n kern.hv_support)
if [[ $hypervisor == "1" ]]; then
    echo "HVF (Apple Hypervisor Framework) is being used"
else
    echo "HVF (Apple Hypervisor Framework) is not being used"
fi

# Check if VT-x is exposed to the guest VM
qemu_capabilities=$(qemu-system-x86_64 -cpu help)
if [[ $qemu_capabilities == *"vmx"* ]]; then
    echo "VT-x (VMX) is exposed to the guest VM"
else
    echo "VT-x (VMX) is not exposed to the guest VM"
fi

# Check if nested virtualization is enabled inside the guest VM
guest_capabilities=$(qemu-system-x86_64 -cpu help | grep "vmxvmcs")
if [[ $guest_capabilities == *"vmxvmcs"* ]]; then
    echo "Nested virtualization is enabled inside the guest VM"
else
    echo "Nested virtualization is not enabled inside the guest VM"
fi
1
  • 1
    Welcome to the site. Please add some explicit explanation to your answer instead of just pasting a shell script, and be it commented - "inline explanations" are much harder to read and understand.
    – AdminBee
    Jul 4 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .