[CRIU] Re: [PATCH 04/14] eventfd: Add checkpoint/restore support
Pavel Emelyanov
xemul at parallels.com
Thu May 3 08:48:43 EDT 2012
On 04/29/2012 05:14 PM, Cyrill Gorcunov wrote:
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> Makefile | 1 +
> cr-dump.c | 22 +++++++
> cr-restore.c | 4 +
> cr-show.c | 23 +++++++
> crtools.c | 7 ++
> eventfs.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> include/crtools.h | 3 +
> include/eventfs.h | 20 +++++++
> include/image.h | 9 +++
> 9 files changed, 254 insertions(+), 0 deletions(-)
> create mode 100644 eventfs.c
> create mode 100644 include/eventfs.h
>
> diff --git a/eventfs.c b/eventfs.c
> new file mode 100644
> index 0000000..dfea4c9
> --- /dev/null
> +++ b/eventfs.c
Plz, rename to eventfd.c
> @@ -99,6 +100,28 @@ void show_fown_cont(fown_t *fown)
> fown->uid, fown->euid, fown->signum, fown->pid_type, fown->pid);
> }
>
> +void show_eventfds(int fd, struct cr_options *o)
> +{
> + struct eventfd_file_entry efe;
> +
> + pr_img_head(CR_FD_EVENTFD);
Plz, put this into eventfd.c
> +static int eventfd_open(struct file_desc *d)
> +{
> + struct eventfd_file_info *info;
> + size_t size;
> + int tmp;
> +
> + info = container_of(d, struct eventfd_file_info, d);
> +
> + tmp = eventfd(0, 0);
> + if (tmp < 0) {
> + pr_perror("Can't create eventfd %#08x",
> + info->efe.id);
> + return -1;
> + }
> +
> + if (fcntl(tmp, F_SETFD, info->efe.flags)) {
This is wrong. F_SETFL should be used instead. I've written the rst_file_parms helper for
such cases, please, use one.
BTW, the flags can be pushed to eventfd()'s 2nd arg, if I'm not mistakes, so it's even
better to go this way.
> + pr_perror("Can't set flags on eventfd %#08x",
> + info->efe.id);
> + goto err_close;
> + }
> + size = sizeof(info->efe.counter);
> + if (write(tmp, &info->efe.counter, size) != size) {
> + pr_perror("Can't write counter to eventfd %#08x",
> + info->efe.id);
> + goto err_close;
> + }
Let's avoid this write by passing initial value to eventfd()'s first argument syscall.
Thanks,
Pavel
More information about the CRIU
mailing list