diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index a495386d9..e39eefbcc 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -147,6 +147,10 @@ # Valid values are 256, 512, 1024 # 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 ( $ensure_package = 'present', $libvirt_virt_type = 'kvm', @@ -175,6 +179,7 @@ class nova::compute::libvirt ( $log_outputs = undef, $rx_queue_size = $::os_service_default, $tx_queue_size = $::os_service_default, + $file_backed_memory = undef, ) inherits nova::params { include ::nova::deps @@ -256,6 +261,7 @@ class nova::compute::libvirt ( 'libvirt/enabled_perf_events': value => join(any2array($libvirt_enabled_perf_events), ','); 'libvirt/rx_queue_size': value => $rx_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 diff --git a/manifests/compute/libvirt/qemu.pp b/manifests/compute/libvirt/qemu.pp index e4893f900..5400e2c23 100644 --- a/manifests/compute/libvirt/qemu.pp +++ b/manifests/compute/libvirt/qemu.pp @@ -28,13 +28,19 @@ # (optional) Enables TLS client cert verification when vnc_tls is enabled. # 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( - $configure_qemu = false, - $group = undef, - $max_files = 1024, - $max_processes = 4096, - $vnc_tls = false, - $vnc_tls_verify = true + $configure_qemu = false, + $group = undef, + $max_files = 1024, + $max_processes = 4096, + $vnc_tls = false, + $vnc_tls_verify = true, + $memory_backing_dir = undef ){ include ::nova::deps @@ -68,7 +74,12 @@ class nova::compute::libvirt::qemu( } else { $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': context => '/files/etc/libvirt/qemu.conf', @@ -83,7 +94,8 @@ class nova::compute::libvirt::qemu( 'rm max_processes', 'rm group', 'rm vnc_tls', - 'rm vnc_tls_x509_verify' + 'rm vnc_tls_x509_verify', + 'rm memory_backing_dir' ], tag => 'qemu-conf-augeas', } diff --git a/releasenotes/notes/nova_file_backed_memory_and_memory_backing_dir_support_for_qemu-a4cde7ab5297f3ac.yaml b/releasenotes/notes/nova_file_backed_memory_and_memory_backing_dir_support_for_qemu-a4cde7ab5297f3ac.yaml new file mode 100644 index 000000000..e2dd46853 --- /dev/null +++ b/releasenotes/notes/nova_file_backed_memory_and_memory_backing_dir_support_for_qemu-a4cde7ab5297f3ac.yaml @@ -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 diff --git a/spec/classes/nova_compute_libvirt_qemu_spec.rb b/spec/classes/nova_compute_libvirt_qemu_spec.rb index 2494a5b54..3d35e674f 100644 --- a/spec/classes/nova_compute_libvirt_qemu_spec.rb +++ b/spec/classes/nova_compute_libvirt_qemu_spec.rb @@ -18,7 +18,7 @@ describe 'nova::compute::libvirt::qemu' do end it { is_expected.to contain_augeas('qemu-conf-limits').with({ :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]') } end @@ -57,6 +57,7 @@ describe 'nova::compute::libvirt::qemu' do :group => 'openvswitch', :max_files => 32768, :max_processes => 131072, + :memory_backing_dir => '/tmp' } end 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 vnc_tls 0", "set vnc_tls_x509_verify 0", - "set group openvswitch" + "set group openvswitch", + "set memory_backing_dir /tmp" ], :tag => 'qemu-conf-augeas', }).that_notifies('Service[libvirt]') }