1

I've recently started deving on a M1 mac, and I wanted to get a simple linux system virtualized. Multipass seemed like a great idea, until I was struggling to forward ports.

So I created a very simple qemu machine, modeled off the way multipass emulates their instances here it is:

qemu-system-aarch64 \
-machine virt,highmem=off \
-accel hvf \
-name ubuntu-qemu \
\
-cpu cortex-a72 \
-smp 4 \
\
-m 4096 \
\
-drive file=edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
-drive file=ubuntu-os.qcow2,if=virtio \
\
-nographic \
\
-net nic,model=rtl8139 \
-net user,hostfwd=tcp::2222-:22 \
\
-fsdev local,id=projects,path=/Users/cdf/Projects,security_model=none \
-device virtio-9p-pci,fsdev=projects,mount_tag=projects

This starts up a very simple ubuntu machine, works great I can forward ports.

the only thing I can't get right is how to share a folder as you can see above I'm trying:

-fsdev local,id=projects,path=/Users/cdf/Projects,security_model=none \
-device virtio-9p-pci,fsdev=projects,mount_tag=projects

on the instance, I have created an entry in /etc/fstab to mount projects

projects /home/cdf/projects 9p trans=virtio 0 0

and this seems to be working... to a point

I can access the share, however I can't write changes to the share:

cdf@ubuntu:~$ ll ./projects
ls: ./projects: Network dropped connection on reset
ls: ./projects/.: Network dropped connection on reset
ls: ./projects/yoco: Network dropped connection on reset
ls: ./projects/cdf: Network dropped connection on reset
total 4
drwxr-xr-x  4 503 dialout  128 Mar 24 07:26 ./
drwxr-xr-x 14 cdf cdf     4096 Mar 26 18:37 ../
drwxr-xr-x  4 503 dialout  128 Mar 24 07:27 cdf/

I also wanted to make the owner and group cdf like multipass mounts do. I'm not too sure what to do to get the mount to work properly, can anyone help me?

1 Answer 1

1

I'm on an Intel mac, but I ran into the same "Network dropped connection on reset" errors in trying to mount a 9p volume. For me, adding version=9p2000.u to the line in fstab seemed to help. This was based on a comment in the NixOS issue. My full /etc/fstab line looks like this:

Downloads /home/gsf/Downloads 9p _netdev,trans=virtio,version=9p2000.u,msize=104857600 0 0

This is the relevant parameter in my qemu command:

-virtfs local,path=/Users/gsf/Downloads,security_model=none,mount_tag=Downloads

With security_model=none I ended up modifying user and group IDs in the guest to match the host. You may have better luck with security_model=mapped. I posted some notes on my setup in a gist at Ubuntu VM on macOS with QEMU.

You must log in to answer this question.

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