Skip to content

Commit 2c7dca4

Browse files
committed
Configuration element for describing video drivers.
The configuration is needed to allow the users to select a non default video driver. Partially implements blueprint libvirt-video-driver-selection Change-Id: Ic6b3e44cfb7e22e0a215f7b159963df35ee1ebac
1 parent 3b32669 commit 2c7dca4

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

nova/tests/virt/libvirt/test_libvirt_config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,3 +1542,28 @@ def test_config_device_pci_subfunction(self):
15421542
self.assertEqual([("0000", "0x0a", "0x1", "0x1"),
15431543
("0001", "0x0a", "0x02", "0x03"), ],
15441544
fun_capability.device_addrs)
1545+
1546+
1547+
class LibvirtConfigGuestVideoTest(LibvirtConfigBaseTest):
1548+
1549+
def test_config_video_driver(self):
1550+
obj = config.LibvirtConfigGuestVideo()
1551+
obj.type = 'qxl'
1552+
1553+
xml = obj.to_xml()
1554+
self.assertXmlEqual(xml, """
1555+
<video>
1556+
<model type='qxl'/>
1557+
</video>""")
1558+
1559+
def test_config_video_driver_vram_heads(self):
1560+
obj = config.LibvirtConfigGuestVideo()
1561+
obj.type = 'qxl'
1562+
obj.vram = '9216'
1563+
obj.heads = '1'
1564+
1565+
xml = obj.to_xml()
1566+
self.assertXmlEqual(xml, """
1567+
<video>
1568+
<model type='qxl' vram='9216' heads='1'/>
1569+
</video>""")

nova/virt/libvirt/config.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,33 @@ def format_dom(self):
906906
return dev
907907

908908

909+
class LibvirtConfigGuestVideo(LibvirtConfigGuestDevice):
910+
911+
def __init__(self, **kwargs):
912+
super(LibvirtConfigGuestVideo, self).__init__(root_name="video",
913+
**kwargs)
914+
915+
self.type = 'cirrus'
916+
self.vram = None
917+
self.heads = None
918+
919+
def format_dom(self):
920+
dev = super(LibvirtConfigGuestVideo, self).format_dom()
921+
922+
model = etree.Element("model")
923+
model.set("type", self.type)
924+
925+
if self.vram:
926+
model.set("vram", str(self.vram))
927+
928+
if self.heads:
929+
model.set("heads", str(self.heads))
930+
931+
dev.append(model)
932+
933+
return dev
934+
935+
909936
class LibvirtConfigGuestHostdev(LibvirtConfigGuestDevice):
910937
def __init__(self, **kwargs):
911938
super(LibvirtConfigGuestHostdev, self).\

0 commit comments

Comments
 (0)