2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +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:
Radostin Stoyanov 2025-05-23 08:33:20 +01:00
parent 6eb5bb06bc
commit 9622b9045c
3 changed files with 18 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;