[libvirt] Improve the reliability of pty path parsing