From 2b0024c04070dcffc056e9df7b9ced40cbfdcc00 Mon Sep 17 00:00:00 2001 From: Boris Bobrov Date: Wed, 25 Sep 2019 20:07:50 +0200 Subject: [PATCH] Switch to uses_virtio to enable iommu driver for AMD SEV In order to use AMD SEV, devices that use virtio should also use iommu driver. The problem is to understand that a device uses virtio, because there are many attributes and values that can indicate it. For example, it can be `model='virtio'` for rng and `` for disk. Add new property for devices `uses_virtio`, that will indicate that a device in its current configuration is a virtio device, and implement it for known devices. The patch does not change how resulting libvirt XMLs look and does not fix user-visible bugs. This refactoring is required for further work on AMD SEV related patches. The changes to memballoon-related tests were required because the tests were using fake values that does are not possible in real life and that were preventing tests of the new method. The tests now use the value that nova currently uses to generate libvirt xml. Change-Id: I0f85918996128d573b5dbd6ac49a9c2356cd40a9 Partial-Bug: #1845986 --- nova/tests/unit/virt/libvirt/test_config.py | 21 +++++++++++++++------ nova/virt/libvirt/config.py | 20 ++++++++++++++++++++ nova/virt/libvirt/designer.py | 11 +---------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/test_config.py b/nova/tests/unit/virt/libvirt/test_config.py index 1cc39c29b7b4..2fa19e0a38e3 100644 --- a/nova/tests/unit/virt/libvirt/test_config.py +++ b/nova/tests/unit/virt/libvirt/test_config.py @@ -1836,6 +1836,7 @@ class LibvirtConfigGuestInterfaceTest(LibvirtConfigBaseTest): obj.mac_addr = "DE:AD:BE:EF:CA:FE" obj.model = "virtio" obj.target_dev = "vnet0" + self.assertTrue(obj.uses_virtio) return obj def test_config_driver_options(self): @@ -2859,6 +2860,8 @@ class LibvirtConfigGuestSnapshotTest(LibvirtConfigBaseTest): obj.target_bus = "virtio" obj.serial = "7a97c4a3-6f59-41d4-bf47-191d7f97f8e9" + self.assertTrue(obj.uses_virtio) + xml = obj.to_xml() self.assertXmlEqual(""" @@ -3265,6 +3268,8 @@ class LibvirtConfigGuestVideoTest(LibvirtConfigBaseTest): obj = config.LibvirtConfigGuestVideo() obj.type = 'qxl' + self.assertFalse(obj.uses_virtio) + xml = obj.to_xml() self.assertXmlEqual(xml, """