[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 04/15] Introduce a virLXCControllerPtr object to hold LXC controller state



On Wed, Jul 04, 2012 at 12:20:44PM +0200, Jiri Denemark wrote:
> On Tue, Jul 03, 2012 at 16:58:43 +0100, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange redhat com>
> > 
> > The LXC controller code is having to pass around an ever increasing
> > number of parameters between methods. To make the code more managable
> > introduce a virLXCControllerPtr to hold all this state, starting with
> > the container name and virDomainDefPtr object
> > 
> > Signed-off-by: Daniel P. Berrange <berrange redhat com>
> > ---
> >  src/lxc/lxc_controller.c |  133 +++++++++++++++++++++++++++++++---------------
> >  1 file changed, 91 insertions(+), 42 deletions(-)
> > 
> > diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> > index b0e9f46..7447f6c 100644
> > --- a/src/lxc/lxc_controller.c
> > +++ b/src/lxc/lxc_controller.c
> > @@ -80,6 +80,64 @@ struct cgroup_device_policy {
> >  };
> >  
> >  
> > +typedef struct _virLXCController virLXCController;
> > +typedef virLXCController *virLXCControllerPtr;
> > +struct _virLXCController {
> > +    char *name;
> > +    virDomainDefPtr def;
> > +};
> > +
> > +static void virLXCControllerFree(virLXCControllerPtr ctrl);
> > +
> > +static virLXCControllerPtr virLXCControllerNew(const char *name)
> > +{
> > +    virLXCControllerPtr ctrl = NULL;
> > +    virCapsPtr caps = NULL;
> > +    char *configFile = NULL;
> > +
> > +    if (VIR_ALLOC(ctrl) < 0)
> > +        goto no_memory;
> > +
> > +    if (!(ctrl->name = strdup(name)))
> > +        goto no_memory;
> > +
> > +    if ((caps = lxcCapsInit(NULL)) == NULL)
> > +        goto cleanup;
> > +
> > +    if ((configFile = virDomainConfigFile(LXC_STATE_DIR,
> > +                                          ctrl->name)) == NULL)
> > +        goto cleanup;
> > +
> > +    if ((ctrl->def = virDomainDefParseFile(caps,
> > +                                           configFile,
> > +                                           1 << VIR_DOMAIN_VIRT_LXC,
> > +                                           0)) == NULL)
> > +        goto cleanup;
> 
> I think all three "goto cleanup"s should rather be goto error...

Doh, of course they should.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]