mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
cpuinfo: show error when image is missing
The `criu cpuinfo check` command calls cpu_validate_cpuinfo(), which attempts to open the cpuinfo.img file using `open_image()`. If the image file is not found, `open_image()` returns an "empty image" object. As a result, `cpu_validate_cpuinfo()` tries to read from it and fails with the following error: (00.002473) Error (criu/protobuf.c:72): Unexpected EOF on (empty-image) This patch adds a check for an empty image and appropriate error message. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
parent
99ba6db89b
commit
a79b33d0c5
3 changed files with 18 additions and 0 deletions
|
|
@ -64,6 +64,12 @@ int cpu_validate_cpuinfo(void)
|
|||
if (!img)
|
||||
return -1;
|
||||
|
||||
if (empty_image(img)) {
|
||||
pr_err("No cpuinfo image\n");
|
||||
close_image(img);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pb_read_one(img, &cpu_info, PB_CPUINFO) < 0)
|
||||
goto error;
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ int cpu_validate_cpuinfo(void)
|
|||
if (!img)
|
||||
return -1;
|
||||
|
||||
if (empty_image(img)) {
|
||||
pr_err("No cpuinfo image\n");
|
||||
close_image(img);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
if (pb_read_one(img, &cpu_info, PB_CPUINFO) < 0)
|
||||
goto error;
|
||||
|
|
|
|||
|
|
@ -407,6 +407,12 @@ int cpu_validate_cpuinfo(void)
|
|||
if (!img)
|
||||
return -1;
|
||||
|
||||
if (empty_image(img)) {
|
||||
pr_err("No cpuinfo image\n");
|
||||
close_image(img);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pb_read_one(img, &img_cpu_info, PB_CPUINFO) < 0)
|
||||
goto err;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue