mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(instances): a new VM can have UEFI Secure Boot and a TPM 2.0
Windows 11 does not install without Secure Boot and a TPM 2.0, and the new VM form offered neither: its firmware list was BIOS and one UEFI loader guessed from file names, which on RHEL never matched the Secure Boot one. The firmware choices are now BIOS, UEFI and UEFI Secure Boot, as the host's libvirt reports them (its firmware features from libvirt 12.1, before that its loaders), and libvirt picks the firmware itself: UEFI without Secure Boot, or with Microsoft's keys enrolled. A TPM 2.0 switch, shown when the host has swtpm, adds an emulated TPM. The create job refuses a firmware or a TPM the host does not offer, and the API takes both. The path-guessing helpers are gone.
This commit is contained in:
parent
40db3dcf3d
commit
005fa59bf0
20 changed files with 399 additions and 228 deletions
|
|
@ -31,6 +31,7 @@ class CreateJobTestCase(TransactionTestCase):
|
|||
self.addCleanup(patcher.stop)
|
||||
self.conn.get_instances.return_value = []
|
||||
self.conn.get_cache_modes.return_value = {"none": "Disable cache"}
|
||||
self.conn.get_firmwares.return_value = ["BIOS", "UEFI", "UEFI Secure Boot"]
|
||||
self.conn.get_disk_bus_types.return_value = ["virtio", "sata"]
|
||||
self.conn.get_dom_capabilities.return_value = {"cpu_modes": ["host-model", "custom"],
|
||||
"cpu_custom_models": ["Skylake-Server-noTSX-IBRS"]}
|
||||
|
|
@ -51,6 +52,19 @@ class CreateJobTestCase(TransactionTestCase):
|
|||
self.assertEqual(self.conn.create_instance.call_args.kwargs["uuid"], op.intent["uuid"])
|
||||
self.assertTrue(Instance.objects.filter(uuid=op.intent["uuid"], name="api-vm").exists())
|
||||
|
||||
def test_the_api_takes_secure_boot_and_a_tpm(self):
|
||||
url = f"/api/v1/computes/{self.compute.pk}/instances/create/x86_64/pc/"
|
||||
body = {**BODY, "firmware": "UEFI Secure Boot", "tpm": True}
|
||||
self.assertEqual(self.client.post(url, body, content_type="application/json").status_code, 202)
|
||||
params = Operation.objects.get().params
|
||||
self.assertEqual((params["firmware"], params["tpm"], params["machine"]), ("UEFI Secure Boot", True, "q35"))
|
||||
|
||||
def test_secure_boot_keeps_a_versioned_q35_machine(self):
|
||||
url = f"/api/v1/computes/{self.compute.pk}/instances/create/x86_64/pc-q35-9.2/"
|
||||
body = {**BODY, "firmware": "UEFI Secure Boot"}
|
||||
self.assertEqual(self.client.post(url, body, content_type="application/json").status_code, 202)
|
||||
self.assertEqual(Operation.objects.get().params["machine"], "pc-q35-9.2")
|
||||
|
||||
def test_a_refused_create_queues_nothing(self):
|
||||
url = f"/api/v1/computes/{self.compute.pk}/instances/create/x86_64/q35/"
|
||||
response = self.client.post(url, {**BODY, "cache_mode": "writeback"}, content_type="application/json")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue