<div dir="ltr"><div><div><div><div><div><div><div>Hi all<br><br></div>I'm new to this list, I've been making use of the Libvirt Java bindings recently.  I wanted to make use of domain events yesterday <br>so my application can be alerted when the state of a domain changes etc.<br>
<br>However I quickly discovered that domain events are completely broken in the current Java bindings.  Whilst some of the Libvirt <br>functions required to support domain events are exposed, the critical underpinnings are not.  Specifically there is no support <br>
for setting up the event loop.<br><br></div>So I have implemented support for domain events in the Java bindings.  Currently I've only implemented the following domain <br>event IDs:<br><br> * VIR_DOMAIN_EVENT_ID_LIFECYCLE<br>
 * VIR_DOMAIN_EVENT_ID_REBOOT<br> * VIR_DOMAIN_EVENT_ID_RTC_CHANGE<br><br></div>Implementing these is enough to test that my implementation is sane, I'm hoping to implement the majority of the other events <br>soon.<br>
<br></div>Events can be listened to by, registering via the Connect object, as follows:<br><br> con.domainEventRegisterAny(DomainEventID.VIR_DOMAIN_EVENT_ID_LIFECYCLE, new DomainLifecycleEventHandler() {<br>   @Override<br>
   public void onStarted(Connect connection, Domain domain, DomainEventType event, DomainEventStartedDetailType detail) throws LibvirtException {<br>     System.out.println("Got start event: " + event + "::" + detail + " for domain " + domain.getName());<br>
   }<br> });<br></div><div><br></div>I've put my clone of the libvirt-java git repository on Github, my modifications to the Java binding are in a separate branch and <br>should be simple to merge.  The changes can be viewed at: <br>
<br>  <a href="https://github.com/intrbiz/libvirt-java/compare/master...ce-domain-events">https://github.com/intrbiz/libvirt-java/compare/master...ce-domain-events</a><br><br></div>I'm keen to get these enhancements / fixes merged into libvirt-java.  I would also like to submit further fixes to race conditions <br>
in the free() handling.<br><br></div><div><br></div><div>Any advice / thoughts / comments welcome.<br><br></div><div>Regards,<br></div><div>Chris Ellis<br></div></div>