I use libvirt to manage a container based environment. Is there an
efficient method for testing if someone has a console session open for a
given container? The approach I'm using at the moment is to use lsof and
check if there is an entry for the container's console pts device. For
example, I can determine a container's console device from its xml
definition:
# virsh dumpxml vm-00|grep -A 4 pty
<console type='pty' tty='/dev/pts/3'>
<source path='/dev/pts/3'/>
<target type='lxc' port='0'/>
<alias name='console0'/>
</console>
Once I have pts device, I can do something like
# if lsof /dev/pts/3; then echo "Container vm-00 has an active console
session"; fi
This all works fine but we've found that lsof is very expensive. Is
there a more efficient means to make this active console check?
Peter
Show replies by date