Contributing a libguestfs enhancement (with examples)

… is easy. You only need to write about 60 lines of code for each new function. Here’s how.

  1. Add the function to the generator [about 10 lines of code per new function].
  2. Add the implementation (in C) to the daemon [about 50 lines of code per new function].
  3. Run src/generator.ml
  4. Build as normal, debug, rinse, repeat until it’s working.
  5. Send the patch to fedora-virt mailing list.

This example shows the generator for 4 new functions: set_e2label, get_e2label, set_e2uuid and get_e2uuid. It’s useful to go and have a look at the other commands in that file to see how the parameter types, return type and tests work.

This example shows the implementation in the daemon of these commands. Again it’s useful to compare this with the functions available in the header files in the daemon, and other implementations.

When you run src/generator.ml from the top level directory, it must not print any errors or warnings. The generator will generate thousands of lines of code for your short function definition. It basically writes the language bindings, RPC protocol, manual pages etc for you. You can see an example of the generated code here. Lucky we don’t have to write that lot

About these ads

1 Comment

Filed under Uncategorized

One response to “Contributing a libguestfs enhancement (with examples)

  1. Pingback: Tip: Run test scripts in guestfish « Richard WM Jones

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s