2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

libcriu: Ability to fetch arguments from notifications

After a bit more thinking I found a way to fetch arguments
from notifications -- pass opaque value into callback and
provide a set of calls for exploring one.

With this we can

a) provide more data if service supplies additional fields
   in the future
b) not check the action name to decide whether or not the
   requested argument is available

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2014-06-26 13:58:53 +04:00
parent 5cea861d7f
commit 43e5d05134
3 changed files with 23 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ const char *criu_lib_version = CRIU_VERSION;
static char *service_address = CR_DEFAULT_SERVICE_ADDRESS;
static CriuOpts *opts;
static int (*notify)(char *action);
static int (*notify)(char *action, criu_notify_arg_t na);
static int saved_errno;
void criu_set_service_address(char *path)
@@ -47,13 +47,18 @@ int criu_init_opts(void)
return 0;
}
void criu_set_notify_cb(int (*cb)(char *action))
void criu_set_notify_cb(int (*cb)(char *action, criu_notify_arg_t na))
{
notify = cb;
opts->has_notify_scripts = true;
opts->notify_scripts = true;
}
int criu_notify_pid(criu_notify_arg_t na)
{
return na->has_pid ? na->pid : 0;
}
void criu_set_pid(int pid)
{
opts->has_pid = true;
@@ -374,7 +379,7 @@ again:
if ((*resp)->type == CRIU_REQ_TYPE__NOTIFY) {
if (notify)
ret = notify((*resp)->notify->script);
ret = notify((*resp)->notify->script, (*resp)->notify);
ret = send_notify_ack(fd, ret);
if (!ret)