Skip to content

Commit

Permalink
make template VMs to use networkInterfaceMultiqueue
Browse files Browse the repository at this point in the history
This PR changes the template VM to be with
networkInterfaceMultiqueue, in order
to receive better network performances.
benefits and reasoning behind networkInterfaceMultiqueue
can be found here:
https://www.linux-kvm.org/page/Multiqueue#Multiqueue_virtio-net
The Windows template is still without networkInterfaceMultiqueue
since the CPU model it uses is e1000 which does not support networkInterfaceMultiqueue.

Signed-off-by: alonSadan <[email protected]>
  • Loading branch information
alonSadan committed Nov 5, 2019
1 parent 9223d49 commit e150b15
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/vm-template-fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ objects:
name: cloudinitdisk
interfaces:
- masquerade: {}
model: virtio
name: default
networkInterfaceMultiqueue: true
rng: {}
machine:
type: ""
Expand Down
2 changes: 2 additions & 0 deletions examples/vm-template-rhel7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ objects:
name: disk0
interfaces:
- masquerade: {}
model: virtio
name: default
networkInterfaceMultiqueue: true
machine:
type: ""
resources:
Expand Down
16 changes: 13 additions & 3 deletions tools/vms-generator/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ const (
imageCirros = "cirros-container-disk-demo"
imageFedora = "fedora-cloud-container-disk-demo"
)

const windowsFirmware = "5d307ca9-b3ef-428c-8861-06e72d69f223"
const defaultInterfaceName = "default"
const enableNetworkInterfaceMultiqueueForTemplate = true
const EthernetAdaptorModelToEnableMultiqueue = "virtio"

var DockerPrefix = "registry:5000/kubevirt"
var DockerTag = "devel"
Expand Down Expand Up @@ -124,15 +125,18 @@ func getBaseVMI(name string) *v1.VirtualMachineInstance {
func initFedora(spec *v1.VirtualMachineInstanceSpec) *v1.VirtualMachineInstanceSpec {
addContainerDisk(spec, fmt.Sprintf("%s/%s:%s", DockerPrefix, imageFedora, DockerTag), busVirtio)
addRNG(spec) // without RNG, newer fedora images may hang waiting for entropy sources

return spec
}
func enableNetworkInterfaceMultiqueue(spec *v1.VirtualMachineInstanceSpec, enable bool) {
spec.Domain.Devices.NetworkInterfaceMultiQueue = &enable
}

func setDefaultNetworkAndInterface(spec *v1.VirtualMachineInstanceSpec, bindingMethod v1.InterfaceBindingMethod, networkSource v1.NetworkSource) *v1.VirtualMachineInstanceSpec {
spec.Domain.Devices.Interfaces = []v1.Interface{
v1.Interface{
Name: defaultInterfaceName,
InterfaceBindingMethod: bindingMethod},
InterfaceBindingMethod: bindingMethod,
Model: EthernetAdaptorModelToEnableMultiqueue},
}
spec.Networks = []v1.Network{
v1.Network{
Expand Down Expand Up @@ -587,6 +591,8 @@ func GetTemplateFedora() *Template {
Pod: &v1.PodNetwork{},
})

enableNetworkInterfaceMultiqueue(spec, enableNetworkInterfaceMultiqueueForTemplate)

template := getBaseTemplate(vm, "4096Mi", "4")
template.ObjectMeta = metav1.ObjectMeta{
Name: VmTemplateFedora,
Expand All @@ -613,6 +619,8 @@ func GetTemplateRHEL7() *Template {
Pod: &v1.PodNetwork{},
})

enableNetworkInterfaceMultiqueue(spec, enableNetworkInterfaceMultiqueueForTemplate)

addPVCDisk(spec, "linux-vm-pvc-${NAME}", busVirtio, "disk0")
pvc := getPVCForTemplate("linux-vm-pvc-${NAME}")
template := newTemplateForRHEL7VM(vm)
Expand All @@ -631,6 +639,8 @@ func GetTestTemplateRHEL7() *Template {
Pod: &v1.PodNetwork{},
})

enableNetworkInterfaceMultiqueue(spec, enableNetworkInterfaceMultiqueueForTemplate)

return newTemplateForRHEL7VM(vm)
}

Expand Down

0 comments on commit e150b15

Please sign in to comment.