Shutdown a VM

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
akjuturub04
Posts: 9
Joined: 19. Jun 2013, 23:14

Shutdown a VM

Post 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
akjuturub04
Posts: 9
Joined: 19. Jun 2013, 23:14

Re: Shutdown a VM

Post 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)
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Shutdown a VM

Post by noteirak »

don't use LockType.VM, but LockType.Shared
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply