Commit ba4366d3 authored by Kinsbursky Stanislav's avatar Kinsbursky Stanislav Committed by Pavel Emelyanov

protobuf: use generic show function for ipc shared memory

Signed-off-by: 's avatarStanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 49ea3128
...@@ -297,15 +297,12 @@ static int dump_ipc_msg(int fd) ...@@ -297,15 +297,12 @@ static int dump_ipc_msg(int fd)
return info.msgpool; return info.msgpool;
} }
static void pr_ipc_shm(unsigned int loglevel, const IpcShmEntry *shm) static void pr_info_ipc_shm(const IpcShmEntry *shm)
{ {
pr_ipc_desc_entry(loglevel, shm->desc); pr_ipc_desc_entry(LOG_INFO, shm->desc);
print_on_level(loglevel, "size: %-10lu\n", shm->size); print_on_level(LOG_INFO, "size: %-10lu\n", shm->size);
} }
#define pr_info_ipc_shm(shm) pr_ipc_shm(LOG_INFO, shm)
#define pr_msg_ipc_shm(shm) pr_ipc_shm(LOG_MSG, shm)
static int ipc_sysctl_req(IpcVarEntry *e, int op) static int ipc_sysctl_req(IpcVarEntry *e, int op)
{ {
struct sysctl_req req[] = { struct sysctl_req req[] = {
...@@ -520,33 +517,21 @@ void show_ipc_msg(int fd, struct cr_options *o) ...@@ -520,33 +517,21 @@ void show_ipc_msg(int fd, struct cr_options *o)
pb_show_plain_payload(fd, ipc_msg_entry, ipc_msg_handler, o->show_pages_content); pb_show_plain_payload(fd, ipc_msg_entry, ipc_msg_handler, o->show_pages_content);
} }
static void show_ipc_shm_entries(int fd) static void ipc_shm_handler(int fd, void *obj, int show_pages_content)
{ {
pr_msg("\nShared memory segments:\n"); IpcShmEntry *e = obj;
while (1) {
int ret;
IpcShmEntry *shm;
ret = pb_read_eof(fd, &shm, ipc_shm_entry);
if (ret <= 0)
return;
pr_msg_ipc_shm(shm);
if (lseek(fd, round_up(shm->size, sizeof(u32)), SEEK_CUR) == (off_t) -1)
ret = -1;
ipc_shm_entry__free_unpacked(shm, NULL); if (show_pages_content) {
if (ret < 0) pr_msg("\n");
break; print_image_data(fd, round_up(e->size, sizeof(u64)));
} } else
lseek(fd, round_up(e->size, sizeof(u32)), SEEK_CUR);
} }
void show_ipc_shm(int fd, struct cr_options *o) void show_ipc_shm(int fd, struct cr_options *o)
{ {
pr_img_head(CR_FD_IPCNS); pb_show_plain_payload(fd, ipc_shm_entry, ipc_shm_handler,
show_ipc_shm_entries(fd); o->show_pages_content);
pr_img_tail(CR_FD_IPCNS);
} }
static void show_ipc_var_entry(int fd) static void show_ipc_var_entry(int fd)
......
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