From c42ef59bf931f8f0a2e9a333574c7c963a5172fd Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Mon, 31 Aug 2015 13:34:14 +0200 Subject: [PATCH] Add criu related debug output While testing different versions of criu it helps to know which criu binary with which options is currently used. Therefore additional debug output to display these information is added. v2: increase readability of printed out criu options Signed-off-by: Adrian Reber --- libcontainer/container_linux.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index 19c4701e6..40bdcd86e 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "reflect" "strings" "sync" "syscall" @@ -32,6 +33,7 @@ type linuxContainer struct { initProcess parentProcess criuPath string m sync.Mutex + criuVersion int } // ID returns the container's unique ID @@ -337,7 +339,9 @@ func (c *linuxContainer) checkCriuVersion(min_version string) error { } } - if x*10000+y*100+z < versionReq { + c.criuVersion = x*10000 + y*100 + z + + if c.criuVersion < versionReq { return fmt.Errorf("CRIU version must be %s or higher", min_version) } @@ -665,6 +669,8 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts * defer criuServer.Close() args := []string{"swrk", "3"} + logrus.Debugf("Using CRIU %d at: %s", c.criuVersion, c.criuPath) + logrus.Debugf("Using CRIU with following args: %s", args) cmd := exec.Command(c.criuPath, args...) if process != nil { cmd.Stdin = process.Stdin @@ -701,6 +707,18 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts * } } + logrus.Debugf("Using CRIU in %s mode", req.GetType().String()) + val := reflect.ValueOf(req.GetOpts()) + v := reflect.Indirect(val) + for i := 0; i < v.NumField(); i++ { + st := v.Type() + name := st.Field(i).Name + if strings.HasPrefix(name, "XXX_") { + continue + } + value := val.MethodByName("Get" + name).Call([]reflect.Value{}) + logrus.Debugf("CRIU option %s with value %v", name, value[0]) + } data, err := proto.Marshal(req) if err != nil { return err