Skip to main content Link Menu Expand (external link) Document Search Copy Copied

QEMU Setup


Please note that many students using M1 Macs who’ve tried this setup (which was introduced during the Fall 2022 semester) have found it to run very slowly. Because of this, we recommend that M1 Mac users use the Instructional machine setup instead.

On macOS, we recommend using QEMU to run the virtual machine. If you have the Homebrew package manager installed, you can install QEMU using brew install qemu@6.2.0.

After that, follow these instructions to set up the virtual machine:

  1. Download the QEMU VM image cs162-student-vm.qcow2.

  2. cd to the folder containing the downloaded image and run the following command in your terminal:

qemu-system-x86_64 -accel hvf -accel tcg -m 512M -drive if=virtio,format=qcow2,file=cs162-student-vm.qcow2 -nic user,model=virtio,hostfwd=tcp:127.0.0.1:12445-:445,hostfwd=tcp:127.0.0.1:16222-:22

Note: Running the above command might give you the following error:

qemu-system-x86_64: -accel hvf: Unknown Error
Abort trap: 6

For macOS Big Sur and onwards, you will need to authorize QEMU to run with HVF to fix this issue using the following two commands:

cat > entitlements.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.hypervisor</key>
    <true/>
</dict>
</plist>
EOF

and

codesign -s - --entitlements entitlements.xml --force $(which qemu-system-x86_64)

Accessing the machine

To access the machine, we recommend that you don’t use the QEMU GUI as you can’t do things like copy-paste. Instead, you can SSH into the VM via the following commmand:

ssh -p 16222 vagrant@localhost

You will then be asked to enter a password. The password is simply “vagrant” (without the quotes). Note that the VM must be running for you to be able to SSH, so ensure that the qemu-system-x86_64 command from the previous step succeeded and the VM is running.