From 68095d704d1aea94f5890f54eefa13929aab737c Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Tue, 26 Sep 2017 23:33:08 -0400 Subject: Fix RT KVM scenario Also change first-boot.yaml to handle updated kernel for rt kvm Change-Id: I66b7159731dd286c4a97ba4f3583e229afbb73b3 Signed-off-by: Feng Pan --- build/first-boot.yaml | 63 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 13 deletions(-) (limited to 'build/first-boot.yaml') diff --git a/build/first-boot.yaml b/build/first-boot.yaml index 1e8921ba..582981c0 100644 --- a/build/first-boot.yaml +++ b/build/first-boot.yaml @@ -16,6 +16,15 @@ parameters: "intel_iommu=on default_hugepagesz=2MB hugepagesz=2MB hugepages=2048" type: string default: "" + KVMForNFVKernelRPM: + description: > + Name of the kvmfornfv kernel rpm. + Example: "kvmfornfv_kernel.rpm" + type: string + default: "" + ComputeHostnameFormat: + type: string + default: "" resources: userdata: @@ -33,23 +42,51 @@ resources: template: | #!/bin/bash set -x - sed 's/^\(GRUB_CMDLINE_LINUX=".*\)"/\1 $KERNEL_ARGS"/g' \ - -i /etc/default/grub ; - grub2-mkconfig -o /etc/grub2.cfg - hugepage_count=$(echo $KERNEL_ARGS | \ - grep -oP ' ?hugepages=\K[0-9]+') - if [ -z "$hugepage_count" ]; then - hugepage_count=1024 + need_reboot='false' + + if [ -n "$KERNEL_ARGS" ]; then + sed 's/^\(GRUB_CMDLINE_LINUX=".*\)"/\1 $KERNEL_ARGS"/g' \ + -i /etc/default/grub ; + grub2-mkconfig -o /etc/grub2.cfg + hugepage_count=$(echo $KERNEL_ARGS | \ + grep -oP ' ?hugepages=\K[0-9]+') + if [ -z "$hugepage_count" ]; then + hugepage_count=1024 + fi + echo vm.hugetlb_shm_group=0 >> /usr/lib/sysctl.d/00-system.conf + HPAGE_CT=$(printf "%.0f" $(echo 2.2*$hugepage_count | bc)) + echo vm.max_map_count=$HPAGE_CT >> \ + /usr/lib/sysctl.d/00-system.conf + HPAGE_CT=$(($hugepage_count * 2 * 1024 * 1024)) + echo kernel.shmmax=$HPAGE_CT >> /usr/lib/sysctl.d/00-system.conf + need_reboot='true' + fi + + if [ -n "$KVMFORNFV_KERNEL_RPM" ]; then + FORMAT=$COMPUTE_HOSTNAME_FORMAT + if [[ -z $FORMAT ]] ; then + FORMAT="compute" ; + else + # Assumption: only %index% and %stackname% are + # the variables in Host name format + FORMAT=$(echo $FORMAT | sed 's/\%index\%//g'); + FORMAT=$(echo $FORMAT | sed 's/\%stackname\%//g'); + fi + if [[ $(hostname) == *$FORMAT* ]] ; then + yum install -y /root/$KVMFORNFV_KERNEL_RPM + grub2-mkconfig -o /etc/grub2.cfg + sleep 5 + need_reboot='true' + fi fi - echo vm.hugetlb_shm_group=0 >> /usr/lib/sysctl.d/00-system.conf - HPAGE_CT=$(printf "%.0f" $(echo 2.2*$hugepage_count | bc)) - echo vm.max_map_count=$HPAGE_CT >> /usr/lib/sysctl.d/00-system.conf - HPAGE_CT=$(($hugepage_count * 2 * 1024 * 1024)) - echo kernel.shmmax=$HPAGE_CT >> /usr/lib/sysctl.d/00-system.conf - reboot + if [ "$need_reboot" == "true" ]; then + reboot + fi params: $KERNEL_ARGS: {get_param: ComputeKernelArgs} + $KVMFORNFV_KERNEL_RPM: {get_param: KVMForNFVKernelRPM} + $COMPUTE_HOSTNAME_FORMAT: {get_param: ComputeHostnameFormat} outputs: OS::stack_id: -- cgit 1.2.3-korg