Nikolay Igotti

pageicon Friday Sep 05, 2008

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/sample
  • export VBOX_PROGRAM_PATH=/opt/VirtualBox-2.0.0/ PYTHONPATH=..:$VBOX_PROGRAM_PATH
  • ./vboxshell.py to start the shell
Currently shell is capable to start/suspend/resume/powerdown VMs, and persistently set any VM variable. You can easily extend shell with your own command, for example let's implement command to show information on hard disk of the machine.
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.

pageicon Thursday Aug 07, 2008

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].

pageicon Wednesday Aug 06, 2008

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!

pageicon Wednesday Aug 15, 2007

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.

pageicon Thursday Aug 02, 2007

FS neutral data recovery tool

Data recovery from ext3 FS success story.[Read More]
pageicon Thursday Jul 19, 2007

Explicit template instantiation in shared libraries

When explicit template instantiation saves the day.[Read More]
pageicon Saturday Jul 14, 2007

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]
pageicon Sunday Jul 08, 2007

Hotspot internals Q&A

If you have question on Hotspot VM internals - feel free to ask here.[Read More]

ILP64, LP64, LLP64

What LP64, LLP64, ILP64 stands for?[Read More]
pageicon Thursday Jul 05, 2007

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]
pageicon Wednesday Jul 04, 2007

Debugger for Win32 (v2)

Mini-debugger for Win32 allowing tracing even statically linked binaries, not only imported symbols.[Read More]
pageicon Tuesday Jul 03, 2007

C mini-contest

Mini-contest: "how well do you know C"?[Read More]

Neat book

Frank Hoffman at Solaris team wrote this book which is neat summary of x86/amd64 low level programming. I like it.
pageicon Friday Jun 29, 2007

SPARC ASIs

Using SPARC address space identifiers(ASIs) in application programming.[Read More]
pageicon Wednesday Jun 27, 2007

VTBL games

Virtual functions table in C++ - an easy target of accidental or intentional override. [Read More]

« October 2008
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today

Feeds

Search this blog

Links

Weblog menu

Today's referrers

Today's Page Hits: 63

Stats