Page 1 of 2

use virtualbox on a remote machine

Posted: 7. Jul 2008, 23:25
by simonchennj
Hi,

I am wondering whether I can ssh to a remote server, start a VM on that server and somehow directly access the console of the VM? I don't want to tunnel the graphic interface...

thanks.
-Simon

Posted: 7. Jul 2008, 23:56
by Sasquatch
You can with the headless command. Run VBoxHeadless, wait for it to start completely and then you can SSH to it if you set it right. Why shouldn't it be possible?

Posted: 8. Jul 2008, 02:20
by simonchennj
Sasquatch wrote:You can with the headless command. Run VBoxHeadless, wait for it to start completely and then you can SSH to it if you set it right. Why shouldn't it be possible?
In this case, you still need to know the IP address of the VM. It's possible that the machine is not properly configured with DHCP.

I want to see the boot up message of the VM as soon as it starts. At that time, no ssh is available...

Posted: 8. Jul 2008, 04:17
by TerryE
No, if you
  • ssh from your PC to fred, say, and type in VBoxHeadless -s yourVM -p 4000 & but don't hit enter yet
  • now again from your PC, RDP to fred:4000 but again don't enter
  • now hit enter on the VBoxHeadless and as soon as the "listening on port" mesage comes up, switch to the RDP command on your PC and hit enter.
Your RDP session will now connect to the VM console and you can watch the entire boot sequence.

I explain in a little more detail in http://forums.virtualbox.org/viewtopic.php?t=7580

Posted: 8. Jul 2008, 05:24
by simonchennj
TerryE wrote:No, if you
  • ssh from your PC to fred, say, and type in VBoxHeadless -s yourVM -p 4000 & but don't hit enter yet
  • now again from your PC, RDP to fred:4000 but again don't enter
  • now hit enter on the VBoxHeadless and as soon as the "listening on port" mesage comes up, switch to the RDP command on your PC and hit enter.
Your RDP session will now connect to the VM console and you can watch the entire boot sequence.

I explain in a little more detail in http://forums.virtualbox.org/viewtopic.php?t=7580
Emm... This sounds like an interesting solution. Is it possible to log into the machine without using RDP? I only want console access...

Posted: 8. Jul 2008, 11:10
by TerryE
Siggghhh. I know RDP is M$'s acronym for Remote Desktop Protocol, but it really means scraping the Graphics Adapter output, and redirecting the keyboard and mouse. It works just as well for a text based console (actually better) as a GUI.

I am an old hack. I tend to stick to console/ssh access to my server VMs. I have my Workstation VMs configured not to start up X by default.

Your last Q is a bit like saying can I do console access without using the protocol designed to give me console access. Of course, you could always take the OSE build and develop your own text based console access implementation, but believe me RDP works well, though I only tend to use it if I am diagnosing the boot sequence on the fly, because like you I prefer ssh.

Posted: 8. Jul 2008, 15:57
by simonchennj
TerryE wrote:Siggghhh. I know RDP is M$'s acronym for Remote Desktop Protocol, but it really means scraping the Graphics Adapter output, and redirecting the keyboard and mouse. It works just as well for a text based console (actually better) as a GUI.

I am an old hack. I tend to stick to console/ssh access to my server VMs. I have my Workstation VMs configured not to start up X by default.

Your last Q is a bit like saying can I do console access without using the protocol designed to give me console access. Of course, you could always take the OSE build and develop your own text based console access implementation, but believe me RDP works well, though I only tend to use it if I am diagnosing the boot sequence on the fly, because like you I prefer ssh.
Thanks for your reply :-)
The main reason is that using RDP from a remote site is kind of slow... ssh cannot be guaranteed because the guest may not have network properly configured. I am looking into how to configure the serial port as a way to access console...

Posted: 8. Jul 2008, 17:04
by TerryE
Simon,

I am not sure how to say this politely so forgive me, I'll be blunt. You need your head examined. If you are on the same LAN segment then text based RDP is really fast; even over a reasonable internet link its still OK; far, FAR faster than any serial comms. The RDP protocol uses compression and this is very efficient for text and you can tweak the framing parameters to optimize performance. And you are only watching the boot sequence for goodness sake!!! So before you start stringing up RS232 cables and posting to ask how to get serial ports working, why don't you just park your preconceptions and try it!!!

Posted: 8. Jul 2008, 17:35
by simonchennj
TerryE wrote:Simon,

I am not sure how to say this politely so forgive me, I'll be blunt. You need your head examined. If you are on the same LAN segment then text based RDP is really fast; even over a reasonable internet link its still OK; far, FAR faster than any serial comms. The RDP protocol uses compression and this is very efficient for text and you can tweak the framing parameters to optimize performance. And you are only watching the boot sequence for goodness sake!!! So before you start stringing up RS232 cables and posting to ask how to get serial ports working, why don't you just park your preconceptions and try it!!!
Maybe I am not explaining myself clearly...
I have remote machine, which I can ssh to and where all the VMs run.
I can configure the VM so that its console can be accessed through its (VM's) serial port. That serial port is accessed as a pipe file on the remote machine. So, I can ssh to the remote machine, use the pipe file to access the VM's console. This only requires ssh connection, not RDP - no matter how efficient it is, it is still bouncing graphical data around...
Is this clear enough?

Running VirtualBox Remotely

Posted: 10. Jul 2008, 13:37
by kunaljain
Hi,

I can run VIrtualBox remotely by using VBoxVRDP command but when i try to save the state of the Virtual Machine the process is aborted in the middle.

I google it but still not able to find any clue regarding the same
Any help will be highly appriciated

I have copied my scripts below which i m using remotely via SSH'ing into the Virtual Server
Scripts to start the VirtualBox

Code: Select all

#!/bin/sh

#ensure that the server name is entered
if [ -z $1 ] ; then
        echo "Please enter the server you wish to start"
        echo "usage cmd <server>"
        exit 1
fi

showvminfo=`VBoxManage showvminfo $1`
showvminfoline=`echo $showvminfo | cut -d":" -f13`
status=`echo $showvminfoline | cut -d" " -f1`

if [[ "$status" = "running" ]] ; then
        echo VM Guest $1 is already powered on!
        exit 1
else
        VBoxVRDP -startvm "$1" &
fi
Script to save state of a running VIrtual Machine remotely

Code: Select all

#!/bin/sh

#ensure that the server name is entered
if [ -z $1 ] ; then
        echo "Please enter the server you wish to stop"
        echo "usage cmd <server>"
        exit 1
fi

showvminfo=`VBoxManage showvminfo $1`
showvminfoline=`echo $showvminfo | cut -d":" -f13`
power=`echo $showvminfoline | cut -d" " -f1`
status=`echo $showvminfoline | cut -d" " -f2`

vm="$power $status"

if [[ "$vm" = "powered off" ]] ; then
        echo VM Guest $1 is already powered off!
        exit 1
else
        VBoxManage controlvm "$1" savestate
fi
If i run these scripts on the virtual server then it works perfectly fine but remotely it abort the savestate process in middle

Modbreak:
Please use code blocks next time, that saves the whole format.

Posted: 10. Jul 2008, 15:33
by TerryE
Two comments: first to Simonchennj, I know exactly what you're trying to Simon. I am sure that we will be interested in a write-up if you get it working. It's just that you are going to an awful log of trouble to do this. Most of the console content is logged directly anyway. Once SSH is up then you can use it. The only time you need to watch the boot sequence is if something it failing and you need to drop into init 1 to fix something -- a mount prob or a config setting. This is once in a blue moon. OK so the display is a bit sluggish, but I've done this across continents. Its workable. Price up the cost of your hourly rate to get your solution working, then price up the seconds delay caused by the RDP overheads and extra cost of the network traffic then decide which is most cost effective.

Now to kunaljain I just want want to clarify something: when you say "remotely via SSH'ing into the Virtual Server", I take it you really mean "remotely via SSH'ing into the physical Server which is acting as the VM host". That you connect to the server using SSH do something like a startVM myVM, then on a later session you reconnect and do a stopVM myVM. I thought that this might be a nohup issue so I did a quick search and came across this http://forums.virtualbox.org/viewtopic.php?t=2817.

Running VirtualBox Remotely

Posted: 11. Jul 2008, 06:30
by kunaljain
Hey TerryE,

Let me clarify one thing i have installed CentOS 5.2 on my Dell PowerEdge R200 Server and i installed VIrtualBox on it and now i m using that VIrtualBox to run Two different Guest OS (Both Debian) and i ssh into my CentOS system through other machine to run Guest OS

Using VBoxVRDP command I can run both the Guest OS but if i try to save their state usting VBoxManage controlvm <Guest OS> savestate remotely then the process is aborted in the middle. Message shown there is

VirtualBox Command Line Management Interface Version 1.6.1
(C) 2005-2008 Sun Microsystems, Inc.

0%...


Any Idea why this is happening

Thanks in advance.

Posted: 11. Jul 2008, 16:51
by TerryE
I'd better come clean. At the moment both the machines I use as hosts are XP, though I am about to upgrade one to Linux. I don't run VBox on the current "bare metal" Linux boxes that I use, because they are "production" systems. So I can only provide limited help because I can't replicated this in my current environments. I've has a thorough search of the VBox site and can't find any discussions or tickets relating to savestate aborts other than this one. So it looks as if it might be worth raising a ticket on this one.

However before you do, I assume that you also start VboxHeadless (VboxVRDP just symlinks to this now) by ssh? Could you try doing something like:
  • nohup VboxHeadless -s yourMachine -p yourPort >/tmp/$$VRDP.log 2>&1 &
as your start-up code and see if this makes any difference. Alternatively, log onto the console and start up VboxHeadless from there and don't log out. Then see if your ssh based savestate still craters.

Posted: 11. Jul 2008, 19:00
by kunaljain
Hey TerryE,


Thanks for your reply.

Yup! i tried all possible combination's but still in black hole. In fact if i run the same shell script on the Cent OS machine (where i installed VirtualBox and Guest OS) It runs perfectly Fine but if i try to run the same script (For Saving State) by SSH'ing into the Cent OS Machine ( I mean Remotely) then Script to start the Guest OS work perfectly Fine for me but i m not able to save the state remotely.


Thanks

Posted: 11. Jul 2008, 19:28
by TerryE
OK, so what you are saying is you have explicitly tried all of the four following scenarios with the following results:
  • console startvm, console savestate: works
  • ssh startvm, console savestate: works
  • console startvm, ssh savestate: fails
  • ssh startvm, ssh savestate: fails
. OK, so have you tried using an at job? You should be able to get this working. So try:
  • console startvm, console initiated at savestate
  • console startvm, ssh initiated at savestate
If the first of these fails then you've taken ssh out of the equation, which make a simpler test case to post as a ticket. If only the second fails then I really need to think again. :roll: