[CRIU] Re: [PATCH 1/4] IPC: dump message queue

Pavel Emelyanov xemul at parallels.com
Wed Feb 8 12:47:42 EST 2012


> +static int dump_ipc_msg_pages(int fd, const struct ipc_msg_entry *entry)
> +{
> +	int msg_nr = 0;
> +
> +	while (msg_nr < entry->qnum) {
> +		struct msgbuf {
> +			long mtype;
> +			char mtext[MSGMAX];
> +		} data;
> +		struct ipc_msg msg;
> +		int ret;
> +
> +		ret = msgrcv(entry->seg.id, &data, sizeof(data), 0, IPC_NOWAIT);

And the message disappears from the queue after dump, right?

> +		if (ret < 0) {
> +			pr_err("Failed to receive IPC message: %d\n", -errno);
> +			return -1;
> +		}
> +		msg.size = ret;
> +		msg.mtype = data.mtype;
> +
> +		print_ipc_msg(msg_nr, &msg);
> +
> +		ret = write_img(fd, &msg);
> +		if (ret < 0) {
> +			pr_err("Failed to write IPC message header\n");
> +			return ret;
> +		}
> +		ret = write_img_buf(fd, data.mtext, round_up(msg.size, sizeof(u64)));
> +		if (ret < 0) {
> +			pr_err("Failed to write IPC message data\n");
> +			return ret;
> +		}
> +		msg_nr++;
> +	}
> +	return 0;
> +}


More information about the CRIU mailing list