Wednesday, November 6, 2013

How to redirect console output of one Virtualbox VM to another?


After I started using Ubuntu VM in VirtualBox, I needed my ubuntu VM's console output to be redirected to another guest VM (in context of kgdb debugging). The way to achieve such redirection is 
  • In VM being redirected from (say VMObserved): Create a serial port in the VM & then enable redirection to serial port in boot options of the VM. 
  • In VM being redirected to (say VMObserver): Attach to the serial port of the above VM using putty.

Following are the steps I used in Virtualbox host, VMObserved & VMObserver:

Steps I used in VMObserved
  • I opened VirtualBox, selected my VM - MyUbuntu1, clicked "Settings".
  • Next, selected my VM & clicked on "Settings" in VirtualBox top menu.
  • Next, clicked on "Ports" tab:

  • Next, checked "Enable Serial Port", selected "Host Pipe" option & provided the file to which redirection should happen:

Steps I used in VMObserver
  • I opened VirtualBox, selected my VM - Ubuntu_Test_VM, clicked "Settings".
  • Next, selected my VM & clicked on "Settings" in VirtualBox top menu.
  • Next, clicked on "Ports" tab:

  • Next, checked "Enable Serial Port", selected "Host Pipe" option, checked "Create Pipe" optio & provided the file (the same filename specified in configuring VMObserved) to which redirection should happen:
  • Start the VMObserver. VM Observer should be started before VMObserved so that pipe is created by VMObserver & its attached to by VMObserved.
  • Install Putty: sudo apt-get install 
  • Start Putty to attach to serial console



Steps I used in VMObserved
  • Start the VMObserved (VMObserved should be started only after starting VMObserver)
  • Next, start the VM & edit boot options during linux booting to add "console=ttyS0 console=tty0 ignore_loglevel"


And here is finally the console output (kernel boot log messages) appearing in VMObserver:


Hope this helps.

    No comments:

    UA-48797665-1