bgarrels / phpvirtualbox

Automatically exported from code.google.com/p/phpvirtualbox
Other
0 stars 0 forks source link

VM's always listed as "Powered Off" #100

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Launch the app in a browser and the VM's list as powered off. 
Launch VB on the host and see that both are running fine.

What is the expected output? What do you see instead?
Expect to see the running VM's listed as running
VM's always listed as "Powered Off"

What version of phpVirtualBox, VirtualBox, and PHP are you using? On what
operating system?
0.5 beta release - build 2
VB version 3.2.10 r66523
Windows 2003 Server - Host
Ubuntu 9 - Quest
WinXP Pro - Guest

Original issue reported on code.google.com by cshaffer...@gmail.com on 18 Oct 2010 at 3:26

GoogleCodeExporter commented 9 years ago
Hello. What version of PHP are you using?

Original comment by imooreya...@gmail.com on 18 Oct 2010 at 6:08

GoogleCodeExporter commented 9 years ago
I am using XAMPPLite 1.7.3 which has PHP 5.3.1 with it.

Original comment by cshaffer...@gmail.com on 18 Oct 2010 at 6:15

GoogleCodeExporter commented 9 years ago
If you use VBoxManage to show running vms, do they show up in the list? Open a 
command prompt and cd to C:\Program Files\Oracle\VirtualBox then type:

VBoxManage list runningvms

Original comment by imooreya...@gmail.com on 18 Oct 2010 at 6:34

GoogleCodeExporter commented 9 years ago
If I start a VM from either the cmd line or phpvirtualbox nothing is listed for 
running vms. If I start a VM with the VirtualBox.exe it shows in the list.

I am not sure why it is not in the list when I start it from cmd line or via 
the browser. It is clearly running as I am connecting remotely to it.

Thanks

Original comment by cshaffer...@gmail.com on 18 Oct 2010 at 7:09

GoogleCodeExporter commented 9 years ago
Very strange. You don't have 2 installations of virtualbox do you? Also, are 
you starting vboxwebsrv from the command line?

Original comment by imooreya...@gmail.com on 18 Oct 2010 at 7:19

GoogleCodeExporter commented 9 years ago
Only have the one install.

The vboxwebsrv is launched from a batch file that is ran via srvany.

I did find the issue. The two VM's I have are being started as a service using 
"VboxVMService". It works however if a VM is started with it, it does not 
report in the output from "VBoxManage list runningvms". 

Starting them this seems to cause not only an issue with phpvirtualbox but the 
VirtualBox.exe GUI as well. Is there a way to get VMs to run as a service (main 
goal is so I do not have the login to the host server or leave it logged in) 
that is compatible with phpvirtualbox?

Thanks

Original comment by cshaffer...@gmail.com on 18 Oct 2010 at 8:35

GoogleCodeExporter commented 9 years ago
I have never figured out how to do this in windows. A google search shows 
people with similar issues (vms not showing up in the virtualbox gui). Once 
they are visible to the virtualbox gui, they will be visible to phpvirtualbox. 
You may try the forums at virtualbox.org.

Original comment by imooreya...@gmail.com on 19 Oct 2010 at 2:41

GoogleCodeExporter commented 9 years ago
Thanks for the assistance. In researching this I am finding no matter what 
method used to run VMs as a service the results are the same in that there is 
no way for the GUI or phpvirtualbox to detect there state. This is unfortunate 
as Virtual Box combined with phpvirtualbox would give Hyper-V and VMWare a run 
for their money if this services thing could be worked out.

Original comment by cshaffer...@gmail.com on 19 Oct 2010 at 6:48

GoogleCodeExporter commented 9 years ago
I have an (untested) idea, if you are willing to try it out. I'm surprised this 
has not been figured out in the virtualbox.org forums.

*) Make sure the service is set to run as the same user that you are logged in 
as. The same user you are running VirtualBox.exe as.

*) Add this at the top of the batch file before the vboxwebsrv line:

set USERNAME=user
set HOMEDRIVE=C:
set HOMEPATH=\users\user

Replace "user" with the actual user name. Make sure HOMEPATH is set to the 
actual path the the user's home directory.

Let me know if that works or not.

Original comment by imooreya...@gmail.com on 19 Oct 2010 at 7:19

GoogleCodeExporter commented 9 years ago
I just finished the test. Here is the setup.

Vboxwebsrv set as a service using srvany set to auto start that runs the 
following batch file.

set USERNAME=administrator
set HOMEDRIVE=C:
set HOMEPATH=\Documents and Settings\administrator
"C:\Program Files\Oracle\VirtualBox\vboxwebsrv.exe"

The service is set to logon using the administrator account. (Used this account 
to rule out any permissions issue that may have altered the results)

Restarted the server but did not logon.

Pointed my browser to the ip of the server and everything loaded. No VM's were 
started as I disabled the VboxVMSirvice. Started a VM via the browser and 
everything worked. The state is reported as running and I have all the 
controls. The console worked perfectly as well so I logged in and shutdown the 
VM. The browser picked up the state change once the VM shutdown and went to 
"Powered Off"

So to take this test one step further I remotely started the VboxVMSerice by 
connecting to the host server's services MMC from my workstation. The VM 
started fine but phpvirtualbox still reported the VM as powered off. I changed 
the VboxVMSerice to run using the administrator acount as well but the result 
is the same.

So I am wondering if the VM was started via the VboxWebSrv at host server 
startup if phpvirtualbox would see the state properly. In my mind it would be 
the no different than me clicking the start from the browser and it sending the 
command to VboxWebSrv which starts the VM. I am reading through the SDK now but 
wanted to get the results of the testing posted right away. I am thinking it 
could be a variation of the function phpvirtualbox has now for starting VM's 
just ran at startup after the vboxwebsrv is started. Or something along thoughs 
line.

Hope this is helpful in some way and sorry for writing a book.

Original comment by cshaffer...@gmail.com on 19 Oct 2010 at 11:21

GoogleCodeExporter commented 9 years ago
Better to have more information than not enough :)

It is not a matter of how a VM is started or stopped. It is a matter of 
VboxVMService using one virtualbox path and vboxwebsrv using another. We just 
have to get them to use the same paths.

I'm not very familiar with VBoxVMService, but it looks like if you change the 
VBOX_USER_HOME setting in VBoxVMService.ini to C:\Documents and 
Settings\administrator\.VirtualBox things may work. Keep both services running 
as the administrator account.

Let me know how it goes.

Original comment by imooreya...@gmail.com on 20 Oct 2010 at 12:34

GoogleCodeExporter commented 9 years ago
I made sure both the VBoxVMService.ini and vboxwebsrv are using the same path 
and both services are using the administrator account. This server is a 
standalone so it does not have a DOMAIN\administrator account to get confused 
with.

Same issue. If the VM is started using VBoxVMService, phpvirtualbox does not 
see as started. I also added the VBOX_USER_HOME to the system variables and 
tried but no change.

Original comment by cshaffer...@gmail.com on 20 Oct 2010 at 11:51

GoogleCodeExporter commented 9 years ago
There is a solution, although I'm not sure I've implemented it correctly in 
VBoxVMService.  I just added the following lines at the end of the 
VBoxVmServiceMain function,

    // Start web service
    // get working dir
    char pWorkingDir[nBufferSize+1];
    char pItem[nBufferSize+1];
    GetPrivateProfileString(pItem,"WorkingDir","",pWorkingDir,nBufferSize,pInitFile);

    RunConsoleApp(NULL, "C:\\Program Files\\Oracle\\VirtualBox\\vboxwebsrv.exe", pWorkingDir, NULL);

so that when starting the service, which starts my VMs, I also have an instance 
of vboxwebsrv running in the same context as the VMs.  And now phpVirtualBox 
sees my machines started by the service.

Original comment by harold.r...@gmail.com on 21 Jun 2011 at 4:05