diff --git a/Makefile.crtools b/Makefile.crtools index aa3461165..9e648b58c 100644 --- a/Makefile.crtools +++ b/Makefile.crtools @@ -46,6 +46,7 @@ obj-y += page-pipe.o obj-y += page-xfer.o obj-y += page-read.o obj-y += kerndat.o +obj-y += stats.o ifneq ($(MAKECMDGOALS),clean) incdeps := y diff --git a/image.c b/image.c index ebbe55622..7d7cbf324 100644 --- a/image.c +++ b/image.c @@ -13,6 +13,7 @@ #include "mount.h" #include "net.h" #include "pstree.h" +#include "stats.h" #include "protobuf.h" #include "protobuf/inventory.pb-c.h" #include "protobuf/pagemap.pb-c.h" @@ -167,6 +168,12 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = { 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) diff --git a/include/crtools.h b/include/crtools.h index b0c885554..cd496e739 100644 --- a/include/crtools.h +++ b/include/crtools.h @@ -16,6 +16,7 @@ enum { CR_FD_INVENTORY, + CR_FD_STATS, /* * Task entries */ diff --git a/include/magic.h b/include/magic.h index 66a4b1c13..a53026559 100644 --- a/include/magic.h +++ b/include/magic.h @@ -21,6 +21,7 @@ #define INVENTORY_MAGIC 0x58313116 /* Veliky Novgorod */ #define PSTREE_MAGIC 0x50273030 /* Kyiv */ +#define STATS_MAGIC 0x57093306 /* Ostashkov */ #define FDINFO_MAGIC 0x56213732 /* Dmitrov */ #define PAGEMAP_MAGIC 0x56084025 /* Vladimir */ #define SHMEM_PAGEMAP_MAGIC PAGEMAP_MAGIC diff --git a/include/protobuf.h b/include/protobuf.h index 9bd666211..5b0ef7531 100644 --- a/include/protobuf.h +++ b/include/protobuf.h @@ -7,6 +7,7 @@ enum { PB_INVENTORY, + PB_STATS, PB_FDINFO, PB_CORE, PB_MM, diff --git a/include/stats.h b/include/stats.h new file mode 100644 index 000000000..0690bc1b9 --- /dev/null +++ b/include/stats.h @@ -0,0 +1,4 @@ +#ifndef __CR_STATS_H__ +#define __CR_STATS_H__ +void show_stats(int fd); +#endif diff --git a/protobuf.c b/protobuf.c index fba095318..a9823dda8 100644 --- a/protobuf.c +++ b/protobuf.c @@ -18,6 +18,7 @@ #include "protobuf.h" #include "protobuf/inventory.pb-c.h" +#include "protobuf/stats.pb-c.h" #include "protobuf/regfile.pb-c.h" #include "protobuf/eventfd.pb-c.h" #include "protobuf/eventpoll.pb-c.h" @@ -93,6 +94,7 @@ static struct cr_pb_message_desc cr_pb_descs[PB_MAX]; void cr_pb_init(void) { CR_PB_DESC(INVENTORY, Inventory, inventory); + CR_PB_DESC(STATS, Stats, stats); CR_PB_DESC(FDINFO, Fdinfo, fdinfo); CR_PB_DESC(REG_FILES, RegFile, reg_file); CR_PB_DESC(EVENTFD, EventfdFile, eventfd_file); diff --git a/protobuf/Makefile b/protobuf/Makefile index d9e578c16..94a965293 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -9,6 +9,7 @@ CFLAGS += -I$(obj)/ +proto-obj-y += stats.o proto-obj-y += core.o proto-obj-y += core-x86.o proto-obj-y += core-arm.o diff --git a/protobuf/stats.proto b/protobuf/stats.proto new file mode 100644 index 000000000..beacc34b3 --- /dev/null +++ b/protobuf/stats.proto @@ -0,0 +1,7 @@ +// This one contains statistics about dump/restore process +message dump_stats_entry { +} + +message stats_entry { + optional dump_stats_entry dump = 1; +} diff --git a/stats.c b/stats.c new file mode 100644 index 000000000..d7f42c5fc --- /dev/null +++ b/stats.c @@ -0,0 +1,8 @@ +#include +#include "protobuf.h" +#include "stats.h" + +void show_stats(int fd) +{ + pb_show_vertical(fd, PB_STATS); +}