mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 11:13:50 +00:00
Remove ephemeral containers from lxc_snapshots
On shutdown ephemeral containers will be destroyed. We use mod_all_rdeps() from lxccontainer.c to update the lxc_snapshots file of the original container. We also include lxclock.h to lock the container when mod_all_rdeps() is called to avoid races. Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
d825fff3ca
commit
f01f7975c1
@ -71,6 +71,7 @@
|
|||||||
#include "caps.h"
|
#include "caps.h"
|
||||||
#include "bdev.h"
|
#include "bdev.h"
|
||||||
#include "lsm/lsm.h"
|
#include "lsm/lsm.h"
|
||||||
|
#include "lxclock.h"
|
||||||
|
|
||||||
lxc_log_define(lxc_start, lxc);
|
lxc_log_define(lxc_start, lxc);
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ const struct ns_info ns_info[LXC_NS_MAX] = {
|
|||||||
[LXC_NS_NET] = {"net", CLONE_NEWNET}
|
[LXC_NS_NET] = {"net", CLONE_NEWNET}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern void mod_all_rdeps(struct lxc_container *c, bool inc);
|
||||||
static bool do_destroy_container(struct lxc_conf *conf);
|
static bool do_destroy_container(struct lxc_conf *conf);
|
||||||
static int lxc_rmdir_onedev_wrapper(void *data);
|
static int lxc_rmdir_onedev_wrapper(void *data);
|
||||||
static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
|
static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
|
||||||
@ -1306,6 +1308,7 @@ static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
|
|||||||
char destroy[MAXPATHLEN];
|
char destroy[MAXPATHLEN];
|
||||||
bool bret = true;
|
bool bret = true;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
struct lxc_container *c;
|
||||||
if (handler->conf && handler->conf->rootfs.path && handler->conf->rootfs.mount) {
|
if (handler->conf && handler->conf->rootfs.path && handler->conf->rootfs.mount) {
|
||||||
bret = do_destroy_container(handler->conf);
|
bret = do_destroy_container(handler->conf);
|
||||||
if (!bret) {
|
if (!bret) {
|
||||||
@ -1322,6 +1325,18 @@ static void lxc_destroy_container_on_signal(struct lxc_handler *handler,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (am_unpriv())
|
if (am_unpriv())
|
||||||
ret = userns_exec_1(handler->conf, lxc_rmdir_onedev_wrapper, destroy);
|
ret = userns_exec_1(handler->conf, lxc_rmdir_onedev_wrapper, destroy);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user