Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running qemu's like this:

$ sudo qemu -boot d -m 1024 \
-netdev tap,id=tap0 \
-device virtio-net-pci,netdev=tap0,id=vth0 \
-drive file=ubuntu.iso,media=cdrom,cache=none,if=ide \
-monitor pty \
-serial pty \
-parallel none \

When I check /dev/pts/:

$ sudo lsof +d /dev/pts/

Qemu pty's do not show up, although they do work using for example:

$ sudo screen /dev/pts/8

How can I figure out which pty's are from which qemu?

share|improve this question
up vote 1 down vote accepted

You can do it this way using virsh along with some scripting:

$ for i in `virsh list | awk '{print $2}' | egrep -v "^$|Name"`; do
     printf "%-14s:%s\n" $i $(virsh ttyconsole $i | grep -v "^$");

cobbler       :/dev/pts/1
xwiki         :/dev/pts/3
fan           :/dev/pts/4
mercury       :/dev/pts/5
mungr         :/dev/pts/0
win2008R2-01  :/dev/pts/7

Incidentally those same VMs through an lsof command:

$ lsof|grep qemu|grep ptmx
qemu-kvm   3796      root   14u      CHR                5,2         0t0        993 /dev/ptmx
qemu-kvm   3895      root   14u      CHR                5,2         0t0        993 /dev/ptmx
qemu-kvm   3972      root   14u      CHR                5,2         0t0        993 /dev/ptmx
qemu-kvm   4294      root   15u      CHR                5,2         0t0        993 /dev/ptmx
qemu-kvm  11897      root   14u      CHR                5,2         0t0        993 /dev/ptmx
qemu-kvm  16250      root   15u      CHR                5,2         0t0        993 /dev/ptmx

It doesn't look like lsof shows which pty they're using, just that they're using the ptmx. See the ptmx man page for more info.


The left side are the names of the VMs and the right side is the pts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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