From 654961a48092c766b5b814c6fd42f24cc532f1af Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Fri, 21 Sep 2018 11:23:35 +0200 Subject: [PATCH] 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 This introduces parameters QemuMemoryBackingDir and NovaLibvirtFileBackedMemory Resolves-Bug: 1793687 Depends-On: I0d9eb21fcab01266e501b7fc63c5b2bbb244956a Change-Id: I47e2f92fb2ed3e66d4bf31814eac9090382ef4e1 --- docker/services/nova-libvirt.yaml | 24 +++++++++++++++++++ puppet/services/nova-compute.yaml | 21 ++++++++++++++++ puppet/services/nova-libvirt.yaml | 23 ++++++++++++++++++ ...dir_support_for_qemu-accfda4919b3d9dd.yaml | 18 ++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 releasenotes/notes/nova_file_backed_memory_and_memory_backing_dir_support_for_qemu-accfda4919b3d9dd.yaml diff --git a/docker/services/nova-libvirt.yaml b/docker/services/nova-libvirt.yaml index e715837c82..b1c3599849 100644 --- a/docker/services/nova-libvirt.yaml +++ b/docker/services/nova-libvirt.yaml @@ -125,6 +125,14 @@ parameters: type: string tags: - role_specific + QemuMemoryBackingDir: + type: string + description: > + Directory used for memoryBacking source if configured as file. + NOTE: big files will be stored here + default: '' + tags: + - role_specific conditions: @@ -165,6 +173,11 @@ conditions: - {get_param: LibvirtVncCACert} - '' + memory_backing_dir_set: + not: + equals: + - {get_param: QemuMemoryBackingDir} + - '' resources: RoleParametersValue: @@ -175,9 +188,11 @@ resources: map_replace: - map_replace: - vhostuser_socket_group: VhostuserSocketGroup + memory_backing_dir: QemuMemoryBackingDir - values: {get_param: [RoleParameters]} - values: VhostuserSocketGroup: {get_param: VhostuserSocketGroup} + QemuMemoryBackingDir: {get_param: QemuMemoryBackingDir} ContainersCommon: @@ -361,6 +376,15 @@ outputs: - get_param: LibvirtVncCACert - /etc/pki/libvirt-vnc:/var/lib/kolla/config_files/src-libvirt-vnc-pki:ro - null + - + if: + - memory_backing_dir_set + - + - str_replace: + template: "MEMORY_BACKING_DIR:MEMORY_BACKING_DIR" + params: + MEMORY_BACKING_DIR: {get_attr: [RoleParametersValue, value, memory_backing_dir]} + - null environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS step_4: diff --git a/puppet/services/nova-compute.yaml b/puppet/services/nova-compute.yaml index e91f668d12..5f1abe02c6 100644 --- a/puppet/services/nova-compute.yaml +++ b/puppet/services/nova-compute.yaml @@ -189,6 +189,13 @@ parameters: - allowed_values: [ 256, 512, 1024 ] tags: - role_specific + NovaLibvirtFileBackedMemory: + description: > + Available capacity in MiB for file-backed memory. + default: 0 + type: number + tags: + - role_specific conditions: enable_live_migration_tunnelled: @@ -196,6 +203,12 @@ conditions: - equals: [{get_param: NovaNfsEnabled}, true] - equals: [{get_param: NovaEnableRbdBackend}, true] + libvirt_file_backed_memory_enabled: + not: + or: + - equals: [{get_param: NovaLibvirtFileBackedMemory}, ''] + - equals: [{get_param: NovaLibvirtFileBackedMemory}, 0] + resources: NovaBase: type: ./nova-base.yaml @@ -224,6 +237,7 @@ resources: nova::compute::resume_guests_state_on_host_boot: NovaResumeGuestsStateOnHostBoot nova::compute::libvirt::rx_queue_size: NovaLibvirtRxQueueSize nova::compute::libvirt::tx_queue_size: NovaLibvirtTxQueueSize + nova::compute::libvirt::file_backed_memory: NovaLibvirtFileBackedMemory - values: {get_param: [RoleParameters]} - values: NovaVcpuPinSet: {get_param: NovaVcpuPinSet} @@ -234,6 +248,7 @@ resources: NovaResumeGuestsStateOnHostBoot: {get_param: NovaResumeGuestsStateOnHostBoot} NovaLibvirtRxQueueSize: {get_param: NovaLibvirtRxQueueSize} NovaLibvirtTxQueueSize: {get_param: NovaLibvirtTxQueueSize} + NovaLibvirtFileBackedMemory: {get_param: NovaLibvirtFileBackedMemory} outputs: role_data: @@ -313,6 +328,12 @@ outputs: nova::vncproxy::common::vncproxy_host: {get_param: [EndpointMap, NovaVNCProxyPublic, host_nobrackets]} nova::vncproxy::common::vncproxy_port: {get_param: [EndpointMap, NovaVNCProxyPublic, port]} nova::compute::verify_glance_signatures: {get_param: [VerifyGlanceSignatures]} + # if libvirt_file_backed_memory_enabled we have to set ram_allocation_ratio to 1.0 + nova::ram_allocation_ratio: + if: + - libvirt_file_backed_memory_enabled + - '1.0' + - null step_config: | # TODO(emilien): figure how to deal with libvirt profile. # We'll probably treat it like we do with Neutron plugins. diff --git a/puppet/services/nova-libvirt.yaml b/puppet/services/nova-libvirt.yaml index 45f3bac60a..924e8c3303 100644 --- a/puppet/services/nova-libvirt.yaml +++ b/puppet/services/nova-libvirt.yaml @@ -130,6 +130,14 @@ parameters: description: The password for the libvirt service when TLS is enabled type: string hidden: true + QemuMemoryBackingDir: + type: string + description: > + Directory used for memoryBacking source if configured as file. + NOTE: big files will be stored here + default: '' + tags: + - role_specific conditions: @@ -173,6 +181,20 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + # Merging role-specific parameters (RoleParameters) with the default parameters. + # RoleParameters will have the precedence over the default parameters. + RoleParametersValue: + type: OS::Heat::Value + properties: + type: json + value: + map_replace: + - map_replace: + - nova::compute::libvirt::qemu::memory_backing_dir: QemuMemoryBackingDir + - values: {get_param: [RoleParameters]} + - values: + QemuMemoryBackingDir: {get_param: QemuMemoryBackingDir} + outputs: role_data: description: Role data for the Libvirt service. @@ -182,6 +204,7 @@ outputs: config_settings: map_merge: - get_attr: [NovaBase, role_data, config_settings] + - get_attr: [RoleParametersValue, value] # we include ::nova::compute::libvirt::services in nova/libvirt profile - nova::compute::libvirt::manage_libvirt_services: false # we manage migration in nova common puppet profile diff --git a/releasenotes/notes/nova_file_backed_memory_and_memory_backing_dir_support_for_qemu-accfda4919b3d9dd.yaml b/releasenotes/notes/nova_file_backed_memory_and_memory_backing_dir_support_for_qemu-accfda4919b3d9dd.yaml new file mode 100644 index 0000000000..e2dd468534 --- /dev/null +++ b/releasenotes/notes/nova_file_backed_memory_and_memory_backing_dir_support_for_qemu-accfda4919b3d9dd.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