[CRIU] [PATCH v2 5/8] ipc: add new flag for preset msgque id on creation

Stanislav Kinsbursky skinsbursky at parallels.com
Wed Feb 8 08:18:26 EST 2012


This patch is required for checkpoint/restore of IPC message queues.

The patch makes IPC_PRESET flag enterpreted as an order to use passed key as
the id of new segment to create on sys_shmget() call. IOW, kernel will try
allocate new segment in specified slot. If slot is not emply, them -EEXIST
returned.
Note: key and id will be identical for such segment after creation.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at parallels.com>

---
 ipc/msg.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index 7385de2..bb66486 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -190,6 +190,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
 
 	msq->q_perm.mode = msgflg & S_IRWXUGO;
 	msq->q_perm.key = key;
+	msq->q_perm.id = 0;
 
 	msq->q_perm.security = NULL;
 	retval = security_msg_queue_alloc(msq);
@@ -198,6 +199,10 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
 		return retval;
 	}
 
+	if (msgflg & IPC_PRESET) {
+		msq->q_perm.id = key;
+		msq->q_perm.seq = (unsigned long) key / SEQ_MULTIPLIER;
+	}
 	/*
 	 * ipc_addid() locks msq
 	 */



More information about the CRIU mailing list