Shutdown a VM

Discussion about using the VirtualBox API, Tutorials, Samples.

Shutdown a VM

Postby akjuturub04 » 25. Jun 2013, 07:57

Hi,

Can you please let me know if it is possible to shutdown a virtual machine using Virtual Box API using OOWS? There doesn't seem to be a straight forward way. Please let me know.

My Setup information:
Virtual box and API version: Version 4.2.12
Connection Type: object-oriented web service (OOWS)
Language: Java
Host OS: Windows 7 64
akjuturub04
 
Posts: 9
Joined: 19. Jun 2013, 23:14

Re: Shutdown a VM

Postby akjuturub04 » 25. Jun 2013, 08:40

I tried the following but I am seeing the error. Please suggest me how it can be done

Code: Select all   Expand viewCollapse view
ISession iSession = mgr.getSessionObject();   
        vbox.getMachines().get(0).lockMachine(iSession, LockType.VM);
             
        IConsole iConsole = iSession.getConsole();
        iConsole.powerDown();


Error:
Code: Select all   Expand viewCollapse view
VBox error: VirtualBox error: The machine 'Amruth-Win7-64' is already locked for a session (or being unlocked) (0x80BB0007) original=org.virtualbox_4_2.jaxws.RuntimeFaultMsg: VirtualBox error: The machine 'Amruth-Win7-64' is already locked for a session (or being unlocked) (0x80BB0007)
org.virtualbox_4_2.VBoxException: VirtualBox error: The machine 'Amruth-Win7-64' is already locked for a session (or being unlocked) (0x80BB0007)
   at org.virtualbox_4_2.IMachine.lockMachine(IMachine.java:2522)
   at testvbox.TestVBox.testStart(TestVBox.java:158)
   at testvbox.TestVBox.main(TestVBox.java:243)
akjuturub04
 
Posts: 9
Joined: 19. Jun 2013, 23:14

Re: Shutdown a VM

Postby noteirak » 25. Jun 2013, 09:33

don't use LockType.VM, but LockType.Shared
Hyperbox - Virtual Infrastructure Manager - https://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7


Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 1 guest