<!DOCTYPE html><html dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><head><body><div><div><br><br><blockquote>---- Original Message ----<br>
From: "Andrew Vagin" &lt;avagin@gmail.com&gt;<br>
To: shawn@churchofgit.com<br>CC: "Andrew Vagin" &lt;avagin@parallels.com&gt;, criu@openvz.org<br>
Sent: Thu, Feb 6, 2014, 11:55 AM<br>
Subject: Re: [CRIU] [PATCH] [RFC] support for dumping anon:[timerfd]<br><br><br>On Thu, Feb 06, 2014 at 06:08:38PM +0000, <a target="_blank" href="mailto:shawn@churchofgit.com">shawn@churchofgit.com</a> wrote:<br><blockquote>---- Original Message ----<br>From: "Andrew Vagin" &lt;<a target="_blank" href="mailto:avagin@parallels.com">avagin@parallels.com</a>&gt;<br>To: shawn@<a target="_blank" href="www.churchofgit.com">www.churchofgit.com</a><br>CC: "Shawn Landden" &lt;<a target="_blank" href="mailto:shawn@churchofgit.com">shawn@churchofgit.com</a>&gt;, <a target="_blank" href="mailto:criu@openvz.org">criu@openvz.org</a><br>Sent: Wed, Feb 5, 2014, 03:13 AM<br>Subject: Re: [CRIU] [PATCH] [RFC] support for dumping anon:[timerfd]<br><br>On Wed, Feb 05, 2014 at 10:15:00AM +0000, shawn@<a target="_blank" href="www.churchofgit.com">www.churchofgit.com</a> wrote:<br><br>---- Original Message ----<br>From: "Andrew Vagin" &lt;<a target="_blank" href="mailto:avagin@parallels.com">avagin@parallels.com</a>&gt;<br>To: "Shawn Landden" &lt;<a target="_blank" href="mailto:shawn@churchofgit.com">shawn@churchofgit.com</a>&gt;<br>CC: <a target="_blank" href="mailto:criu@openvz.org">criu@openvz.org</a><br>Sent: Wed, Feb 5, 2014, 12:00 AM<br>Subject: Re: [CRIU] [PATCH] [RFC] support for dumping anon:[timerfd]<br><br>On Tue, Feb 04, 2014 at 04:51:15PM -0800, Shawn Landden wrote:<br><br>How do I properly pack arguments for cr_exec()?<br><br>You didn't answer this important question. My patch doesn't work<br>because I<br>don't know how to use the parasite in criu.<br><br>You need to add:<br>* a new parasite command (PARASITE_CMD_*)<br>* handler in pie/parasite.c<br>* executer in parasite-syscall.c<br><br>You can find many examples there.<br><br>I am not sure, that we need something in parasite for dumping timerfd.<br>Why a file descriptor isn't enough for dumping timerfd state?<br><br>You can look at eventfd.c for example.<br><br>Oh, so the restored process is forked off of the criu process I see. However<br>this does not take care of getting the itimerspec. (timerfd_gettime())<br>You suggested just putting this in fdinfo, but given that there is a syscall to<br>do it, i'd kinda like to just use that rather than proliferate<br>the Linux kernel API, which would mean that this syscall would require the<br>parasite. Or do you think its better to just add the itimerspec to fdinfo?</blockquote><br><br>I am not sure that you understand me. I want to say, that you don't need<br>a parasite code, because all file descriptors are transferred to criu</blockquote><blockquote></blockquote><span>O i.c. I forgot about unix socket passing of fd's. </span><br><blockquote>and you can call timerfd_gettime from the "criu dump" process.<br><br>Look at this code:<br><br>static int dump_one_timerfdfd(int lfd, u32 id, const struct fd_parms *p)<br>{<br>   struct itimerspec *curr_value;<br><br>   if (timerfd_gettime(lfd, curr_value))<br>      ....<br>      return -1;<br>   ...<br>}<br><br>const struct fdtype_ops timerfd_dump_ops = {<br>.type           = FD_TYPES__EVENTFD,<br>.dump           = dump_one_timerfd,<br>};<br><br> <br><blockquote>Pls, split this patch on a few patches.<br><br>I recomend to read the third section of<br><a target="_blank" href="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/">https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/</a><br>Documentation/SubmittingPatches<br><br>I see four patches here:<br>1. add the pid agrument to file_desc_ops-&gt;open<br>2. dump/restore of timerfd<br>3. s/tty_open/open_tty, s/signalfd_open/open_signalfd, etc<br>4. .gitignor<br><br>A new functionality can be accepted only with a proper set of tests.<br>Pls, look at test/zdtm and create a test for timefd.<br><br>Signed-off-by: Shawn Landden &lt;<a target="_blank" href="mailto:shawn@churchofgit.com">shawn@churchofgit.com</a>&gt;<br>---<br>.gitignore              |   1 +<br>Makefile.crtools        |   1 +<br>eventfd.c               |   2 +-<br>eventpoll.c             |   2 +-<br>fifo.c                  |   2 +-<br>files-ext.c             |   2 +-<br>files-reg.c             |   2 +-<br>files.c                 |   5 +-<br>fsnotify.c              |   4 +-<br>image-desc.c            |   1 +<br>include/files.h         |   2 +-<br>include/image-desc.h    |   1 +<br>include/magic.h         |   1 +<br>include/proc_parse.h    |   2 +<br>include/protobuf-desc.h |   1 +<br>namespaces.c            |   2 +-<br>pipes.c                 |   2 +-<br>proc_parse.c            |  16 ++++++<br>protobuf-desc.c         |   1 +<br>protobuf/Makefile       |   1 +<br>protobuf/fdinfo.proto   |   1 +<br>protobuf/timer.proto    |   1 +<br>protobuf/timerfd.proto  |  10 ++++<br>signalfd.c              |   4 +-<br>sk-inet.c               |   4 +-<br>sk-netlink.c            |   2 +-<br>sk-packet.c             |   2 +-<br>sk-unix.c               |   2 +-<br>timerfd.c               | 150<br>++++++++++++++++++++++++++++++++++++++++++++++++<br>tty.c                   |   4 +-<br>tun.c                   |   4 +-<br>31 files changed, 213 insertions(+), 22 deletions(-)<br>create mode 100644 protobuf/timerfd.proto<br>create mode 100644 timerfd.c<br><br>diff --git a/.gitignore b/.gitignore<br>index 9e403ce..6394161 100644<br>--- a/.gitignore<br>+++ b/.gitignore<br>@@ -1,3 +1,4 @@<br>+*~<br>*.o<br>*.d<br>*.img<br>diff --git a/Makefile.crtools b/Makefile.crtools<br>index 094013e..cf8bcba 100644<br>--- a/Makefile.crtools<br>+++ b/Makefile.crtools<br>@@ -39,6 +39,7 @@ obj-y   += ipc_ns.o<br>obj-y   += netfilter.o<br>obj-y   += shmem.o<br>obj-y   += eventfd.o<br>+obj-y   += timerfd.o<br>obj-y   += eventpoll.o<br>obj-y   += mount.o<br>obj-y   += fsnotify.o<br>diff --git a/eventfd.c b/eventfd.c<br>index d4e7bf8..761bcc2 100644<br>--- a/eventfd.c<br>+++ b/eventfd.c<br>@@ -80,7 +80,7 @@ const struct fdtype_ops eventfd_dump_ops = {<br>.dump      = dump_one_eventfd,<br>};<br><br>-static int eventfd_open(struct file_desc *d)<br>+static int eventfd_open(struct file_desc *d, int pid)<br>{<br>struct eventfd_file_info *info;<br>int tmp;<br>diff --git a/eventpoll.c b/eventpoll.c<br>index d82c19e..7f66c05 100644<br>--- a/eventpoll.c<br>+++ b/eventpoll.c<br>@@ -88,7 +88,7 @@ const struct fdtype_ops eventpoll_dump_ops = {<br>.dump      = dump_one_eventpoll,<br>};<br><br>-static int eventpoll_open(struct file_desc *d)<br>+static int eventpoll_open(struct file_desc *d, int pid)<br>{<br>struct eventpoll_file_info *info;<br>int tmp;<br>diff --git a/fifo.c b/fifo.c<br>index 67d7f56..f025995 100644<br>--- a/fifo.c<br>+++ b/fifo.c<br>@@ -105,7 +105,7 @@ out:<br>return new_fifo;<br>}<br><br>-static int open_fifo_fd(struct file_desc *d)<br>+static int open_fifo_fd(struct file_desc *d, int pid)<br>{<br>struct fifo_info *info = container_of(d, struct fifo_info, d);<br><br>diff --git a/files-ext.c b/files-ext.c<br>index cd434ee..c6ab60e 100644<br>--- a/files-ext.c<br>+++ b/files-ext.c<br>@@ -37,7 +37,7 @@ struct ext_file_info {<br>ExtFileEntry      *xfe;<br>};<br><br>-static int open_fd(struct file_desc *d)<br>+static int open_fd(struct file_desc *d, int pid)<br>{<br>struct ext_file_info *xfi;<br>int fd;<br>diff --git a/files-reg.c b/files-reg.c<br>index f98c792..31d1a1d 100644<br>--- a/files-reg.c<br>+++ b/files-reg.c<br>@@ -653,7 +653,7 @@ static int do_open_reg(struct reg_file_info *rfi,<br>void *arg)<br>return fd;<br>}<br><br>-static int open_fe_fd(struct file_desc *fd)<br>+static int open_fe_fd(struct file_desc *fd, int pid)<br>{<br>return open_path(fd, do_open_reg, NULL);<br>}<br>diff --git a/files.c b/files.c<br>index df0e2f1..84b19c0 100644<br>--- a/files.c<br>+++ b/files.c<br>@@ -27,6 +27,7 @@<br>#include "pipes.h"<br>#include "fifo.h"<br>#include "eventfd.h"<br>+#include "timerfd.h"<br>#include "eventpoll.h"<br>#include "fsnotify.h"<br>#include "signalfd.h"<br>@@ -326,6 +327,8 @@ static int dump_one_file(struct parasite_ctl *ctl,<br>int fd, int lfd, struct fd_op<br>ops = &amp;fanotify_dump_ops;<br>else if (is_signalfd_link(lfd))<br>ops = &amp;signalfd_dump_ops;<br>+      else if (is_timerfd_link(lfd))<br>+         ops = &amp;timerfd_dump_ops;<br>else {<br>char more[64];<br><br>@@ -856,7 +859,7 @@ static int open_fd(int pid, struct<br>fdinfo_list_entry *fle)<br>if (fle != file_master(d))<br>return 0;<br><br>-   new_fd = d-&gt;ops-&gt;open(d);<br>+   new_fd = d-&gt;ops-&gt;open(d, pid);<br>if (new_fd &lt; 0)<br>return -1;<br><br>diff --git a/fsnotify.c b/fsnotify.c<br>index a9412a0..f339f1b 100644<br>--- a/fsnotify.c<br>+++ b/fsnotify.c<br>@@ -429,7 +429,7 @@ err:<br>return ret;<br>}<br><br>-static int open_inotify_fd(struct file_desc *d)<br>+static int open_inotify_fd(struct file_desc *d, int pid)<br>{<br>struct fsnotify_file_info *info;<br>struct fsnotify_mark_info *wd_info;<br>@@ -457,7 +457,7 @@ static int open_inotify_fd(struct file_desc *d)<br>return tmp;<br>}<br><br>-static int open_fanotify_fd(struct file_desc *d)<br>+static int open_fanotify_fd(struct file_desc *d, int pid)<br>{<br>struct fsnotify_file_info *info;<br>struct fsnotify_mark_info *mark;<br>diff --git a/image-desc.c b/image-desc.c<br>index aa879e6..1e8950e 100644<br>--- a/image-desc.c<br>+++ b/image-desc.c<br>@@ -26,6 +26,7 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {<br>FD_ENTRY(EXT_FILES,   "ext-files"),<br>FD_ENTRY(NS_FILES,   "ns-files"),<br>FD_ENTRY(EVENTFD_FILE,   "eventfd"),<br>+   FD_ENTRY(TIMERFD_FILE,   "timerfd"),<br>FD_ENTRY(EVENTPOLL_FILE,"eventpoll"),<br>FD_ENTRY(EVENTPOLL_TFD,   "eventpoll-tfd"),<br>FD_ENTRY(SIGNALFD,   "signalfd"),<br>diff --git a/include/files.h b/include/files.h<br>index 975470f..9128f5b 100644<br>--- a/include/files.h<br>+++ b/include/files.h<br>@@ -83,7 +83,7 @@ struct file_desc_ops {<br>* The returned descriptor may be closed (dup2-ed to another)<br>* so it shouldn't be saved for any post-actions.<br>*/<br>-   int         (*open)(struct file_desc *d);<br>+   int         (*open)(struct file_desc *d, int pid);<br>/*<br>* Called on a file when all files of that type are opened<br>* and with the fd being the "restored" one.<br>diff --git a/include/image-desc.h b/include/image-desc.h<br>index f43ad43..32b1177 100644<br>--- a/include/image-desc.h<br>+++ b/include/image-desc.h<br>@@ -72,6 +72,7 @@ enum {<br>CR_FD_EVENTPOLL_FILE,<br>CR_FD_EVENTPOLL_TFD,<br>CR_FD_SIGNALFD,<br>+   CR_FD_TIMERFD_FILE,<br>CR_FD_INOTIFY_FILE,<br>CR_FD_INOTIFY_WD,<br>CR_FD_FANOTIFY_FILE,<br>diff --git a/include/magic.h b/include/magic.h<br>index dfcf31d..e4460cb 100644<br>--- a/include/magic.h<br>+++ b/include/magic.h<br>@@ -53,6 +53,7 @@<br>#define GHOST_FILE_MAGIC   0x52583605 /* Oryol */<br>#define TCP_STREAM_MAGIC   0x51465506 /* Orenburg */<br>#define EVENTFD_FILE_MAGIC   0x44523722 /* Anapa */<br>+#define TIMERFD_FILE_MAGIC   0x48551221 /* Nooksack WA USA */<br>#define EVENTPOLL_FILE_MAGIC   0x45023858 /* Krasnodar */<br>#define EVENTPOLL_TFD_MAGIC   0x44433746 /* Novorossiysk */<br>#define SIGNALFD_MAGIC      0x57323820 /* Uglich */<br>diff --git a/include/proc_parse.h b/include/proc_parse.h<br>index 7fbf4aa..d684764 100644<br>--- a/include/proc_parse.h<br>+++ b/include/proc_parse.h<br>@@ -9,6 +9,7 @@<br>#include "protobuf/eventpoll.pb-c.h"<br>#include "protobuf/signalfd.pb-c.h"<br>#include "protobuf/fsnotify.pb-c.h"<br>+#include "protobuf/timerfd.pb-c.h"<br><br>#define PROC_TASK_COMM_LEN   32<br>#define PROC_TASK_COMM_LEN_FMT   "(%31s"<br>@@ -145,6 +146,7 @@ extern int parse_pid_status(pid_t pid, struct<br>proc_status_creds *);<br><br>union fdinfo_entries {<br>EventfdFileEntry efd;<br>+   TimerfdFileEntry tfd;<br>EventpollTfdEntry epl;<br>SignalfdEntry sfd;<br>InotifyWdEntry ify;<br>diff --git a/include/protobuf-desc.h b/include/protobuf-desc.h<br>index fa9dd61..5bb8452 100644<br>--- a/include/protobuf-desc.h<br>+++ b/include/protobuf-desc.h<br>@@ -13,6 +13,7 @@ enum {<br>PB_VMA,<br>PB_ITIMER,<br>PB_POSIX_TIMER,<br>+   PB_TIMERFD_FILE,<br>PB_CREDS,<br>PB_FS,<br>PB_UTSNS,      /* 10 */<br>diff --git a/namespaces.c b/namespaces.c<br>index 37e232c..60a439b 100644<br>--- a/namespaces.c<br>+++ b/namespaces.c<br>@@ -227,7 +227,7 @@ struct ns_file_info {<br>NsFileEntry      *nfe;<br>};<br><br>-static int open_ns_fd(struct file_desc *d)<br>+static int open_ns_fd(struct file_desc *d, int pid)<br>{<br>struct ns_file_info *nfi = container_of(d, struct ns_file_info, d);<br>struct pstree_item *item, *t;<br>diff --git a/pipes.c b/pipes.c<br>index ef260aa..05d01e3 100644<br>--- a/pipes.c<br>+++ b/pipes.c<br>@@ -292,7 +292,7 @@ static int recv_pipe_fd(struct pipe_info *pi)<br>return fd;<br>}<br><br>-static int open_pipe(struct file_desc *d)<br>+static int open_pipe(struct file_desc *d, int pid)<br>{<br>struct pipe_info *pi, *p;<br>int ret, tmp;<br>diff --git a/proc_parse.c b/proc_parse.c<br>index 55d7c78..0ebe11b 100644<br>--- a/proc_parse.c<br>+++ b/proc_parse.c<br>@@ -1002,6 +1002,22 @@ static int parse_fdinfo_pid_s(char *pid, int fd,<br>int type,<br>entry_met = true;<br>continue;<br>}<br>+      if (fdinfo_field(str, "clockid")) {<br>+         timerfd_file_entry__init(&amp;entry.tfd);<br>+<br>+         if (type != FD_TYPES__TIMERFD)<br>+            goto parse_err;<br>+         ret = sscanf(str, "clockid: %d",<br>+               (int *)&amp;entry.tfd.clockid);<br>+         if (ret != 1)<br>+            goto parse_err;<br>+         ret = cb(&amp;entry, arg);<br>+         if (ret)<br>+            goto out;<br>+<br>+         entry_met = true;<br>+         continue;<br>+      }<br>if (fdinfo_field(str, "fanotify flags")) {<br>struct fsnotify_params *p = arg;<br><br>diff --git a/protobuf-desc.c b/protobuf-desc.c<br>index a86ec38..9da2feb 100644<br>--- a/protobuf-desc.c<br>+++ b/protobuf-desc.c<br>@@ -38,6 +38,7 @@<br>#include "protobuf/sk-packet.pb-c.h"<br>#include "protobuf/creds.pb-c.h"<br>#include "protobuf/timer.pb-c.h"<br>+#include "protobuf/timerfd.pb-c.h"<br>#include "protobuf/utsns.pb-c.h"<br>#include "protobuf/ipc-var.pb-c.h"<br>#include "protobuf/ipc-shm.pb-c.h"<br>diff --git a/protobuf/Makefile b/protobuf/Makefile<br>index 2bfd696..85a6a92 100644<br>--- a/protobuf/Makefile<br>+++ b/protobuf/Makefile<br>@@ -35,6 +35,7 @@ proto-obj-y   += mnt.o<br>proto-obj-y   += pipe-data.o<br>proto-obj-y   += sa.o<br>proto-obj-y   += timer.o<br>+proto-obj-y   += timerfd.o<br>proto-obj-y   += mm.o<br>proto-obj-y   += sk-opts.o<br>proto-obj-y   += sk-unix.o<br>diff --git a/protobuf/fdinfo.proto b/protobuf/fdinfo.proto<br>index 2eb7986..2324c28 100644<br>--- a/protobuf/fdinfo.proto<br>+++ b/protobuf/fdinfo.proto<br>@@ -16,6 +16,7 @@ enum fd_types {<br>NS      = 14;<br>TUN      = 15;<br>EXT      = 16;<br>+   TIMERFD      = 17;<br>}<br><br>message fdinfo_entry {<br>diff --git a/protobuf/timer.proto b/protobuf/timer.proto<br>index d11f7ef..1383a53 100644<br>--- a/protobuf/timer.proto<br>+++ b/protobuf/timer.proto<br>@@ -1,3 +1,4 @@<br>+// with timerfd these "usec"s are actually nsecs<br>message itimer_entry {<br>required uint64      isec      = 1;<br>required uint64      iusec      = 2;<br>diff --git a/protobuf/timerfd.proto b/protobuf/timerfd.proto<br>new file mode 100644<br>index 0000000..708c957<br>--- /dev/null<br>+++ b/protobuf/timerfd.proto<br>@@ -0,0 +1,10 @@<br>+import "fown.proto";<br>+import "timer.proto";<br>+<br>+message timerfd_file_entry {<br>+   required uint32      id      = 1;<br>+   required uint32      flags      = 2;<br>+   required fown_entry   fown      = 3;<br>+   required itimer_entry   timer      = 4;<br>+   required int32      clockid      = 5;<br>+}<br>diff --git a/signalfd.c b/signalfd.c<br>index 48816ed..72e4f1e 100644<br>--- a/signalfd.c<br>+++ b/signalfd.c<br>@@ -73,7 +73,7 @@ static void sigset_fill(sigset_t *to, unsigned long<br>long from)<br>}<br>}<br><br>-static int signalfd_open(struct file_desc *d)<br>+static int open_signalfd(struct file_desc *d, int pid)<br>{<br>struct signalfd_info *info;<br>int tmp;<br>@@ -104,7 +104,7 @@ err_close:<br><br>static struct file_desc_ops signalfd_desc_ops = {<br>.type = FD_TYPES__SIGNALFD,<br>-   .open = signalfd_open,<br>+   .open = open_signalfd,<br>};<br><br>static int collect_one_sigfd(void *o, ProtobufCMessage *msg)<br>diff --git a/sk-inet.c b/sk-inet.c<br>index 02c653f..b00bbad 100644<br>--- a/sk-inet.c<br>+++ b/sk-inet.c<br>@@ -370,7 +370,7 @@ int inet_collect_one(struct nlmsghdr *h, int<br>family, int type)<br>return ret;<br>}<br><br>-static int open_inet_sk(struct file_desc *d);<br>+static int open_inet_sk(struct file_desc *d, int pid);<br>static int post_open_inet_sk(struct file_desc *d, int sk);<br><br>static struct file_desc_ops inet_desc_ops = {<br>@@ -467,7 +467,7 @@ static int post_open_inet_sk(struct file_desc *d,<br>int sk)<br>return 0;<br>}<br><br>-static int open_inet_sk(struct file_desc *d)<br>+static int open_inet_sk(struct file_desc *d, int pid)<br>{<br>struct inet_sk_info *ii;<br>InetSkEntry *ie;<br>diff --git a/sk-netlink.c b/sk-netlink.c<br>index 83a2090..f562408 100644<br>--- a/sk-netlink.c<br>+++ b/sk-netlink.c<br>@@ -159,7 +159,7 @@ struct netlink_sock_info {<br>struct file_desc d;<br>};<br><br>-static int open_netlink_sk(struct file_desc *d)<br>+static int open_netlink_sk(struct file_desc *d, int pid)<br>{<br>struct netlink_sock_info *nsi;<br>NetlinkSkEntry *nse;<br>diff --git a/sk-packet.c b/sk-packet.c<br>index 2ed7ca6..ed9353b 100644<br>--- a/sk-packet.c<br>+++ b/sk-packet.c<br>@@ -393,7 +393,7 @@ static int restore_rings(int sk, PacketSockEntry<br>*psk)<br>return 0;<br>}<br><br>-static int open_packet_sk(struct file_desc *d)<br>+static int open_packet_sk(struct file_desc *d, int pid)<br>{<br>struct packet_sock_info *psi;<br>PacketSockEntry *pse;<br>diff --git a/sk-unix.c b/sk-unix.c<br>index aa6d22f..bff1836 100644<br>--- a/sk-unix.c<br>+++ b/sk-unix.c<br>@@ -950,7 +950,7 @@ out:<br>return sk;<br>}<br><br>-static int open_unix_sk(struct file_desc *d)<br>+static int open_unix_sk(struct file_desc *d, int pid)<br>{<br>struct unix_sk_info *ui;<br><br>diff --git a/timerfd.c b/timerfd.c<br>new file mode 100644<br>index 0000000..9d32da8<br>--- /dev/null<br>+++ b/timerfd.c<br>@@ -0,0 +1,150 @@<br>+#include &lt;unistd.h&gt;<br>+#include &lt;signal.h&gt;<br>+#include &lt;time.h&gt;<br>+#include &lt;inttypes.h&gt;<br>+#include &lt;sys/timerfd.h&gt;<br>+<br>+<br>+#include "compiler.h"<br>+#include "asm/types.h"<br>+#include "proc_parse.h"<br>+#include "fdset.h"<br>+#include "image.h"<br>+#include "util.h"<br>+#include "log.h"<br>+#include "files.h"<br>+#include "crtools.h"<br>+<br>+#include "timerfd.h"<br>+<br>+#include "protobuf.h"<br>+#include "protobuf/timerfd.pb-c.h"<br>+<br>+#undef   LOG_PREFIX<br>+#define LOG_PREFIX "timerfd: "<br>+<br>+struct timerfd_file_info {<br>+   TimerfdFileEntry      *tfe;<br>+   struct file_desc      d;<br>+};<br>+<br>+/* Checks if file descriptor @lfd is eventfd */<br>+int is_timerfd_link(int lfd)<br>+{<br>+   return is_anon_link_type(lfd, "[timerfd]");<br>+}<br>+<br>+static void pr_info_timerfd(char *action, TimerfdFileEntry *tfe)<br>+{<br>+   pr_info("%s: id %#08x flags %#04x isec %"PRIu64" iusec %"PRIu64"<br>vsec %"PRIu64" uvsec %"PRIu64"\n",<br>+      action, tfe-&gt;id, tfe-&gt;flags, tfe-&gt;timer-&gt;isec,<br>+      tfe-&gt;timer-&gt;iusec, tfe-&gt;timer-&gt;vsec, tfe-&gt;timer-&gt;vusec);<br>+}<br>+<br>+struct timerfd_dump_arg {<br>+   u32 id;<br>+   const struct fd_parms *p;<br>+   bool dumped;<br>+};<br>+<br>+<br>+/* UGLY: global */<br>+struct itimerspec itimer = {{0,0},{0,0}};<br>+<br>+static int dump_timerfd_entry(union fdinfo_entries *e, void *arg)<br>+{<br>+   struct timerfd_dump_arg *da = arg;<br>+<br>+   if (da-&gt;dumped) {<br>+      pr_err("Several counters in a file?\n");<br>+      return -1;<br>+   }<br>+<br>+   da-&gt;dumped = true;<br>+   e-&gt;efd.id = da-&gt;id;<br>+   e-&gt;efd.flags = da-&gt;p-&gt;flags;<br>+   e-&gt;efd.fown = (FownEntry *)&amp;da-&gt;p-&gt;fown;<br>+<br>+   e-&gt;tfd.timer-&gt;isec = itimer.it_interval.tv_sec;<br>+   e-&gt;tfd.timer-&gt;iusec = itimer.it_interval.tv_nsec;<br>+   e-&gt;tfd.timer-&gt;vsec = itimer.it_value.tv_sec;<br>+   e-&gt;tfd.timer-&gt;vusec = itimer.it_value.tv_nsec;<br>+<br>+   pr_info_timerfd("Dumping ", &amp;e-&gt;tfd);<br>+   return pb_write_one(fdset_fd(glob_fdset, CR_FD_TIMERFD_FILE),<br>+         &amp;e-&gt;tfd, PB_TIMERFD_FILE);<br>+}<br>+<br>+static int pre_dump_one_timerfd(int pid, int lfd) {<br>+   int r;<br>+<br>+   r = cr_exec(pid, (char **){"timerfd_gettime", (char *)lfd, (char *)<br>&amp;itimer});<br><br>I don't think that we need to make predump for timerfd. It's useful for<br>inotify, becuse we need to look up a file handle to dump inotify.<br>This operation is heavy, so we do it in pre-dump.<br><br>+   if (r &lt; 0) {<br>+      pr_err("timerfd_gettime failed: %m\n");<br>+      return -errno;<br>+   }<br>+   return 0;<br>+}<br>+<br>+static int dump_one_timerfd(int lfd, u32 id, const struct fd_parms *p)<br>+{<br>+   struct timerfd_dump_arg da = { .id = id, .p = p, };<br>+   return parse_fdinfo(lfd, FD_TYPES__TIMERFD, dump_timerfd_entry, &amp;<br>da);<br>+}<br>+<br>+const struct fdtype_ops timerfd_dump_ops = {<br>+   .type      = FD_TYPES__TIMERFD,<br>+   .dump      = dump_one_timerfd,<br>+   .dump_pre   = pre_dump_one_timerfd,<br>+};<br>+<br>+static int timerfd_open(struct file_desc *d, int pid)<br>+{<br>+   struct timerfd_file_info *info;<br>+   int tmp;<br>+<br>+   info = container_of(d, struct timerfd_file_info, d);<br>+   struct itimerspec itimer = {{info-&gt;tfe-&gt;timer-&gt;isec, info-&gt;tfe-&gt;<br>timer-&gt;iusec}, {info-&gt;tfe-&gt;timer-&gt;vsec, info-&gt;tfe-&gt;timer-&gt;vusec}};<br><br>This line is too long<br><br><a target="_blank" href="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/">https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/</a><br>Documentation/CodingStyle<br><br>+<br>+   tmp = cr_exec(pid, (char **){"timerfd_create", (char *)info-&gt;tfe-&gt;<br>clockid, (char *)0});<br>+   if (tmp &lt; 0) {<br>+      pr_perror("Can't create timerfd %#08x",<br>+           info-&gt;tfe-&gt;id);<br>+      return -1;<br>+   }<br>+<br>+   cr_exec(pid, (char **){"timerfd_settime", (char *)tmp, 0, (char *)&amp;<br>itimer, NULL});<br>+<br>+   if (rst_file_params(tmp, info-&gt;tfe-&gt;fown, info-&gt;tfe-&gt;flags)) {<br>+      pr_perror("Can't restore params on timerfd %#08x",<br>+           info-&gt;tfe-&gt;id);<br>+      goto err_close;<br>+   }<br>+<br>+   return tmp;<br>+<br>+err_close:<br>+   close(tmp);<br>+   return -1;<br>+}<br>+<br>+static struct file_desc_ops timerfd_desc_ops = {<br>+   .type = FD_TYPES__TIMERFD,<br>+   .open = timerfd_open,<br>+};<br>+<br>+static int collect_one_tfd(void *obj, ProtobufCMessage *msg)<br>+{<br>+   struct timerfd_file_info *info = obj;<br>+<br>+   info-&gt;tfe = pb_msg(msg, TimerfdFileEntry);<br>+   pr_info_timerfd("Collected ", info-&gt;tfe);<br>+   return file_desc_add(&amp;info-&gt;d, info-&gt;tfe-&gt;id, &amp;timerfd_desc_ops);<br>+}<br>+<br>+struct collect_image_info timerfd_cinfo = {<br>+   .fd_type = CR_FD_TIMERFD_FILE,<br>+   .pb_type = PB_TIMERFD_FILE,<br>+   .priv_size = sizeof(struct timerfd_file_info),<br>+   .collect = collect_one_tfd,<br>+};<br>diff --git a/tty.c b/tty.c<br>index 2ad76cb..553d64f 100644<br>--- a/tty.c<br>+++ b/tty.c<br>@@ -645,7 +645,7 @@ err:<br>return -1;<br>}<br><br>-static int tty_open(struct file_desc *d)<br>+static int open_tty(struct file_desc *d, int pid)<br>{<br>struct tty_info *info = container_of(d, struct tty_info, d);<br><br>@@ -682,7 +682,7 @@ static struct list_head *tty_select_pslist(struct<br>file_desc *d, struct rst_info<br><br>static struct file_desc_ops tty_desc_ops = {<br>.type      = FD_TYPES__TTY,<br>-   .open      = tty_open,<br>+   .open      = open_tty,<br>.post_open   = tty_restore_ctl_terminal,<br>.want_transport = tty_transport,<br>.select_ps_list   = tty_select_pslist,<br>diff --git a/tun.c b/tun.c<br>index d453015..194585d 100644<br>--- a/tun.c<br>+++ b/tun.c<br>@@ -318,7 +318,7 @@ struct tunfile_info {<br>TunfileEntry *tfe;<br>};<br><br>-static int tunfile_open(struct file_desc *d)<br>+static int open_tunfile(struct file_desc *d, int pid)<br>{<br>int fd;<br>struct tunfile_info *ti;<br>@@ -375,7 +375,7 @@ err:<br><br>static struct file_desc_ops tunfile_desc_ops = {<br>.type = FD_TYPES__TUN,<br>-   .open = tunfile_open,<br>+   .open = open_tunfile,<br>};<br><br>static int collect_one_tunfile(void *o, ProtobufCMessage *base)<br>--<br>1.9.rc0.143.g6fd479e<br><br>_______________________________________________<br>CRIU mailing list<br><a target="_blank" href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br><a target="_blank" href="https://lists.openvz.org/mailman/listinfo/criu">https://lists.openvz.org/mailman/listinfo/criu</a></blockquote><br><br><blockquote>_______________________________________________<br>CRIU mailing list<br><a target="_blank" href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br><a target="_blank" href="https://lists.openvz.org/mailman/listinfo/criu">https://lists.openvz.org/mailman/listinfo/criu</a></blockquote></blockquote></div></div></body></html>