Skip to content

Commit 5f6ea0e

Browse files
avagincrosbymichael
authored andcommitted
cr: fix parsing of criu version
The format of criu version is X.Y[.Z]. The current code can not parse X.Y, because scanf returns the "input does not match format" error. Signed-off-by: Andrey Vagin <[email protected]>
1 parent 206b5e6 commit 5f6ea0e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

container_linux.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,12 @@ func (c *linuxContainer) checkCriuVersion() error {
276276
return err
277277
}
278278

279-
n, err := fmt.Sscanf(string(out), "Version: %d.%d.%d", &x, &y, &z)
279+
n, err := fmt.Sscanf(string(out), "Version: %d.%d.%d\n", &x, &y, &z) // 1.5.2
280+
if err != nil {
281+
n, err = fmt.Sscanf(string(out), "Version: %d.%d\n", &x, &y) // 1.6
282+
}
280283
if n < 2 || err != nil {
281-
return fmt.Errorf("Unable to parse the CRIU version: %s", out)
284+
return fmt.Errorf("Unable to parse the CRIU version: %s %d %s", out, n, err)
282285
}
283286

284287
if x*10000+y*100+z < 10502 {

0 commit comments

Comments
 (0)