linux guest running as a service on a Windows host
Posted: 15. Mar 2009, 04:06
I have spent some time researching options other than vboxvmservice for running virtualbox virtual machines as services on windows. I'm posting this mainly as a reference for myself and to save other people time if they need to do this.
I wanted to see why the usual method for running an application as a service did not work and why vbox had special needs.
The usual methods:
SRVANY
A howto for srvany here
NT WRAPPER
A howto for NT Wrapper here
Basically when either of these methods closes a virtual machine they terminate the process and either leave the virtual machine running or kill it without putting the virtual machine into a safe state first.
An Alternative to VBOXVMSERVICE : SRVSTART
Srvstart appears to have some functionality that might work. I guess it is very similar to VboxVMService but has slimmer requirements (Visual c++ redistributable only).
A howto for srvstart here
I have found that srvstart works quite well. The main issue with srvstart is it's simplicity (as well as it's benefit). You can build you environment up using environment variables, you can set an external program up to test whether the service is running and also to stop the service. You can also set timeouts for the service. It's not very clever at parsing parameters, so you have to get your configuration right or it throws out (meaningful but) obtuse win32 system error messages. Another issue is that one cannot redirect stdout/stderr so the service needs to open a console or virtualbox fails to start. Bearing these issues in mind srvstart does what it says on the box and does it with great flexibility.
Here are some other tools to have handy when working with virtualbox when running as a service:
I wanted to see why the usual method for running an application as a service did not work and why vbox had special needs.
The usual methods:
SRVANY
A howto for srvany here
NT WRAPPER
A howto for NT Wrapper here
Basically when either of these methods closes a virtual machine they terminate the process and either leave the virtual machine running or kill it without putting the virtual machine into a safe state first.
An Alternative to VBOXVMSERVICE : SRVSTART
Srvstart appears to have some functionality that might work. I guess it is very similar to VboxVMService but has slimmer requirements (Visual c++ redistributable only).
A howto for srvstart here
I have found that srvstart works quite well. The main issue with srvstart is it's simplicity (as well as it's benefit). You can build you environment up using environment variables, you can set an external program up to test whether the service is running and also to stop the service. You can also set timeouts for the service. It's not very clever at parsing parameters, so you have to get your configuration right or it throws out (meaningful but) obtuse win32 system error messages. Another issue is that one cannot redirect stdout/stderr so the service needs to open a console or virtualbox fails to start. Bearing these issues in mind srvstart does what it says on the box and does it with great flexibility.
Here are some other tools to have handy when working with virtualbox when running as a service:
- Null Logics' Windows Service Commander - Windows service manager with great add/remove/edit functionality.
- Serviwin- Another Windows Service Manager
- Turbo Service Manager - Portable Windows Service manager (no dependancies, v. small standalone executable)
- Service Manager - Another Service Manager
- Service Snapshot Manager - Manage groups of services together (teaming?)
- Sysinternals' Process Explorer - Really, really see what's going on with your processes (with the exception of perhaps a couple of rootkits).
- Code Sectors Teracopy - Copy (large)files (much)faster than explorer, integrates with explorer file cut/copy/paste, file transfer queue so that multiple transfers don't compete for I/O. Really, an essential tool.
- Commercial software 1: Firedaemon - it does stdout redirection to a file amongst many other things.
- Commercial software 2: Application as service - it does stdout redirection to a file amongst many other things.