Re: [libvirt] RFC: Domain events add DEFINED and UNDEFINED events

2008-11-07 Thread Daniel P. Berrange
On Fri, Nov 07, 2008 at 07:12:46AM -0500, Ben Guthro wrote:
 I think this sounds reasonable.
 
 Let me see if I understand the state machine for a newly created persistent 
 domain:
 DEFINED-ADDED-STARTED-STOPPED

Actually, swap ADDED  DEFINED, and for completeness, if I
add in an virDomainUndefine, you'd get

 ADDED-DEFINED-STARTED-STOPPED-UNDEFINED-REMOVED

 
 Starting, then stopping a previously defined persistent domain would just 
 emit 
 STARTED-STOPPED
 
 and a transient domain would be:
 ADDED-STARTED-STOPPED-REMOVED

Yes, that's one possible path. If you were to define a config
for an existing transient domain though you could end up with

  ADDED-STARTED-DEFINED-STOPPED-UNDEFINED-REMOVED

 Will it be an issue for domains that only support a 
 subset of these events (like xen)

I think it is inevitable that this happens, so we likely
want some way to inform the application what events are
available for the driver.

 Yesterday, I began looking into creating a xen driver patch for emitting the 
 DEFINED/UNDEFINED events via inotify.
 It looks like the easiest way to do this right now is to create yet another 
 Xen sub-driver.
 I don't expect this to take an extremely long time, as this tutorial from IBM 
 makes it fairly straightforward to understand:
 http://www-128.ibm.com/developerworks/linux/library/l-inotify.html

The experimental user mode linux driver has some iNotify code in
it too if you want another point of reference. See the
umlInotifyEvent() method umlStartup() where I register for the
events

http://www.redhat.com/archives/libvir-list/2008-October/msg00355.html

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] RFC: Domain events add DEFINED and UNDEFINED events

2008-11-07 Thread Ben Guthro
I suppose I could make some sort of configure option to only compile it in 
optionally...

I don't have access to a solaris box though...so don't really know what the 
appropriate API would be in that situation

Daniel Veillard wrote on 11/07/2008 07:39 AM:
 On Fri, Nov 07, 2008 at 12:26:23PM +, Daniel P. Berrange wrote:
 Yesterday, I began looking into creating a xen driver patch for emitting 
 the DEFINED/UNDEFINED events via inotify.
 It looks like the easiest way to do this right now is to create yet another 
 Xen sub-driver.
 I don't expect this to take an extremely long time, as this tutorial from 
 IBM makes it fairly straightforward to understand:
 http://www-128.ibm.com/developerworks/linux/library/l-inotify.html
 The experimental user mode linux driver has some iNotify code in
 it too if you want another point of reference. See the
 umlInotifyEvent() method umlStartup() where I register for the
 events

 http://www.redhat.com/archives/libvir-list/2008-October/msg00355.html
 
   Hum, the only problem is that contrary to uml , the xen drivers should
 not be Linux specific, but inotify is linux specific.
 Making this subdriver Linux only should still be okay until someone
 using Solaris comes with an appropriate patch though,
 
 /me hopes to never get involved again into the mess of portable APIs
 for file changes notifications.
 
 Daniel
 

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] RFC: Domain events add DEFINED and UNDEFINED events

2008-11-07 Thread Daniel Veillard
On Fri, Nov 07, 2008 at 12:26:23PM +, Daniel P. Berrange wrote:
  Yesterday, I began looking into creating a xen driver patch for emitting 
  the DEFINED/UNDEFINED events via inotify.
  It looks like the easiest way to do this right now is to create yet another 
  Xen sub-driver.
  I don't expect this to take an extremely long time, as this tutorial from 
  IBM makes it fairly straightforward to understand:
  http://www-128.ibm.com/developerworks/linux/library/l-inotify.html

 The experimental user mode linux driver has some iNotify code in
 it too if you want another point of reference. See the
 umlInotifyEvent() method umlStartup() where I register for the
 events

 http://www.redhat.com/archives/libvir-list/2008-October/msg00355.html

  Hum, the only problem is that contrary to uml , the xen drivers should
not be Linux specific, but inotify is linux specific.
Making this subdriver Linux only should still be okay until someone
using Solaris comes with an appropriate patch though,

/me hopes to never get involved again into the mess of portable APIs
for file changes notifications.

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
[EMAIL PROTECTED]  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


RE: [libvirt] RFC: Domain events add DEFINED and UNDEFINED events

2008-11-07 Thread Ben Guthro
I think this sounds reasonable.

Let me see if I understand the state machine for a newly created persistent 
domain:
DEFINED-ADDED-STARTED-STOPPED

Starting, then stopping a previously defined persistent domain would just emit 
STARTED-STOPPED

and a transient domain would be:
ADDED-STARTED-STOPPED-REMOVED

Will it be an issue for domains that only support a subset of these events 
(like xen)

Yesterday, I began looking into creating a xen driver patch for emitting the 
DEFINED/UNDEFINED events via inotify.
It looks like the easiest way to do this right now is to create yet another Xen 
sub-driver.
I don't expect this to take an extremely long time, as this tutorial from IBM 
makes it fairly straightforward to understand:
http://www-128.ibm.com/developerworks/linux/library/l-inotify.html



-Original Message-
From: [EMAIL PROTECTED] on behalf of Daniel P. Berrange
Sent: Fri 11/7/2008 5:34 AM
To: libvir-list@redhat.com
Subject: [libvirt] RFC: Domain events add DEFINED and UNDEFINED events
 
We currently have the following list of events for domains:

  VIR_DOMAIN_EVENT_ADDED,
  VIR_DOMAIN_EVENT_REMOVED,
  VIR_DOMAIN_EVENT_STARTED,
  VIR_DOMAIN_EVENT_SUSPENDED,
  VIR_DOMAIN_EVENT_RESUMED,
  VIR_DOMAIN_EVENT_STOPPED,
  VIR_DOMAIN_EVENT_SAVED,
  VIR_DOMAIN_EVENT_RESTORED,

The QEMU driver supports all of them, except for ADDED and REMOVED. I
was looking at adding these and wondering how exactly we should define
the semantics

Originally I was just going to emit 'ADDED' from virDomainDefine() driver
impl and 'REMOVED' from virDomainUndefine().

This does not, however, take into account that there are two sorts of
domains, so called 'persistent' and 'transient' domains.

With a transient domain, there is no config file, so the first time you
know about the domain is when it is booted via virDomainCreateXML(),
and all trace of it disappears when it shuts down, or migrates, or is
saved.  With a persistent domain though, it is visible before it is
booted, and remains visible after shutdown/migrate/save etc.

The current set of events does not allow applications to get this level
of visibility. eg when receiving a VIR_DOMAIN_EVENT_STOPPED event, there
is no way to know wether the domain was transient / persistent, and thus
whether to remove it from your list of VMs, or simply mark it shutoff.

So, I'd like to propose that we do the following:

 - Clarify the semantics for 

* VIR_DOMAIN_EVENT_ADDED

Emitted when a domain comes into existance, by which I mean a
previously known inactive domain is defined, or a transient
domain is booted. This is emited before any other events for
a domain with that UUID/name.

* VIR_DOMAIN_EVENT_REMOVED

Emitted when a domains goes out of existance, by which I mean
a transient domain shuts down / migrates / is saved, or a
persistent domain is undefined. This is the last event ever to
be emitted for a domain with that UUID/name.


 - Create two more events

 * VIR_DOMAIN_EVENT_DEFINED

 Emitted whenenever a domain's config file is created. This can
 be when a peristent domain is first defined, when it is later
 re-defined, or when an transient domain gains a confi file,
 becoming persistent.

 * VIR_DOMAIN_EVENT_UNDEFINED

 Emitted when a domain's config file is removed.

With this complete set of events, virt-manager is able to track domains
without ever having to poll for the domain listing.

I think we also need to provide some way for an application to determine
what set of events a hypervisor backend supports. eg, if it only supports
the STARTED/STOPPED events, virt-manager would still need to do polling to
find out about defined/undefined domains.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list