<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.38">
<TITLE>RE: [libvirt] RFC: Add a 'reason' argument for domain events ?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>To revisit the DEFINED, UNDEFINED topic - I have been giving this some thought, and it seems like it is redundant information to me.<BR>
<BR>
Doesn't the existence of a config file define the difference between a transient and a persistent domain?<BR>
Therefore this could be tracked solely with the enum values we have?<BR>
If a transient domain becomes persistent via adding a config file, the ADDED event would be emitted, denoting a config file came into being, and by definition changing this domain from transient, to persistent.<BR>
I'm not sure I understand the need for these events.<BR>
<BR>
<BR>
Moving on to the shutdown reason discussion -<BR>
I can certainly see the need to know why a domain stopped.<BR>
That said - would it not be more consistent with the API to introduce an event "sub-type" enum to be passed alongside of the event-type, passed as a second integer?<BR>
This would reduce the size of the wire protocol, not needing to pass the full character string, as well.<BR>
<BR>
This would trivially allow us finer grained notifications within a particular event.<BR>
<BR>
A downside is that it may become a bit noisy for clients who may not be interested in all of the sub-events.<BR>
Perhaps we should add some sort of filtering mechanism?<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: libvir-list-bounces@redhat.com on behalf of Daniel P. Berrange<BR>
Sent: Fri 11/14/2008 6:18 AM<BR>
To: libvir-list@redhat.com<BR>
Subject: [libvirt] RFC: Add a 'reason' argument for domain events ?<BR>
<BR>
We currently have a set of domain lifecycle events<BR>
<BR>
      VIR_DOMAIN_EVENT_ADDED = 0,<BR>
      VIR_DOMAIN_EVENT_REMOVED = 1,<BR>
      VIR_DOMAIN_EVENT_STARTED = 2,<BR>
      VIR_DOMAIN_EVENT_SUSPENDED = 3,<BR>
      VIR_DOMAIN_EVENT_RESUMED = 4,<BR>
      VIR_DOMAIN_EVENT_STOPPED = 5,<BR>
      VIR_DOMAIN_EVENT_SAVED = 6,<BR>
      VIR_DOMAIN_EVENT_RESTORED = 7,<BR>
<BR>
And a couple more I proposed last week to allow distinguishing of new<BR>
domains which are transient vs persistent<BR>
<BR>
      VIR_DOMAIN_EVENT_DEFINED = 8,<BR>
      VIR_DOMAIN_EVENT_UNDEFINED = 9,<BR>
<BR>
Previously Stefan has suggested we should consider having an event for<BR>
migration, and though I rejected that at the time, I'm now inclined to<BR>
agree that this info would be useful here. I'm also thinking I'd like<BR>
to have more information about STOPPED & STARTED events in general.<BR>
<BR>
eg, there are a number of reasons why an domain may have started<BR>
<BR>
 - explicitly booted on the host<BR>
 - restored from a saved image<BR>
 - incoming migration operation<BR>
<BR>
and there are a number of reasons why a domain might have stopped<BR>
<BR>
 - forcably destroyed by host admin<BR>
 - shutdown by host admin<BR>
 - shutdown by guest admin<BR>
 - host emulator process crashed<BR>
 - killed by mgmt after host emulation hung<BR>
 - migrated to another host<BR>
 - saved to a memory image<BR>
<BR>
We have explicit events for the SAVED/RESTORED reasons, but what should<BR>
we do about the other reasons ?<BR>
<BR>
One option is to add alot more events<BR>
<BR>
  VIR_DOMAIN_MIGRATED_IN   (migrated to another node)<BR>
  VIR_DOMAIN_MIGRATED_OUT  (migrated from another node)<BR>
  VIR_DOMAIN_SHUTDOWN      (graceful shutdown by host admin)<BR>
  VIR_DOMAIN_DESTROYED     (force destroyed by host admin)<BR>
  VIR_DOMAIN_CRASHED       (guest kernel crashed)<BR>
  VIR_DOMAIN_HUNG          (host emulator hung)<BR>
<BR>
leaving STOPPED to just be a generic stop event, with no particular<BR>
reason.<BR>
<BR>
The downside with this, is if an application just wants to know about<BR>
whether a domain shutdown, not why, then they have to track lots and<BR>
lots of events.<BR>
<BR>
Also, not every driver  would be able to provide all of these events,<BR>
so would often have to fallback on a generic STOPPED event<BR>
<BR>
So one alternative is to provide a generic 'char * reason' with each<BR>
event with provides scope on the cause of the lifecycle operation.<BR>
So you'd get<BR>
<BR>
  VIR_DOMAIN_STOPPED  ("crashed", "shutdown", "destroyed",<BR>
                       "quit", "hung", "migrated", "saved")<BR>
  VIR_DOMAIN_STARTED  ("booted", "migrated", "restored")<BR>
<BR>
nb, we could remove the explicit SAVED and RESTORED events in this style.<BR>
<BR>
With such a 'reason' arg, we could possibly avoid adding the DEFINED<BR>
and UNDEFINED events I suggested. Instead, adding a reason for ADDED<BR>
and REMOVED events,<BR>
<BR>
   VIR_DOMAIN_ADDED    ("started", "defined")<BR>
   VIR_DOMAIN_REMOVED  ("shutdown", "undefined")<BR>
<BR>
which lets you distinguish transient from persistent domains. The downside<BR>
of this though, is that we can't explicitly track when a configuration<BR>
file is 're-defined', eg adding a config file for an existing running<BR>
guest.<BR>
<BR>
Daniel<BR>
--<BR>
|: Red Hat, Engineering, London   -o-   <A HREF="http://people.redhat.com/berrange/">http://people.redhat.com/berrange/</A> :|<BR>
|: <A HREF="http://libvirt.org">http://libvirt.org</A>  -o-  <A HREF="http://virt-manager.org">http://virt-manager.org</A>  -o-  <A HREF="http://ovirt.org">http://ovirt.org</A> :|<BR>
|: <A HREF="http://autobuild.org">http://autobuild.org</A>       -o-         <A HREF="http://search.cpan.org/~danberr/">http://search.cpan.org/~danberr/</A> :|<BR>
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|<BR>
<BR>
--<BR>
Libvir-list mailing list<BR>
Libvir-list@redhat.com<BR>
<A HREF="https://www.redhat.com/mailman/listinfo/libvir-list">https://www.redhat.com/mailman/listinfo/libvir-list</A><BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>