Package org.libvirt
Class Library
java.lang.Object
org.libvirt.Library
This class represents an instance of the JNA mapped libvirt
library.
The library will get loaded when first accessing this class.
Additionally, this class contains internal methods to ease
implementing the public API.
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
Returns the version of the native libvirt library.static void
Initialize the event loop.static void
Run one iteration of the event loop.static void
Runs the event loop.static void
Stops the event loop.
-
Method Details
-
getVersion
Returns the version of the native libvirt library.- Returns:
- major * 1,000,000 + minor * 1,000 + release
- Throws:
LibvirtException
-
initEventLoop
Initialize the event loop. Registers a default event loop implementation based on the poll() system call.Once registered, the application has to invoke
processEvent()
in a loop or callrunEventLoop()
in another thread.Note: You must call this function before connecting to the hypervisor.
- Throws:
LibvirtException
- on failure- See Also:
-
processEvent()
runLoop
-
processEvent
Run one iteration of the event loop.Applications will generally want to have a thread which invokes this method in an infinite loop:
while (true) connection.processEvent();
Failure to do so may result in connections being closed unexpectedly as a result of keepalive timeout.
- Throws:
LibvirtException
- on failure- See Also:
-
runEventLoop
Runs the event loop. This method blocks untilstopEventLoop()
is called or an exception is thrown.Usually, this method is run in another thread.
- Throws:
LibvirtException
- if there was an error during the call of a native libvirt functionInterruptedException
- if this thread was interrupted by a call toThread.interrupt()
-
stopEventLoop
Stops the event loop. This methods stops an event loop when an event loop is currently running, otherwise it does nothing.- Throws:
LibvirtException
- See Also:
-