Commit 17b0a47b authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

image: Move image descriptors to own files

Move image object descriptors to own image-desc
file(s). This allow to reuse the code in other tools.
I had to move show declarations to cr-show.h as well.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 22571627
...@@ -3,6 +3,7 @@ obj-y += mem.o ...@@ -3,6 +3,7 @@ obj-y += mem.o
obj-y += cr-restore.o obj-y += cr-restore.o
obj-y += crtools.o obj-y += crtools.o
obj-y += image.o obj-y += image.o
obj-y += image-desc.o
obj-y += net.o obj-y += net.o
obj-y += proc_parse.o obj-y += proc_parse.o
obj-y += cr-dump.o obj-y += cr-dump.o
......
#include <stdlib.h>
#include "image-desc.h"
#include "cr-show.h"
#include "magic.h"
/*
* The cr fd set is the set of files where the information
* about dumped processes is stored. Each file carries some
* small portion of info about the whole picture, see below
* for more details.
*/
#define FD_ENTRY(_name, _fmt, _show) \
[CR_FD_##_name] = { \
.fmt = _fmt ".img", \
.magic = _name##_MAGIC, \
.show = _show, \
}
struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
FD_ENTRY(INVENTORY, "inventory", show_inventory),
FD_ENTRY(FDINFO, "fdinfo-%d", show_files),
FD_ENTRY(PAGEMAP, "pagemap-%ld", show_pagemap),
FD_ENTRY(SHMEM_PAGEMAP, "pagemap-shmem-%ld", show_pagemap),
FD_ENTRY(REG_FILES, "reg-files", show_reg_files),
FD_ENTRY(NS_FILES, "ns-files", show_ns_files),
FD_ENTRY(EVENTFD, "eventfd", show_eventfds),
FD_ENTRY(EVENTPOLL, "eventpoll", show_eventpoll),
FD_ENTRY(EVENTPOLL_TFD, "eventpoll-tfd", show_eventpoll_tfd),
FD_ENTRY(SIGNALFD, "signalfd", show_signalfd),
FD_ENTRY(INOTIFY, "inotify", show_inotify),
FD_ENTRY(INOTIFY_WD, "inotify-wd", show_inotify_wd),
FD_ENTRY(FANOTIFY, "fanotify", show_fanotify),
FD_ENTRY(FANOTIFY_MARK, "fanotify-mark", show_fanotify_mark),
FD_ENTRY(CORE, "core-%d", show_core),
FD_ENTRY(IDS, "ids-%d", show_ids),
FD_ENTRY(MM, "mm-%d", show_mm),
FD_ENTRY(VMAS, "vmas-%d", show_vmas),
FD_ENTRY(PIPES, "pipes", show_pipes),
FD_ENTRY(PIPES_DATA, "pipes-data", show_pipes_data),
FD_ENTRY(FIFO, "fifo", show_fifo),
FD_ENTRY(FIFO_DATA, "fifo-data", show_fifo_data),
FD_ENTRY(PSTREE, "pstree", show_pstree),
FD_ENTRY(SIGACT, "sigacts-%d", show_sigacts),
FD_ENTRY(UNIXSK, "unixsk", show_unixsk),
FD_ENTRY(INETSK, "inetsk", show_inetsk),
FD_ENTRY(PACKETSK, "packetsk", show_packetsk),
FD_ENTRY(NETLINKSK, "netlinksk", show_netlinksk),
FD_ENTRY(SK_QUEUES, "sk-queues", show_sk_queues),
FD_ENTRY(ITIMERS, "itimers-%d", show_itimers),
FD_ENTRY(CREDS, "creds-%d", show_creds),
FD_ENTRY(UTSNS, "utsns-%d", show_utsns),
FD_ENTRY(IPCNS_VAR, "ipcns-var-%d", show_ipc_var),
FD_ENTRY(IPCNS_SHM, "ipcns-shm-%d", show_ipc_shm),
FD_ENTRY(IPCNS_MSG, "ipcns-msg-%d", show_ipc_msg),
FD_ENTRY(IPCNS_SEM, "ipcns-sem-%d", show_ipc_sem),
FD_ENTRY(FS, "fs-%d", show_fs),
FD_ENTRY(REMAP_FPATH, "remap-fpath", show_remap_files),
FD_ENTRY(GHOST_FILE, "ghost-file-%x", show_ghost_file),
FD_ENTRY(TCP_STREAM, "tcp-stream-%x", show_tcp_stream),
FD_ENTRY(MOUNTPOINTS, "mountpoints-%d", show_mountpoints),
FD_ENTRY(NETDEV, "netdev-%d", show_netdevices),
FD_ENTRY(IFADDR, "ifaddr-%d", show_raw_image),
FD_ENTRY(ROUTE, "route-%d", show_raw_image),
FD_ENTRY(TMPFS, "tmpfs-%d.tar.gz", show_raw_image),
FD_ENTRY(TTY, "tty", show_tty),
FD_ENTRY(TTY_INFO, "tty-info", show_tty_info),
FD_ENTRY(FILE_LOCKS, "filelocks-%d", show_file_locks),
FD_ENTRY(RLIMIT, "rlimit-%d", show_rlimit),
FD_ENTRY(PAGES, "pages-%u", NULL),
FD_ENTRY(PAGES_OLD, "pages-%d", NULL),
FD_ENTRY(SHM_PAGES_OLD, "pages-shmem-%ld", NULL),
FD_ENTRY(SIGNAL, "signal-s-%d", show_siginfo), /* shared signals */
FD_ENTRY(PSIGNAL, "signal-p-%d", show_siginfo), /* private signals */
[CR_FD_STATS] = {
.fmt = "stats-%s",
.magic = STATS_MAGIC,
.show = show_stats,
},
};
...@@ -95,89 +95,12 @@ void kill_inventory(void) ...@@ -95,89 +95,12 @@ void kill_inventory(void)
fdset_template[CR_FD_INVENTORY].fmt, 0); fdset_template[CR_FD_INVENTORY].fmt, 0);
} }
static void show_inventory(int fd) void show_inventory(int fd)
{ {
pb_show_vertical(fd, PB_INVENTORY); pb_show_vertical(fd, PB_INVENTORY);
} }
/* void show_raw_image(int fd) {};
* The cr fd set is the set of files where the information
* about dumped processes is stored. Each file carries some
* small portion of info about the whole picture, see below
* for more details.
*/
#define FD_ENTRY(_name, _fmt, _show) \
[CR_FD_##_name] = { \
.fmt = _fmt ".img", \
.magic = _name##_MAGIC, \
.show = _show, \
}
static void show_raw_image(int fd) {};
struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
FD_ENTRY(INVENTORY, "inventory", show_inventory),
FD_ENTRY(FDINFO, "fdinfo-%d", show_files),
FD_ENTRY(PAGEMAP, "pagemap-%ld", show_pagemap),
FD_ENTRY(SHMEM_PAGEMAP, "pagemap-shmem-%ld", show_pagemap),
FD_ENTRY(REG_FILES, "reg-files", show_reg_files),
FD_ENTRY(NS_FILES, "ns-files", show_ns_files),
FD_ENTRY(EVENTFD, "eventfd", show_eventfds),
FD_ENTRY(EVENTPOLL, "eventpoll", show_eventpoll),
FD_ENTRY(EVENTPOLL_TFD, "eventpoll-tfd", show_eventpoll_tfd),
FD_ENTRY(SIGNALFD, "signalfd", show_signalfd),
FD_ENTRY(INOTIFY, "inotify", show_inotify),
FD_ENTRY(INOTIFY_WD, "inotify-wd", show_inotify_wd),
FD_ENTRY(FANOTIFY, "fanotify", show_fanotify),
FD_ENTRY(FANOTIFY_MARK, "fanotify-mark", show_fanotify_mark),
FD_ENTRY(CORE, "core-%d", show_core),
FD_ENTRY(IDS, "ids-%d", show_ids),
FD_ENTRY(MM, "mm-%d", show_mm),
FD_ENTRY(VMAS, "vmas-%d", show_vmas),
FD_ENTRY(PIPES, "pipes", show_pipes),
FD_ENTRY(PIPES_DATA, "pipes-data", show_pipes_data),
FD_ENTRY(FIFO, "fifo", show_fifo),
FD_ENTRY(FIFO_DATA, "fifo-data", show_fifo_data),
FD_ENTRY(PSTREE, "pstree", show_pstree),
FD_ENTRY(SIGACT, "sigacts-%d", show_sigacts),
FD_ENTRY(UNIXSK, "unixsk", show_unixsk),
FD_ENTRY(INETSK, "inetsk", show_inetsk),
FD_ENTRY(PACKETSK, "packetsk", show_packetsk),
FD_ENTRY(NETLINKSK, "netlinksk", show_netlinksk),
FD_ENTRY(SK_QUEUES, "sk-queues", show_sk_queues),
FD_ENTRY(ITIMERS, "itimers-%d", show_itimers),
FD_ENTRY(CREDS, "creds-%d", show_creds),
FD_ENTRY(UTSNS, "utsns-%d", show_utsns),
FD_ENTRY(IPCNS_VAR, "ipcns-var-%d", show_ipc_var),
FD_ENTRY(IPCNS_SHM, "ipcns-shm-%d", show_ipc_shm),
FD_ENTRY(IPCNS_MSG, "ipcns-msg-%d", show_ipc_msg),
FD_ENTRY(IPCNS_SEM, "ipcns-sem-%d", show_ipc_sem),
FD_ENTRY(FS, "fs-%d", show_fs),
FD_ENTRY(REMAP_FPATH, "remap-fpath", show_remap_files),
FD_ENTRY(GHOST_FILE, "ghost-file-%x", show_ghost_file),
FD_ENTRY(TCP_STREAM, "tcp-stream-%x", show_tcp_stream),
FD_ENTRY(MOUNTPOINTS, "mountpoints-%d", show_mountpoints),
FD_ENTRY(NETDEV, "netdev-%d", show_netdevices),
FD_ENTRY(IFADDR, "ifaddr-%d", show_raw_image),
FD_ENTRY(ROUTE, "route-%d", show_raw_image),
FD_ENTRY(TMPFS, "tmpfs-%d.tar.gz", show_raw_image),
FD_ENTRY(TTY, "tty", show_tty),
FD_ENTRY(TTY_INFO, "tty-info", show_tty_info),
FD_ENTRY(FILE_LOCKS, "filelocks-%d", show_file_locks),
FD_ENTRY(RLIMIT, "rlimit-%d", show_rlimit),
FD_ENTRY(PAGES, "pages-%u", NULL),
FD_ENTRY(PAGES_OLD, "pages-%d", NULL),
FD_ENTRY(SHM_PAGES_OLD, "pages-shmem-%ld", NULL),
FD_ENTRY(SIGNAL, "signal-s-%d", show_siginfo), /* shared signals */
FD_ENTRY(PSIGNAL, "signal-p-%d", show_siginfo), /* private signals */
[CR_FD_STATS] = {
.fmt = "stats-%s",
.magic = STATS_MAGIC,
.show = show_stats,
},
};
static struct cr_fdset *alloc_cr_fdset(int nr) static struct cr_fdset *alloc_cr_fdset(int nr)
{ {
......
#ifndef __CR_SHOW_H__
#define __CR_SHOW_H__
extern void show_files(int fd);
extern void show_pagemap(int fd);
extern void show_reg_files(int fd);
extern void show_ns_files(int fd);
extern void show_core(int fd);
extern void show_ids(int fd);
extern void show_mm(int fd);
extern void show_vmas(int fd);
extern void show_pipes(int fd);
extern void show_pipes_data(int fd);
extern void show_fifo(int fd);
extern void show_fifo_data(int fd);
extern void show_pstree(int fd);
extern void show_sigacts(int fd);
extern void show_siginfo(int fd);
extern void show_itimers(int fd);
extern void show_creds(int fd);
extern void show_fs(int fd);
extern void show_remap_files(int fd);
extern void show_ghost_file(int fd);
extern void show_fown_cont(void *p);
extern void show_eventfds(int fd);
extern void show_tty(int fd);
extern void show_tty_info(int fd);
extern void show_file_locks(int fd);
extern void show_rlimit(int fd);
extern void show_inventory(int fd);
extern void show_raw_image(int fd);
extern void show_eventpoll(int fd);
extern void show_eventpoll_tfd(int fd);
extern void show_signalfd(int fd);
extern void show_inotify(int fd);
extern void show_inotify_wd(int fd);
extern void show_fanotify(int fd);
extern void show_fanotify_mark(int fd);
extern void show_unixsk(int fd);
extern void show_inetsk(int fd);
extern void show_packetsk(int fd);
extern void show_netlinksk(int fd);
extern void show_sk_queues(int fd);
extern void show_utsns(int fd);
extern void show_ipc_var(int fd);
extern void show_ipc_shm(int fd);
extern void show_ipc_msg(int fd);
extern void show_ipc_sem(int fd);
extern void show_tcp_stream(int fd);
extern void show_mountpoints(int fd);
extern void show_netdevices(int fd);
extern void show_stats(int fd);
#endif /* __CR_SHOW_H__ */
...@@ -9,91 +9,12 @@ ...@@ -9,91 +9,12 @@
#include "util.h" #include "util.h"
#include "image.h" #include "image.h"
#include "lock.h" #include "lock.h"
#include "cr-show.h"
#include "protobuf/vma.pb-c.h" #include "protobuf/vma.pb-c.h"
#define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) #define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
enum {
CR_FD_INVENTORY,
CR_FD_STATS,
/*
* Task entries
*/
_CR_FD_TASK_FROM,
CR_FD_FILE_LOCKS,
CR_FD_CORE,
CR_FD_IDS,
CR_FD_MM,
CR_FD_VMAS,
CR_FD_SIGACT,
CR_FD_ITIMERS,
CR_FD_CREDS,
CR_FD_FS,
CR_FD_RLIMIT,
CR_FD_SIGNAL,
_CR_FD_TASK_TO,
CR_FD_PAGEMAP,
/*
* NS entries
*/
_CR_FD_NS_FROM,
CR_FD_UTSNS,
CR_FD_IPCNS_VAR,
CR_FD_IPCNS_SHM,
CR_FD_IPCNS_MSG,
CR_FD_IPCNS_SEM,
CR_FD_MOUNTPOINTS,
CR_FD_NETDEV,
CR_FD_IFADDR,
CR_FD_ROUTE,
_CR_FD_NS_TO,
CR_FD_PSTREE,
CR_FD_SHMEM_PAGEMAP,
CR_FD_GHOST_FILE,
CR_FD_TCP_STREAM,
CR_FD_FDINFO,
_CR_FD_GLOB_FROM,
CR_FD_SK_QUEUES,
CR_FD_REG_FILES,
CR_FD_NS_FILES,
CR_FD_INETSK,
CR_FD_UNIXSK,
CR_FD_PACKETSK,
CR_FD_NETLINKSK,
CR_FD_PIPES,
CR_FD_PIPES_DATA,
CR_FD_FIFO,
CR_FD_FIFO_DATA,
CR_FD_TTY,
CR_FD_TTY_INFO,
CR_FD_REMAP_FPATH,
CR_FD_EVENTFD,
CR_FD_EVENTPOLL,
CR_FD_EVENTPOLL_TFD,
CR_FD_SIGNALFD,
CR_FD_INOTIFY,
CR_FD_INOTIFY_WD,
CR_FD_FANOTIFY,
CR_FD_FANOTIFY_MARK,
_CR_FD_GLOB_TO,
CR_FD_TMPFS,
CR_FD_PAGES,
CR_FD_PSIGNAL,
CR_FD_PAGES_OLD,
CR_FD_SHM_PAGES_OLD,
CR_FD_MAX
};
struct script { struct script {
struct list_head node; struct list_head node;
char *path; char *path;
...@@ -152,40 +73,6 @@ extern int close_service_fd(enum sfd_type type); ...@@ -152,40 +73,6 @@ extern int close_service_fd(enum sfd_type type);
extern bool is_service_fd(int fd, enum sfd_type type); extern bool is_service_fd(int fd, enum sfd_type type);
extern bool is_any_service_fd(int fd); extern bool is_any_service_fd(int fd);
/* file descriptors template */
struct cr_fd_desc_tmpl {
const char *fmt; /* format for the name */
u32 magic; /* magic in the header */
void (*show)(int fd);
};
void show_files(int fd);
void show_pagemap(int fd);
void show_reg_files(int fd);
void show_ns_files(int fd);
void show_core(int fd);
void show_ids(int fd);
void show_mm(int fd);
void show_vmas(int fd);
void show_pipes(int fd);
void show_pipes_data(int fd);
void show_fifo(int fd);
void show_fifo_data(int fd);
void show_pstree(int fd);
void show_sigacts(int fd);
void show_siginfo(int fd);
void show_itimers(int fd);
void show_creds(int fd);
void show_fs(int fd);
void show_remap_files(int fd);
void show_ghost_file(int fd);
void show_fown_cont(void *p);
void show_eventfds(int fd);
void show_tty(int fd);
void show_tty_info(int fd);
void show_file_locks(int fd);
void show_rlimit(int fd);
int check_img_inventory(void); int check_img_inventory(void);
int write_img_inventory(void); int write_img_inventory(void);
void kill_inventory(void); void kill_inventory(void);
......
#ifndef __CR_IMAGE_DESC_H__
#define __CR_IMAGE_DESC_H__
#include "asm/int.h"
enum {
CR_FD_INVENTORY,
CR_FD_STATS,
/*
* Task entries
*/
_CR_FD_TASK_FROM,
CR_FD_FILE_LOCKS,
CR_FD_CORE,
CR_FD_IDS,
CR_FD_MM,
CR_FD_VMAS,
CR_FD_SIGACT,
CR_FD_ITIMERS,
CR_FD_CREDS,
CR_FD_FS,
CR_FD_RLIMIT,
CR_FD_SIGNAL,
_CR_FD_TASK_TO,
CR_FD_PAGEMAP,
/*
* NS entries
*/
_CR_FD_NS_FROM,
CR_FD_UTSNS,
CR_FD_IPCNS_VAR,
CR_FD_IPCNS_SHM,
CR_FD_IPCNS_MSG,
CR_FD_IPCNS_SEM,
CR_FD_MOUNTPOINTS,
CR_FD_NETDEV,
CR_FD_IFADDR,
CR_FD_ROUTE,
_CR_FD_NS_TO,
CR_FD_PSTREE,
CR_FD_SHMEM_PAGEMAP,
CR_FD_GHOST_FILE,
CR_FD_TCP_STREAM,
CR_FD_FDINFO,
_CR_FD_GLOB_FROM,
CR_FD_SK_QUEUES,
CR_FD_REG_FILES,
CR_FD_NS_FILES,
CR_FD_INETSK,
CR_FD_UNIXSK,
CR_FD_PACKETSK,
CR_FD_NETLINKSK,
CR_FD_PIPES,
CR_FD_PIPES_DATA,
CR_FD_FIFO,
CR_FD_FIFO_DATA,
CR_FD_TTY,
CR_FD_TTY_INFO,
CR_FD_REMAP_FPATH,
CR_FD_EVENTFD,
CR_FD_EVENTPOLL,
CR_FD_EVENTPOLL_TFD,
CR_FD_SIGNALFD,
CR_FD_INOTIFY,
CR_FD_INOTIFY_WD,
CR_FD_FANOTIFY,
CR_FD_FANOTIFY_MARK,
_CR_FD_GLOB_TO,
CR_FD_TMPFS,
CR_FD_PAGES,
CR_FD_PSIGNAL,
CR_FD_PAGES_OLD,
CR_FD_SHM_PAGES_OLD,
CR_FD_MAX
};
/* file descriptors template */
struct cr_fd_desc_tmpl {
const char *fmt; /* format for the name */
u32 magic; /* magic in the header */
void (*show)(int fd);
};
#endif /* __CR_IMAGE_DESC_H__ */
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "compiler.h" #include "compiler.h"
#include "image-desc.h"
#include "magic.h" #include "magic.h"
#define PAGE_IMAGE_SIZE 4096 #define PAGE_IMAGE_SIZE 4096
......
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