libvirt: 'video.vram' property must be an integer
The 'vram' property of the 'video' device must be an integer else libvirt will spit the dummy out, e.g. libvirt.libvirtError: XML error: cannot parse video vram '8192.0' The division operator in Python 3 results in a float, not an integer like in Python 2. Use the truncation division operator instead. Change-Id: Iebf678c229da4f455459d068cafeee5f241aea1f Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Closes-Bug: #1896496 (cherry picked from commitf2ca089bce
) (cherry picked from commitfd7c66f61c
)
This commit is contained in:
parent
845c383b93
commit
121e481a88
|
@ -6200,7 +6200,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
|
||||
self.assertEqual(cfg.devices[4].type, "spice")
|
||||
self.assertEqual(cfg.devices[5].type, "qxl")
|
||||
self.assertEqual(cfg.devices[5].vram, 64 * units.Mi / units.Ki)
|
||||
self.assertEqual(cfg.devices[5].vram, 65536)
|
||||
|
||||
def _test_add_video_driver(self, model):
|
||||
self.flags(virt_type='kvm', group='libvirt')
|
||||
|
@ -6211,15 +6211,19 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
guest = vconfig.LibvirtConfigGuest()
|
||||
instance_ref = objects.Instance(**self.test_instance)
|
||||
flavor = instance_ref.get_flavor()
|
||||
flavor = objects.Flavor(
|
||||
extra_specs={'hw_video:ram_max_mb': '512'})
|
||||
image_meta = objects.ImageMeta.from_dict({
|
||||
'properties': {'hw_video_model': model}})
|
||||
'properties': {
|
||||
'hw_video_model': model,
|
||||
'hw_video_ram': 8,
|
||||
},
|
||||
})
|
||||
|
||||
self.assertTrue(drvr._guest_add_video_device(guest))
|
||||
video = drvr._add_video_driver(guest, image_meta,
|
||||
flavor)
|
||||
video = drvr._add_video_driver(guest, image_meta, flavor)
|
||||
self.assertEqual(model, video.type)
|
||||
self.assertEqual(8192, video.vram) # should be in bytes
|
||||
|
||||
def test__add_video_driver(self):
|
||||
self._test_add_video_driver('qxl')
|
||||
|
|
|
@ -5412,7 +5412,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
raise exception.RequestedVRamTooHigh(req_vram=video_ram,
|
||||
max_vram=max_vram)
|
||||
if max_vram and video_ram:
|
||||
video.vram = video_ram * units.Mi / units.Ki
|
||||
video.vram = video_ram * units.Mi // units.Ki
|
||||
guest.add_device(video)
|
||||
|
||||
# NOTE(sean-k-mooney): return the video device we added
|
||||
|
|
Loading…
Reference in New Issue