QEMU and rdesktop

Although I use Gentoo Linux on my desktop and I’m happy with it, there are times when my employer requires me to use the Leading Operation System™, mostly to write detailed instruction on how to use their system.

I don’t want to reboot my desktop machine, because I have a lot of open applications and terminal sessions. Closing them and setting them up again would consume too much time. I have a laptop, but since my girlfriend uses it, I have to take it away from her when I need it. I want a virtual machine on my Gentoo.

I’ve tried QEMU. I managed to start it and install the system. Setting up the network took me some time, mostly due to lack of examples in the QEMU documentation. Finally I got the system running, with network support and Internet Access.

The speed of the guest operating system is fair, but there’s one thing that is slow and causing problems: the mouse. It sometimes stops on the way just as if there was an invisible fence. I have to go to the opposite side of the screen and return.

Why use the emulated mouse? I could connect to the guest OS with rdesktop and have native mouse. The problem is that QEMU doesn’t allow TCP connection to the guest OS. I tried to create a reverse SSH tunnel with Putty, but Putty won’t start on the guest OS, displaying an useless error message which suggests reinstalling Putty. A friend of mine suggested the commercial SSH client. I tried it and managed to establish a reverse tunnel to the host OS.

Unfortunately, the proprietary SSH client couldn’t handle the tunnel, because the after logging in, the window of rdesktop remained black. I finally found a Windows port of the OpenSSH client, which created a tunnel and worked correctly.

Summarizing, what I’ve done was:

  1. Install QEMU
  2. Run the guest machine
    sudo modprobe tun
    sudo chmod 666 /dev/net/tun
    sleep 5
    qemu -net nic -net tap -hda xp.img -net user xp.img
    (please note that my Windows system image is named xp.img)
  3. Install Windows on the guest machine
  4. Install OpenSSH for Windows on the guest machine
  5. Guest machine: open a command-line (DOS?) window and:
    ssh -f -N -R 13389: myusername@
    ( is IP number of the host machine)
  6. On the host machine, run the rdesktop client
    rdesktop -u Mywindowusername -E -a 16 localhost:13389

Through rdesktop, the guest system works at the same speed, but the mouse is more responsive and it doesn’t get imprisoned inside the QEMU’s window.


Author: automatthias

You won't believe what a skeptic I am.