From 1e2311043ead1e07b3f22d4704959faa08edfb87 Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Mon, 15 Oct 2018 10:10:54 -0700 Subject: Improve setup.sh script The setup.sh script contains instructions to configure and install dependencies for this project. This change includes instructions to enable nested-virtualization. Change-Id: I35b66d08f0e3813d18e661f73edc04fd2cf585fe Signed-off-by: Victor Morales Issue-ID: MULTICLOUD-301 --- vagrant/setup.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/vagrant/setup.sh b/vagrant/setup.sh index 85900fda..2dfae83b 100755 --- a/vagrant/setup.sh +++ b/vagrant/setup.sh @@ -114,7 +114,7 @@ case ${ID,,} in ;; libvirt) # vagrant-libvirt dependencies - packages+=(qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev) + packages+=(qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev cpu-checker) # NFS packages+=(nfs-kernel-server) ;; @@ -153,6 +153,27 @@ case ${ID,,} in esac +# Enable Nested-Virtualization +vendor_id=$(lscpu|grep "Vendor ID") +if [[ $vendor_id == *GenuineIntel* ]]; then + kvm_ok=$(cat /sys/module/kvm_intel/parameters/nested) + if [[ $kvm_ok == 'N' ]]; then + echo "Enable Intel Nested-Virtualization" + rmmod kvm-intel + echo 'options kvm-intel nested=y' >> /etc/modprobe.d/dist.conf + modprobe kvm-intel + fi +else + kvm_ok=$(cat /sys/module/kvm_amd/parameters/nested) + if [[ $kvm_ok == '0' ]]; then + echo "Enable AMD Nested-Virtualization" + rmmod kvm-amd + sh -c "echo 'options kvm-amd nested=1' >> /etc/modprobe.d/dist.conf" + modprobe kvm-amd + fi +fi +modprobe vhost_net + ${INSTALLER_CMD} ${packages[@]} if ! which pip; then curl -sL https://bootstrap.pypa.io/get-pip.py | sudo python @@ -166,4 +187,5 @@ if [ $VAGRANT_DEFAULT_PROVIDER == libvirt ]; then vagrant plugin install vagrant-libvirt sudo usermod -a -G $libvirt_group $USER # This might require to reload user's group assigments sudo systemctl restart libvirtd + kvm-ok fi -- cgit 1.2.3-korg