The LXC driver makes use of new clone flags for creating containers. It
creates a dummy container which immediately exits in order to test for
availabilty of this feature in the kernel. Unfortunately valgrind has
no knowledge of these new clone flags, gets very very unhappy and then
reports bogus memory leaks, bogus illegal instructions, and then often
SEGV's itself. Not cool. While obviously valgrind needs fixing, I looked
at its code, and it doesn't seem easy, so this patch adds a quick check
for a LD_PRELOAD environemnt variable which contains a library whose
name contains 'vgpreload'. If it sees this, LXC driver totally disables
itself. This lets me reliably valgrind the libvirtd daemon again.
Second, I also move the lxcProbe() call in the lxcOpen() method down a
little, so we only probe if we are actually about to try opening the
connection. This avoids some unneccessary container creation checks
for most virConnectOpen scenarios.
Daniel
diff -r 6c8e581563aa src/lxc_driver.c
--- a/src/lxc_driver.c Fri Jan 30 11:00:43 2009 +0000
+++ b/src/lxc_driver.c Fri Jan 30 11:01:10 2009 +0000
@@ -80,14 +80,14 @@ static virDrvOpenStatus lxcOpen(virConne
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED)
{
- if (!lxcProbe())
- goto declineConnection;
-
if (lxc_driver == NULL)
goto declineConnection;
/* Verify uri was specified */
if (conn->uri == NULL) {
+ if (!lxcProbe())
+ goto declineConnection;
+
conn->uri = xmlParseURI("lxc:///");
if (!conn->uri) {
virReportOOMError(conn);
@@ -96,8 +96,11 @@ static virDrvOpenStatus lxcOpen(virConne
} else if (conn->uri->scheme == NULL ||
STRNEQ(conn->uri->scheme, "lxc")) {
goto declineConnection;
+ } else if (!lxcProbe()) {
+ goto declineConnection;
}
+
conn->privateData = lxc_driver;
return VIR_DRV_OPEN_SUCCESS;
@@ -1119,6 +1122,13 @@ static int lxcStartup(void)
{
uid_t uid = getuid();
unsigned int i;
+ char *ld;
+
+ /* Valgrind gets very annoyed when we clone containers, so
+ * disable LXC when under valgrind */
+ ld = getenv("LD_PRELOAD");
+ if (ld && strstr(ld, "vgpreload"))
+ return -1;
/* Check that the user is root */
if (0 != uid) {
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|