Nikolay Igotti
Python API to the VirtualBox VM
One of the important advantages of the VirtualBox virtualization solution is powerful public API allowing to control every aspect of virtual machine configuration and execution. Last month I was working on Python and Java bindings to that API. Those bindings are shipped with VirtualBox 2.0 SDK.
There are two families of API bindings:
SOAP allows to control remote VMs over HTTP, while XPCOM is much more high-performing and exposes certain functionality not available with SOAP. They use very different technologies (SOAP is procedural, while XPCOM is OOP), but as it is ultimately API to the same functionality of the VirtualBox, we kept in bindings original semantics, so other that connection establishment, code could be written in such a way that people may not care what communication channel with VirtualBox instance is used. As an example of how flexible and powerful those API are, I developed extensible Python command line shell to the ViritualBox, usable as simpler CLI alternative to GUI. Same shell code can work with either SOAP or XPCOM connection to the VirtualBox. To start XPCOM version of shell:- download VirtualBox 2.0 for your platform (Linux and Solaris Python bindings officially supported)
- download SDK
- unpack SDK
cd sdk/bindings/xpcom/python/sampleexport VBOX_PROGRAM_PATH=/opt/VirtualBox-2.0.0/ PYTHONPATH=..:$VBOX_PROGRAM_PATH./vboxshell.pyto start the shell
def showvdiCmd(ctx, args):
mach = argsToMach(ctx,args)
if mach == None:
return 0
hdd = mach.getHardDisk(ctx['ifaces'].StorageBus.IDE, 0, 0)
print 'HDD0 info: id=%s desc="%s" size=%dM location=%s' %(hdd.id,hdd.description,hdd.size,hdd.location)
return 0
and add following line to commands map:
'vdiinfo':['Show VDI info', showvdiCmd],
Then you can run it like this: vdiinfo Win32 (or however your VM of interest is named).
Easy, isn't it? Moreover this command will work not only with XPCOM bindings, but with SOAP too.
This example also shows how to access VirtualBox constants in toolkit neutral manner - 'ifaces' field of context contains reflection information
useadble to get values of the constant.
Actually, there are other languages bindings to VirtualBox API shipped with SDK, including Java and C++, but I personally find Python easiest for start. You can ask here questions on VirtualBox language bindings (not only Python), and I will try to help.
Posted at 01:26PM Sep 05, 2008 by nike in Sun | Comments[7]
Informative paper on memory
Ulrich Drepper wrote pretty interesting, yet somewhat longish and probably too detailed paper on memory management. Wouldn't say that I recommend it to everybody, but software people who want look cool knowing that SRAM cell needs 6 transistors, while for DRAM it's enough to have 1 transistor and 1 capacitor should read it for sure.Seriously speaking, this paper could be of interest if you want to understand what really goes on when you do MOV EAX,[ECX].
Posted at 11:23PM Aug 07, 2008 by nike in Sun | Comments[0]
Back at Sun
Now I'm back at Sun again — definitively love this place! This time I'm working on the VirtualBox project - OS virtualization software. Project looks very interesting, so in my future postings will cover what I encounter in my journeys deep into the kernel and back
.
If you have questions I'm capable to answer - feel free to ask me in comments.
Update: thanks everybody who welcomed me back!
Posted at 08:07PM Aug 06, 2008 by nike in Sun | Comments[5]
Leaving Sun
Starting Aug 17 I leave Sun Microsystems. My personal e-mail is igotti@gmail.com. Have fun!PS: I have no other technical blog yet, you may look at my Livejournal blog, but it's in Russian and generally have not that much info yet
PPS: my last project - compressed object pointers is now of production quality, being reviewed and hopefully will be integrated into Hotspot workspace rather soon.
Posted at 03:15PM Aug 15, 2007 by nike in Personal | Comments[6]
FS neutral data recovery tool
Data recovery from ext3 FS success story.[Read More]Posted at 11:18AM Aug 02, 2007 by nike in Personal | Comments[0]
Explicit template instantiation in shared libraries
When explicit template instantiation saves the day.[Read More]Posted at 11:09PM Jul 19, 2007 by nike in Sun | Comments[0]
Double mapping of memory regions on Unix
Mapping same physical memory pages onto several different virtual addresses locations at the time from the userland.[Read More]Posted at 04:54PM Jul 14, 2007 by nike in Sun | Comments[0]
Hotspot internals Q&A
If you have question on Hotspot VM internals - feel free to ask here.[Read More]Posted at 12:22PM Jul 08, 2007 by nike in Sun | Comments[15]
ILP64, LP64, LLP64
What LP64, LLP64, ILP64 stands for?[Read More]Posted at 10:32AM Jul 08, 2007 by nike in Sun | Comments[1]
Raw page table access
Solaris x86 code demonstrating raw access to CPU's page table. As usual, don't try this on sensitive machines (although this code is pretty safe). [Read More]Posted at 06:26PM Jul 05, 2007 by nike in Sun | Comments[0]
Debugger for Win32 (v2)
Mini-debugger for Win32 allowing tracing even statically linked binaries, not only imported symbols.[Read More]Posted at 04:09PM Jul 04, 2007 by nike in Sun | Comments[0]
C mini-contest
Mini-contest: "how well do you know C"?[Read More]Posted at 04:32PM Jul 03, 2007 by nike in Personal | Comments[6]
Neat book
Frank Hoffman at Solaris team wrote this book which is neat summary of x86/amd64 low level programming. I like it.Posted at 04:05PM Jul 03, 2007 by nike in Sun | Comments[1]
SPARC ASIs
Using SPARC address space identifiers(ASIs) in application programming.[Read More]Posted at 09:33PM Jun 29, 2007 by nike in Sun | Comments[2]
VTBL games
Virtual functions table in C++ - an easy target of accidental or intentional override. [Read More]Posted at 10:00PM Jun 27, 2007 by nike in Sun | Comments[0]
Friday Sep 05, 2008