Skip to content

Commit

Permalink
action-scripts: Add pre-stream hook
Browse files Browse the repository at this point in the history
This hook allows to start image streamer process from an action script.

Signed-off-by: Radostin Stoyanov <[email protected]>
  • Loading branch information
rst0git authored and avagin committed Jun 12, 2023
1 parent 9301b69 commit 72e794c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions criu/action-scripts.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "common/scm.h"

static const char *action_names[ACT_MAX] = {
[ACT_PRE_STREAM] = "pre-stream",
[ACT_PRE_DUMP] = "pre-dump",
[ACT_POST_DUMP] = "post-dump",
[ACT_PRE_RESTORE] = "pre-restore",
Expand Down
8 changes: 8 additions & 0 deletions criu/img-streamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "rst-malloc.h"
#include "common/scm.h"
#include "common/lock.h"
#include "action-scripts.h"

/*
* We use different path names for the dump and restore sockets because:
Expand Down Expand Up @@ -49,10 +50,17 @@ static const char *socket_name_for_mode(int mode)
int img_streamer_init(const char *image_dir, int mode)
{
struct sockaddr_un addr;
int pre_stream_ret;
int sockfd;

img_streamer_mode = mode;

pre_stream_ret = run_scripts(ACT_PRE_STREAM);
if (pre_stream_ret != 0) {
pr_err("Pre-stream script failed with %d!\n", pre_stream_ret);
return -1;
}

sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0) {
pr_perror("Unable to instantiate UNIX socket");
Expand Down
1 change: 1 addition & 0 deletions criu/include/action-scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "asm/int.h"

enum script_actions {
ACT_PRE_STREAM,
ACT_PRE_DUMP,
ACT_POST_DUMP,
ACT_PRE_RESTORE,
Expand Down

0 comments on commit 72e794c

Please sign in to comment.