File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -583,6 +583,43 @@ ensure_ci_artifacts() {
583583 fi
584584}
585585
586+ # Attempt to load the appropriate KVM module for the current platform.
587+ # Returns 0 on success, non-zero on failure.
588+ #
589+ load_kvm () {
590+ local arch
591+ arch=$( uname -m)
592+
593+ case " $arch " in
594+ x86_64|i* 86)
595+ if grep -q " vmx" /proc/cpuinfo; then
596+ modprobe kvm_intel || return 1
597+ elif grep -q " svm" /proc/cpuinfo; then
598+ modprobe kvm_amd avic=1 || return 1
599+ else
600+ return 1
601+ fi
602+ ;;
603+ aarch64|arm* )
604+ modprobe kvm || return 1
605+ ;;
606+ * )
607+ return 1
608+ ;;
609+ esac
610+
611+ # Check /dev/kvm now exists
612+ [[ -c /dev/kvm ]]
613+ }
614+
615+ # Check if /dev/kvm exists. Attempt to load the module if it doesn't.
616+ # Exit if KVM is unavailable. Upon returning from this call, the caller
617+ # can be certain /dev/kvm is available.
618+ #
619+ ensure_kvm () {
620+ [[ -c /dev/kvm ]] || load_kvm || die " /dev/kvm not found. Aborting."
621+ }
622+
586623apply_linux_61_tweaks () {
587624 KV=$( uname -r)
588625 if [[ $KV != 6.1.* ]] || [ $( uname -m) != x86_64 ]; then
Original file line number Diff line number Diff line change @@ -125,15 +125,3 @@ function validate_version {
125125 die "Invalid version number: $version. Version should not contain \`wip\` or \`dirty\`."
126126 fi
127127}
128-
129- #########################
130- # Firecracker functions #
131- #########################
132-
133- # Check if /dev/kvm exists. Exit if it doesn't.
134- # Upon returning from this call, the caller can be certain /dev/kvm is
135- # available.
136- #
137- ensure_kvm() {
138- [[ -c /dev/kvm ]] || die "/dev/kvm not found. Aborting."
139- }
You can’t perform that action at this time.
0 commit comments