libvirt: add supported vif types for virtuozzo virt_type

Enable vif driver configuring for virtuozzo and make configuration
parameter use_virtio_for_bridges be usable for virtuozzo hypervisor.

Change-Id: Ied17a5406d5625f1e9f704e5b9b46d300f2870c2
Closes-Bug: #1635230
This commit is contained in:
Maxim Nestratov 2016-09-06 11:33:05 +03:00
parent f3d535b862
commit e5e4dfcfdb
3 changed files with 32 additions and 11 deletions

View File

@ -641,18 +641,31 @@ class LibvirtVifTestCase(test.NoDBTestCase):
xml = self._get_instance_xml(d, self.vif_bridge)
self._assertModel(xml, network_model.VIF_MODEL_VIRTIO)
def test_model_kvm_qemu_custom(self):
for virt in ('kvm', 'qemu'):
def test_model_parallels(self):
self.flags(use_virtio_for_bridges=True,
virt_type='parallels',
group='libvirt')
d = vif.LibvirtGenericVIFDriver()
xml = self._get_instance_xml(d, self.vif_bridge)
self._assertModel(xml, network_model.VIF_MODEL_VIRTIO)
def test_model_kvm_qemu_parallels_custom(self):
for virt in ('kvm', 'qemu', 'parallels'):
self.flags(use_virtio_for_bridges=True,
virt_type=virt,
group='libvirt')
d = vif.LibvirtGenericVIFDriver()
supported = (network_model.VIF_MODEL_NE2K_PCI,
network_model.VIF_MODEL_PCNET,
network_model.VIF_MODEL_RTL8139,
network_model.VIF_MODEL_E1000,
network_model.VIF_MODEL_SPAPR_VLAN)
if virt == 'parallels':
supported = (network_model.VIF_MODEL_RTL8139,
network_model.VIF_MODEL_E1000)
else:
supported = (network_model.VIF_MODEL_NE2K_PCI,
network_model.VIF_MODEL_PCNET,
network_model.VIF_MODEL_RTL8139,
network_model.VIF_MODEL_E1000,
network_model.VIF_MODEL_SPAPR_VLAN)
for model in supported:
image_meta = objects.ImageMeta.from_dict(
{'properties': {'hw_vif_model': model}})

View File

@ -68,6 +68,9 @@ def is_vif_model_valid_for_virt(virt_type, vif_model):
network_model.VIF_MODEL_E1000],
'lxc': [],
'uml': [],
'parallels': [network_model.VIF_MODEL_VIRTIO,
network_model.VIF_MODEL_RTL8139,
network_model.VIF_MODEL_E1000],
}
if vif_model is None:
@ -107,10 +110,10 @@ class LibvirtGenericVIFDriver(object):
if image_meta:
model = osinfo.HardwareProperties(image_meta).network_model
# Else if the virt type is KVM/QEMU, use virtio according
# to the global config parameter
# Else if the virt type is KVM/QEMU/VZ(Parallels), then use virtio
# according to the global config parameter
if (model is None and
virt_type in ('kvm', 'qemu') and
virt_type in ('kvm', 'qemu', 'parallels') and
CONF.libvirt.use_virtio_for_bridges):
model = network_model.VIF_MODEL_VIRTIO
@ -124,7 +127,7 @@ class LibvirtGenericVIFDriver(object):
model):
raise exception.UnsupportedHardware(model=model,
virt=virt_type)
if (virt_type == 'kvm' and
if (virt_type in ('kvm', 'parallels') and
model == network_model.VIF_MODEL_VIRTIO):
vhost_drv, vhost_queues = self._get_virtio_mq_settings(image_meta,
inst_type)

View File

@ -0,0 +1,5 @@
---
features:
- A list of valid vif models is extended for
Virtuozzo hypervisor (virt_type=parallels) with
VIRTIO, RTL8139 and E1000 models.