Friday, June 13, 2008

Windows Host Quoting Gotcha, and the VProbe Toolkit

Workstation 6.5 is now in public beta. It includes experimental support for VProbes in the guest, virtual machine monitor, and a few spots in the virtual hardware. We'd like to invite anybody curious about vprobes to give it a whirl.

A common problem came up on the forums yesterday: if you're using VProbes from Windows' native command-line, you'll soon notice that the following:
C:\> vmrun vprobeLoad foo.vmx '(vprobe VMM1Hz (printf "greetings windows\n"))'
produces the cryptic error message:
vprobeLoad: error: unknown ident windows\n
vprobeLoad: 0 warnings, 1 errors
What gives? In short, cmd's weird quoting. As far as I can tell, single quotes are basically the same as double-quotes, except cmd will only nest like-with like, so cmd ends up passing along the string '(vprobe VMM1Hz (printf greetings windows\n))'. Check the forum post for the band-aid solution for cmd; I predict you'll only be able to tolerate the syntax for cmd one-liners so long before you give up and install cygwin.

Once you embrace cygwin, you might as well go whole-hog and get the vprobe-toolkit. The abstraction level of vp is very low; while the parentheses might remind you of scheme for a while, pretty soon the semantics will remind you of assembly language. This was an intentional choice: since bugs in the vp compiler can nuke your system, we're motivated to keep it as simple as possible. While it's possible to use vp directly for machine-level things (e.g., instruction or stack profilers), for more complex tasks automatic code generation is more appropriate.

Introducing Emmett


Emmett is a small language that provides C-like type, expression, and conditional operators, some syntactic sugar for aggregation, and automatic inference of type for undeclared variables. The vprobe-toolkit provides a wrapper script, named "vprobe", that invokes the Emmett compiler on your input, loads the resulting VP into the target VM, and runs user-specified pretty-printers on your output. E.g., "vprobe -a" pretty-prints sorted aggregates, and "vprobe -s" pretty-prints stacks.

Where in VP, you'd have to write:
(defaggr a 1 1)
(vprobe USEC:1001
(do
(aggr a (VCPUID) ((curprocname)) 1)
(logaggr a )))

Emmett produces the more readable:

USEC:1001
{
a[VCPUID, curprocname()]++;
logaggr(a); # OK, this is a lot of output.
}


There are a bunch of examples in the cookbook subdirectory.

I want to emphasize that Emmett is a replaceable component. If you're a python programmer, and curly braces make your shoulder blades clench with rage, feel free to write your own little language...

Pragmatics

vprobe-toolkit is open source. We've licensed it with a variant of the BSD license, which VMware's lawyers assure me means you can basically do whatever you want with it; if you're feeling paranoid, though, please run the license file past your local lawfolk rather than taking my word for it. You'll notice the link above is to a subversion repository, not a download page. In its current state, it would be inappropriate to expose it to those unwilling to hack a bit; if ws 6.5 is currently in "beta", this is probably somewhere past "prototype" but not really "alpha" yet. Join us!

2 Comments:

Blogger tiltdad said...

Seems like vprobe is quite similar to Sun's dtrace. Is that correct?

6:20 PM  
Blogger Keith Adams said...

Yes, we have similar goals to DTrace: safe programmability and global scope. There are differences here and there, but DTrace's influence is obvious. Unfortunately, DTrace is a poor technical fit for VMware's virtual machine monitor, so VProbes does not literally share code with DTrace today.

12:43 PM  

Post a Comment

<< Home