[lxc-devel] [PATCH] Add remove_snapshots_entry() (rebased - v2)
Serge Hallyn
serge.hallyn at ubuntu.com
Tue Sep 15 17:35:41 UTC 2015
Quoting Christian Brauner (christianvanbrauner at gmail.com):
> On Tue, Sep 15, 2015 at 12:57:26AM +0000, Serge Hallyn wrote:
> > Quoting Christian Brauner (christianvanbrauner at gmail.com):
> > > The easiest way to achieve this would be to #include lxccontainer.h in utils.h
> > > because we need mod_all_rdep() multiple times in lxccontainer.c and start.c and
> > > mod_all_rdep() needs struct lxc_container declared. Unless I'm missing something
> > > terribly obvious. Fine with that? Or rather some extern trickery? Or other
> > > ideas?
> >
> > Does it work if you just define mod_all_rdeps as non-static in lxccontainer.c
> > and then, in start.c, put
> >
> > struct lxc_container;
> > extern void mod_all_rdeps(struct lxc_container *c, bool inc);
> >
> > then use that in your fn?
>
> Yes, that was what I meant when I said "use some extern trickery" :) If you're
Oh sorry I missed that :)
> fine with that we can easily do it this way. We would then in start.c have:
>
> struct lxc_container;
> extern void mod_all_rdeps(struct lxc_container *c, bool inc);
>
> /* Lots of code */
>
> static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
> const char *name)
> {
> char destroy[MAXPATHLEN];
> bool bret = true;
> int ret = 0;
> struct lxc_container *c;
> if (handler->conf && handler->conf->rootfs.path && handler->conf->rootfs.mount) {
> bret = do_destroy_container(handler->conf);
> if (!bret) {
> ERROR("Error destroying rootfs for %s", name);
> return;
> }
> }
> INFO("Destroyed rootfs for %s", name);
>
> ret = snprintf(destroy, MAXPATHLEN, "%s/%s", handler->lxcpath, name);
> if (ret < 0 || ret >= MAXPATHLEN) {
> ERROR("Error printing path for %s", name);
> ERROR("Error destroying directory for %s", name);
> return;
> }
>
> /* Relevant part start */
>
> c = lxc_container_new(name, handler->lxcpath);
> if (c) {
> if (container_disk_lock(c)) {
> INFO("Could not update lxc_snapshots file");
> lxc_container_put(c);
> } else {
> mod_all_rdeps(c, false);
> container_disk_unlock(c);
> lxc_container_put(c);
> }
> }
>
> /* Relevant part end */
>
> if (am_unpriv())
> ret = userns_exec_1(handler->conf, lxc_rmdir_onedev_wrapper, destroy);
> else
> ret = lxc_rmdir_onedev(destroy, NULL);
>
> if (ret < 0) {
> ERROR("Error destroying directory for %s", name);
> return;
> }
> INFO("Destroyed directory for %s", name);
> }
>
> I could either just update this patch and resend it as v4 or update the whole
> series of patches I sent so far, including this one. Whatever you find more
> convenient.
The rest of the patches have already been acked and i dont 'want to confuse
Stéphane, so let's go with a new v4.
thanks!
-serge
More information about the lxc-devel
mailing list