[CRIU] [PATCH v2 20/36] proto: Add ns_hookup_entry description
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Feb 13 01:25:09 PST 2017
On 08.02.2017 22:56, Andrei Vagin wrote:
> On Fri, Feb 03, 2017 at 07:14:34PM +0300, Kirill Tkhai wrote:
>> New image format, generic for all namespaces.
>> Currently, it's for pid, net and user ns.
>>
>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>> ---
>> criu/image-desc.c | 1 +
>> criu/include/image-desc.h | 1 +
>> criu/include/magic.h | 1 +
>> criu/include/protobuf-desc.h | 1 +
>> criu/protobuf-desc.c | 1 +
>> images/ns.proto | 18 ++++++++++++++++++
>> lib/py/images/images.py | 1 +
>> 7 files changed, 24 insertions(+)
>>
>> diff --git a/criu/image-desc.c b/criu/image-desc.c
>> index bac7ca276..76419ebc8 100644
>> --- a/criu/image-desc.c
>> +++ b/criu/image-desc.c
>> @@ -99,6 +99,7 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = {
>> FD_ENTRY(USERNS, "userns-%d"),
>> FD_ENTRY(NETNF_CT, "netns-ct-%d"),
>> FD_ENTRY(NETNF_EXP, "netns-exp-%d"),
>> + FD_ENTRY(NS_HOOKUP, "ns-hookup"),
>>
>> [CR_FD_STATS] = {
>> .fmt = "stats-%s",
>> diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h
>> index 09d187d22..16d0183ff 100644
>> --- a/criu/include/image-desc.h
>> +++ b/criu/include/image-desc.h
>> @@ -107,6 +107,7 @@ enum {
>> CR_FD_EVENTPOLL_TFD,
>>
>> CR_FD_AUTOFS,
>> + CR_FD_NS_HOOKUP,
>>
>> CR_FD_MAX
>> };
>> diff --git a/criu/include/magic.h b/criu/include/magic.h
>> index deb54b1d0..34e766fa3 100644
>> --- a/criu/include/magic.h
>> +++ b/criu/include/magic.h
>> @@ -93,6 +93,7 @@
>> #define SECCOMP_MAGIC 0x64413049 /* Kostomuksha */
>> #define BINFMT_MISC_MAGIC 0x67343323 /* Apatity */
>> #define AUTOFS_MAGIC 0x49353943 /* Sochi */
>> +#define NS_HOOKUP_MAGIC 0x55523343 /* Dnepropetrovsk */
>>
>> #define IFADDR_MAGIC RAW_IMAGE_MAGIC
>> #define ROUTE_MAGIC RAW_IMAGE_MAGIC
>> diff --git a/criu/include/protobuf-desc.h b/criu/include/protobuf-desc.h
>> index 6c76b494f..e45700b3d 100644
>> --- a/criu/include/protobuf-desc.h
>> +++ b/criu/include/protobuf-desc.h
>> @@ -70,6 +70,7 @@ enum {
>> PB_SK_QUEUES,
>> PB_IPCNS_MSG,
>> PB_IPCNS_MSG_ENT,
>> + PB_NS_HOOKUP,
>>
>> PB_MAX,
>> };
>> diff --git a/criu/protobuf-desc.c b/criu/protobuf-desc.c
>> index 05f3eb386..f3361ff5f 100644
>> --- a/criu/protobuf-desc.c
>> +++ b/criu/protobuf-desc.c
>> @@ -97,6 +97,7 @@ void cr_pb_init(void)
>> CR_PB_DESC(REMAP_FPATH, RemapFilePath, remap_file_path);
>> CR_PB_DESC(NETDEV, NetDevice, net_device);
>> CR_PB_MDESC_INIT(cr_pb_descs[PB_PAGEMAP_HEAD], PagemapHead, pagemap_head);
>> + CR_PB_DESC(NS_HOOKUP, NsHookup, ns_hookup);
>>
>> #include "protobuf-desc-gen.h"
>> }
>> diff --git a/images/ns.proto b/images/ns.proto
>> index 7f7b09094..0f6a0b89d 100644
>> --- a/images/ns.proto
>> +++ b/images/ns.proto
>> @@ -17,3 +17,21 @@ message userns_entry {
>> repeated uid_gid_extent uid_map = 1;
>> repeated uid_gid_extent gid_map = 2;
>> }
>> +
>> +message pidns_entry {
>> + required uint32 userns_id = 1;
>> +}
>> +
>> +message netns_entry2 {
>> + required uint32 userns_id = 1;
>> +}
>> +
>> +message ns_hookup_entry {
>> + required uint32 id = 1;
>> + required uint32 ns_cflag = 2;
>> + optional uint32 parent_id = 3;
>
> I think we need to move parent_id to pid_ext, because it will be used
> only for pid namespaces.
It's used for user_ns too, but anyway, we should.
> And I think userns_id has to be here, because it is required for all
> namespaces. In this case we will not need to create netns_entry2.
>
> What do you think about this?
Yeah, sounds good.
>> +
>> + optional userns_entry user_ext = 4;
>> + optional pidns_entry pid_ext = 5;
>> + optional netns_entry2 net_ext = 6;
>> +}
>> diff --git a/lib/py/images/images.py b/lib/py/images/images.py
>> index c593a3b85..69f813c40 100644
>> --- a/lib/py/images/images.py
>> +++ b/lib/py/images/images.py
>> @@ -454,6 +454,7 @@ handlers = {
>> 'USERNS' : entry_handler(userns_entry),
>> 'SECCOMP' : entry_handler(seccomp_entry),
>> 'AUTOFS' : entry_handler(autofs_entry),
>> + 'NS_HOOKUP' : entry_handler(ns_hookup_entry),
>> }
>>
>> def __rhandler(f):
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list