runC源码分析——主体调用链

本文将简单的对runC的源码调用主体逻辑进行梳理,为跟系统的阅读runC源码。

runC总体调用逻辑

下图中,runC源码逻辑跳转流程总体上分为三步:
main入口 ——> runC处理 ——> libcontainer处理。

runC其实就是在libcontainer的基础上进行了封装成各个Command。

runC源码分析——主体调用链_第1张图片

具体runC的各个Command的调用链见如下:

runC处理

checkpoint

checkpointCommand(main.go) —> checkpointCommand(checkpoint.go)

container

createCommand(main.go)—>createCommand(create.go)—>startContainer(untils_linux.go)—>run(untils_linux.go)
deleteCommand(main.go)—>deleteCommand(delete.go)—>destroy(untils_linux.go)
eventsCommand(main.go)—>eventsCommand(events.go)
execCommand(main.go)—>execCommand(exec.go)—>execProcess(exec.go)->run(untils_linux.go)
initCommand(main.go)—>initCommand(main_unix.go)
killCommand(main.go)—>killCommand(kill.go)
listCommand(main.go)—>getContainers(list.go)
pauseCommand(main.go) —>pauseCommand(pause.go)
psCommand(main.go)—>psCommand(ps.go)
restoreCommand(main.go)—>restoreCommand(restore.go)—>restoreContainer(restore.go)
resumeCommand(main.go)—>resumeCommand(pause.go)
runCommand(main.go)—>runCommand(run.go)—>startContainer(untils_linux.go)
specCommand(main.go)—>specCommand(spec.go) end
startCommand(main.go)—>startCommand(start.go)
stateCommand(main.go)—>stateCommand(state.go)
updateCommand(main.go)—>updateCommand(update.go)

runC to libcontainer

checkpoint

checkpointCommand(checkpoint.go)—> Checkpoint(libcontainer/container_linux.go)

container

run(untils_linux.go)—>Run(libcontainer/container_linux.go)
destroy(untils_linux.go)—>Destroy(libcontainer/container_linux.go)
eventsCommand(events.go)—>Status(libcontainer/container_linux.go)
execProcess(exec.go)—>Status\Stopped\State(libcontainer/container_linux.go) || run(untils_linux.go)—>Start\Run\Destroy(libcontainer/container_linux.go)
initCommand(main_unix.go)—>StartInitialization(libcontainer/factory_linux.go)
killCommand(kill.go)—>Signal(libcontainer/container_linux.go)
getContainers(list.go)—>Status\State\Stopped(libcontainer/container_linux.go)
pauseCommand(pause.go)—>Pause(libcontainer/container_linux.go)
psCommand(ps.go)—>exec.Command(“ps”, psArgs…).Output()
restoreContainer(restore.go)—>Restore(libcontainer/container_linux.go)
resumeCommand(pause.go)—>Resume(libcontainer/container_linux.go)
startContainer(untils_linux.go)—>Run(libcontainer/factory.go)
startCommand(start.go)—>Exec(libcontainer/container_linux.go)
stateCommand(state.go)—>State(libcontainer/container_linux.go)
updateCommand(update.go)—>Set(libcontainer/container_linux.go)

你可能感兴趣的:(docker,runC)