From 8566dcfef4dc0cee7a8af58507dec01f83a85c59 Mon Sep 17 00:00:00 2001 From: Zack Cornelius Date: Wed, 20 Jun 2018 13:29:24 -0500 Subject: [PATCH] Fix nits from change I676291ec0faa1dea0bd5050ef8e3426d171de4c6 Change-Id: If6ea6701d73a4a8abb6a75c54308a386eec7a4b2 Implements: blueprint libvirt-file-backed-memory --- doc/source/admin/file-backed-memory.rst | 36 +++++++++----------- doc/source/admin/huge-pages.rst | 5 ++- doc/source/user/support-matrix.ini | 7 ++-- nova/conf/libvirt.py | 4 +-- nova/tests/unit/objects/test_migrate_data.py | 2 +- nova/tests/unit/virt/libvirt/test_driver.py | 10 +++--- nova/tests/unit/virt/libvirt/test_host.py | 4 +-- nova/virt/libvirt/driver.py | 8 ++--- nova/virt/libvirt/migration.py | 6 ++-- 9 files changed, 39 insertions(+), 43 deletions(-) diff --git a/doc/source/admin/file-backed-memory.rst b/doc/source/admin/file-backed-memory.rst index 148fcf2985b9..4e77d81aa3b2 100644 --- a/doc/source/admin/file-backed-memory.rst +++ b/doc/source/admin/file-backed-memory.rst @@ -1,5 +1,5 @@ ================== -File backed memory +File-backed memory ================== .. important:: @@ -7,7 +7,7 @@ File backed memory As of the 18.0.0 Rocky release, the functionality described below is only supported by the libvirt/KVM driver. -The file backed memory feature in Openstack allows a Nova node to serve guest +The file-backed memory feature in Openstack allows a Nova node to serve guest memory from a file backing store. This mechanism uses the libvirt file memory source, causing guest instance memory to be allocated as files within the libvirt memory backing directory. @@ -17,48 +17,46 @@ this feature works best when used with very fast block devices or virtual file systems - such as flash or RAM devices. When configured, ``nova-compute`` will report the capacity configured for -file backed memory to placement in place of the total system memory capacity. +file-backed memory to placement in place of the total system memory capacity. This allows the node to run more instances than would normally fit within system memory. -To enable file backed memory, follow the steps below: +To enable file-backed memory, follow the steps below: #. `Configure the backing store`_ -#. `Configure Nova Compute for file backed memory`_ +#. `Configure Nova Compute for file-backed memory`_ .. important:: It is not possible to live migrate from a node running a version of - OpenStack that does not support file backed memory to a node with file + OpenStack that does not support file-backed memory to a node with file backed memory enabled. It is recommended that all Nova compute nodes are - upgraded to Rocky before enabling file backed memory. + upgraded to Rocky before enabling file-backed memory. Prerequisites and Limitations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Libvirt - File backed memory requires libvirt version 4.0.0 or newer + File-backed memory requires libvirt version 4.0.0 or newer Qemu - File backed memory requires qemu version 2.6.0 or newer + File-backed memory requires qemu version 2.6.0 or newer Memory overcommit - File backed memory is not compatible with memory overcommit. + File-backed memory is not compatible with memory overcommit. ``ram_allocation_ratio`` must be set to ``1.0`` in ``nova.conf``, and the host must not be added to a host aggregate with ``ram_allocation_ratio`` set to anything but ``1.0``. Huge pages - File backed memory is not compatible with huge pages. Instances with huge - pages configured will not start on a host with file backed memory enabled. It + File-backed memory is not compatible with huge pages. Instances with huge + pages configured will not start on a host with file-backed memory enabled. It is recommended to use host aggregates to ensure instances configured for - huge pages are not placed on hosts with file backed memory configured + huge pages are not placed on hosts with file-backed memory configured. Handling these limitations could be optimized with a scheduler filter in the -future - - +future. Configure the backing store ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -95,12 +93,12 @@ store mounted at (or above) this location. # mount /dev/sdb /var/lib/libvirt/qemu/ram -Configure Nova Compute for file backed memory +Configure Nova Compute for file-backed memory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#. Enable File backed memory in ``nova-compute`` +#. Enable File-backed memory in ``nova-compute`` - Configure Nova to utilize file backed memory with the capacity of the + Configure Nova to utilize file-backed memory with the capacity of the backing store in MiB. 1048576 MiB (1 TiB) is used in this example. Edit ``/etc/nova/nova.conf`` diff --git a/doc/source/admin/huge-pages.rst b/doc/source/admin/huge-pages.rst index fe640e8275b3..e53a58167e4f 100644 --- a/doc/source/admin/huge-pages.rst +++ b/doc/source/admin/huge-pages.rst @@ -56,8 +56,8 @@ Enabling huge pages on the host ------------------------------- .. important:: - Huge pages may not be used on a host configured for file backed memory. See - `File backed memory`_ for details + Huge pages may not be used on a host configured for file-backed memory. See + :doc:`file-backed-memory` for details Persistent huge pages are required owing to their guaranteed availability. However, persistent huge pages are not enabled by default in most environments. @@ -240,4 +240,3 @@ guide. .. _`Linux THP guide`: https://www.kernel.org/doc/Documentation/vm/transhuge.txt .. _`Linux hugetlbfs guide`: https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt .. _`Image metadata`: https://docs.openstack.org/image-guide/image-metadata.html -.. _`File backed memory`: https://docs.openstack.org/nova/latest/admin/file-backed-memory.html diff --git a/doc/source/user/support-matrix.ini b/doc/source/user/support-matrix.ini index 6fbf237b849e..06cfa7d55fc7 100644 --- a/doc/source/user/support-matrix.ini +++ b/doc/source/user/support-matrix.ini @@ -1476,6 +1476,7 @@ driver-impl-ironic=missing driver-impl-libvirt-vz-vm=complete driver-impl-libvirt-vz-ct=complete driver-impl-powervm=missing + [operation.file-backed-memory] title=File backed memory status=optional @@ -1487,9 +1488,9 @@ notes=The file backed memory feature in Openstack allows a Nova node to serve cli= driver-impl-xenserver=missing driver-impl-libvirt-kvm-x86=complete -driver-impl-libvirt-kvm-aarch64=complete -driver-impl-libvirt-kvm-ppc64=complete -driver-impl-libvirt-kvm-s390x=complete +driver-impl-libvirt-kvm-aarch64=unknown +driver-impl-libvirt-kvm-ppc64=unknown +driver-impl-libvirt-kvm-s390x=unknown driver-impl-libvirt-qemu-x86=complete driver-impl-libvirt-lxc=missing driver-impl-libvirt-xen=missing diff --git a/nova/conf/libvirt.py b/nova/conf/libvirt.py index f1113e63d3fa..6316d0c4b99b 100644 --- a/nova/conf/libvirt.py +++ b/nova/conf/libvirt.py @@ -747,9 +747,9 @@ Default value '0' moves calculating amount of ports to libvirt. default=0, min=0, help=""" -Available capacity in MiB for file backed memory. +Available capacity in MiB for file-backed memory. -Set to 0 to disable file backed memory. +Set to 0 to disable file-backed memory. When enabled, instances will create memory files in the directory specified in ``/etc/libvirt/qemu.conf``'s ``memory_backing_dir`` option. The default diff --git a/nova/tests/unit/objects/test_migrate_data.py b/nova/tests/unit/objects/test_migrate_data.py index bcd791ea7bd5..d27f26264dfb 100644 --- a/nova/tests/unit/objects/test_migrate_data.py +++ b/nova/tests/unit/objects/test_migrate_data.py @@ -239,7 +239,7 @@ class _TestLibvirtLiveMigrateData(object): data = lambda x: x['nova_object.data'] primitive = data(obj.obj_to_primitive()) - self.assertIn('serial_listen_addr', primitive) + self.assertIn('dst_wants_file_backed_memory', primitive) primitive = data(obj.obj_to_primitive(target_version='1.0')) self.assertNotIn('target_connect_addr', primitive) self.assertNotIn('supported_perf_events', primitive) diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 58d61783efdc..e2769b199a33 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -1069,12 +1069,12 @@ class LibvirtConnTestCase(test.NoDBTestCase, drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) drvr.init_host("dummyhost") - @mock.patch.object( - libvirt_driver.LibvirtDriver, "_check_file_backed_memory_support",) - def test_file_backed_memory_support_called(self, mock_file_backed_support): + def test_file_backed_memory_support_called(self): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) - drvr.init_host("dummyhost") - self.assertTrue(mock_file_backed_support.called) + with mock.patch.object(drvr, + '_check_file_backed_memory_support') as mock_check_fb_support: + drvr.init_host("dummyhost") + self.assertTrue(mock_check_fb_support.called) @mock.patch.object(fakelibvirt.Connection, 'getLibVersion', return_value=versionutils.convert_version_to_int( diff --git a/nova/tests/unit/virt/libvirt/test_host.py b/nova/tests/unit/virt/libvirt/test_host.py index 2b22ebca5059..97d16b72d7ea 100644 --- a/nova/tests/unit/virt/libvirt/test_host.py +++ b/nova/tests/unit/virt/libvirt/test_host.py @@ -676,9 +676,7 @@ class HostTestCase(test.NoDBTestCase): self.assertEqual('one', self.host.get_memory_mb_total()) def test_get_memory_total_file_backed(self): - self.flags(file_backed_memory=1048576, - group="libvirt") - + self.flags(file_backed_memory=1048576, group="libvirt") self.assertEqual(1048576, self.host.get_memory_mb_total()) def test_get_memory_used(self): diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 24b7a96bda88..001f2ddaa656 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -607,8 +607,8 @@ class LibvirtDriver(driver.ComputeDriver): 'qemu': libvirt_utils.version_to_string( MIN_QEMU_FILE_BACKED_VERSION)}) - # file backed memory doesn't work with memory overcommit. - # Block service startup if file backed memory is enabled and + # file-backed memory doesn't work with memory overcommit. + # Block service startup if file-backed memory is enabled and # ram_allocation_ratio is not 1.0 if CONF.ram_allocation_ratio != 1.0: raise exception.InternalError( @@ -4713,7 +4713,7 @@ class LibvirtDriver(driver.ComputeDriver): wantsfilebacked = CONF.libvirt.file_backed_memory > 0 if wantsmempages and wantsfilebacked: - # Can't use file backed memory with hugepages + # Can't use file-backed memory with hugepages LOG.warning("Instance requested huge pages, but file-backed " "memory is enabled, and incompatible with huge pages") raise exception.MemoryPagesUnsupported() @@ -6552,7 +6552,7 @@ class LibvirtDriver(driver.ComputeDriver): """ # TODO(zcornelius): Remove this check in Stein, as we'll only support - # Rocky and newer computes. + # Rocky and newer computes. # If file_backed_memory is enabled on this host, we have to make sure # the source is new enough to support it. Since the source generates # the XML for the destination, we depend on the source generating a diff --git a/nova/virt/libvirt/migration.py b/nova/virt/libvirt/migration.py index 1734fed4c29d..4284ba31f32c 100644 --- a/nova/virt/libvirt/migration.py +++ b/nova/virt/libvirt/migration.py @@ -224,14 +224,14 @@ def _update_perf_events_xml(xml_doc, migrate_data): def _update_memory_backing_xml(xml_doc, migrate_data): - """Update libvirt domain XML for file backed memory + """Update libvirt domain XML for file-backed memory If incoming XML has a memoryBacking element, remove access, source, and allocation children elements to get it to a known consistent state. If no incoming memoryBacking element, create one. - If destination wants file backed memory, add source, access, + If destination wants file-backed memory, add source, access, and allocation children. """ old_xml_has_memory_backing = True @@ -248,7 +248,7 @@ def _update_memory_backing_xml(xml_doc, migrate_data): old_xml_has_memory_backing = False else: memory_backing = memory_backing[0] - # Remove existing file backed memory tags, if they exist. + # Remove existing file-backed memory tags, if they exist. for name in ("access", "source", "allocation"): tag = memory_backing.findall(name) if tag: