From e5e4dfcfdb918b57dcbd3e3cfb171e3b70e3c701 Mon Sep 17 00:00:00 2001 From: Maxim Nestratov Date: Tue, 6 Sep 2016 11:33:05 +0300 Subject: [PATCH] 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 --- nova/tests/unit/virt/libvirt/test_vif.py | 27 ++++++++++++++----- nova/virt/libvirt/vif.py | 11 +++++--- .../virtuozzo_vif_types-6e50217b295a1589.yaml | 5 ++++ 3 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 releasenotes/notes/virtuozzo_vif_types-6e50217b295a1589.yaml diff --git a/nova/tests/unit/virt/libvirt/test_vif.py b/nova/tests/unit/virt/libvirt/test_vif.py index 6972a594f378..a5638ada3770 100644 --- a/nova/tests/unit/virt/libvirt/test_vif.py +++ b/nova/tests/unit/virt/libvirt/test_vif.py @@ -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}}) diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index b1591ee143ed..5339a7b50f6d 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -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) diff --git a/releasenotes/notes/virtuozzo_vif_types-6e50217b295a1589.yaml b/releasenotes/notes/virtuozzo_vif_types-6e50217b295a1589.yaml new file mode 100644 index 000000000000..a3e9d3cd740e --- /dev/null +++ b/releasenotes/notes/virtuozzo_vif_types-6e50217b295a1589.yaml @@ -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.