Draft: Add POSIX message queue dump/restore support via MQ_IOC_BULK_PEEK (GSoC 2026 PoC)#2990
Draft
DongSunchao wants to merge 4 commits intocheckpoint-restore:criu-devfrom
Draft
Draft: Add POSIX message queue dump/restore support via MQ_IOC_BULK_PEEK (GSoC 2026 PoC)#2990DongSunchao wants to merge 4 commits intocheckpoint-restore:criu-devfrom
DongSunchao wants to merge 4 commits intocheckpoint-restore:criu-devfrom
Conversation
Define the image format needed to checkpoint/restore POSIX message queue file descriptors. - Add posix-mqueue.proto with ipcns_pmq_data_entry (queue attributes, repeated message entries, flags, fown) and posix_mqueue_msg_entry (priority, length, payload bytes). - Extend file_entry in fdinfo.proto with a new fd_types value PQEFD (21) and an optional ipcns_pmq_data_entry field pqmfd. - Register the new image type (IPCNS_PMQ_DATA) throughout the image infrastructure: magic number, image-desc template, protobuf descriptor enum and include.
Implement dump and restore of open POSIX message queue file descriptors. Dump side (dump_one_pmq_fd): - Triggered by MQUEUE_MAGIC fs_type in the fd dispatch table in files.c. - Uses mq_getattr() to read queue attributes and the custom kernel ioctl MQ_IOC_BULK_PEEK to non-destructively snapshot all messages in one or more batched calls. Messages are returned in priority-then-FIFO order, which is exactly the order a subsequent mq_receive() would consume them. - A local fallback definition of the ioctl structures and command is included under #ifndef MQ_IOC_BULK_PEEK for kernels that do not yet expose the header. - Serialises the queue name, attributes, flags, fown, and message list into a FileEntry / IpcnsPmqDataEntry protobuf written to the files image. Restore side (pmq_open): - Unlinks any pre-existing queue with the same name (the process was killed after dump but the named queue persists in the kernel). - Re-creates the queue with the saved attributes, replays messages via mq_send() in the saved order to preserve priority ordering, then restores fd flags and ownership through rst_file_params(). Adds POSIX_MQUEUE_MAGIC to fs-magic.h and wires the new module into files.c (dispatch and collection) and the build system.
Add a static ZDTM test for checkpoint/restore of open POSIX message queue file descriptors. The test: - Creates a named queue with mq_maxmsg=10 / mq_msgsize=256. - Enqueues four messages with distinct priorities (20, 10, 10, 5) to exercise both priority ordering and FIFO tie-breaking. - Records the mqueue inode with fstat() before C/R to detect a false pass: if dump fails, zdtm.py sends SIGTERM and the process resumes with the original fd intact (same inode); the test fails explicitly in that case. - After restore, verifies that mq_receive() returns messages in the expected priority-then-FIFO order with correct payload content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This Draft PR is a Proof of Concept (PoC) prepared for GSoC 2026: Checkpointing of POSIX message queues.
Currently, CRIU cannot non-destructively dump POSIX message queues because the standard
mq_receive()is destructive, and reading the virtual filesystem (/dev/mqueue) does not expose the raw message payloads.To solve this, I have designed a new Linux kernel ioctl (
MQ_IOC_BULK_PEEK) and integrated the corresponding userspace logic into this CRIU branch.Architectural Highlights of this PoC:
start_offset, and theMQ_PEEK_FLAG_HAS_MOREflag to prevent memory spikes and scheduling latency.mq_open()and utilizesmq_send()to perfectly restore the exact priority ordering.Current Status & ZDTM Test Results
The basic dump and restore logic is fully functional. I have successfully run ZDTM tests (
test/zdtm/static/posix-mqueue.c) against my custom kernel. The logs confirm that message priority ordering is perfectly preserved during migration:Dependencies
This branch requires a custom Linux kernel to function.
Kernel Patch Series (RFC): https://github.com/DongSunchao/gsoc-mqueue-bulk-peek
Questions for Mentors
@rst0git @Snorch
Hello Radostin and Pavel! As I am finalizing my GSoC 2026 proposal, I wanted to share this early PoC to prove the technical viability of the
MQ_IOC_BULK_PEEKapproach.I would highly appreciate any early feedback on:
I look forward to discussing this further during the application period. Thank you for your time!
Note on Code Style
As this is an early PoC focused on validating the core technical approach, the code formatting and style may not yet fully perfectly align with CRIU's strict coding guidelines. Refining the code style, adding proper error handling, and writing comprehensive comments are my top priorities for the initial phase of the GSoC coding period.