Skip to content

Commit 104a828

Browse files
rst0gitavagin
authored andcommitted
action-scripts: Add pre-stream hook
This hook allows to start image streamer process from an action script. Signed-off-by: Radostin Stoyanov <[email protected]>
1 parent 358f09c commit 104a828

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

criu/action-scripts.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "common/scm.h"
1919

2020
static const char *action_names[ACT_MAX] = {
21+
[ACT_PRE_STREAM] = "pre-stream",
2122
[ACT_PRE_DUMP] = "pre-dump",
2223
[ACT_POST_DUMP] = "post-dump",
2324
[ACT_PRE_RESTORE] = "pre-restore",

criu/img-streamer.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "rst-malloc.h"
1313
#include "common/scm.h"
1414
#include "common/lock.h"
15+
#include "action-scripts.h"
1516

1617
/*
1718
* We use different path names for the dump and restore sockets because:
@@ -49,10 +50,17 @@ static const char *socket_name_for_mode(int mode)
4950
int img_streamer_init(const char *image_dir, int mode)
5051
{
5152
struct sockaddr_un addr;
53+
int pre_stream_ret;
5254
int sockfd;
5355

5456
img_streamer_mode = mode;
5557

58+
pre_stream_ret = run_scripts(ACT_PRE_STREAM);
59+
if (pre_stream_ret != 0) {
60+
pr_err("Pre-stream script failed with %d!\n", pre_stream_ret);
61+
return -1;
62+
}
63+
5664
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
5765
if (sockfd < 0) {
5866
pr_perror("Unable to instantiate UNIX socket");

criu/include/action-scripts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "asm/int.h"
55

66
enum script_actions {
7+
ACT_PRE_STREAM,
78
ACT_PRE_DUMP,
89
ACT_POST_DUMP,
910
ACT_PRE_RESTORE,

0 commit comments

Comments
 (0)