mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
uts: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is uniq for each namespace, so it's more convient, if image files are opened per namespace. Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
faf7b94868
commit
e63f8c20e9
@ -3,7 +3,7 @@
|
||||
|
||||
#include "crtools.h"
|
||||
|
||||
int dump_uts_ns(int ns_pid, struct cr_fdset *fdset);
|
||||
int dump_uts_ns(int ns_pid, int ns_id);
|
||||
int prepare_utsns(int pid);
|
||||
|
||||
extern struct ns_desc uts_ns_desc;
|
||||
|
@ -360,7 +360,7 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
|
||||
|
||||
if (ns_flags & CLONE_NEWUTS) {
|
||||
pr_info("Dump UTS namespace\n");
|
||||
ret = dump_uts_ns(ns_pid->real, fdset);
|
||||
ret = dump_uts_ns(ns_pid->real, ns_id);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
}
|
||||
|
17
uts_ns.c
17
uts_ns.c
@ -13,26 +13,33 @@
|
||||
#include "protobuf.h"
|
||||
#include "protobuf/utsns.pb-c.h"
|
||||
|
||||
int dump_uts_ns(int ns_pid, struct cr_fdset *fdset)
|
||||
int dump_uts_ns(int ns_pid, int ns_id)
|
||||
{
|
||||
int ret;
|
||||
int ret, img_fd;
|
||||
struct utsname ubuf;
|
||||
UtsnsEntry ue = UTSNS_ENTRY__INIT;
|
||||
|
||||
img_fd = open_image(CR_FD_UTSNS, O_DUMP, ns_id);
|
||||
if (img_fd < 0)
|
||||
return -1;
|
||||
|
||||
ret = switch_ns(ns_pid, &uts_ns_desc, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto err;
|
||||
|
||||
ret = uname(&ubuf);
|
||||
if (ret < 0) {
|
||||
pr_perror("Error calling uname");
|
||||
return ret;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ue.nodename = ubuf.nodename;
|
||||
ue.domainname = ubuf.domainname;
|
||||
|
||||
return pb_write_one(fdset_fd(fdset, CR_FD_UTSNS), &ue, PB_UTSNS);
|
||||
ret = pb_write_one(img_fd, &ue, PB_UTSNS);
|
||||
err:
|
||||
close(img_fd);
|
||||
return ret < 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
int prepare_utsns(int pid)
|
||||
|
Loading…
x
Reference in New Issue
Block a user