diff --git a/nova/conf/libvirt.py b/nova/conf/libvirt.py index 4d87ea616a75..abd574bff1d3 100644 --- a/nova/conf/libvirt.py +++ b/nova/conf/libvirt.py @@ -721,25 +721,25 @@ http://man7.org/linux/man-pages/man7/random.7.html. ('none', 'A serial number entry is not added to the guest ' 'domain xml.'), ('os', 'A UUID serial number is generated from the host ' - '``/etc/machine-id`` file. This will also affect ' - 'existing instances on this host once they stop ' - 'and start again.'), + '``/etc/machine-id`` file.'), ('hardware', 'A UUID for the host hardware as reported by ' 'libvirt. This is typically from the host ' 'SMBIOS data, unless it has been overridden ' 'in ``libvirtd.conf``.'), ('auto', 'Uses the "os" source if possible, else ' '"hardware".'), - ('unique', 'Uses instance UUID as the serial number. ' - 'This will also affect existing instances ' - 'on this host once they stop and start again.'), + ('unique', 'Uses instance UUID as the serial number.'), ), - help='The data source used to the populate the host "serial" ' - 'UUID exposed to guest in the virtual BIOS. All choices ' - 'except ``unique`` will change the serial when migrating ' - 'instance to other host. Changing the choice of this ' - 'option will also affect existing instances on this host ' - 'once they stopped and started again.' + help=""" +The data source used to the populate the host "serial" UUID exposed to guest +in the virtual BIOS. All choices except ``unique`` will change the serial when +migrating the instance to another host. Changing the choice of this option will +also affect existing instances on this host once they are stopped and started +again. It is recommended to use the default choice (``unique``) since that will +not change when an instance is migrated. However, if you have a need for +per-host serials in addition to per-instance serial numbers, then consider +restricting flavors via host aggregates. +""" ), cfg.IntOpt('mem_stats_period_seconds', default=10, diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 12c3e82f86bb..af0a7f8453cf 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -17928,7 +17928,7 @@ class TestGuestConfigSysinfoSerialOS(test.NoDBTestCase): self.assertEqual(version.version_string_with_package(), cfg.system_version) if expected_serial == 'instance_uuid': - expected_serial = instance_ref['uuid'] + expected_serial = instance_ref.uuid self.assertEqual(expected_serial, cfg.system_serial) self.assertEqual(instance_ref['uuid'], diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 0d18bc5663ad..6d1603373ed0 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -366,6 +366,9 @@ class LibvirtDriver(driver.ComputeDriver): self._volume_api = cinder.API() self._image_api = image.API() + # The default choice for the sysinfo_serial config option is "unique" + # which does not have a special function since the value is just the + # instance.uuid. sysinfo_serial_funcs = { 'none': lambda: None, 'hardware': self._get_host_sysinfo_serial_hardware, diff --git a/releasenotes/notes/per-instance-serial-f2e597cb05d1b09e.yaml b/releasenotes/notes/per-instance-serial-f2e597cb05d1b09e.yaml index 66ac2f4bab8a..a70ae75cf7d4 100644 --- a/releasenotes/notes/per-instance-serial-f2e597cb05d1b09e.yaml +++ b/releasenotes/notes/per-instance-serial-f2e597cb05d1b09e.yaml @@ -3,5 +3,7 @@ upgrade: - | Added a new ``unique`` choice to the ``[libvirt]/sysinfo_serial`` configuration which if set will result in the guest serial number being - set to ``instance.uuid`` on this host. This is now the default value - of ``[libvirt]/sysinfo_serial`` config option. + set to ``instance.uuid``. This is now the default value + of the ``[libvirt]/sysinfo_serial`` config option and is the recommended + choice since it ensures the guest serial is the same even if the instance + is migrated between hosts.