mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 10:16:41 +00:00
util: add an unique ID of the current criu run
This ID will be used to generate resource ID-s that can conflicts with other CRIU processes. Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
parent
b13b95e522
commit
408a7d82d6
3 changed files with 19 additions and 0 deletions
|
|
@ -254,6 +254,8 @@ int main(int argc, char *argv[], char *envp[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
util_init();
|
||||
|
||||
if (log_init(opts.output))
|
||||
return 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -393,4 +393,10 @@ static inline void cleanup_freep(void *p)
|
|||
|
||||
extern int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args);
|
||||
|
||||
/*
|
||||
* criu_run_id is a unique value of the current run. It can be used to
|
||||
* generate resource ID-s to avoid conflicts with other CRIU processes.
|
||||
*/
|
||||
extern uint64_t criu_run_id;
|
||||
extern void util_init(void);
|
||||
#endif /* __CR_UTIL_H__ */
|
||||
|
|
|
|||
11
criu/util.c
11
criu/util.c
|
|
@ -27,6 +27,7 @@
|
|||
#include <netinet/tcp.h>
|
||||
#include <sched.h>
|
||||
#include <ftw.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "linux/mount.h"
|
||||
|
||||
|
|
@ -1804,3 +1805,13 @@ int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args)
|
|||
|
||||
return fret;
|
||||
}
|
||||
|
||||
uint64_t criu_run_id;
|
||||
|
||||
void util_init()
|
||||
{
|
||||
struct timespec tp;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
criu_run_id = ((uint64_t)getpid() << 32) + tp.tv_sec + tp.tv_nsec;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue