From c4b795a9ec27389bddfe7452e9f83a368adada8c Mon Sep 17 00:00:00 2001 From: LiFeng Date: Thu, 30 Apr 2020 17:00:29 +0800 Subject: [PATCH] attch: add err msg when call attach failed Signed-off-by: LiFeng --- ...nd-error-msg-when-call-attach-failed.patch | 49 +++++++++++++++++++ lxc.spec | 3 +- series.conf | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 0060-attach-append-error-msg-when-call-attach-failed.patch diff --git a/0060-attach-append-error-msg-when-call-attach-failed.patch b/0060-attach-append-error-msg-when-call-attach-failed.patch new file mode 100644 index 0000000..838da34 --- /dev/null +++ b/0060-attach-append-error-msg-when-call-attach-failed.patch @@ -0,0 +1,49 @@ +From de512a0c11bff1bfc8f0045e144bddc689742a21 Mon Sep 17 00:00:00 2001 +From: LiFeng +Date: Thu, 30 Apr 2020 16:40:14 +0800 +Subject: [PATCH] attach: append error msg when call attach failed + +Signed-off-by: LiFeng +--- + src/lxc/tools/lxc_attach.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c +index 190f3c8..dbddc2a 100644 +--- a/src/lxc/tools/lxc_attach.c ++++ b/src/lxc/tools/lxc_attach.c +@@ -401,12 +401,17 @@ static int do_attach_foreground(struct lxc_container *c, lxc_attach_command_t *c + ret = c->attach(c, lxc_attach_run_command, command, attach_options, &pid); + else + ret = c->attach(c, lxc_attach_run_shell, NULL, attach_options, &pid); +- if (ret < 0) ++ if (ret < 0) { ++ *errmsg = safe_strdup("Internal error, failed to call attach"); + goto out; ++ } + + ret = lxc_wait_for_pid_status(pid); +- if (ret < 0) ++ if (ret < 0) { ++ free(*errmsg); ++ *errmsg = safe_strdup("Internal error, failed to wait attached process"); + goto out; ++ } + + if (WIFEXITED(ret)) + wexit = WEXITSTATUS(ret); +@@ -421,8 +426,10 @@ static int do_attach_foreground(struct lxc_container *c, lxc_attach_command_t *c + ERROR("Execd pid %d exit with %d", pid, wexit); + + out: +- if (c->lxc_conf->errmsg) ++ if (c->lxc_conf->errmsg) { ++ free(*errmsg); + *errmsg = safe_strdup(c->lxc_conf->errmsg); ++ } + return wexit; + } + +-- +1.8.3.1 + diff --git a/lxc.spec b/lxc.spec index 082ac29..4eceed1 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 2020042801 +%global _release 2020043001 %global debug_package %{nil} Name: lxc @@ -67,6 +67,7 @@ Patch9055: 0056-attach-add-sigfd-to-monitor-the-exit-of-pid.patch Patch9056: 0057-attach-add-read-data-from-attach-sigfd.patch Patch9057: 0058-support-syslog-for-console.patch Patch9058: 0059-set-state-to-stopped.patch +Patch9059: 0060-attach-append-error-msg-when-call-attach-failed.patch BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) diff --git a/series.conf b/series.conf index 8ee2ff5..c7abb4c 100644 --- a/series.conf +++ b/series.conf @@ -57,3 +57,4 @@ 0057-attach-add-read-data-from-attach-sigfd.patch 0058-support-syslog-for-console.patch 0059-set-state-to-stopped.patch +0060-attach-append-error-msg-when-call-attach-failed.patch -- Gitee