Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/compel
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2022-04-01 09:52:33 +0300
committerAndrei Vagin <avagin@gmail.com>2022-04-29 03:53:52 +0300
commit45e048d77a6a64f11e3b91368e4c83edea3bcaf9 (patch)
tree55d2ffd29ce487fbf40d1614b01d7e08abbbb1a6 /compel
parent75064b74242116ff37f726d74795fb115a486306 (diff)
criu: generate unique socket names
CRIU has a few places where it creates unix sockets and their names have to be unique for each criu run. Fixes: #1798 Signed-off-by: Andrei Vagin <avagin@google.com>
Diffstat (limited to 'compel')
-rw-r--r--compel/include/uapi/infect-util.h6
-rw-r--r--compel/src/lib/infect-util.c2
-rw-r--r--compel/src/lib/infect.c3
3 files changed, 10 insertions, 1 deletions
diff --git a/compel/include/uapi/infect-util.h b/compel/include/uapi/infect-util.h
index 4e32d13dc..ace6f6b6b 100644
--- a/compel/include/uapi/infect-util.h
+++ b/compel/include/uapi/infect-util.h
@@ -3,6 +3,12 @@
#include "common/compiler.h"
+/*
+ * compel_run_id is a unique value of the current run. It can be used to
+ * generate resource ID-s to avoid conflicts with other processes.
+ */
+extern uint64_t compel_run_id;
+
struct parasite_ctl;
extern int __must_check compel_util_send_fd(struct parasite_ctl *ctl, int fd);
extern int compel_util_recv_fd(struct parasite_ctl *ctl, int *pfd);
diff --git a/compel/src/lib/infect-util.c b/compel/src/lib/infect-util.c
index 5d6d0ddd8..00a7c83f7 100644
--- a/compel/src/lib/infect-util.c
+++ b/compel/src/lib/infect-util.c
@@ -7,6 +7,8 @@
#include "infect-rpc.h"
#include "infect-util.h"
+uint64_t compel_run_id;
+
int compel_util_send_fd(struct parasite_ctl *ctl, int fd)
{
int sk;
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index 0fb9e715c..78e4d7e0e 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -1,3 +1,4 @@
+#include <inttypes.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
@@ -364,7 +365,7 @@ static int gen_parasite_saddr(struct sockaddr_un *saddr, int key)
int sun_len;
saddr->sun_family = AF_UNIX;
- snprintf(saddr->sun_path, UNIX_PATH_MAX, "X/crtools-pr-%d", key);
+ snprintf(saddr->sun_path, UNIX_PATH_MAX, "X/crtools-pr-%d-%" PRIx64, key, compel_run_id);
sun_len = SUN_LEN(saddr);
*saddr->sun_path = '\0';