Skip to content

Posix mqueue#2981

Open
Abdullah-Badawy1 wants to merge 3 commits intocheckpoint-restore:criu-devfrom
Abdullah-Badawy1:posix-mqueue
Open

Posix mqueue#2981
Abdullah-Badawy1 wants to merge 3 commits intocheckpoint-restore:criu-devfrom
Abdullah-Badawy1:posix-mqueue

Conversation

@Abdullah-Badawy1
Copy link
Copy Markdown

Add foundation for POSIX message queues [[#2285]]

What and How

  • Feature Detection: Added check_posix_mqueue() [[criu: cr-check: add POSIX mqueue kernel support check #2957]] to criu/cr-check.c to verify kernel support by checking the /proc/sys/fs/mqueue interface.
  • Filesystem Identification: Defined MQUEUE_MAGIC [#2958] and registered it in the fstypes array in criu/filesystems.c. This enables CRIU to recognize and validate mqueue mounts using standard statfs() calls.

These are foundational for the upcoming POSIX mqueue feature. Before implementing message retrieval logic, it is essential that CRIU can properly identify the mqueue virtual filesystem and verify kernel support.

Signed-off-by: Abdullah Albadawy abdullahalbadawy1@gmail.com

@Abdullah-Badawy1
Copy link
Copy Markdown
Author

Abdullah-Badawy1 commented Mar 23, 2026

@avagin I am reading ipc/mqueue.c in the kernel source. mq_timedreceive lacks a flags argument, we can't simply add a
MSG_PEEK flag like we have in sockets. so should i focus with ioctl interface ? or fcntl , or syscall I don't know <😕>

@rst0git
Copy link
Copy Markdown
Member

rst0git commented Mar 25, 2026

mq_timedreceive lacks a flags argument, we can't simply add a MSG_PEEK flag like we have in sockets

If I understand correctly, the following GSoC project idea aims to introduce this kernel interface:
https://criu.org/Google_Summer_of_Code_Ideas#Checkpointing_of_POSIX_message_queues

@Abdullah-Badawy1
Copy link
Copy Markdown
Author

@rst0git Yes , we need kernal interface, the pr is just to ckeck the old kernals support the posix feature and pave the way for this interface, I am currently working on the kernel side

Dumping a process that holds open mqueue descriptors fails with
"Can't lookup mount" because CRIU has no handler for the mqueue
fd type. There is no runtime check to surface this gap early,
so users get a cryptic dump failure with no actionable output.

Add check_posix_mqueue() that probes /proc/sys/fs/mqueue, which
only exists when CONFIG_POSIX_MQUEUE=y. The check is placed in
the Category 2 block alongside check_posix_timers() and wired
into feature_list[] so it can be queried directly:

  criu check --feature posix_mqueue

Signed-off-by: Abdullah Albadawy <abdullahalbadawy1@gmail.com>
MQUEUE_MAGIC (0x19800202) is missing from fs-magic.h while
every other filesystem CRIU handles is listed there. The value
is defined in ipc/mqueue.c in the kernel source and is needed
to identify mqueue file descriptors via fstatfs() when
implementing POSIX mqueue full feature

Signed-off-by: Abdullah Albadawy <abdullahalbadawy1@gmail.com>
POSIX message queues are implemented as the mqueue virtual
filesystem. Dumping a process that holds open mqueue descriptors
currently fails with "Can't lookup mount" because CRIU has no
handler for the mqueue fd type and no way to save queue contents.

Add support using the intrusive approach: during dump, messages
are drained from each queue with mq_receive(), serialised to the
image, then put back with mq_send() before the process is
resumed.  The process is frozen by ptrace for the entire
operation so no new messages can arrive in the window between
drain and refill.

Changes:
- images/mqueue.proto: protobuf schema for queue attributes
  (pmq_data_entry), per-message data (mqueue_message), and
  open file descriptor state (pmqfd_entry)
- criu/mqueue.c + criu/include/mqueue.h: core implementation
  with intrusive_mq_peek_all(), restore_pmq_messages(),
  dump_pmq_fd(), open_pmq_fd(), and pmqfd_cinfo
- criu/ipc_ns.c: dump_ipc_pmq() enumerates /dev/mqueue and
  calls intrusive_mq_peek_all(); prepare_ipc_pmq() recreates
  queues with saved attributes and restores messages
- criu/files.c: route fds on MQUEUE_MAGIC filesystem to
  dump_pmq_fd()
- criu/cr-restore.c: register pmqfd_cinfo for fd collection
- criu/image-desc.c + image-desc.h: IPCNS_PMQ, PMQ_DATA,
  PMQFD image types
- criu/include/protobuf-desc.h + protobuf-desc.c: register
  PB_PMQFD, PB_IPCNS_PMQ_DATA, PB_MQUEUE_MESSAGE descriptors
- images/fdinfo.proto: add PMQFD fd type and pmqfd_entry
- test/zdtm/static/posix_mqueue.c: ZDTM test that creates a
  queue, sends two messages with different priorities, checkpoints,
  restores, and verifies both messages are intact in priority order

Link: checkpoint-restore#2285
Assisted-by: Claude:sonnet-4.6
Signed-off-by: Abdullah Albadawy <abdullahalbadawy1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants