remap: add remap_type field and use it

Maintain backwards compatibility for old images, but don't set the REMAP_GHOST
bit going forward, only use the remap_type field.

v2: * preserve remap_id in GHOST_REMAP case
    * protobuf field is remap_type enum not u32

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
restore: TASK_HELPERs live until RESTORE_FS stage

In order to use TASK_HELPERS to open files from dead processes, they should
persist until criu is done restoring the filesystem (i.e. until after
restore_fs is called). To accomplish this, we add a new stage called
CR_STATE_RESTORE_FS and require all helpers to wait until that stage is done
before exiting, then we wait() on the helpers after that is done.

This commit is in preparation for the remap_dead_pid commits.

v2: wait() on helpers after restore stage is over
v3: add CR_STATE_RESTORE_FS stage
v4: CR_STATE_RESTORE_FS waits for nr_tasks + nr_helpers, not nr_threads

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
remap: add a dead pid /proc remap

If a file like /proc/20/mountinfo is open, but 20 is a zombie (or doesn't exist
any more), we can't read this file at all, so a link remap won't work. Instead,
we add a new remap, called the dead process remap, which forks a TASK_HELPER as
that dead pid so that the restore task can open the new /proc/20/mountinfo
instead.

This commit also adds a new stage CR_STATE_RESTORE_SHARED. Since new
TASK_HELPERS are added when loading the shared resource images, we need to wait
to start forking tasks until after these resources are loaded.

v2: fix a mutex bug

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
test: add a test for remap_dead_pid

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>