+ All Categories
Home > Documents > A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization...

A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization...

Date post: 09-Feb-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
22
Nested Virtualization with OpenNebula (and PCI Passthrough) A Practical Approach Venko Moyankov OpenNebulaConf 2019 Barcelona, October 21-22
Transcript
Page 1: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Nested Virtualization with OpenNebula(and PCI Passthrough)

A Practical Approach

Venko MoyankovOpenNebulaConf 2019

Barcelona, October 21-22

Page 2: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

The Problem

KVM KVM KVM

KVM KVM KVM

KVM KVM KVM

KVM KVM KVM

H-V H-V H-V

XEN XEN XEN

Page 3: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

KVMKVM

StorPool Lab

KVM KVM KVM

KVM KVM KVM

KVM KVM KVM

KVM KVM KVM

also and more ...

H-V H-V H-V

XEN XEN XEN

Page 4: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

The Technologies Behind● Hardware virtualization (VT-x)● Nested Virtualization● VMCS Shadowing● IOMMU (PCI Passthrough)● SR-IOV● ACS (IOMMU groups)● OpenNebula PCI Passthrough● libvirt Domain XML tweaks (VF Net only)

Host

OpenNebula

Page 5: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Hardware VirtualizationVT-x

AMD-V or SVM

All CPUs, but may need to enable it in BIOS

Page 6: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Nested VirtualizationEnables hardware virtualization in the guest

KVM feature

Page 7: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

VMCS Shadowing● Hardware feature ● Accelerates nested virtualization● Available in most CPUs since 2013 (Haswell)

Source: https://software.intel.com/en-us/blogs/2014/12/12/enabling-virtual-machine-control-structure-shadowing-on-a-nested-virtual-machine

Page 8: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

PCI PassthroughAllows guests to have direct

exclusive access to PCI devices

● I/O MMU virtualization (IOMMU)VT-dAMD-Vi

Mostly used for GPU and NIC

Host

GPU1

Hypervisor / VMM

VM

Hostdriver

driver

VM

driver

VM

driver

GPU2 GPU3GPU0

PCIe

IOMMU / VT-d

Page 9: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

SR-IOV● Single Root I/O Virtualization● One physical device appears as

multiple virtual functions (VF)● Allows different VMs to share a

single PCIe hardware● Mostly used for NIC

Host

NICVF1

Hypervisor / VMM

VM

Hostdriver

driver

VM

driver

VM

driver

VF2 VF3PF

PCIe

IOMMU / VT-d

Page 10: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

ACS and IOMMU GroupsHost

GPU1

Hypervisor / VMM

VM

Hostdriver

driver

VMVM

driver

VM

driver

GPU2 GPU3GPU0

IOMMU / VT-dRAM

ACS

PCIe

Page 11: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Let's Do It

Page 12: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

HostHardware VirtualizationCheck it is available with: lscpu | grep vmx

Nested Virtualizationkvm-intel.conf: options kvm-intel nested=1Check it in the guest with: lscpu | grep vmx

VMCS Shadowingkvm-intel.conf: options kvm-intel enable_shadow_vmcs=1

Page 13: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

PCI Passthrough & SR-IOVPCI PassthroughEnabled via kernel options:

Intel:intel_iommu=on iommu=pt

AMD:amd_iommu=pt

SR-IOV● Ensure SR-IOV and VT-d are enabled in BIOS.

● Setup VFs:# echo '8' > /sys/class/net/eth3/device/sriov_numvfs

Page 14: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

ACS and IOMMU Groups● Check ACS is supportedlspci -vv | egrep “Access Control Services”

https://heiko-sieger.info/iommu-groups-what-you-need-to-consider/

● Check IOMMU groupsfor a in /sys/kernel/iommu_groups/*; do find $a -type l; done | sort --version-sort

Page 15: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Congratulations!

You are ready to run Nested Virtualization !

Almost

Page 16: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Enable PCI passthrough in OpenNebula

/var/lib/one/remotes/im/kvm-probes.d/pci.rb/var/lib/one/remotes/etc/im/kvm-probes.d/pci.conf

:filter: '15b3:1018':short_address: []:device_name: []

Page 17: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization
Page 18: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Tweak domain.xml<hostdev mode='subsystem' type='pci' managed='yes'> <source> <address domain='0x0000' bus='0xd8' slot='0x00' function='0x5'/> </source> <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0'/></hostdev>

<interface managed="yes" type="hostdev"> <driver name="vfio" /> <mac address="02:00:11:ab:cd:01" /> <source> <address bus="0xd8" domain="0x0000" function="0x5" slot="0x00" type="pci" /> </source> <address bus="0x01" domain="0x0000" function="0" slot="0x01" type="pci" /></interface>

https://github.com/OpenNebula/addon-storpool/blob/master/docs/advanced_configuration.md#vms-domain-xml-tweaking

Page 19: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

OpenNebula

Page 20: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Summary

CPU BIOS Kernel KVM OpenNebula

VT-x 🗸 🗸

Nested Virt. 🗸

VMCS Shadowing 🗸 🗸 🗸

IOMMU (PCI Passthrough) 🗸 🗸 🗸 🗸

SR-IOV 🗸 🗸

ACS (IOMMU groups) 🗸

libvirt Domain XML (VF Net only) 🗸

Page 21: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Q&A

Page 22: A Practical Approach (and PCI Passthrough) Venko Moyankov ......OpenNebula. Hardware Virtualization VT-x AMD-V or SVM All CPUs, but may need to enable it in BIOS. Nested Virtualization

Venko Moyankov [email protected]

StorPool Storagewww.storpool.com

@storpool

Thank you!


Recommended