[CRIU] [PATCH 3/4] unix: add ability to set callbacks for external sockets
Pavel Emelyanov
xemul at parallels.com
Mon Dec 2 02:27:32 PST 2013
On 11/30/2013 09:43 PM, Andrey Vagin wrote:
> We don't know a state behind an external socket. It depends on logic
> of the program, which handles this socket.
>
> This patch adds ability to load a library with callbacks for dumping
> and restoring external sockets.
>
> This patch introduces two callbacks cr_dump_unix_sk and
> cr_restore_unix_sk. If a callback can not handle a socket, it
> must return CR_SK_SKIP.
>
> The main questions, what kind of information should be tranfered in
> these callbacks. Pls, think a few minutes about that and send me
> your opinion.
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> include/cr-lib.h | 12 +++++++
> protobuf/sk-unix.proto | 1 +
> sk-unix.c | 92 ++++++++++++++++++++++++++++++++++++++++++++------
> 3 files changed, 95 insertions(+), 10 deletions(-)
>
> diff --git a/include/cr-lib.h b/include/cr-lib.h
> index 75042aa..041ef74 100644
> --- a/include/cr-lib.h
> +++ b/include/cr-lib.h
> @@ -1,6 +1,18 @@
> #ifndef __CR_LIB_H__
> #define __CR_LIB_H__
>
> +#include <limits.h>
> +
> typedef int (cr_init_t)(void);
>
> +#define CR_CB_SKIP INT_MIN
> +/*
> + * The callbacks for unix sockets resturn:
> + * - CR_CB_SKIP if this callback is not suitable for this socket
> + * - negative values, if something failed
> + * - zero, if the socket was dumped or restored
> + */
> +typedef int (cr_dump_unix_sk_t)(int fd, int ino, int peer_ino);
> +typedef int (cr_restore_unix_sk_t)(int ino, char *name, int len);
> +
> #endif
> diff --git a/protobuf/sk-unix.proto b/protobuf/sk-unix.proto
> index bbe2588..9f87baa 100644
> --- a/protobuf/sk-unix.proto
> +++ b/protobuf/sk-unix.proto
> @@ -39,4 +39,5 @@ message unix_sk_entry {
> optional sk_shutdown shutdown = 12;
>
> optional file_perms_entry file_perms = 13;
> + optional bool need_callback = 14;
Use uflags for this.
> }
More information about the CRIU
mailing list