Add nova file_backed_memory and memory_backing_dir support for qemu.conf

The libvirt driver now allows utilizing file backed memory for qemu/KVM
virtual machines, via a new configuration attribute
``[libvirt]/file_backed_memory``, defaulting to 0 (disabled).

``[libvirt]/file_backed_memory`` specifies the available capacity in MiB
for file backed memory, at the directory configured for
``memory_backing_dir`` in libvirt's ``qemu.conf``. When enabled, the
libvirt driver will report the configured value for the total memory
capacity of the node, and will report used memory as the sum of all
configured guest memory.

Running Nova with file_backed_memory requires libvirt version 4.0.0 and
qemu version 2.6.0

Related-Bug: 1793687

Change-Id: I0d9eb21fcab01266e501b7fc63c5b2bbb244956a
This commit is contained in:
Martin Schuppert 2018-09-21 10:59:48 +02:00
parent 8a8f5ad65e
commit 84f90bd1bb
4 changed files with 48 additions and 10 deletions

View File

@ -147,6 +147,10 @@
# Valid values are 256, 512, 1024 # Valid values are 256, 512, 1024
# Defaults to $::os_service_default # Defaults to $::os_service_default
# #
# [*file_backed_memory*]
# (optional) Available capacity in MiB for file-backed memory.
# Defaults to $::os_service_default
#
class nova::compute::libvirt ( class nova::compute::libvirt (
$ensure_package = 'present', $ensure_package = 'present',
$libvirt_virt_type = 'kvm', $libvirt_virt_type = 'kvm',
@ -175,6 +179,7 @@ class nova::compute::libvirt (
$log_outputs = undef, $log_outputs = undef,
$rx_queue_size = $::os_service_default, $rx_queue_size = $::os_service_default,
$tx_queue_size = $::os_service_default, $tx_queue_size = $::os_service_default,
$file_backed_memory = undef,
) inherits nova::params { ) inherits nova::params {
include ::nova::deps include ::nova::deps
@ -256,6 +261,7 @@ class nova::compute::libvirt (
'libvirt/enabled_perf_events': value => join(any2array($libvirt_enabled_perf_events), ','); 'libvirt/enabled_perf_events': value => join(any2array($libvirt_enabled_perf_events), ',');
'libvirt/rx_queue_size': value => $rx_queue_size; 'libvirt/rx_queue_size': value => $rx_queue_size;
'libvirt/tx_queue_size': value => $tx_queue_size; 'libvirt/tx_queue_size': value => $tx_queue_size;
'libvirt/file_backed_memory': value => $file_backed_memory;
} }
# cpu_model param is only valid if cpu_mode=custom # cpu_model param is only valid if cpu_mode=custom

View File

@ -28,13 +28,19 @@
# (optional) Enables TLS client cert verification when vnc_tls is enabled. # (optional) Enables TLS client cert verification when vnc_tls is enabled.
# Defaults to true. # Defaults to true.
# #
# [*memory_backing_dir*]
# (optional) This directory is used for memoryBacking source if configured as file.
# NOTE: big files will be stored here
# Defaults to undef.
#
class nova::compute::libvirt::qemu( class nova::compute::libvirt::qemu(
$configure_qemu = false, $configure_qemu = false,
$group = undef, $group = undef,
$max_files = 1024, $max_files = 1024,
$max_processes = 4096, $max_processes = 4096,
$vnc_tls = false, $vnc_tls = false,
$vnc_tls_verify = true $vnc_tls_verify = true,
$memory_backing_dir = undef
){ ){
include ::nova::deps include ::nova::deps
@ -68,7 +74,12 @@ class nova::compute::libvirt::qemu(
} else { } else {
$augues_group_changes = [] $augues_group_changes = []
} }
$augues_changes = concat($augues_changes_default, $augues_group_changes) if $memory_backing_dir and !empty($memory_backing_dir) {
$augues_memory_backing_dir_changes = ["set memory_backing_dir ${memory_backing_dir}"]
} else {
$augues_memory_backing_dir_changes = []
}
$augues_changes = concat($augues_changes_default, $augues_group_changes, $augues_memory_backing_dir_changes)
augeas { 'qemu-conf-limits': augeas { 'qemu-conf-limits':
context => '/files/etc/libvirt/qemu.conf', context => '/files/etc/libvirt/qemu.conf',
@ -83,7 +94,8 @@ class nova::compute::libvirt::qemu(
'rm max_processes', 'rm max_processes',
'rm group', 'rm group',
'rm vnc_tls', 'rm vnc_tls',
'rm vnc_tls_x509_verify' 'rm vnc_tls_x509_verify',
'rm memory_backing_dir'
], ],
tag => 'qemu-conf-augeas', tag => 'qemu-conf-augeas',
} }

View File

@ -0,0 +1,18 @@
---
features:
- |
Add nova file_backed_memory and memory_backing_dir support for qemu.conf
The libvirt driver now allows utilizing file backed memory for qemu/KVM
virtual machines, via a new configuration attribute
``[libvirt]/file_backed_memory``, defaulting to 0 (disabled).
``[libvirt]/file_backed_memory`` specifies the available capacity in MiB
for file backed memory, at the directory configured for
``memory_backing_dir`` in libvirt's ``qemu.conf``. When enabled, the
libvirt driver will report the configured value for the total memory
capacity of the node, and will report used memory as the sum of all
configured guest memory.
Running Nova with file_backed_memory requires libvirt version 4.0.0 and
qemu version 2.6.0

View File

@ -18,7 +18,7 @@ describe 'nova::compute::libvirt::qemu' do
end end
it { is_expected.to contain_augeas('qemu-conf-limits').with({ it { is_expected.to contain_augeas('qemu-conf-limits').with({
:context => '/files/etc/libvirt/qemu.conf', :context => '/files/etc/libvirt/qemu.conf',
:changes => [ "rm max_files", "rm max_processes", "rm group", "rm vnc_tls", "rm vnc_tls_x509_verify" ], :changes => [ "rm max_files", "rm max_processes", "rm group", "rm vnc_tls", "rm vnc_tls_x509_verify", "rm memory_backing_dir" ],
}).that_notifies('Service[libvirt]') } }).that_notifies('Service[libvirt]') }
end end
@ -57,6 +57,7 @@ describe 'nova::compute::libvirt::qemu' do
:group => 'openvswitch', :group => 'openvswitch',
:max_files => 32768, :max_files => 32768,
:max_processes => 131072, :max_processes => 131072,
:memory_backing_dir => '/tmp'
} }
end end
it { is_expected.to contain_augeas('qemu-conf-limits').with({ it { is_expected.to contain_augeas('qemu-conf-limits').with({
@ -66,7 +67,8 @@ describe 'nova::compute::libvirt::qemu' do
"set max_processes 131072", "set max_processes 131072",
"set vnc_tls 0", "set vnc_tls 0",
"set vnc_tls_x509_verify 0", "set vnc_tls_x509_verify 0",
"set group openvswitch" "set group openvswitch",
"set memory_backing_dir /tmp"
], ],
:tag => 'qemu-conf-augeas', :tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') } }).that_notifies('Service[libvirt]') }