Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions criu/Makefile.crtools
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ CFLAGS_REMOVE_vdso-compat.o += $(CFLAGS-ASAN) $(CFLAGS-GCOV)
obj-y += pidfd-store.o
obj-y += hugetlb.o
obj-y += pidfd.o
obj-y += posix-mqueue.o

PROTOBUF_GEN := scripts/protobuf-gen.sh

Expand Down
13 changes: 13 additions & 0 deletions criu/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <linux/limits.h>
#include <linux/major.h>
#include <linux/magic.h>

#include <sys/types.h>
#include <sys/prctl.h>
Expand Down Expand Up @@ -50,6 +51,7 @@
#include "fdstore.h"
#include "bpfmap.h"
#include "pidfd.h"
#include "posix-mqueue.h"

#include "protobuf.h"
#include "util.h"
Expand All @@ -59,6 +61,11 @@
#include "plugin.h"

#define FDESC_HASH_SIZE 64

#ifndef MQUEUE_MAGIC
#define MQUEUE_MAGIC 0x19800202
#endif

static struct hlist_head file_desc_hash[FDESC_HASH_SIZE];
/* file_desc's, which fle is not owned by a process, that is able to open them */
static LIST_HEAD(fake_master_head);
Expand Down Expand Up @@ -562,6 +569,9 @@ static int dump_one_file(struct pid *pid, int fd, int lfd, struct fd_opts *opts,
return do_dump_gen_file(&p, lfd, ops, e);
}

if (p.fs_type == MQUEUE_MAGIC)
return do_dump_gen_file(&p, lfd, &pmq_dump_ops, e);

if (S_ISREG(p.stat.st_mode) || S_ISDIR(p.stat.st_mode) || S_ISLNK(p.stat.st_mode)) {
if (fill_fdlink(lfd, &p, &link))
return -1;
Expand Down Expand Up @@ -1793,6 +1803,9 @@ static int collect_one_file(void *o, ProtobufCMessage *base, struct cr_img *i)
ret = collect_one_file_entry(fe, fe->bpf->id, &fe->bpf->base, &bpfmap_cinfo);
break;
#endif
case FD_TYPES__PQEFD:
ret = collect_one_file_entry(fe, fe->pqmfd->id, &fe->pqmfd->base, &pmqfd_cinfo);
break;
}

return ret;
Expand Down
1 change: 1 addition & 0 deletions criu/image-desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = {
FD_ENTRY_F(IPCNS_SHM, "ipcns-shm-%u", O_NOBUF), /* writes segments of data */
FD_ENTRY(IPCNS_MSG, "ipcns-msg-%u"),
FD_ENTRY(IPCNS_SEM, "ipcns-sem-%u"),
FD_ENTRY(IPCNS_PMQ_DATA, "ipcns-pmq-%u"),
FD_ENTRY(FS, "fs-%u"),
FD_ENTRY(REMAP_FPATH, "remap-fpath"),
FD_ENTRY_F(GHOST_FILE, "ghost-file-%x", O_NOBUF),
Expand Down
1 change: 1 addition & 0 deletions criu/include/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __CR_FILES_H__

#include <sys/stat.h>
#include <linux/magic.h>

#include "int.h"
#include "common/compiler.h"
Expand Down
4 changes: 4 additions & 0 deletions criu/include/fs-magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@
#define PID_FS_MAGIC 0x50494446
#endif

#ifndef POSIX_MQUEUE_MAGIC
#define POSIX_MQUEUE_MAGIC 0x19800202
#endif

#endif /* __CR_FS_MAGIC_H__ */
1 change: 1 addition & 0 deletions criu/include/image-desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum {
CR_FD_IPCNS_SHM,
CR_FD_IPCNS_MSG,
CR_FD_IPCNS_SEM,
CR_FD_IPCNS_PMQ_DATA,
_CR_FD_IPCNS_TO,

_CR_FD_NETNS_FROM,
Expand Down
1 change: 1 addition & 0 deletions criu/include/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#define IPCNS_SHM_MAGIC 0x46283044 /* Odessa */
#define IPCNS_MSG_MAGIC 0x55453737 /* Moscow */
#define IPCNS_SEM_MAGIC 0x59573019 /* St. Petersburg */
#define IPCNS_PMQ_DATA_MAGIC 0x504d5131
#define REG_FILES_MAGIC 0x50363636 /* Belgorod */
#define EXT_FILES_MAGIC 0x59255641 /* Usolye */
#define FS_MAGIC 0x51403912 /* Voronezh */
Expand Down
28 changes: 28 additions & 0 deletions criu/include/posix-mqueue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef __CR_MQUEUE_H__
#define __CR_MQUEUE_H__

#include <mqueue.h>
#include <stdint.h>
#include "files.h"
#include "images/posix-mqueue.pb-c.h"

struct mqueue_message {
uint32_t prio;
uint32_t len;
char *data;
};

extern struct collect_image_info pmqfd_cinfo;

struct mqueue_file_info {
IpcnsPmqDataEntry *mfe;
struct file_desc d;
int fd;
struct list_head rlist;
};

extern const struct fdtype_ops pmq_dump_ops;

extern int pmq_peek_messages(int fd, struct mqueue_message *msgs, long nmsgs, long msgsize);

#endif /* __CR_MQUEUE_H__ */
1 change: 1 addition & 0 deletions criu/include/protobuf-desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum {
PB_IPC_VAR,
PB_IPC_SHM,
PB_IPC_SEM,
PB_IPCNS_PMQ_DATA,
PB_MNT,
PB_PSTREE,
PB_GHOST_FILE,
Expand Down
Loading
Loading