|
|
43fe83 |
From 6fb618488723ceee1f422006b2517154733cd0dc Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <6fb618488723ceee1f422006b2517154733cd0dc.1381871412.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Mon, 14 Oct 2013 16:45:22 +0100
|
|
|
43fe83 |
Subject: [PATCH] Improve error reporting with LXC controller
|
|
|
43fe83 |
|
|
|
43fe83 |
For
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=927072
|
|
|
43fe83 |
|
|
|
43fe83 |
The LXC code would read the log file if an LXC guest failed to
|
|
|
43fe83 |
startup. There were a number of failure cases where the guest
|
|
|
43fe83 |
will not start and libvirtd never gets as far as looking at the
|
|
|
43fe83 |
log file.
|
|
|
43fe83 |
|
|
|
43fe83 |
Fix this by replacing some earlier generic errors with messages
|
|
|
43fe83 |
from the log.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit 1815e2d0812a9cd1c85363e93db5c00e302d1c96)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/lxc/lxc_process.c | 29 +++++++++++++++++++++++------
|
|
|
43fe83 |
1 file changed, 23 insertions(+), 6 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
|
|
|
43fe83 |
index 724ffa9..ccf86af 100644
|
|
|
43fe83 |
--- a/src/lxc/lxc_process.c
|
|
|
43fe83 |
+++ b/src/lxc/lxc_process.c
|
|
|
43fe83 |
@@ -980,6 +980,7 @@ int virLXCProcessStart(virConnectPtr conn,
|
|
|
43fe83 |
virErrorPtr err = NULL;
|
|
|
43fe83 |
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
|
|
|
43fe83 |
virCgroupPtr selfcgroup;
|
|
|
43fe83 |
+ int status;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (virCgroupNewSelf(&selfcgroup) < 0)
|
|
|
43fe83 |
return -1;
|
|
|
43fe83 |
@@ -1182,9 +1183,18 @@ int virLXCProcessStart(virConnectPtr conn,
|
|
|
43fe83 |
VIR_WARN("Unable to seek to end of logfile: %s",
|
|
|
43fe83 |
virStrerror(errno, ebuf, sizeof(ebuf)));
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (virCommandRun(cmd, NULL) < 0)
|
|
|
43fe83 |
+ if (virCommandRun(cmd, &status) < 0)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ if (status != 0) {
|
|
|
43fe83 |
+ if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, sizeof(ebuf)) <= 0)
|
|
|
43fe83 |
+ snprintf(ebuf, sizeof(ebuf), "unexpected exit status %d", status);
|
|
|
43fe83 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
43fe83 |
+ _("guest failed to start: %s"), ebuf);
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+
|
|
|
43fe83 |
if (VIR_CLOSE(handshakefds[1]) < 0) {
|
|
|
43fe83 |
virReportSystemError(errno, "%s", _("could not close handshake fd"));
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
@@ -1193,16 +1203,23 @@ int virLXCProcessStart(virConnectPtr conn,
|
|
|
43fe83 |
/* Connect to the controller as a client *first* because
|
|
|
43fe83 |
* this will block until the child has written their
|
|
|
43fe83 |
* pid file out to disk & created their cgroup */
|
|
|
43fe83 |
- if (!(priv->monitor = virLXCProcessConnectMonitor(driver, vm)))
|
|
|
43fe83 |
+ if (!(priv->monitor = virLXCProcessConnectMonitor(driver, vm))) {
|
|
|
43fe83 |
+ /* Intentionally overwrite the real monitor error message,
|
|
|
43fe83 |
+ * since a better one is almost always found in the logs
|
|
|
43fe83 |
+ */
|
|
|
43fe83 |
+ if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, sizeof(ebuf)) > 0) {
|
|
|
43fe83 |
+ virResetLastError();
|
|
|
43fe83 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
43fe83 |
+ _("guest failed to start: %s"), ebuf);
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
|
|
|
43fe83 |
/* And get its pid */
|
|
|
43fe83 |
if ((r = virPidFileRead(cfg->stateDir, vm->def->name, &vm->pid)) < 0) {
|
|
|
43fe83 |
- char out[1024];
|
|
|
43fe83 |
-
|
|
|
43fe83 |
- if (virLXCProcessReadLogOutput(vm, logfile, pos, out, 1024) > 0)
|
|
|
43fe83 |
+ if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, sizeof(ebuf)) > 0)
|
|
|
43fe83 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
43fe83 |
- _("guest failed to start: %s"), out);
|
|
|
43fe83 |
+ _("guest failed to start: %s"), ebuf);
|
|
|
43fe83 |
else
|
|
|
43fe83 |
virReportSystemError(-r,
|
|
|
43fe83 |
_("Failed to read pid file %s/%s.pid"),
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|