Redirect guest COM port to host tty
Hi all! I have a slackware64-15.0 linux host running libvirt-11.10.0 with qemu 10.2.2 and a windows XP guest. I'm trying to have the gustes COM1 port redirected to the hosts /dev/ttyUSB0 device. I have not found a direct way of doing this in virt-manager since the only options for a serial device are "Output to a file", "Pseudo TTY" or a "UNIX socket". I have managed to modify the domains XML adding the following
<commandline xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <arg value='-chardev'/> <arg value='serial,path=/dev/ttyUSB0,id=hostserial0'/> <arg value='-device'/> <arg value='pci-serial,chardev=hostserial0'/> </commandline>
When I start the VM with this I get an error that says
Could not open '/dev/ttyUSB0': Operation not permitted
I checked the device's permissions which are u+rw,g+rw and qemu is being executed with root permissions, I added o+rw to /dev/ttyUSB0 just in case but got the same error. I also tried with /dev/tty0 but got the same error. Thanks in advance! Best regards, Dave. Sent with Proton Mail secure email.
On Fri, Aug 21, 2026 at 19:44:06 +0000, bd730c5053df9efb via Users wrote:
Hi all!
I have a slackware64-15.0 linux host running libvirt-11.10.0 with qemu 10.2.2 and a windows XP guest. I'm trying to have the gustes COM1 port redirected to the hosts /dev/ttyUSB0 device. I have not found a direct way of doing this in virt-manager since the only options for a serial device are "Output to a file", "Pseudo TTY" or a "UNIX socket". I have managed to modify the domains XML adding the following
<commandline xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <arg value='-chardev'/> <arg value='serial,path=/dev/ttyUSB0,id=hostserial0'/> <arg value='-device'/> <arg value='pci-serial,chardev=hostserial0'/> </commandline>
Use of qemu:commandline is at your own risk because libvirt can't know what host resources the VM needs access for.
When I start the VM with this I get an error that says
Could not open '/dev/ttyUSB0': Operation not permitted
So this is not surprising, because ...
I checked the device's permissions which are u+rw,g+rw and qemu is being executed with root permissions, I added o+rw to /dev/ttyUSB0 just in case but got the same error. I also tried with /dev/tty0 but got the same error.
... libvirt creates a private /dev/ filesystem (via a mount namespace) that is populated *only* by devices that the XML requests. As qemu:commandline directly manipulates the commandline libvirt doesn't know that you need access to /dev/ttyUSB0. Said that there is no reason to do qemu:commandline backdoor as host character devices are directly supported: <serial type='dev'> <source path='/dev/ttyUSB0'/> <target port='0'/> </serial> https://www.libvirt.org/formatdomain.html#host-device-proxy
Thank you very much for the explanation and the solution! I looked for the answer and saw the page you linked but didn't catch that section. Thank you very much again! Best regards, Dave. Sent with Proton Mail secure email. On Monday, August 24th, 2026 at 04:32, Peter Krempa via Users <users@lists.libvirt.org> wrote:
On Fri, Aug 21, 2026 at 19:44:06 +0000, bd730c5053df9efb via Users wrote:
Hi all!
I have a slackware64-15.0 linux host running libvirt-11.10.0 with qemu 10.2.2 and a windows XP guest. I'm trying to have the gustes COM1 port redirected to the hosts /dev/ttyUSB0 device. I have not found a direct way of doing this in virt-manager since the only options for a serial device are "Output to a file", "Pseudo TTY" or a "UNIX socket". I have managed to modify the domains XML adding the following
<commandline xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <arg value='-chardev'/> <arg value='serial,path=/dev/ttyUSB0,id=hostserial0'/> <arg value='-device'/> <arg value='pci-serial,chardev=hostserial0'/> </commandline>
Use of qemu:commandline is at your own risk because libvirt can't know what host resources the VM needs access for.
When I start the VM with this I get an error that says
Could not open '/dev/ttyUSB0': Operation not permitted
So this is not surprising, because ...
I checked the device's permissions which are u+rw,g+rw and qemu is being executed with root permissions, I added o+rw to /dev/ttyUSB0 just in case but got the same error. I also tried with /dev/tty0 but got the same error.
... libvirt creates a private /dev/ filesystem (via a mount namespace) that is populated *only* by devices that the XML requests.
As qemu:commandline directly manipulates the commandline libvirt doesn't know that you need access to /dev/ttyUSB0.
Said that there is no reason to do qemu:commandline backdoor as host character devices are directly supported:
<serial type='dev'> <source path='/dev/ttyUSB0'/> <target port='0'/> </serial>
participants (2)
-
bd730c5053df9efb -
Peter Krempa