Stefan Lankes bio photo

Stefan Lankes

Email Twitter Google+ LinkedIn XING Github

Maybe you can recognize from my former posts, that - beside Linux - OS X is my favorite operating system. On OS X, I use also Qemu to test my kernel extensions. To improve the performance, Qemu is able to use KVM, which is Linux’s kernel framework to support Intel’s and AMD’s hardware virtualization extensions (e. g. nested page tables).

Since OS X 10.10 (Yosemite), a hypervisor framework is integrated, which could be used to support similar features. xhyve is a lightweight virtualization solution, which supports this framework and is at least capable to run Linux and FreeBSD on OS X. In principle, it is a port of FreeBSD’s bhyve.

xhyve works very well. I tested it with the Linux kernel, which I built in my kernel guide. I created and started the virtual machine with the following command:

xhyve -m 1G -c 2 -s 0:0,hostbridge -s 31,lpc -l com1,stdio -f kexec,./bzImage,./myinitrd.cpio,"earlyprintk=serial root=/dev/ram0 rootfstype=ramfs init=init console=ttyS0"

The flag -m 1G specifies the memory size of the VM to 1 GByte, while -c 2 defines the number of cores to 2. The Linux kernel is configured to use the serial port (ttyS0) as standard communication interface. To establish a valid serial port and to redirect the output of the virtual machines to the console of my host system, the flags -s 0:0,hostbridge -s 31,lpc -l com1,stdio are used. The final flag -f specifies the location of the kernel, the location of the intial ramdisk and the kernel parameter.

That’s it! xhyve is simple and it works!