Page 1 of 1

Shutdown a VM

Posted: 25. Jun 2013, 07:57
by akjuturub04
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

Re: Shutdown a VM

Posted: 25. Jun 2013, 08:40
by akjuturub04
I tried the following but I am seeing the error. Please suggest me how it can be done

Code: Select all

ISession iSession = mgr.getSessionObject();   
        vbox.getMachines().get(0).lockMachine(iSession, LockType.VM);
             
        IConsole iConsole = iSession.getConsole();
        iConsole.powerDown();
Error:

Code: Select all

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)

Re: Shutdown a VM

Posted: 25. Jun 2013, 09:33
by noteirak
don't use LockType.VM, but LockType.Shared