|
|
43fe83 |
From 1d0e74a42e6f308bad8603911335d4fda841d316 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <1d0e74a42e6f308bad8603911335d4fda841d316.1381871412.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Mon, 14 Oct 2013 16:45:29 +0100
|
|
|
43fe83 |
Subject: [PATCH] Initialize threading & error layer in LXC controller
|
|
|
43fe83 |
|
|
|
43fe83 |
For
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1018725
|
|
|
43fe83 |
|
|
|
43fe83 |
In Fedora 20, libvirt_lxc crashes immediately at startup with a
|
|
|
43fe83 |
trace
|
|
|
43fe83 |
|
|
|
43fe83 |
#0 0x00007f0cddb653ec in free () from /lib64/libc.so.6
|
|
|
43fe83 |
#1 0x00007f0ce0e16f4a in virFree (ptrptr=ptrptr@entry=0x7f0ce1830058) at util/viralloc.c:580
|
|
|
43fe83 |
#2 0x00007f0ce0e2764b in virResetError (err=0x7f0ce1830030) at util/virerror.c:354
|
|
|
43fe83 |
#3 0x00007f0ce0e27a5a in virResetLastError () at util/virerror.c:387
|
|
|
43fe83 |
#4 0x00007f0ce0e28858 in virEventRegisterDefaultImpl () at util/virevent.c:233
|
|
|
43fe83 |
#5 0x00007f0ce0db47c6 in main (argc=11, argv=0x7fff4596c328) at lxc/lxc_controller.c:2352
|
|
|
43fe83 |
|
|
|
43fe83 |
Normally virInitialize calls virErrorInitialize and
|
|
|
43fe83 |
virThreadInitialize, but we don't link to libvirt.so
|
|
|
43fe83 |
in libvirt_lxc, and nor did we ever call the error
|
|
|
43fe83 |
or thread initializers.
|
|
|
43fe83 |
|
|
|
43fe83 |
I have absolutely no idea how this has ever worked, let alone
|
|
|
43fe83 |
what caused it to stop working in Fedora 20.
|
|
|
43fe83 |
|
|
|
43fe83 |
In addition not all code paths from virLogSetFromEnv will
|
|
|
43fe83 |
ensure virLogInitialize is called correctly, which is another
|
|
|
43fe83 |
possible crash scenario.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit 97973ebb7a64a3be6710ddd38d124307991ad7cb)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/lxc/lxc_controller.c | 4 +++-
|
|
|
43fe83 |
src/util/virlog.c | 6 ++++++
|
|
|
43fe83 |
2 files changed, 9 insertions(+), 1 deletion(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
|
|
|
43fe83 |
index e301c43..357910d 100644
|
|
|
43fe83 |
--- a/src/lxc/lxc_controller.c
|
|
|
43fe83 |
+++ b/src/lxc/lxc_controller.c
|
|
|
43fe83 |
@@ -2257,7 +2257,9 @@ int main(int argc, char *argv[])
|
|
|
43fe83 |
|
|
|
43fe83 |
if (setlocale(LC_ALL, "") == NULL ||
|
|
|
43fe83 |
bindtextdomain(PACKAGE, LOCALEDIR) == NULL ||
|
|
|
43fe83 |
- textdomain(PACKAGE) == NULL) {
|
|
|
43fe83 |
+ textdomain(PACKAGE) == NULL ||
|
|
|
43fe83 |
+ virThreadInitialize() < 0 ||
|
|
|
43fe83 |
+ virErrorInitialize() < 0) {
|
|
|
43fe83 |
fprintf(stderr, _("%s: initialization failed\n"), argv[0]);
|
|
|
43fe83 |
exit(EXIT_FAILURE);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
diff --git a/src/util/virlog.c b/src/util/virlog.c
|
|
|
43fe83 |
index daf964b..6f791ad 100644
|
|
|
43fe83 |
--- a/src/util/virlog.c
|
|
|
43fe83 |
+++ b/src/util/virlog.c
|
|
|
43fe83 |
@@ -547,6 +547,9 @@ virLogDefineFilter(const char *match,
|
|
|
43fe83 |
|
|
|
43fe83 |
virCheckFlags(VIR_LOG_STACK_TRACE, -1);
|
|
|
43fe83 |
|
|
|
43fe83 |
+ if (virLogInitialize() < 0)
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
if ((match == NULL) || (priority < VIR_LOG_DEBUG) ||
|
|
|
43fe83 |
(priority > VIR_LOG_ERROR))
|
|
|
43fe83 |
return -1;
|
|
|
43fe83 |
@@ -662,6 +665,9 @@ virLogDefineOutput(virLogOutputFunc f,
|
|
|
43fe83 |
|
|
|
43fe83 |
virCheckFlags(0, -1);
|
|
|
43fe83 |
|
|
|
43fe83 |
+ if (virLogInitialize() < 0)
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
if (f == NULL)
|
|
|
43fe83 |
return -1;
|
|
|
43fe83 |
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|