Disable nouveau driver
Change-Id: I7f4ba2ba173d40baa9ba140007e7c4bb8055f000
This commit is contained in:
@@ -95,6 +95,11 @@ def install_nvidia_software_if_needed(stored, config, resources):
|
|||||||
apt_install([nvidia_software_path], fatal=True)
|
apt_install([nvidia_software_path], fatal=True)
|
||||||
stored.last_installed_resource_hash = nvidia_software_hash
|
stored.last_installed_resource_hash = nvidia_software_hash
|
||||||
|
|
||||||
|
# The nouveau driver prevents the nvidia-vgpu-mgr service from
|
||||||
|
# starting, thus it needs to be disabled. Unfortunately this requires
|
||||||
|
# a reboot. The operator will be notified via a blocked unit status.
|
||||||
|
nvidia_utils.disable_nouveau_driver()
|
||||||
|
|
||||||
|
|
||||||
def check_status(config, services):
|
def check_status(config, services):
|
||||||
"""Determine the unit status to be set.
|
"""Determine the unit status to be set.
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import cached
|
from charmhelpers.core.hookenv import cached
|
||||||
|
from charmhelpers.core.kernel import update_initramfs
|
||||||
|
from charmhelpers.core.templating import render
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
apt_cache,
|
apt_cache,
|
||||||
)
|
)
|
||||||
@@ -45,6 +48,17 @@ def installed_nvidia_software_package_names():
|
|||||||
_installed_nvidia_software_packages()]
|
_installed_nvidia_software_packages()]
|
||||||
|
|
||||||
|
|
||||||
|
def disable_nouveau_driver():
|
||||||
|
"""Disable the nouveau driver.
|
||||||
|
|
||||||
|
This driver prevents the nvidia-vgpu-mgr service from starting. A reboot is
|
||||||
|
required.
|
||||||
|
"""
|
||||||
|
config_file = '/etc/modprobe.d/disable-nouveau.conf'
|
||||||
|
render(os.path.basename(config_file), config_file, {})
|
||||||
|
update_initramfs()
|
||||||
|
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
def has_nvidia_gpu_hardware():
|
def has_nvidia_gpu_hardware():
|
||||||
"""Search for NVIDIA GPU hardware.
|
"""Search for NVIDIA GPU hardware.
|
||||||
|
|||||||
2
templates/disable-nouveau.conf
Normal file
2
templates/disable-nouveau.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
blacklist nouveau
|
||||||
|
options nouveau modeset=0
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from mock import MagicMock, patch
|
from mock import ANY, MagicMock, patch
|
||||||
|
|
||||||
sys.path.append('src') # noqa
|
sys.path.append('src') # noqa
|
||||||
|
|
||||||
@@ -45,12 +45,14 @@ class TestCharmUtils(unittest.TestCase):
|
|||||||
charm_utils.is_nvidia_software_to_be_installed_notcached({
|
charm_utils.is_nvidia_software_to_be_installed_notcached({
|
||||||
'force-install-nvidia-vgpu': False}))
|
'force-install-nvidia-vgpu': False}))
|
||||||
|
|
||||||
|
@patch('nvidia_utils.update_initramfs')
|
||||||
|
@patch('nvidia_utils.render')
|
||||||
@patch('charm_utils.apt_install')
|
@patch('charm_utils.apt_install')
|
||||||
@patch('charm_utils._path_and_hash_nvidia_resource')
|
@patch('charm_utils._path_and_hash_nvidia_resource')
|
||||||
@patch('charm_utils.is_nvidia_software_to_be_installed')
|
@patch('charm_utils.is_nvidia_software_to_be_installed')
|
||||||
def test_install_nvidia_software_if_needed(
|
def test_install_nvidia_software_if_needed(
|
||||||
self, is_software_to_be_installed_mock, path_and_hash_mock,
|
self, is_software_to_be_installed_mock, path_and_hash_mock,
|
||||||
apt_install_mock):
|
apt_install_mock, render_template_mock, update_initramfs_mock):
|
||||||
is_software_to_be_installed_mock.return_value = True
|
is_software_to_be_installed_mock.return_value = True
|
||||||
unit_stored_state = MagicMock()
|
unit_stored_state = MagicMock()
|
||||||
unit_stored_state.last_installed_resource_hash = 'hash-1'
|
unit_stored_state.last_installed_resource_hash = 'hash-1'
|
||||||
@@ -75,6 +77,9 @@ class TestCharmUtils(unittest.TestCase):
|
|||||||
None)
|
None)
|
||||||
apt_install_mock.assert_called_once_with(['path-to-software'],
|
apt_install_mock.assert_called_once_with(['path-to-software'],
|
||||||
fatal=True)
|
fatal=True)
|
||||||
|
render_template_mock.assert_called_once_with(
|
||||||
|
'disable-nouveau.conf', ANY, ANY)
|
||||||
|
update_initramfs_mock.assert_called_once_with()
|
||||||
|
|
||||||
@patch('charm_utils.ows_check_services_running')
|
@patch('charm_utils.ows_check_services_running')
|
||||||
@patch('charm_utils.is_nvidia_software_to_be_installed')
|
@patch('charm_utils.is_nvidia_software_to_be_installed')
|
||||||
|
|||||||
Reference in New Issue
Block a user