Default video type to 'vga' for PowerKVM

PowerKVM currently doesn't support 'cirrus' video type. For now, we can
detect if Nova compute is running on ppc64 or ppc architecture systems
and set the default to 'vga', which is supported on PowerKVM.

This patch did some reordering of the logic in
nova.virt.libvirt.driver.LibvirtDriver.get_guest_config in an attempt to
set the video.type depending on the compute host architecture and
implementation specifics. The video.type can still be set using
image_meta.

Change-Id: I49a1a8e6d9ebdc28d876d2f958c8cb960892f322
Closes-Bug: 1274367
This commit is contained in:
Lance Bragstad 2014-01-30 04:01:10 +00:00
parent 270c017d55
commit 852c7f3969
3 changed files with 51 additions and 5 deletions

View File

@ -204,3 +204,7 @@ def list_rbd_volumes(pool):
def remove_rbd_volumes(pool, *names):
pass
def get_arch(image_meta):
pass

View File

@ -1440,6 +1440,38 @@ class LibvirtConnTestCase(test.TestCase):
image_meta, disk_info)
self.assertEqual(cfg.os_cmdline, "fake_os_command_line")
def _test_get_guest_config_ppc64(self, device_index):
"""Test for nova.virt.libvirt.driver.LibvirtDriver.get_guest_config.
"""
self.flags(virt_type='kvm', group='libvirt')
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
instance_ref = db.instance_create(self.context, self.test_instance)
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
instance_ref)
image_meta = {}
expected = ('ppc64', 'ppc')
for arch in expected:
with mock.patch.object(libvirt_driver.libvirt_utils,
'get_arch',
return_value=arch):
cfg = conn.get_guest_config(instance_ref, [],
image_meta,
disk_info)
self.assertEqual(type(cfg.devices[device_index]),
vconfig.LibvirtConfigGuestVideo)
self.assertEqual(cfg.devices[device_index].type, 'vga')
def test_get_guest_config_ppc64_through_image_meta_vnc_enabled(self):
self.flags(vnc_enabled=True)
self._test_get_guest_config_ppc64(6)
def test_get_guest_config_ppc64_through_image_meta_spice_enabled(self):
self.flags(enabled=True,
agent_enabled=True,
group='spice')
self._test_get_guest_config_ppc64(8)
def test_get_guest_cpu_config_none(self):
self.flags(cpu_mode="none", group='libvirt')
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)

View File

@ -3230,17 +3230,27 @@ class LibvirtDriver(driver.ComputeDriver):
if add_video_driver:
VALID_VIDEO_DEVICES = ("vga", "cirrus", "vmvga", "xen", "qxl")
video = vconfig.LibvirtConfigGuestVideo()
meta_prop = image_meta.get('properties', {}) if image_meta else {}
# NOTE(ldbragst): The following logic sets the video.type
# depending on supported defaults given the architecture,
# virtualization type, and features. The video.type attribute can
# be overridden by the user with image_meta['properties'], which
# is carried out in the next if statement below this one.
arch = libvirt_utils.get_arch(image_meta)
if guest.os_type == vm_mode.XEN:
video.type = 'xen'
elif arch in ('ppc', 'ppc64'):
# NOTE(ldbragst): PowerKVM doesn't support 'cirrus' be default
# so use 'vga' instead when running on Power hardware.
video.type = 'vga'
elif CONF.spice.enabled:
video.type = 'qxl'
meta_prop = image_meta.get('properties', {}) if image_meta else {}
if meta_prop.get('hw_video_model'):
video.type = meta_prop.get('hw_video_model')
if (video.type not in VALID_VIDEO_DEVICES):
raise exception.InvalidVideoMode(model=video.type)
elif CONF.spice.enabled:
video.type = 'qxl'
if guest.os_type == vm_mode.XEN:
video.type = 'xen'
guest.add_device(video)
# Qemu guest agent only support 'qemu' and 'kvm' hypervisor