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
This commit is contained in:
Vladik Romanovsky
2013-11-25 22:12:39 -05:00
parent 3b32669390
commit 2c7dca4ede
2 changed files with 52 additions and 0 deletions

View File

@@ -1542,3 +1542,28 @@ class LibvirtConfigNodeDevicePciSubFunctionCap(LibvirtConfigBaseTest):
self.assertEqual([("0000", "0x0a", "0x1", "0x1"),
("0001", "0x0a", "0x02", "0x03"), ],
fun_capability.device_addrs)
class LibvirtConfigGuestVideoTest(LibvirtConfigBaseTest):
def test_config_video_driver(self):
obj = config.LibvirtConfigGuestVideo()
obj.type = 'qxl'
xml = obj.to_xml()
self.assertXmlEqual(xml, """
<video>
<model type='qxl'/>
</video>""")
def test_config_video_driver_vram_heads(self):
obj = config.LibvirtConfigGuestVideo()
obj.type = 'qxl'
obj.vram = '9216'
obj.heads = '1'
xml = obj.to_xml()
self.assertXmlEqual(xml, """
<video>
<model type='qxl' vram='9216' heads='1'/>
</video>""")

View File

@@ -906,6 +906,33 @@ class LibvirtConfigGuestGraphics(LibvirtConfigGuestDevice):
return dev
class LibvirtConfigGuestVideo(LibvirtConfigGuestDevice):
def __init__(self, **kwargs):
super(LibvirtConfigGuestVideo, self).__init__(root_name="video",
**kwargs)
self.type = 'cirrus'
self.vram = None
self.heads = None
def format_dom(self):
dev = super(LibvirtConfigGuestVideo, self).format_dom()
model = etree.Element("model")
model.set("type", self.type)
if self.vram:
model.set("vram", str(self.vram))
if self.heads:
model.set("heads", str(self.heads))
dev.append(model)
return dev
class LibvirtConfigGuestHostdev(LibvirtConfigGuestDevice):
def __init__(self, **kwargs):
super(LibvirtConfigGuestHostdev, self).\