1

My goal is to pass a tty device from the host to guest in Qemu.

I'm trying to emulate a ARM64 linux device using Qemu that has a USB-CDC device plugged into it. So far, I have emulated said USB-CDC device by passing simulated data via UDP to a pts device on my host machine like so:

sudo socat -d -d UDP-L:14550 pty,link=/dev/ttyFAKEACM0,raw,echo=0

I can use minicom on the host machine to read ttyACM0 and I get the data I expect.

I want to pass /dev/ttyFAKEACM0 on the host machine to the guest Qemu and have it show up as a tty on the guest. I have attempted to use -chardev like so:

  qemu-system-aarch64 \
  -m 4G \
  -smp 4 \
  -cpu cortex-a57 \
  -M virt -nographic \
  -kernel ${IMGDIR}/Image \
  -initrd ${IMGDIR}/uInitrd-5.7.0 \
  -append "root=/dev/vda1 serial=tty0 ubootpart=00000000-01 console=ttyAMA0,115200n8 rootwait init=/sbin/init rw earlyprintk rootfstype=ext4" \
  -drive if=none,id=mmc0,file=${IMGDIR}/edge-rootfs.img,index=1,format=raw \
  -device virtio-blk-device,drive=mmc0 \
  -chardev tty,path=/dev/ttyFAKEACM0,id=facm \
  -device pci-serial,chardev=facm 

When i start Qemu ttyFAKEACM0 does not show up at all in the guest. Am I misunderstanding how chardev works? How can pass a character device from the host to guest?

Thanks

0

1 Answer 1

1

I am also trying to pass through a TTY device from host to guest. In my case it is a USB adapter, controller.

I had success using the Qemu USB emulation:

-chardev serial,path=/dev/ttyACM0,id=acm \
-usb -device usb-serial,chardev=acm

The USB was captured by the guest as ttyUSB0.

If running as any other user than "root" then you may need to adjust the permissions to the device. In my case I created a special group for the adapter, controller and adjusted the permission accordingly; chmod g+rw /dev/ttyACM0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.