mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 14:55:39 +00:00
show: UNIX sockets queue support
Based on xemul@ patches. Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org> Acked-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
committed by
Cyrill Gorcunov
parent
131f5a1d49
commit
e518c44c7c
54
cr-show.c
54
cr-show.c
@@ -5,6 +5,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define PR_SYMBOL(sym) \
|
#define PR_SYMBOL(sym) \
|
||||||
((sym < 32 || sym > 126) ? '.' : sym)
|
(isprint(sym) ? sym : '.')
|
||||||
|
|
||||||
#define pr_regs4(s, n1, n2, n3, n4) \
|
#define pr_regs4(s, n1, n2, n3, n4) \
|
||||||
pr_info("%8s: %16lx " \
|
pr_info("%8s: %16lx " \
|
||||||
@@ -148,6 +149,29 @@ static void show_vma(int fd_vma)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_data(unsigned long addr, unsigned char *data, size_t size)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i+= 16) {
|
||||||
|
pr_info("%16lx: ", addr + i);
|
||||||
|
for (j = 0; j < 8; j++)
|
||||||
|
pr_info("%02x ", data[i + j]);
|
||||||
|
pr_info(" ");
|
||||||
|
for (j = 8; j < 16; j++)
|
||||||
|
pr_info("%02x ", data[i + j]);
|
||||||
|
|
||||||
|
pr_info(" |");
|
||||||
|
for (j = 0; j < 8; j++)
|
||||||
|
pr_info("%c ", PR_SYMBOL(data[i + j]));
|
||||||
|
pr_info(" ");
|
||||||
|
for (j = 8; j < 16; j++)
|
||||||
|
pr_info("%c ", PR_SYMBOL(data[i + j]));
|
||||||
|
|
||||||
|
pr_info("|\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void show_pages(int fd_pages, bool show_content)
|
static void show_pages(int fd_pages, bool show_content)
|
||||||
{
|
{
|
||||||
pr_img_head(CR_FD_PAGES);
|
pr_img_head(CR_FD_PAGES);
|
||||||
@@ -155,32 +179,13 @@ static void show_pages(int fd_pages, bool show_content)
|
|||||||
if (show_content) {
|
if (show_content) {
|
||||||
while (1) {
|
while (1) {
|
||||||
struct page_entry e;
|
struct page_entry e;
|
||||||
unsigned long addr;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
if (read_img(fd_pages, &e) < 0)
|
if (read_img(fd_pages, &e) < 0)
|
||||||
break;
|
break;
|
||||||
if (final_page_entry(&e))
|
if (final_page_entry(&e))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
addr = e.va;
|
print_data(e.va, e.data, PAGE_IMAGE_SIZE);
|
||||||
for (i = 0; i < PAGE_IMAGE_SIZE; i+= 16) {
|
|
||||||
pr_info("%16lx: ", addr + i);
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
pr_info("%02x ", e.data[i + j]);
|
|
||||||
pr_info(" ");
|
|
||||||
for (j = 8; j < 16; j++)
|
|
||||||
pr_info("%02x ", e.data[i + j]);
|
|
||||||
|
|
||||||
pr_info(" |");
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
pr_info("%c ", PR_SYMBOL(e.data[i + j]));
|
|
||||||
pr_info(" ");
|
|
||||||
for (j = 8; j < 16; j++)
|
|
||||||
pr_info("%c ", PR_SYMBOL(e.data[i + j]));
|
|
||||||
|
|
||||||
pr_info("|\n");
|
|
||||||
}
|
|
||||||
pr_info("\n --- End of page ---\n\n");
|
pr_info("\n --- End of page ---\n\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -504,6 +509,9 @@ static int cr_parse_file(struct cr_options *opts)
|
|||||||
case INETSK_MAGIC:
|
case INETSK_MAGIC:
|
||||||
show_inetsk(fd);
|
show_inetsk(fd);
|
||||||
break;
|
break;
|
||||||
|
case SK_QUEUES_MAGIC:
|
||||||
|
show_sk_queues(fd);
|
||||||
|
break;
|
||||||
case ITIMERS_MAGIC:
|
case ITIMERS_MAGIC:
|
||||||
show_itimers(fd);
|
show_itimers(fd);
|
||||||
break;
|
break;
|
||||||
@@ -551,6 +559,10 @@ static int cr_show_all(unsigned long pid, struct cr_options *opts)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
ret = show_sk_queues(cr_fdset->fds[CR_FD_SK_QUEUES]);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
close_cr_fdset(&cr_fdset);
|
close_cr_fdset(&cr_fdset);
|
||||||
|
|
||||||
ret = try_show_namespaces(pid);
|
ret = try_show_namespaces(pid);
|
||||||
|
@@ -29,5 +29,6 @@ extern int collect_sockets(void);
|
|||||||
extern int prepare_sockets(int pid);
|
extern int prepare_sockets(int pid);
|
||||||
extern void show_unixsk(int fd);
|
extern void show_unixsk(int fd);
|
||||||
extern void show_inetsk(int fd);
|
extern void show_inetsk(int fd);
|
||||||
|
extern int show_sk_queues(int fd);
|
||||||
|
|
||||||
#endif /* CR_SOCKETS_H__ */
|
#endif /* CR_SOCKETS_H__ */
|
||||||
|
29
sockets.c
29
sockets.c
@@ -196,8 +196,8 @@ static void show_one_unix(char *act, const struct unix_sk_desc *sk)
|
|||||||
|
|
||||||
static void show_one_unix_img(const char *act, const struct unix_sk_entry *e)
|
static void show_one_unix_img(const char *act, const struct unix_sk_entry *e)
|
||||||
{
|
{
|
||||||
pr_debug("\t%s: fd %d type %d state %d name %d bytes\n",
|
pr_info("\t%s: id %u fd %d type %d state %d name %d bytes\n",
|
||||||
act, e->fd, e->type, e->state, e->namelen);
|
act, e->id, e->fd, e->type, e->state, e->namelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_dump_inet_sk(const struct inet_sk_desc *sk)
|
static int can_dump_inet_sk(const struct inet_sk_desc *sk)
|
||||||
@@ -1282,3 +1282,28 @@ out:
|
|||||||
pr_img_tail(CR_FD_UNIXSK);
|
pr_img_tail(CR_FD_UNIXSK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void print_data(unsigned long addr, unsigned char *data, size_t size);
|
||||||
|
|
||||||
|
int show_sk_queues(int fd)
|
||||||
|
{
|
||||||
|
struct sk_packet_entry pe;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
pr_img_head(CR_FD_SK_QUEUES);
|
||||||
|
while (1) {
|
||||||
|
ret = read_img_eof(fd, &pe);
|
||||||
|
if (ret <= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
pr_info("pkt for %u length %u bytes\n",
|
||||||
|
pe.id_for, pe.length);
|
||||||
|
|
||||||
|
ret = read_img_buf(fd, (unsigned char *)buf, pe.length);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
print_data(0, (unsigned char *)buf, pe.length);
|
||||||
|
}
|
||||||
|
pr_img_tail(CR_FD_SK_QUEUES);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user