13th December, 2006

HOWTO - Debugging a remote Windows HVM under Xen using Windbg   

Posted in random | by evilbitz |



This HOWTO describes how do debug a Windows HVM domain under the Xen 3.0.3 virtual machine monitor using Windbg. It is taken for granted that you know how to debug a local windows using a serial modem cable, and that you know how to manage Xen virtual machines, these issues are not going to be addressed in this howto.

In order to remotely debug a windows HVM using Windbg we’ll create a setup that will allow us to do so. You’ll basically need to have a network connection (that supports TCP/IP) between the host and target (the one that is being debugged) machines.

Target Computer Configuration

Let’s start with the Windows virtual machine (HVM) - Start Windows (using xm create…) and once it started, open the boot.ini file with your favourite text editor. Duplicate the right boot line that is booting the installation of Windows that you want to debug, in the new line, add the following boot switches: “/debug /debugbreak /debugport=COM1″ (the serial baud rate default value is 19200).

Your new line should look something like this:

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS=”Microsoft Windows XP Professional” /fastdetect /debug /debugbreak /debugport=COM1

Save the file and shut-down the VM, open your HVM’s config file with a text editor. Make sure that the line “serial = ‘pty’” exists there, if it’s not than add it, but be sure that your Xen version supports this “feature”.

Now, launch the VM and attach the STDIN/STDOUT of the console (mapped to the HVM’s COM1 device) to a socket that you create with netcat:

xm create xp1
netcat -lk -p 4444 -c “xm console domain_id”

The second command creates a TCP socket and listens on port 4444. The INPUT and OUTPUT of the HVM COM1 serial port is now redirected to that socket. Not all versions of netcat on linux supports the -c switch, If you don’t have the right version of Netcat, then you can download it from here. We are now ready to configure the host computer.

Host Computer Configuration

At the host machine, which runs a native installation of Windows, we will create a virtual serial port that is associated with the target computer’s socket that we’ve created. In order to do that, we will use a tool called HW VSP (Virtual Serial Port), It is made by a company named Hw-Group which specialized in hardware kits. Anyway, the INPUT/OUTPUT of the serial port that you are going to create with HW-VSP will be redirected to the target’s remote socket. Write the target computer’s IP and port (4444), and name your virtual serial port COM5. This closes the loop between the HVM COM1 serial port and the local virtual serial port that you created.

Before you go and create the virtual serial port, you’ll have to configure HW-VSP not to use NVT, a feature that encapsulates the data being sent over the network for the virtual serial port, and not to use TEA based authentication. See the following image:

HW-VSP Configuration

That’s pretty much about it. Run windbg. Go to File->Kernel Debug.. and choose the virtual serial port you had created (COM5), specify the value 19200 for the baud rate. Press OK. You are ready to debug that HVM. Press ‘g’ to let Windows run after the debug break.

Some notes

It is possible to debug a Windows HVM from a windbg process that runs on anohter Windows HVM, but this can be accomplished pretty much in the same way that I described in this howto.

Comments and suggestions are welcome!

Update - 19/08/2008

Instead of using netcat, you can use the inetd service to redirect the i/o of the virtual serial port to a socket. This is more useful and easy since it is done automatically when you create the hvm. In order to do that you will have to edit these files: (I assume your hvm config file is called vistasp1)

  • /etc/inetd.conf - add this line at the end: “windbg_vistasp1 stream tcp nowait root /usr/sbin/tcpd xm console vistasp1″
  • /etc/services - add this line: “windbg_vistasp1 4444/tcp”
Digg!


There are currently 3 responses to “HOWTO - Debugging a remote Windows HVM under Xen using Windbg”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On October 1st, 2007, billyc said:

    some help on HOWTO - Debugging a remote Windows HVM under Xen using Windbg

    I have downloaded the gnu netcat 0.71 and build. Then I try the command after I do a

    xm create vista-debug.hvm
    ithan xm list

    my vista-debug id is 15
    netcat -lk -p 4444 -c “xm console 15″

    I was told the -k is not the option
    if I remove k which will show as
    netcat -l -p 4444 -c “xm console 15″

    the message is shown Couldn’t result host “xm console 15″

    My Dom0 is Fedora 2.6.18 + Xen 3.1 build would you please give some pointer for how to set up. the netcat and redirect the com to net port 4444 ! thanks.

  2. 2 On October 16th, 2007, andy g said:

    netcat -l -p 4444 -e “xm console ” worked for me. Notice the -e instead of -c.

    Also make sure to get the old version of HW Virtual Serial Port, to match these directions.

  3. 3 On November 6th, 2007, billyc said:

    Many thanks for the information. I got it work for my HVM Vista amd64. The old version 2.5.10 can be find in this links

    http://www.sofotex.com/HW-Virtual-Serial-Port-download_L36423.html

    The 3.0.2 newer version does not work that will under Windows XP (My Windbg PC)

Leave a Reply

Top »
"If you can't join them, beat them!"
Search Evilbitz: