File 0001-Backport-of-the-NUMA-checks-from-the-master-branch.patch of Package openstack-nova

From 784d331ff97277f6314133d9bda385fc3d9d42fa Mon Sep 17 00:00:00 2001
From: Nanuk Krinner <nkrinner@suse.de>
Date: Mon, 20 Jul 2015 16:27:47 +0200
Subject: [PATCH] Backport of the NUMA checks from the master branch

Backport of the NUMA checks from the master branch:

author	Daniel P. Berrange <berrange@redhat.com>
committer	Nikola Dipanov <ndipanov@redhat.com>
commit	945ab28df04e22f3c1b8948972f538ee6b5e7410
tree	a985fe6c2e18eafead21c86e626c23fe9e3fabca
parent	ef42f74a07b6a96252f91f1755631ddc314a3b2f
libvirt: fix disablement of NUMA & hugepages on unsupported platforms
https://git.openstack.org/cgit/openstack/nova/commit/?id=945ab28df04e22f3c1b8948972f538ee6b5e7410

omitting tests
---
 nova/exception.py           |  4 ++++
 nova/virt/libvirt/driver.py | 29 ++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

Index: nova-2014.2.4.dev70/nova/exception.py
===================================================================
--- nova-2014.2.4.dev70.orig/nova/exception.py
+++ nova-2014.2.4.dev70/nova/exception.py
@@ -1759,3 +1759,7 @@ class InvalidHypervisorVirtType(Invalid)
 
 class InvalidVirtualMachineMode(Invalid):
     msg_fmt = _("Virtual machine mode '%(vmmode)s' is not recognised")
+
+
+class NUMATopologyUnsupported(Invalid):
+    msg_fmt = _("Host does not support guests with NUMA topology set")
Index: nova-2014.2.4.dev70/nova/virt/libvirt/driver.py
===================================================================
--- nova-2014.2.4.dev70.orig/nova/virt/libvirt/driver.py
+++ nova-2014.2.4.dev70/nova/virt/libvirt/driver.py
@@ -361,8 +361,13 @@ MIN_LIBVIRT_BLOCKCOMMIT_RELATIVE_VERSION
 MIN_LIBVIRT_DISCARD_VERSION = (1, 0, 6)
 MIN_QEMU_DISCARD_VERSION = (1, 6, 0)
 REQ_HYPERVISOR_DISCARD = "QEMU"
-# libvirt numa topology support
-MIN_LIBVIRT_NUMA_TOPOLOGY_VERSION = (1, 0, 4)
+# While earlier versions could support NUMA reporting and
+# NUMA placement, not until 1.2.7 was there the ability
+# to pin guest nodes to host nodes, so mandate that. Without
+# this the scheduler cannot make guaranteed decisions, as the
+# guest placement may not match what was requested
+MIN_LIBVIRT_NUMA_VERSION = (1, 2, 7)
+
 
 
 def libvirt_error_handler(context, err):
@@ -3746,6 +3751,15 @@ class LibvirtDriver(driver.ComputeDriver
                with the instance's requested topology. If the host does
                not support NUMA, then guest_cpu_tune will be None.
         """
+
+        if (not self._has_numa_support() and
+                instance.numa_topology is not None):
+            # We should not get here, since we should have avoided
+            # reporting NUMA topology from _get_host_numa_topology
+            # in the first place. Just in case of a scheduler
+            # mess up though, raise an exception
+            raise exception.NUMATopologyUnsupported()
+
         topology = self._get_host_numa_topology()
         # We have instance NUMA so translate it to the config class
         guest_cpu_numa = self._get_cpu_numa_config_from_instance(
@@ -4851,8 +4865,17 @@ class LibvirtDriver(driver.ComputeDriver
 
         return jsonutils.dumps(pci_info)
 
+    def _has_numa_support(self):
+        if not self._has_min_version(MIN_LIBVIRT_NUMA_VERSION):
+            return False
+
+        if CONF.libvirt.virt_type not in ['qemu', 'kvm']:
+            return False
+
+        return True
+
     def _get_host_numa_topology(self):
-        if not self._has_min_version(MIN_LIBVIRT_NUMA_TOPOLOGY_VERSION):
+        if not self._has_numa_support():
             return
 
         caps = self._get_host_capabilities()
openSUSE Build Service is sponsored by