Using QEMU on x86_64 macOS
Setting up a virtual machine (VM) on Linux using open source software is the standard way of doing things, but on macOS it usually involves VMware Fusion or Boot Camp. QEMU is my favorite hypervisor and wanted to use it when I have to use macOS as well.
First, install a package manager like brew, then run
brew install qemu.
On Linux, QEMU is typically used in conjunction with the KVM framework. This is a Linux kernel specific framework that is not implemented on macOS, but it has a somewhat functionally equivalent called Hypervisor.Framework, which is implemented using the hvf code from Veertu Inc. This can be used using the following flag:
-accel=hvf. It is missing some features, as documented on the QEMU wiki
Sharing files (but not clipboard)
For exchanging files, support for 9p file system was packaged in 2022 for Homebrew, so we can use this for exchanging files between the host and the guest operating system using the following configuration:
mount -t 9p -o trans=virtio Downloads /tmp/shared -oversion=9p2000.L,poxiacl,msize=104857600,cache=none
Ideally, this should be done using an entry in
Clipboard sharing would be convient but I have disabled this for security reasons because my personal purpose for this VM is CTF usage and running untrusted binaries. I use a shared file as a clipboard, which works fine for me personally.
Somehow I was unable to get bridged networking interfaces working, but I have not debugged this problem in depth. Using an adapter with NAT, accessing the internet works fine. This is done using the following flag:
On a macOS keyboard, the titlebar of QEMU VMs are a bit confusing. It says “press ctrl + alt + g to release Mouse”, but in practice this is control + option + g. Using a Linux VM on a MacBook is still very confusing to me when it comes to shortcuts.