Mark McLoughlin da05e0
From 663bf081dc6737c7fcc68a7ca1169aca60fbf8e5 Mon Sep 17 00:00:00 2001
Mark McLoughlin da05e0
From: Daniel P. Berrange <berrange@redhat.com>
Mark McLoughlin da05e0
Date: Thu, 13 Aug 2009 11:56:31 +0100
Mark McLoughlin da05e0
Subject: [PATCH] Make LXC / UML drivers robust against NUMA topology brokenness
Daniel P. Berrange 581b5f
Mark McLoughlin da05e0
Some kernel versions expose broken NUMA topology for some machines.
Mark McLoughlin da05e0
This causes the LXC/UML drivers to fail to start. QEMU driver was
Mark McLoughlin da05e0
already fixed for this problem
Mark McLoughlin da05e0
Mark McLoughlin da05e0
* src/lxc_conf.c: Log and ignore failure to populate NUMA info
Mark McLoughlin da05e0
* src/uml_conf.c: Log and ignore failure to populate NUMA info
Mark McLoughlin da05e0
* src/capabilities.c: Reset nnumaCell to 0 after freeing
Mark McLoughlin da05e0
Mark McLoughlin da05e0
(cherry picked from commit 19bac57b26c2d46ac8a7601158f210f34acdceac)
Mark McLoughlin da05e0
Mark McLoughlin da05e0
Fedora-patch: libvirt-0.7.0-numa-ignore-fail.patch
Mark McLoughlin da05e0
---
Mark McLoughlin da05e0
 src/capabilities.c |    1 +
Mark McLoughlin da05e0
 src/lxc_conf.c     |   12 ++++++++++--
Mark McLoughlin da05e0
 src/uml_conf.c     |   11 +++++++++--
Mark McLoughlin da05e0
 3 files changed, 20 insertions(+), 4 deletions(-)
Daniel P. Berrange 581b5f
Daniel P. Berrange 581b5f
diff --git a/src/capabilities.c b/src/capabilities.c
Daniel P. Berrange 581b5f
index c6766b6..193a9fe 100644
Daniel P. Berrange 581b5f
--- a/src/capabilities.c
Daniel P. Berrange 581b5f
+++ b/src/capabilities.c
Daniel P. Berrange 581b5f
@@ -139,6 +139,7 @@ virCapabilitiesFreeNUMAInfo(virCapsPtr caps)
Daniel P. Berrange 581b5f
     for (i = 0 ; i < caps->host.nnumaCell ; i++)
Daniel P. Berrange 581b5f
         virCapabilitiesFreeHostNUMACell(caps->host.numaCell[i]);
Daniel P. Berrange 581b5f
     VIR_FREE(caps->host.numaCell);
Daniel P. Berrange 581b5f
+    caps->host.nnumaCell = 0;
Daniel P. Berrange 581b5f
 }
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
 /**
Daniel P. Berrange 581b5f
diff --git a/src/lxc_conf.c b/src/lxc_conf.c
Daniel P. Berrange 581b5f
index d06a024..fef60ba 100644
Daniel P. Berrange 581b5f
--- a/src/lxc_conf.c
Daniel P. Berrange 581b5f
+++ b/src/lxc_conf.c
Daniel P. Berrange 581b5f
@@ -30,6 +30,8 @@
Daniel P. Berrange 581b5f
 #include "lxc_conf.h"
Daniel P. Berrange 581b5f
 #include "nodeinfo.h"
Daniel P. Berrange 581b5f
 #include "virterror_internal.h"
Daniel P. Berrange 581b5f
+#include "logging.h"
Daniel P. Berrange 581b5f
+
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
 #define VIR_FROM_THIS VIR_FROM_LXC
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
@@ -46,8 +48,14 @@ virCapsPtr lxcCapsInit(void)
Daniel P. Berrange 581b5f
                                    0, 0)) == NULL)
Daniel P. Berrange 581b5f
         goto no_memory;
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
-    if (nodeCapsInitNUMA(caps) < 0)
Daniel P. Berrange 581b5f
-        goto no_memory;
Daniel P. Berrange 581b5f
+    /* Some machines have problematic NUMA toplogy causing
Daniel P. Berrange 581b5f
+     * unexpected failures. We don't want to break the QEMU
Daniel P. Berrange 581b5f
+     * driver in this scenario, so log errors & carry on
Daniel P. Berrange 581b5f
+     */
Daniel P. Berrange 581b5f
+    if (nodeCapsInitNUMA(caps) < 0) {
Daniel P. Berrange 581b5f
+        virCapabilitiesFreeNUMAInfo(caps);
Daniel P. Berrange 581b5f
+        VIR_WARN0("Failed to query host NUMA topology, disabling NUMA capabilities");
Daniel P. Berrange 581b5f
+    }
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
     /* XXX shouldn't 'borrow' KVM's prefix */
Daniel P. Berrange 581b5f
     virCapabilitiesSetMacPrefix(caps, (unsigned char []){ 0x52, 0x54, 0x00 });
Daniel P. Berrange 581b5f
diff --git a/src/uml_conf.c b/src/uml_conf.c
Daniel P. Berrange 581b5f
index 48e05a8..4f756d4 100644
Daniel P. Berrange 581b5f
--- a/src/uml_conf.c
Daniel P. Berrange 581b5f
+++ b/src/uml_conf.c
Daniel P. Berrange 581b5f
@@ -45,6 +45,7 @@
Daniel P. Berrange 581b5f
 #include "nodeinfo.h"
Daniel P. Berrange 581b5f
 #include "verify.h"
Daniel P. Berrange 581b5f
 #include "bridge.h"
Daniel P. Berrange 581b5f
+#include "logging.h"
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
 #define VIR_FROM_THIS VIR_FROM_UML
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
@@ -63,8 +64,14 @@ virCapsPtr umlCapsInit(void) {
Daniel P. Berrange 581b5f
                                    0, 0)) == NULL)
Daniel P. Berrange 581b5f
         goto no_memory;
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
-    if (nodeCapsInitNUMA(caps) < 0)
Daniel P. Berrange 581b5f
-        goto no_memory;
Daniel P. Berrange 581b5f
+    /* Some machines have problematic NUMA toplogy causing
Daniel P. Berrange 581b5f
+     * unexpected failures. We don't want to break the QEMU
Daniel P. Berrange 581b5f
+     * driver in this scenario, so log errors & carry on
Daniel P. Berrange 581b5f
+     */
Daniel P. Berrange 581b5f
+    if (nodeCapsInitNUMA(caps) < 0) {
Daniel P. Berrange 581b5f
+        virCapabilitiesFreeNUMAInfo(caps);
Daniel P. Berrange 581b5f
+        VIR_WARN0("Failed to query host NUMA topology, disabling NUMA capabilities");
Daniel P. Berrange 581b5f
+    }
Daniel P. Berrange 581b5f
 
Daniel P. Berrange 581b5f
     if ((guest = virCapabilitiesAddGuest(caps,
Daniel P. Berrange 581b5f
                                          "uml",
Mark McLoughlin da05e0
-- 
Mark McLoughlin da05e0
1.6.2.5
Mark McLoughlin da05e0