Ejemplo n.º 1
0
int prepare_inventory(InventoryEntry *he)
{
	struct {
		struct pstree_item i;
		struct dmp_info d;
	} crt = { };

	pr_info("Perparing image inventory (version %u)\n", CRTOOLS_IMAGES_V1);

	he->img_version = CRTOOLS_IMAGES_V1_1;
	he->fdinfo_per_id = true;
	he->has_fdinfo_per_id = true;
	he->ns_per_id = true;
	he->has_ns_per_id = true;
	he->lsmtype = host_lsm_type();

	crt.i.state = TASK_ALIVE;
	crt.i.pid.real = getpid();
	if (get_task_ids(&crt.i))
		return -1;

	he->has_root_cg_set = true;
	if (dump_task_cgroup(NULL, &he->root_cg_set))
		return -1;

	he->root_ids = crt.i.ids;

	return 0;
}
Ejemplo n.º 2
0
int write_img_inventory(void)
{
	struct cr_img *img;
	InventoryEntry he = INVENTORY_ENTRY__INIT;
	struct {
		struct pstree_item i;
		struct dmp_info d;
	} crt = { };

	pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1);

	img = open_image(CR_FD_INVENTORY, O_DUMP);
	if (!img)
		return -1;

	he.img_version = CRTOOLS_IMAGES_V1_1;
	he.fdinfo_per_id = true;
	he.has_fdinfo_per_id = true;
	he.ns_per_id = true;
	he.has_ns_per_id = true;
	he.lsmtype = host_lsm_type();

	crt.i.state = TASK_ALIVE;
	crt.i.pid.real = getpid();
	if (get_task_ids(&crt.i)) {
		close_image(img);
		return -1;
	}

	he.has_root_cg_set = true;
	if (dump_task_cgroup(NULL, &he.root_cg_set))
		return -1;

	he.root_ids = crt.i.ids;

	if (pb_write_one(img, &he, PB_INVENTORY) < 0)
		return -1;

	xfree(crt.i.ids);
	close_image(img);
	return 0;
}
Ejemplo n.º 3
0
Archivo: image.c Proyecto: blindFS/criu
int write_img_inventory(void)
{
	int fd;
	InventoryEntry he = INVENTORY_ENTRY__INIT;
	struct pstree_item crt = { };

	pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1);

	fd = open_image(CR_FD_INVENTORY, O_DUMP);
	if (fd < 0)
		return -1;

	he.img_version = CRTOOLS_IMAGES_V1;
	he.fdinfo_per_id = true;
	he.has_fdinfo_per_id = true;
	he.ns_per_id = true;
	he.has_ns_per_id = true;

	crt.state = TASK_ALIVE;
	crt.pid.real = getpid();
	if (get_task_ids(&crt)) {
		close(fd);
		return -1;
	}

	he.has_root_cg_set = true;
	if (dump_task_cgroup(NULL, &he.root_cg_set))
		return -1;

	he.root_ids = crt.ids;

	if (pb_write_one(fd, &he, PB_INVENTORY) < 0)
		return -1;

	xfree(crt.ids);
	close(fd);
	return 0;
}
Ejemplo n.º 4
0
Archivo: image.c Proyecto: hqhq/criu
int prepare_inventory(InventoryEntry *he)
{
	struct pid pid;
	struct {
		struct pstree_item i;
		struct dmp_info d;
	} crt = { .i.pid = &pid };

	pr_info("Perparing image inventory (version %u)\n", CRTOOLS_IMAGES_V1);

	he->img_version = CRTOOLS_IMAGES_V1_1;
	he->fdinfo_per_id = true;
	he->has_fdinfo_per_id = true;
	he->ns_per_id = true;
	he->has_ns_per_id = true;
	he->has_lsmtype = true;
	he->lsmtype = host_lsm_type();

	crt.i.pid->state = TASK_ALIVE;
	crt.i.pid->real = getpid();
	if (get_task_ids(&crt.i))
		return -1;

	he->has_root_cg_set = true;
	if (dump_task_cgroup(NULL, &he->root_cg_set, NULL))
		return -1;

	he->root_ids = crt.i.ids;

	return 0;
}

static struct cr_imgset *alloc_cr_imgset(int nr)
{
	struct cr_imgset *cr_imgset;
	unsigned int i;

	cr_imgset = xmalloc(sizeof(*cr_imgset));
	if (cr_imgset == NULL)
		return NULL;

	cr_imgset->_imgs = xmalloc(nr * sizeof(struct cr_img *));
	if (cr_imgset->_imgs == NULL) {
		xfree(cr_imgset);
		return NULL;
	}

	for (i = 0; i < nr; i++)
		cr_imgset->_imgs[i] = NULL;
	cr_imgset->fd_nr = nr;
	return cr_imgset;
}

static void __close_cr_imgset(struct cr_imgset *cr_imgset)
{
	unsigned int i;

	if (!cr_imgset)
		return;

	for (i = 0; i < cr_imgset->fd_nr; i++) {
		if (!cr_imgset->_imgs[i])
			continue;
		close_image(cr_imgset->_imgs[i]);
		cr_imgset->_imgs[i] = NULL;
	}
}