Skip to content

GSoC 18 Summary

RamyElkest edited this page Aug 14, 2018 · 7 revisions

Introduction

In April 2018 I was accepted as part of the Google Summer of Code program to work with libvirt on generating nodejs bindings for the C libvirt API based on libvirt's exported API XML (see here and here for more details).

With Martin Kletzander and Erik Skultety as my mentors, I've worked over the following three months on this repository aiming for our goal.

Weekly updates

Weekly updates (including what was done and links to PRs) can be found here. (thanks to a suggestion by mentors).

I've included it here for convenience

Week 1 (May 14)


Week 2 (May 21)


Week 3 (May 28)


Week 4 (June 4)

  • Created a PR to create generation infrastructure, this includes
    • A generator script that (for now) just outputs the previous manual code to files
    • A bunch of npm scripts to:
      • check libvirt version / api xmls / etc.
      • run the generate script
      • install and test
    • a makefile to wrap the npm scripts
  • Created proof of concept for defining js interface using node-addon-api (wrapping c++ objects).
  • My main aim was to highlight that we can arrive to something like this where with a bit of framework forwarding calls is a(n easily generatable) one liner
    • However I still stand by our decision to expose the API as a JS API. I think we're now in a good position to fill out the JS vs. C(++) API design decision
  • I tried to get in touch with the node-libvirt contributors in hope to schedule a few minutes to discuss any difficulties/hacks they had etc. however no response just yet.

Week 5 (June 11)

  • Repository (branch) cleanup to move things along
  • Created travis CI to run on PRs
  • Opened PR for initial Override and manual infrastructure to enable overridding generated functions (although we don't have the generated stubs yet)
  • Committed manual implementation of virConnectClose and partial virConnectRegisterCloseCallback (but still requires some work before PR)..
  • (Started work on API parser, but nothing useful yet)

Week 6 (June 18)


Week 7 (June 25)

  • Refactoring generators
  • Following functions are now generated using the parser and a whitelist with Generating most manual functions
    • virConnectOpen
    • virConnectClose
    • virDomainLookupByName
    • virDomainGetID
    • virDomainGetURI

Week 8 (July 2)


Week 9 (July 9)


Week 10 (July 16) & Week 11 (July 23)

  • Major refactoring to allow:
    • Adding file dependencies at runtime
    • Adding ability to override default generators (and manual implementations)
    • Adding support to generate library level functions (eg. libvirt.open, etc.)
    • Adding support to generated enums at library level
  • Started Architecture documentation

Week 12 (July 30)


Final Week (Aug 6)

Current State / GSoC Deliverable

The gsoc18 branch represents a frozen snapshot of the final deliverable for GSoC18.

On a high level what has been done:

  • Some initial research to decide on the direction to move in
  • A build system (Make integrated with npm) that checks libvirt dependencies, compiles, runs tests, etc.
  • Continuous integration via travis-ci to validate builds / pull requests
  • sanitytest.js to report the API coverage
  • Framework in place to easily override default implementations with a handwritten one
  • Sample tests for usage and sanity
  • High level documentation on architecture and build process
  • Generation of all enums at library level (similar to libvirt-python)
  • Generation of all libvirt functions that use ~primitive types (eg. int, const char *) or one of the generated types eg. (virInterface)
  • published npm module

What's pending

Although this is a solid step in the right direction, there's still plenty to be done for this project.

  • sanitytest.js currently reports ~65% of functions have been generated. We need more work to get this closer to 100%.
  • Tested support for lxc and qemu APIs: The APIs are parsed and processed but not generated as the focus was on libvirt-api.
  • Issues that have been raised need to be addressed.
  • It would be good to get it battle-tested before hitting v1.0.0 through additional tests and additional users/contributors.
  • Some potentially beneficial future improvements like an async API and typescript interface definitions.