Red Hat Bugzilla – Bug 790789
virsh console fails when executed via remote ssh
Last modified: 2012-06-20 02:48:29 EDT
Description of problem: Trying to get a VM's console from a remote machine with no libvirt installed: [user@client]$ ssh root@libvirthost virsh console myVM root@libvirthost's password: 13:09:00.592: 32727: info : libvirt version: 0.9.4, package: 23.el6_2.4 (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>, 2012-01-06-02:50:25, x86-007.build.bos.redhat.com) 13:09:00.592: 32727: error : vshRunConsole:299 : unable to get tty attributes: Invalid argument Connected to domain RHEL6x64 Escape character is ^] [user@client]$ if I first ssh into libvirthost, and then run "virsh console myVM" it works fine Version-Release number of selected component (if applicable): RHEL 6.2 libvirt-0.9.4-23.el6_2.4.x86_64 How reproducible: Always Steps to Reproduce: 1. see console output above 2. 3. Actual results: Cannot access console Expected results: get access to VM's serial console Additional info:
virsh console needs to see a pseudo-terminal and ssh doesn't create one if it is asked to execute a remote command directly. You may, however, explicitly ask ssh to create the terminal with -t option: ssh -t root@libvirthost virsh console myVM
Two things - The error reporting from virsh console here sucks - 'ssh -t' won't actually work, because although that lets virsh puts the remote console into rawmode, the local console is still in cooked mode. So newlines get interpreted wrongly AFAICT, the only thing we can do is to improve the error reporting
With this patch https://www.redhat.com/archives/libvir-list/2012-February/msg00690.html You'll see $ ssh root@somehost virsh console f16x86_64 error: Cannot run interactive console without a controlling TTY
> - 'ssh -t' won't actually work, because although that lets virsh puts the > remote console into rawmode, the local console is still in cooked mode. So > newlines get interpreted wrongly Ignore this comment, it is wrong.
Dan Y., out of curiosity, what are you trying to implement with this?
One other thought, you could also use the remote stream support to connect the console, I don't know if that requires installing stuff on the machine from which you are connecting that you're uncomfortable with.
(In reply to comment #8) > One other thought, you could also use the remote stream support to connect the > console, I don't know if that requires installing stuff on the machine from > which you are connecting that you're uncomfortable with. What do you mean by "remote stream" - to set up a socket?
I mean http://libvirt.org/html/libvirt-libvirt.html#virStreamNew and friends that let you create a data pipe over a remote connection so you can do things like implement a serial console for on a VM on another machine.
(In reply to comment #10) > I mean http://libvirt.org/html/libvirt-libvirt.html#virStreamNew and friends > that let you create a data pipe over a remote connection so you can do things > like implement a serial console for on a VM on another machine. Thanks, I wasn't aware of this. My current solution seems to work, and looks like it's enough for now. I suppose this will be considered as a full-fledged feature in the future
The patch fixing the error handling of that case is available in build libvirt-0.9.10-4.el6, Daniel
Verify this bug with : libvirt-0.9.10-4.el6.x86_64 qemu-kvm-0.12.1.2-2.236.el6.x86_64 [ssh without -t ]: # ssh 10.66.85.217 virsh console r root@10.66.85.217's password: error: Cannot run interactive console without a controlling TTY [ssh with -t ]: # ssh -t 10.66.85.217 virsh console r root@10.66.85.217's password: Connected to domain r Escape character is ^] [ OK ] Setting hostname virtlab-66-84-201.englab.nay.redhat.com: [ OK ] Setting up Logical Volume Management: 2 logical volume(s) in volume group "vg_virtlab6684201" now active [ OK ] Checking filesystems Checking all file systems. ...
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2012-0748.html