On Fri, Nov 14, 2008 at 11:18:48AM +0000, Daniel P. Berrange wrote:
[...]
One option is to add alot more events
VIR_DOMAIN_MIGRATED_IN (migrated to another node)
VIR_DOMAIN_MIGRATED_OUT (migrated from another node)
VIR_DOMAIN_SHUTDOWN (graceful shutdown by host admin)
VIR_DOMAIN_DESTROYED (force destroyed by host admin)
VIR_DOMAIN_CRASHED (guest kernel crashed)
VIR_DOMAIN_HUNG (host emulator hung)
leaving STOPPED to just be a generic stop event, with no particular
reason.
The downside with this, is if an application just wants to know about
whether a domain shutdown, not why, then they have to track lots and
lots of events.
Also, not every driver would be able to provide all of these events,
so would often have to fallback on a generic STOPPED event
yes that makes using the API way harder than it should, though
enumerating the cases: in a switch is not that hard...
So one alternative is to provide a generic 'char * reason'
with each
event with provides scope on the cause of the lifecycle operation.
So you'd get
VIR_DOMAIN_STOPPED ("crashed", "shutdown", "destroyed",
"quit", "hung", "migrated",
"saved")
VIR_DOMAIN_STARTED ("booted", "migrated", "restored")
nb, we could remove the explicit SAVED and RESTORED events in this style.
With such a 'reason' arg, we could possibly avoid adding the DEFINED
and UNDEFINED events I suggested. Instead, adding a reason for ADDED
and REMOVED events,
VIR_DOMAIN_ADDED ("started", "defined")
VIR_DOMAIN_REMOVED ("shutdown", "undefined")
which lets you distinguish transient from persistent domains. The downside
of this though, is that we can't explicitly track when a configuration
file is 're-defined', eg adding a config file for an existing running
guest.
I like this, I wonder if a free form part to the message might make
sense, even if we don't have currently a way to pass this say from virsh
command line.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/