[CRIU] [PATCH] Show error messages when failing early in the init process
Nicolas Viennot
Nicolas.Viennot at twosigma.com
Fri Sep 6 22:26:04 MSK 2019
* Shows an error message when failing to open images directory
* Fixes chdir() error message logging. Logging is not initialized yet
making pr_perror() unavailable.
Signed-off-by: Nicolas Viennot <nviennot at twosigma.com>
---
criu/cr-service.c | 2 +-
criu/crtools.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/criu/cr-service.c b/criu/cr-service.c
index 0938db02..5303eb77 100644
--- a/criu/cr-service.c
+++ b/criu/cr-service.c
@@ -336,7 +336,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
SET_CHAR_OPTS(img_parent, req->parent_img);
if (open_image_dir(images_dir_path) < 0) {
- pr_perror("Can't open images directory");
+ pr_perror("Can't open images directory %s", images_dir_path);
goto err;
}
diff --git a/criu/crtools.c b/criu/crtools.c
index 97a6d6d6..ab08c894 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -147,8 +147,11 @@ int main(int argc, char *argv[], char *envp[])
/* We must not open imgs dir, if service is called */
if (strcmp(argv[optind], "service")) {
ret = open_image_dir(opts.imgs_dir);
- if (ret < 0)
+ if (ret < 0) {
+ pr_msg("Error: Can't open images directory %s: %s\n",
+ opts.imgs_dir, strerror(errno));
return 1;
+ }
}
/*
@@ -162,7 +165,8 @@ int main(int argc, char *argv[], char *envp[])
pr_warn("Stopped and detached shell job will get SIGHUP from OS.\n");
if (chdir(opts.work_dir)) {
- pr_perror("Can't change directory to %s", opts.work_dir);
+ pr_msg("Error: Can't change directory to %s: %s\n",
+ opts.work_dir, strerror(errno));
return 1;
}
--
2.19.1
More information about the CRIU
mailing list