[libvirt] [PATCH 09/34] Create virDomainEventLifecycle to start removing the huge union

Cedric Bosdonnat cbosdonnat at suse.com
Mon Dec 2 12:52:51 UTC 2013


On Fri, 2013-11-29 at 17:09 +0000, Daniel P. Berrange wrote:
> On Fri, Nov 29, 2013 at 04:18:45PM +0100, Cédric Bosdonnat wrote:
> >
> >  static virClassPtr virObjectEventClass;
> >  static virClassPtr virDomainEventClass;
> > +static virClassPtr virDomainEventLifecycleClass;
> >  static void virObjectEventDispose(void *obj);
> >  static void virDomainEventDispose(void *obj);
> > +static void virDomainEventLifecycleDispose(void *obj);
> >  
> >  struct _virObjectEvent {
> >      virObject parent;
> 
> > @@ -764,37 +786,37 @@ static void *virDomainEventNewInternal(virClassPtr klass,
> >      return event;
> >  }
> >  
> > -virDomainEventPtr virDomainEventNew(int id, const char *name,
> > +void *virDomainEventNew(int id, const char *name,
> >                                      const unsigned char *uuid,
> >                                      int type, int detail)
> >  {
> > -    virDomainEventPtr event;
> > +    virDomainEventLifecyclePtr event;
> >  
> >      if (virObjectEventInitialize() < 0)
> >          return NULL;
> >  
> > -    if (!(event = virDomainEventNewInternal(virDomainEventClass,
> > -                                      VIR_DOMAIN_EVENT_ID_LIFECYCLE,
> > -                                      id, name, uuid)))
> > +    if (!(event = virDomainEventNewInternal(virDomainEventLifecycleClass,
> > +                                            VIR_DOMAIN_EVENT_ID_LIFECYCLE,
> > +                                            id, name, uuid)))
> >          return NULL;
> >  
> > -    event->data.lifecycle.type = type;
> > -    event->data.lifecycle.detail = detail;
> > +    event->type = type;
> > +    event->detail = detail;
> >  
> >      return event;
> >  }
> >  
> > -virDomainEventPtr virDomainEventNewFromDom(virDomainPtr dom, int type, int detail)
> > +void *virDomainEventNewFromDom(virDomainPtr dom, int type, int detail)
> >  {
> >      return virDomainEventNew(dom->id, dom->name, dom->uuid, type, detail);
> >  }
> >  
> > -virDomainEventPtr virDomainEventNewFromObj(virDomainObjPtr obj, int type, int detail)
> > +void *virDomainEventNewFromObj(virDomainObjPtr obj, int type, int detail)
> >  {
> >      return virDomainEventNewFromDef(obj->def, type, detail);
> >  }
> >  
> > -virDomainEventPtr virDomainEventNewFromDef(virDomainDefPtr def, int type, int detail)
> > +void *virDomainEventNewFromDef(virDomainDefPtr def, int type, int detail)
> 
> I think I'd prefer these to return 'virObjectEventPtr' rather than void *, 
> since that's the shared base class of all these event types

OK, I just won't change that in this commit (and the other similar ones)
as it would break builds. I'll change that later when changing from
virDomainEventPtr to virObjectPtr.

--
Cedric




More information about the libvir-list mailing list