lxc-console流程分析

extern int lxc_command_mainloop_add(const char *name,
        struct lxc_epoll_descr *descr,
        struct lxc_handler *handler)
{
 int ret, fd;
 char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 };
 char *offset = &path[1];

 sprintf(offset, abstractname, name);

 fd = lxc_af_unix_open(path, SOCK_STREAM, 0);
抽象名是/usr/local/var/lib/lxc/vp1/command——socket名,是在外面的。

lxc_console  ->lxc_command_connected  ->__lxc_command  ->lxc_af_unix_send_credential -> sendmsg
——lxc_console发消息

__lxc_start ->lxc_poll ->lxc_command_mainloop_add ->incoming_command_handler ->accept
——接收信息

incoming_command_handler ->command_handler ->lxc_af_unix_rcv_credential ->recvmsg
——取出消息

command_handler ->trigger_command
——根据消息触发相应动作lxc_console_callback

extern int lxc_console(const char *name, int ttynum, int *fd)
{
 int ret, stopped = 0;
 struct lxc_command command = {
  .request = { .type = LXC_COMMAND_TTY, .data = ttynum },
 };

猜你喜欢

转载自blog.csdn.net/tdaajames/article/details/8961392