Description
===========
When a user tries to launch an instance with memory encryption enabled, the instance always becomes error state if the nova-compute has [libvirt] cpu_mode = custom.
Steps to reproduce
==================
1. Set the following options in nova.conf and restart nova-compute
[libvirt]
cpu_mode = custom
cpu_model = EPYC
2. Prepare a flavor with memory encryption enabled
Description
===========
When a user tries to launch an instance with memory encryption enabled, the instance always becomes error state if the nova-compute has [libvirt] cpu_mode = custom.
Steps to reproduce
==================
1. Set the following options in nova.conf and restart nova-compute
[libvirt]
cpu_mode = custom
cpu_model = EPYC
2. Prepare a flavor with memory encryption enabled
$ openstack flavor show m1.small-enc -f yaml DISABLED: disabled: false EXT-DATA: ephemeral: 0 8948-4cdd- a5cd-71411cf9c8 e4 access: is_public: true encryption: 'true'
OS-FLV-
OS-FLV-
access_project_ids: null
description: null
disk: 20
id: ee97652f-
name: m1.small-enc
os-flavor-
properties:
hw:mem_
ram: 2048
rxtx_factor: 1.0
swap: 0
vcpus: 1
3. Create an image with hw_firmware_type property set to 'uefi'
$ openstack image show cirros-uefi -f yaml afe616360717719 06 25T02:46: 57Z' d6353363- f580-464c- 9909-93212298a5 8a/file f580-464c- 9909-93212298a5 8a fa1e83738d78219 04 e41235a4de260de b791ff571670c03 42666c8582fbb9c aefe6af07ebb11d 34f44f8414b609b 29c1bdf1d72ffa6 faa39c88e8721d0 9847952b specified. openstack. md5: '' specified. openstack. object: images/cirros-uefi specified. openstack. sha256: '' 25T06:00: 15Z'
checksum: c8fc807773e5354
container_format: bare
created_at: '2023-10-
disk_format: qcow2
file: /v2/images/
id: d6353363-
min_disk: 0
min_ram: 0
name: cirros-uefi
owner: 5a2803c4cdb1412
properties:
hw_disk_bus: scsi
hw_firmware_type: uefi
hw_scsi_model: virtio-scsi
os_hash_algo: sha512
os_hash_value: 1103b92ce8ad966
os_hidden: false
owner_
owner_
owner_
stores: fs
protected: false
schema: /v2/schemas/image
size: 21430272
status: active
tags: []
updated_at: '2023-10-
virtual_size: 117440512
visibility: public
4. launch an instance using the flavr and the image
$ openstack server create --image cirros-uefi --flavor m1.small-enc --network private cirros-enc
Expected result
===============
The instance becomes active state
Actual result
=============
Instance becomes error state. The following traceback is found in nova-compute.log
``` manager [None req-104288bc- 7bf5-4bcd- a728-cd85ac7241 6f 69d6ccfef7e2403 98970c80f0be8cc f7 5a2803c4cdb1412 fa1e83738d78219 04 - - default default] [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] Failed to build and run instance: nova.exception. FlavorImageConf lict: Memory encryption requested by hw:mem_encryption extra spec in m1.small-enc flavor but image None doesn't have 'hw_firmware_type' property set to 'uefi' or volume-backed instance was requested manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] Traceback (most recent call last): manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/compute/ manager. py", line 2615, in _build_ and_run_ instance manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] self.driver. spawn(context, instance, image_meta, manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ libvirt/ driver. py", line 4413, in spawn manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] xml = self._get_ guest_xml( context, instance, network_info, manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ libvirt/ driver. py", line 7565, in _get_guest_xml manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] conf = self._get_ guest_config( instance, network_info, image_meta, manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ libvirt/ driver. py", line 7045, in _get_guest_config manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] guest.cpu = self._get_ guest_cpu_ config( manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ libvirt/ driver. py", line 5451, in _get_guest_ cpu_config manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] cpu = self._get_ guest_cpu_ model_config( flavor, arch) manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ libvirt/ driver. py", line 5398, in _get_guest_ cpu_model_ config manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] flags = libvirt_ utils.get_ flags_by_ flavor_ specs(flavor) manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ libvirt/ utils.py" , line 658, in get_flags_ by_flavor_ specs manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] resource_request = scheduler_ utils.ResourceR equest. from_request_ spec( manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/scheduler/ utils.py" , line 187, in from_request_spec manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] res_req. _translate_ memory_ encryption( request_ spec.flavor, image) manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/scheduler/ utils.py" , line 297, in _translate_ memory_ encryption manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] if not hardware. get_mem_ encryption_ constraint( flavor, image): manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ hardware. py", line 1197, in get_mem_ encryption_ constraint manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] _check_ mem_encryption_ uses_uefi_ image(requester s, image_meta) manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] File "/usr/lib/ python3/ dist-packages/ nova/virt/ hardware. py", line 1243, in _check_ mem_encryption_ uses_uefi_ image manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] raise exception. FlavorImageConf lict(emsg % data) manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42] nova.exception. FlavorImageConf lict: Memory encryption requested by hw:mem_encryption extra spec in m1.small-enc flavor but image None doesn't have 'hw_firmware_type' property set to 'uefi' or volume-backed instance was requested manager [instance: 000b22bc- 6b28-4adb- a3af-44b1f090c5 42]
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
2023-10-25 06:33:20.674 38337 ERROR nova.compute.
```
Environment 0-0ubuntu1~ cloud0
===========
The issue was found in a deployment using Ubuntu 22.04 + UCA Bobcat.
Nova packages are all 3:28.0.