2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 18:07:57 +00:00
criu/include/image.h

137 lines
3.9 KiB
C
Raw Normal View History

#ifndef __CR_IMAGE_H__
#define __CR_IMAGE_H__
#include "types.h"
#include "compiler.h"
/*
* Basic multi-file images
*/
#define CRTOOLS_IMAGES_V1 1
/*
* Raw images are images in which data is stored in some
* non-crtool format (ip tool dumps, tarballs, etc.)
*/
#define RAW_IMAGE_MAGIC 0x0
/*
* The magic-s below correspond to coordinates
* of various Russian towns in the NNNNEEEE form.
*/
#define INVENTORY_MAGIC 0x58313116 /* Veliky Novgorod */
#define PSTREE_MAGIC 0x50273030 /* Kyiv */
#define FDINFO_MAGIC 0x56213732 /* Dmitrov */
#define PAGES_MAGIC 0x56084025 /* Vladimir */
#define SHMEM_PAGES_MAGIC PAGES_MAGIC
#define CORE_MAGIC 0x55053847 /* Kolomna */
#define VMAS_MAGIC 0x54123737 /* Tula */
#define PIPES_MAGIC 0x56513555 /* Tver */
#define PIPES_DATA_MAGIC 0x56453709 /* Dubna */
#define FIFO_MAGIC 0x58364939 /* Kirov */
#define FIFO_DATA_MAGIC 0x59333054 /* Tosno */
#define SIGACT_MAGIC 0x55344201 /* Murom */
#define UNIXSK_MAGIC 0x54373943 /* Ryazan */
#define INETSK_MAGIC 0x56443851 /* Pereslavl */
#define PACKETSK_MAGIC 0x60454618 /* Veliky Ustyug */
#define ITIMERS_MAGIC 0x57464056 /* Kostroma */
#define SK_QUEUES_MAGIC 0x56264026 /* Suzdal */
#define UTSNS_MAGIC 0x54473203 /* Smolensk */
#define CREDS_MAGIC 0x54023547 /* Kozelsk */
#define IPCNS_VAR_MAGIC 0x53115007 /* Samara */
#define IPCNS_SHM_MAGIC 0x46283044 /* Odessa */
#define IPCNS_MSG_MAGIC 0x55453737 /* Moscow */
#define IPCNS_SEM_MAGIC 0x59573019 /* St. Petersburg */
#define REG_FILES_MAGIC 0x50363636 /* Belgorod */
#define FS_MAGIC 0x51403912 /* Voronezh */
#define MM_MAGIC 0x57492820 /* Pskov */
#define REMAP_FPATH_MAGIC 0x59133954 /* Vologda */
#define GHOST_FILE_MAGIC 0x52583605 /* Oryol */
#define TCP_STREAM_MAGIC 0x51465506 /* Orenburg */
#define EVENTFD_MAGIC 0x44523722 /* Anapa */
#define EVENTPOLL_MAGIC 0x45023858 /* Krasnodar */
#define EVENTPOLL_TFD_MAGIC 0x44433746 /* Novorossiysk */
#define SIGNALFD_MAGIC 0x57323820 /* Uglich */
#define INOTIFY_MAGIC 0x48424431 /* Volgograd */
#define INOTIFY_WD_MAGIC 0x54562009 /* Svetlogorsk (Rauschen) */
#define MOUNTPOINTS_MAGIC 0x55563928 /* Petushki */
#define NETDEV_MAGIC 0x57373951 /* Yaroslavl */
tty: Add checkpoint/restore for unix terminals v6 Usually the PTYs represent a pair of links -- master peer and slave peer. Master peer must be opened before slave. Internally, when kernel creates master peer it also generates a slave interface in a form of /dev/pts/N, where N is that named pty "index". Master/slave connection unambiguously identified by this index. Still, one master can carry multiple slaves -- for example a user opens one master via /dev/ptmx and appropriate /dev/pts/N in sequence. The result will be the following master `- slave 1 `- slave 2 both slave will have same master index but different file descriptors. Still inside the kernel pty parameters are same for both slaves. Thus only one slave parameters should be restored, there is no need to carry all parameters for every slave peer we've found. Not yet addressed problems: - At moment of restore the master peer might be already closed for any reason so to resolve such problem we need to open a fake master peer with proper index and hook a slave on it, then we close master peer. - Need to figure out how to deal with ttys which have some data in buffers not yet flushed, at moment this data will be simply lost during c/r - Need to restore control terminals - Need to fetch tty flags such as exclusive/packet-mode, this can't be done without kernel patching [ avagin@: - ideas on contol terminals restore - overall code redesign and simplification ] v4: - drop redundant pid from dump_chrdev - make sure optional fown is passed on regular ptys - add a comments about zeroifying termios - get rid of redundant empty line in files.c v5 (by avagin@): - complete rework of tty image format, now we have two files -- tty.img and tty-info.img. The idea behind to reduce data being stored. v6 (by xemul@): - packet mode should be set to true in image, until properly fetched from the kernel - verify image data on retrieval Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> CC: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-12 20:00:54 +04:00
#define TTY_MAGIC 0x59433025 /* Pushkin */
#define TTY_INFO_MAGIC 0x59453036 /* Kolpino */
#define IFADDR_MAGIC RAW_IMAGE_MAGIC
#define ROUTE_MAGIC RAW_IMAGE_MAGIC
#define TMPFS_MAGIC RAW_IMAGE_MAGIC
#define PAGE_IMAGE_SIZE 4096
#define PAGE_RSS 1
#define PAGE_ANON 2
/*
* Top bit set in the tgt id means we've remapped
* to a ghost file.
*/
#define REMAP_GHOST (1 << 31)
#define USK_EXTERN (1 << 0)
#define VMA_AREA_NONE (0 << 0)
#define VMA_AREA_REGULAR (1 << 0) /* Dumpable area */
#define VMA_AREA_STACK (1 << 1)
#define VMA_AREA_VSYSCALL (1 << 2)
#define VMA_AREA_VDSO (1 << 3)
#define VMA_FORCE_READ (1 << 4) /* VMA changed to be readable */
#define VMA_AREA_HEAP (1 << 5)
#define VMA_FILE_PRIVATE (1 << 6)
#define VMA_FILE_SHARED (1 << 7)
#define VMA_ANON_SHARED (1 << 8)
#define VMA_ANON_PRIVATE (1 << 9)
#define VMA_AREA_SYSVIPC (1 << 10)
#define VMA_AREA_SOCKET (1 << 11)
#define vma_premmaped_start(vma) ((vma)->shmid)
#define vma_entry_is(vma, s) (((vma)->status & (s)) == (s))
#define vma_entry_len(vma) ((vma)->end - (vma)->start)
struct page_entry {
u64 va;
u8 data[PAGE_IMAGE_SIZE];
} __packed;
#define CR_CAP_SIZE 2
#ifdef CONFIG_X86_64
#define GDT_ENTRY_TLS_ENTRIES 3
#define TASK_COMM_LEN 16
#define TASK_PF_USED_MATH 0x00002000
#ifdef CONFIG_X86_64
# define AT_VECTOR_SIZE 44
#else
# define AT_VECTOR_SIZE 22 /* Not needed at moment */
#endif
#define TASK_ALIVE 0x1
#define TASK_DEAD 0x2
#define TASK_STOPPED 0x3 /* FIXME - implement */
#define TASK_HELPER 0x4
#endif /* CONFIG_X86_64 */
/*
* There are always 4 magic bytes at the
* beginning of the every file.
*/
#define MAGIC_OFFSET (sizeof(u32))
#define GET_FILE_OFF(s, m) (offsetof(s,m) + MAGIC_OFFSET)
#define GET_FILE_OFF_AFTER(s) (sizeof(s) + MAGIC_OFFSET)
#endif /* CR_IMAGE_H */