managing snapshots programatically with the java API

This is for discussing general topics about how to use VirtualBox.
Post Reply
halplus
Posts: 1
Joined: 10. Jun 2011, 21:56
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, FreeBSD

managing snapshots programatically with the java API

Post by halplus »

Hi:

Does anyone knows about an example on how to handle snapshots with the java API. It is not very well documented and there seems to be some sort of circular references there or something like that. I am using the platform independent method of communicating with virtualbox.

This is the sample of what i am trying but doesn't works fails to lock the session.

Code: Select all

mgr.connect(url, user, passwd);
				
				IVirtualBox vbox = mgr.getVBox();
				
				List<IMachine> machs = vbox.getMachines();
				for (IMachine m : machs)
				{
					System.out.println("VM name: " + m.getName());// + ", RAM size: " +
																	// m.getMemorySize()
																	// + "MB");
					System.out.println(" HWVirt: "
							+ m.getHWVirtExProperty(HWVirtExPropertyType.Enabled)
							+ ", Nested Paging: "
							+ m.getHWVirtExProperty(HWVirtExPropertyType.NestedPaging)
							+ ", PAE: " + m.getCPUProperty(CPUPropertyType.PAE));
					
					
					session = mgr.getSessionObject();
					IProgress p = m.launchVMProcess(session, "gui", "");
					
					p.waitForCompletion(-1);
					
					m.lockMachine(session, LockType.Shared);
					IConsole console = session.getConsole();
					console.takeSnapshot("testsnap", "test description");
                           }
Post Reply