[lxc-devel] [PATCH 4/6] Add bdev_destroy() to bdev.c and bdev.h static do_bdev_destroy() in lxccontainer.c becomes public bdev_destroy()

Christian Brauner christianvanbrauner at gmail.com
Tue Sep 8 14:09:32 UTC 2015


On Mon, Sep 07, 2015 at 05:05:47PM +0000, Serge Hallyn wrote:
> Quoting Christian Brauner (christianvanbrauner at gmail.com):
> > Signed-off-by: Christian Brauner <christianvanbrauner at gmail.com>
> > 
> >  100.0% src/lxc/
> > diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
> > index ada3958..475d878 100644
> > --- a/src/lxc/bdev.c
> > +++ b/src/lxc/bdev.c
> > @@ -3614,3 +3614,21 @@ bool rootfs_is_blockdev(struct lxc_conf *conf)
> >  		return true;
> >  	return false;
> >  }
> > +
> > +bool bdev_destroy(struct lxc_conf *conf)
> > +{
> > +	struct bdev *r;
> > +	bool ret = false;
> > +
> > +	r = bdev_init(conf, conf->rootfs.path, conf->rootfs.mount, NULL);
> > +	if (!r)
> > +		return ret;
> > +
> > +	if (r->ops->destroy(r) < 0)
> 
> You need to bdev_put here.

Ok. I think this bug also affects all current branches of lxc. I'll send a
patch.

> 
> > +		return ret;
> > +	bdev_put(r);
> > +
> > +	ret = true;
> > +	return ret;
> > +}
> > +
> > diff --git a/src/lxc/bdev.h b/src/lxc/bdev.h
> > index 428b3b7..b034bcb 100644
> > --- a/src/lxc/bdev.h
> > +++ b/src/lxc/bdev.h
> > @@ -123,6 +123,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
> >  struct bdev *bdev_create(const char *dest, const char *type,
> >  			const char *cname, struct bdev_specs *specs);
> >  void bdev_put(struct bdev *bdev);
> > +bool bdev_destroy(struct lxc_conf *conf);
> >  
> >  /*
> >   * these are really for qemu-nbd support, as container shutdown
> > -- 
> > 2.5.1
> > 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150908/37231896/attachment.sig>


More information about the lxc-devel mailing list