3

I'm trying to access a Windows 10 virtual machine from my Linux host by using virsh console.

But when I do so, I get the empty console that many others have experienced.

virsh console win10
Connected to domain 'win10'
Escape character is ^] (Ctrl + ])

And I can't type at all. Anyway, is there a configuration that I can do in the VM to allow this, specifically for Windows? Thanks

2 Answers 2

5

virsh console is a TTY console, which is the uart in the VM (a.k.a. "the COM port"). Does your Windows 10 output anything into this COM port?

Windows expects a VGA hardware to output into, so configure a VNC for the VM and connect with VNC Viewer for interacting with the VM. For this to be possible, you'd configure in the libvirt xml domain config something like this:

    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5901' autoport='no'/>
    <video>
      <model type='cirrus' vram='5120' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>

(it is possible you'd need to use another PCI slot address and TCP port for VNC to this machine).

Then restart (stop then start) a VM, and confirm qemu is listening on the chosen port:

vh1 ~ # netstat -lnpt | grep 590
tcp        0      0 127.0.0.1:5900          0.0.0.0:*               LISTEN      1774/qemu-system-x8 
tcp        0      0 127.0.0.1:5901          0.0.0.0:*               LISTEN      13692/qemu-system-x 
tcp        0      0 127.0.0.1:5902          0.0.0.0:*               LISTEN      2526/qemu-system-x8 
tcp        0      0 127.0.0.1:5903          0.0.0.0:*               LISTEN      3755/qemu-system-x8 

Notice, in my case it listens on localhost, for security.

To connect to this via SSH tunnel, use a TCP port forwarding. It is built into standard Linux VNC client package:

vncviewer -via virtualization.host.name localhost:1

(for connecting to the 5901's VNC you use VNC screen 1). It'll connect via SSH to the virtualization.host.name and forward some local port to the localhost:5901 of the server, right as we need; then connects VNC client to this forwarded port. So your VNC will be secured with SSH.

Or, you can listen on any IP address (less secure). Or you can set up this TCP tunnel some other way. But this way I presented here is more convenient. Or, I forgot about that, use virt-viewer to connect to the screen, didn't used it for ages.

Also, Windows Server supports (at least, supported some time ago) a special administration console (SAC) that runs on the COM port and can be used to do some operations (task kill, etc.). This console can be accessed with virsh console. But I doubt Windows 10 has that.

4
  • Can I connect to VNC if I have a console-only server?
    – tymur999
    Sep 11, 2021 at 16:18
  • Also, I'm trying to add an output to the COM port with this command bootcfg /EMS /PORT com1 /BAUD 115200 /ID 1, but it's throwing a syntax error and saying that a "default argument is missing". Do you know what's wrong with this command?
    – tymur999
    Sep 11, 2021 at 16:20
  • No, I don't know much about Windows. However, I don't know what's the problem with VNC; you'd connect to the VM screen, for which the emulator (Qemu) provides a VNC interface. I updated the answer on how to configure libvirt to allow this connection. Sep 11, 2021 at 16:22
  • 1
    In the end I ended up using VNC and connecting from a remote PC. Thanks for the suggestion!
    – tymur999
    Sep 11, 2021 at 17:30
4

virsh console opens the VM's serial console, if it has one. If not, as in the case of Windows generally, then nothing happens.

You should be using virt-viewer to view VMs with graphical consoles, or better yet, the well integrated virt-manager.

4
  • Sorry, but I have a console server, so I can't use any graphical tools on it
    – tymur999
    Sep 11, 2021 at 16:54
  • @tymur999 virt-manager can work over SSH tunnel, so you may run in on the local PC and manage a remote headless server Sep 11, 2021 at 19:03
  • @tymur999 Yes, use virt-manager with an ssh tunnel to your remote server. It's quite surprising that you aren't already doing so. Sep 11, 2021 at 20:12
  • Sorry, I didn't know that existed. But it's great! I'm using it now
    – tymur999
    Sep 11, 2021 at 20:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .