Commit 1a609756 authored by Pavel Emelyanov's avatar Pavel Emelyanov

img: Save crtools process IDs in inventory

On restore we'll need to know whether the root task should be
cloned in new set of namespaces. It's natural to do it by
comparing root ids with some "other-world" IDs.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 15999f6b
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "sk-packet.h" #include "sk-packet.h"
#include "mount.h" #include "mount.h"
#include "net.h" #include "net.h"
#include "pstree.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/inventory.pb-c.h" #include "protobuf/inventory.pb-c.h"
...@@ -48,6 +49,7 @@ int write_img_inventory(void) ...@@ -48,6 +49,7 @@ int write_img_inventory(void)
{ {
int fd; int fd;
InventoryEntry he = INVENTORY_ENTRY__INIT; InventoryEntry he = INVENTORY_ENTRY__INIT;
struct pstree_item crt = { };
pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1); pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1);
...@@ -59,9 +61,16 @@ int write_img_inventory(void) ...@@ -59,9 +61,16 @@ int write_img_inventory(void)
he.fdinfo_per_id = true; he.fdinfo_per_id = true;
he.has_fdinfo_per_id = true; he.has_fdinfo_per_id = true;
crt.pid.real = getpid();
if (get_task_ids(&crt))
return -1;
he.root_ids = crt.ids;
if (pb_write_one(fd, &he, PB_INVENTORY) < 0) if (pb_write_one(fd, &he, PB_INVENTORY) < 0)
return -1; return -1;
xfree(crt.ids);
close(fd); close(fd);
return 0; return 0;
} }
......
PROTO_LIBRARY := protobuf-lib.o PROTO_LIBRARY := protobuf-lib.o
PROTO_FILES += core.proto
PROTO_FILES += inventory.proto PROTO_FILES += inventory.proto
PROTO_FILES += fdinfo.proto PROTO_FILES += fdinfo.proto
PROTO_FILES += fown.proto PROTO_FILES += fown.proto
...@@ -34,7 +35,6 @@ PROTO_FILES += ipc-sem.proto ...@@ -34,7 +35,6 @@ PROTO_FILES += ipc-sem.proto
PROTO_FILES += utsns.proto PROTO_FILES += utsns.proto
PROTO_FILES += creds.proto PROTO_FILES += creds.proto
PROTO_FILES += vma.proto PROTO_FILES += vma.proto
PROTO_FILES += core.proto
PROTO_FILES += netdev.proto PROTO_FILES += netdev.proto
PROTO_FILES += tty.proto PROTO_FILES += tty.proto
PROTO_FILES += file-lock.proto PROTO_FILES += file-lock.proto
......
import "core.proto";
message inventory_entry { message inventory_entry {
required uint32 img_version = 1; required uint32 img_version = 1;
optional bool fdinfo_per_id = 2; optional bool fdinfo_per_id = 2;
optional task_kobj_ids_entry root_ids = 3;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment