mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-28 04:48:16 +00:00
criu: use libuuid for criu_run_id generation
criu_run_id will be used in upcoming changes to create and remove network rules for network locking. Instead of trying to come up with a way to create unique IDs, just use an existing library. libuuid should be installed on most systems as it is indirectly required by systemd (via libmount). Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
parent
b3869c9172
commit
d165b94bb5
@ -36,7 +36,7 @@ task:
|
|||||||
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
|
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
|
||||||
dnf config-manager --set-enabled crb # Same as CentOS 8 powertools
|
dnf config-manager --set-enabled crb # Same as CentOS 8 powertools
|
||||||
dnf -y install epel-release epel-next-release
|
dnf -y install epel-release epel-next-release
|
||||||
dnf -y install --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python-devel python-PyYAML python-protobuf python-junit_xml python3-importlib-metadata xmlto libdrm-devel
|
dnf -y install --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python-devel python-PyYAML python-protobuf python-junit_xml python3-importlib-metadata xmlto libdrm-devel libuuid-devel
|
||||||
# The image has a too old version of nettle which does not work with gnutls.
|
# The image has a too old version of nettle which does not work with gnutls.
|
||||||
# Just upgrade to the latest to make the error go away.
|
# Just upgrade to the latest to make the error go away.
|
||||||
dnf -y upgrade nettle nettle-devel
|
dnf -y upgrade nettle nettle-devel
|
||||||
|
2
.github/workflows/check-commits.yml
vendored
2
.github/workflows/check-commits.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
# Checkout pull request HEAD commit instead of merge commit
|
# Checkout pull request HEAD commit instead of merge commit
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo scripts/ci/apt-install libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf libnl-3-dev libnet-dev libcap-dev
|
run: sudo scripts/ci/apt-install libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf libnl-3-dev libnet-dev libcap-dev uuid-dev
|
||||||
- name: Configure git user details
|
- name: Configure git user details
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "checkpoint-restore@users.noreply.github.com"
|
git config --global user.email "checkpoint-restore@users.noreply.github.com"
|
||||||
|
@ -3,11 +3,20 @@
|
|||||||
|
|
||||||
#include "common/compiler.h"
|
#include "common/compiler.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The length of the hash is based on what libuuid provides.
|
||||||
|
* According to the manpage this is:
|
||||||
|
*
|
||||||
|
* The uuid_unparse() function converts the supplied UUID uu from the binary
|
||||||
|
* representation into a 36-byte string (plus trailing '\0')
|
||||||
|
*/
|
||||||
|
#define RUN_ID_HASH_LENGTH 37
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* compel_run_id is a unique value of the current run. It can be used to
|
* 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.
|
* generate resource ID-s to avoid conflicts with other processes.
|
||||||
*/
|
*/
|
||||||
extern uint64_t compel_run_id;
|
extern char compel_run_id[RUN_ID_HASH_LENGTH];
|
||||||
|
|
||||||
struct parasite_ctl;
|
struct parasite_ctl;
|
||||||
extern int __must_check compel_util_send_fd(struct parasite_ctl *ctl, int fd);
|
extern int __must_check compel_util_send_fd(struct parasite_ctl *ctl, int fd);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "infect-rpc.h"
|
#include "infect-rpc.h"
|
||||||
#include "infect-util.h"
|
#include "infect-util.h"
|
||||||
|
|
||||||
uint64_t compel_run_id;
|
char compel_run_id[RUN_ID_HASH_LENGTH];
|
||||||
|
|
||||||
int compel_util_send_fd(struct parasite_ctl *ctl, int fd)
|
int compel_util_send_fd(struct parasite_ctl *ctl, int fd)
|
||||||
{
|
{
|
||||||
|
@ -427,7 +427,7 @@ static int gen_parasite_saddr(struct sockaddr_un *saddr, int key)
|
|||||||
int sun_len;
|
int sun_len;
|
||||||
|
|
||||||
saddr->sun_family = AF_UNIX;
|
saddr->sun_family = AF_UNIX;
|
||||||
snprintf(saddr->sun_path, UNIX_PATH_MAX, "X/crtools-pr-%d-%" PRIx64, key, compel_run_id);
|
snprintf(saddr->sun_path, UNIX_PATH_MAX, "X/crtools-pr-%d-%s", key, compel_run_id);
|
||||||
|
|
||||||
sun_len = SUN_LEN(saddr);
|
sun_len = SUN_LEN(saddr);
|
||||||
*saddr->sun_path = '\0';
|
*saddr->sun_path = '\0';
|
||||||
|
@ -6,6 +6,7 @@ REQ-RPM-PKG-NAMES += protobuf-devel
|
|||||||
REQ-RPM-PKG-NAMES += protobuf-python
|
REQ-RPM-PKG-NAMES += protobuf-python
|
||||||
REQ-RPM-PKG-NAMES += libnl3-devel
|
REQ-RPM-PKG-NAMES += libnl3-devel
|
||||||
REQ-RPM-PKG-NAMES += libcap-devel
|
REQ-RPM-PKG-NAMES += libcap-devel
|
||||||
|
REQ-RPM-PKG-NAMES += libuuid-devel
|
||||||
|
|
||||||
REQ-RPM-PKG-TEST-NAMES += libaio-devel
|
REQ-RPM-PKG-TEST-NAMES += libaio-devel
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ REQ-DEB-PKG-NAMES += protobuf-compiler
|
|||||||
REQ-DEB-PKG-NAMES += $(PYTHON)-protobuf
|
REQ-DEB-PKG-NAMES += $(PYTHON)-protobuf
|
||||||
REQ-DEB-PKG-NAMES += libnl-3-dev
|
REQ-DEB-PKG-NAMES += libnl-3-dev
|
||||||
REQ-DEB-PKG-NAMES += libcap-dev
|
REQ-DEB-PKG-NAMES += libcap-dev
|
||||||
|
REQ-DEB-PKG-NAMES += uuid-dev
|
||||||
|
|
||||||
REQ-DEB-PKG-TEST-NAMES += $(PYTHON)-yaml
|
REQ-DEB-PKG-TEST-NAMES += $(PYTHON)-yaml
|
||||||
REQ-DEB-PKG-TEST-NAMES += libaio-dev
|
REQ-DEB-PKG-TEST-NAMES += libaio-dev
|
||||||
@ -25,7 +27,7 @@ REQ-DEB-PKG-TEST-NAMES += libaio-dev
|
|||||||
REQ-RPM-PKG-TEST-NAMES += $(PYTHON)-PyYAML
|
REQ-RPM-PKG-TEST-NAMES += $(PYTHON)-PyYAML
|
||||||
|
|
||||||
|
|
||||||
export LIBS += -lprotobuf-c -ldl -lnl-3 -lsoccr -Lsoccr/ -lnet
|
export LIBS += -lprotobuf-c -ldl -lnl-3 -lsoccr -Lsoccr/ -lnet -luuid
|
||||||
|
|
||||||
check-packages-failed:
|
check-packages-failed:
|
||||||
$(warning Can not find some of the required libraries)
|
$(warning Can not find some of the required libraries)
|
||||||
|
@ -58,7 +58,7 @@ int fdstore_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
addrlen = snprintf(addr.sun_path, sizeof(addr.sun_path), "X/criu-fdstore-%" PRIx64 "-%" PRIx64, st.st_ino,
|
addrlen = snprintf(addr.sun_path, sizeof(addr.sun_path), "X/criu-fdstore-%" PRIx64 "-%s", st.st_ino,
|
||||||
criu_run_id);
|
criu_run_id);
|
||||||
addrlen += sizeof(addr.sun_family);
|
addrlen += sizeof(addr.sun_family);
|
||||||
|
|
||||||
|
@ -978,7 +978,7 @@ static int receive_fd(struct fdinfo_list_entry *fle);
|
|||||||
static void transport_name_gen(struct sockaddr_un *addr, int *len, int pid)
|
static void transport_name_gen(struct sockaddr_un *addr, int *len, int pid)
|
||||||
{
|
{
|
||||||
addr->sun_family = AF_UNIX;
|
addr->sun_family = AF_UNIX;
|
||||||
snprintf(addr->sun_path, UNIX_PATH_MAX, "x/crtools-fd-%d-%" PRIx64, pid, criu_run_id);
|
snprintf(addr->sun_path, UNIX_PATH_MAX, "x/crtools-fd-%d-%s", pid, criu_run_id);
|
||||||
*len = SUN_LEN(addr);
|
*len = SUN_LEN(addr);
|
||||||
*addr->sun_path = '\0';
|
*addr->sun_path = '\0';
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "common/err.h"
|
#include "common/err.h"
|
||||||
|
|
||||||
|
#include "compel/infect-util.h"
|
||||||
|
|
||||||
#define PREF_SHIFT_OP(pref, op, size) ((size)op(pref##BYTES_SHIFT))
|
#define PREF_SHIFT_OP(pref, op, size) ((size)op(pref##BYTES_SHIFT))
|
||||||
#define KBYTES_SHIFT 10
|
#define KBYTES_SHIFT 10
|
||||||
#define MBYTES_SHIFT 20
|
#define MBYTES_SHIFT 20
|
||||||
@ -420,7 +422,7 @@ extern int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void
|
|||||||
* criu_run_id is a unique value of the current run. It can be used to
|
* 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.
|
* generate resource ID-s to avoid conflicts with other CRIU processes.
|
||||||
*/
|
*/
|
||||||
extern uint64_t criu_run_id;
|
extern char criu_run_id[RUN_ID_HASH_LENGTH];
|
||||||
extern void util_init(void);
|
extern void util_init(void);
|
||||||
|
|
||||||
extern char *resolve_mountpoint(char *path);
|
extern char *resolve_mountpoint(char *path);
|
||||||
|
@ -99,7 +99,7 @@ int init_pidfd_store_sk(pid_t pid, int sk)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
addrlen = snprintf(addr.sun_path, sizeof(addr.sun_path), "X/criu-pidfd-store-%d-%d-%" PRIx64, pid, sk,
|
addrlen = snprintf(addr.sun_path, sizeof(addr.sun_path), "X/criu-pidfd-store-%d-%d-%s", pid, sk,
|
||||||
criu_run_id);
|
criu_run_id);
|
||||||
addrlen += sizeof(addr.sun_family);
|
addrlen += sizeof(addr.sun_family);
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "compel/infect-util.h"
|
||||||
|
|
||||||
int add_external(char *key)
|
int add_external(char *key)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -141,4 +143,4 @@ int check_mount_v2(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t compel_run_id;
|
char compel_run_id[RUN_ID_HASH_LENGTH];
|
||||||
|
17
criu/util.c
17
criu/util.c
@ -28,6 +28,7 @@
|
|||||||
#include <ftw.h>
|
#include <ftw.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#include <uuid/uuid.h>
|
||||||
|
|
||||||
#include "linux/mount.h"
|
#include "linux/mount.h"
|
||||||
|
|
||||||
@ -2026,20 +2027,16 @@ int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args)
|
|||||||
return fret;
|
return fret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t criu_run_id;
|
char criu_run_id[RUN_ID_HASH_LENGTH];
|
||||||
|
|
||||||
void util_init(void)
|
void util_init(void)
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
uuid_t uuid;
|
||||||
|
|
||||||
criu_run_id = getpid();
|
uuid_generate(uuid);
|
||||||
if (!stat("/proc/self/ns/pid", &statbuf))
|
uuid_unparse(uuid, criu_run_id);
|
||||||
criu_run_id |= (uint64_t)statbuf.st_ino << 32;
|
pr_info("CRIU run id = %s\n", criu_run_id);
|
||||||
else if (errno != ENOENT)
|
memcpy(compel_run_id, criu_run_id, sizeof(criu_run_id));
|
||||||
pr_perror("Can't stat /proc/self/ns/pid - CRIU run id might not be unique");
|
|
||||||
|
|
||||||
compel_run_id = criu_run_id;
|
|
||||||
pr_info("CRIU run id = %#" PRIx64 "\n", criu_run_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -24,7 +24,8 @@ RUN apk update && apk add \
|
|||||||
sudo \
|
sudo \
|
||||||
libcap-utils \
|
libcap-utils \
|
||||||
libdrm-dev \
|
libdrm-dev \
|
||||||
util-linux
|
util-linux \
|
||||||
|
util-linux-dev
|
||||||
|
|
||||||
COPY . /criu
|
COPY . /criu
|
||||||
WORKDIR /criu
|
WORKDIR /criu
|
||||||
|
@ -56,6 +56,7 @@ RUN apt-get clean -qqy && apt-get update -qqy && apt-get install -qqy --no-insta
|
|||||||
python-protobuf \
|
python-protobuf \
|
||||||
python3-minimal \
|
python3-minimal \
|
||||||
python-ipaddress \
|
python-ipaddress \
|
||||||
|
uuid-dev \
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
vim \
|
vim \
|
||||||
|
@ -35,6 +35,7 @@ RUN pacman -Syu --noconfirm \
|
|||||||
python-junit-xml \
|
python-junit-xml \
|
||||||
python-importlib-metadata \
|
python-importlib-metadata \
|
||||||
libdrm \
|
libdrm \
|
||||||
|
util-linux-libs \
|
||||||
diffutils
|
diffutils
|
||||||
|
|
||||||
COPY . /criu
|
COPY . /criu
|
||||||
|
@ -19,6 +19,7 @@ RUN apk update && apk add \
|
|||||||
maven \
|
maven \
|
||||||
ip6tables \
|
ip6tables \
|
||||||
iptables \
|
iptables \
|
||||||
|
util-linux-dev \
|
||||||
bash
|
bash
|
||||||
|
|
||||||
COPY . /criu
|
COPY . /criu
|
||||||
|
@ -22,6 +22,7 @@ RUN apt-install protobuf-c-compiler \
|
|||||||
pkg-config \
|
pkg-config \
|
||||||
iptables \
|
iptables \
|
||||||
gcc \
|
gcc \
|
||||||
|
uuid-dev \
|
||||||
maven
|
maven
|
||||||
|
|
||||||
COPY . /criu
|
COPY . /criu
|
||||||
|
@ -21,6 +21,7 @@ RUN apt-install \
|
|||||||
pkg-config \
|
pkg-config \
|
||||||
protobuf-c-compiler \
|
protobuf-c-compiler \
|
||||||
protobuf-compiler \
|
protobuf-compiler \
|
||||||
|
uuid-dev \
|
||||||
python3-minimal
|
python3-minimal
|
||||||
|
|
||||||
COPY . /criu
|
COPY . /criu
|
||||||
|
@ -22,6 +22,7 @@ RUN apt-install protobuf-c-compiler \
|
|||||||
pkg-config \
|
pkg-config \
|
||||||
iptables \
|
iptables \
|
||||||
gcc \
|
gcc \
|
||||||
|
uuid-dev \
|
||||||
maven
|
maven
|
||||||
|
|
||||||
RUN mkdir -p /etc/criu && echo 'ghost-limit 16777216' > /etc/criu/default.conf
|
RUN mkdir -p /etc/criu && echo 'ghost-limit 16777216' > /etc/criu/default.conf
|
||||||
|
@ -33,6 +33,7 @@ RUN apt-get install -y --no-install-recommends \
|
|||||||
libprotobuf-c-dev:${DEBIAN_ARCH} \
|
libprotobuf-c-dev:${DEBIAN_ARCH} \
|
||||||
libcap-dev:${DEBIAN_ARCH} \
|
libcap-dev:${DEBIAN_ARCH} \
|
||||||
libaio-dev:${DEBIAN_ARCH} \
|
libaio-dev:${DEBIAN_ARCH} \
|
||||||
|
uuid-dev:${DEBIAN_ARCH} \
|
||||||
libnl-route-3-dev:${DEBIAN_ARCH} \
|
libnl-route-3-dev:${DEBIAN_ARCH} \
|
||||||
libnftables-dev:${DEBIAN_ARCH} \
|
libnftables-dev:${DEBIAN_ARCH} \
|
||||||
libgnutls28-dev:${DEBIAN_ARCH} \
|
libgnutls28-dev:${DEBIAN_ARCH} \
|
||||||
|
@ -18,6 +18,7 @@ RUN apt-install \
|
|||||||
libnl-3-dev:${DEBIAN_ARCH} \
|
libnl-3-dev:${DEBIAN_ARCH} \
|
||||||
libprotobuf-dev:${DEBIAN_ARCH} \
|
libprotobuf-dev:${DEBIAN_ARCH} \
|
||||||
libnet-dev:${DEBIAN_ARCH} \
|
libnet-dev:${DEBIAN_ARCH} \
|
||||||
|
uuid-dev:${DEBIAN_ARCH} \
|
||||||
libprotobuf-c-dev:${DEBIAN_ARCH} \
|
libprotobuf-c-dev:${DEBIAN_ARCH} \
|
||||||
libcap-dev:${DEBIAN_ARCH} \
|
libcap-dev:${DEBIAN_ARCH} \
|
||||||
libaio-dev:${DEBIAN_ARCH} \
|
libaio-dev:${DEBIAN_ARCH} \
|
||||||
|
@ -29,6 +29,7 @@ RUN apt-install \
|
|||||||
protobuf-compiler \
|
protobuf-compiler \
|
||||||
python3-minimal \
|
python3-minimal \
|
||||||
python3-protobuf \
|
python3-protobuf \
|
||||||
|
uuid-dev \
|
||||||
python3-yaml
|
python3-yaml
|
||||||
|
|
||||||
COPY . /criu
|
COPY . /criu
|
||||||
|
@ -17,6 +17,7 @@ RUN apt-install \
|
|||||||
python3-protobuf \
|
python3-protobuf \
|
||||||
libnl-3-dev:${DEBIAN_ARCH} \
|
libnl-3-dev:${DEBIAN_ARCH} \
|
||||||
libprotobuf-dev:${DEBIAN_ARCH} \
|
libprotobuf-dev:${DEBIAN_ARCH} \
|
||||||
|
uuid-dev:${DEBIAN_ARCH} \
|
||||||
libnet-dev:${DEBIAN_ARCH} \
|
libnet-dev:${DEBIAN_ARCH} \
|
||||||
libprotobuf-c-dev:${DEBIAN_ARCH} \
|
libprotobuf-c-dev:${DEBIAN_ARCH} \
|
||||||
libcap-dev:${DEBIAN_ARCH} \
|
libcap-dev:${DEBIAN_ARCH} \
|
||||||
|
@ -36,6 +36,7 @@ dnf install -y \
|
|||||||
e2fsprogs \
|
e2fsprogs \
|
||||||
rubygem-asciidoctor \
|
rubygem-asciidoctor \
|
||||||
libdrm-devel \
|
libdrm-devel \
|
||||||
|
libuuid-devel \
|
||||||
kmod
|
kmod
|
||||||
|
|
||||||
# /tmp is no longer 755 in the rawhide container image and breaks CI - fix it
|
# /tmp is no longer 755 in the rawhide container image and breaks CI - fix it
|
||||||
|
@ -4,7 +4,7 @@ set -x -e
|
|||||||
CI_PKGS=(protobuf-c-compiler libprotobuf-c-dev libaio-dev libgnutls28-dev
|
CI_PKGS=(protobuf-c-compiler libprotobuf-c-dev libaio-dev libgnutls28-dev
|
||||||
libgnutls30 libprotobuf-dev protobuf-compiler libcap-dev
|
libgnutls30 libprotobuf-dev protobuf-compiler libcap-dev
|
||||||
libnl-3-dev gdb bash libnet-dev util-linux asciidoctor
|
libnl-3-dev gdb bash libnet-dev util-linux asciidoctor
|
||||||
libnl-route-3-dev time libbsd-dev python3-yaml
|
libnl-route-3-dev time libbsd-dev python3-yaml uuid-dev
|
||||||
libperl-dev pkg-config python3-protobuf python3-pip
|
libperl-dev pkg-config python3-protobuf python3-pip
|
||||||
python3-importlib-metadata python3-junit.xml libdrm-dev)
|
python3-importlib-metadata python3-junit.xml libdrm-dev)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ setup() {
|
|||||||
ssh default sudo dnf install -y gcc git gnutls-devel nftables-devel libaio-devel \
|
ssh default sudo dnf install -y gcc git gnutls-devel nftables-devel libaio-devel \
|
||||||
libasan libcap-devel libnet-devel libnl3-devel libbsd-devel make protobuf-c-devel \
|
libasan libcap-devel libnet-devel libnl3-devel libbsd-devel make protobuf-c-devel \
|
||||||
protobuf-devel python3-protobuf python3-importlib-metadata python3-junit_xml \
|
protobuf-devel python3-protobuf python3-importlib-metadata python3-junit_xml \
|
||||||
rubygem-asciidoctor iptables libselinux-devel libbpf-devel python3-yaml
|
rubygem-asciidoctor iptables libselinux-devel libbpf-devel python3-yaml libuuid-devel
|
||||||
# Disable sssd to avoid zdtm test failures in pty04 due to sssd socket
|
# Disable sssd to avoid zdtm test failures in pty04 due to sssd socket
|
||||||
ssh default sudo systemctl mask sssd
|
ssh default sudo systemctl mask sssd
|
||||||
ssh default cat /proc/cmdline
|
ssh default cat /proc/cmdline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user