File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -692,6 +692,43 @@ download_ci_artifacts() {
692692 LOCAL_ARTIFACTS_PATH=$local_artifacts_path
693693}
694694
695+ # Attempt to load the appropriate KVM module for the current platform.
696+ # Returns 0 on success, non-zero on failure.
697+ #
698+ load_kvm () {
699+ local arch
700+ arch=$( uname -m)
701+
702+ case " $arch " in
703+ x86_64|i* 86)
704+ if grep -q " vmx" /proc/cpuinfo; then
705+ modprobe kvm_intel || return 1
706+ elif grep -q " svm" /proc/cpuinfo; then
707+ modprobe kvm_amd avic=1 || return 1
708+ else
709+ return 1
710+ fi
711+ ;;
712+ aarch64|arm* )
713+ modprobe kvm || return 1
714+ ;;
715+ * )
716+ return 1
717+ ;;
718+ esac
719+
720+ # Check /dev/kvm now exists
721+ [[ -c /dev/kvm ]]
722+ }
723+
724+ # Check if /dev/kvm exists. Attempt to load the module if it doesn't.
725+ # Exit if KVM is unavailable. Upon returning from this call, the caller
726+ # can be certain /dev/kvm is available.
727+ #
728+ ensure_kvm () {
729+ [[ -c /dev/kvm ]] || load_kvm || die " /dev/kvm not found. Aborting."
730+ }
731+
695732apply_linux_61_tweaks () {
696733 KV=$( uname -r)
697734 if [[ $KV != 6.1.* ]] || [ $( uname -m) != x86_64 ]; then
Original file line number Diff line number Diff line change @@ -125,44 +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- # Attempt to load the appropriate KVM module for the current platform.
134- # Returns 0 on success, non-zero on failure.
135- #
136- load_kvm() {
137- local arch
138- arch=$(uname -m)
139-
140- case "$arch" in
141- x86_64|i*86)
142- if grep -q "vmx" /proc/cpuinfo; then
143- modprobe kvm_intel || return 1
144- elif grep -q "svm" /proc/cpuinfo; then
145- modprobe kvm_amd avic=1 || return 1
146- else
147- return 1
148- fi
149- ;;
150- aarch64|arm*)
151- modprobe kvm || return 1
152- ;;
153- *)
154- return 1
155- ;;
156- esac
157-
158- # Check /dev/kvm now exists
159- [[ -c /dev/kvm ]]
160- }
161-
162- # Check if /dev/kvm exists. Attempt to load the module if it doesn't.
163- # Exit if KVM is unavailable. Upon returning from this call, the caller
164- # can be certain /dev/kvm is available.
165- #
166- ensure_kvm() {
167- [[ -c /dev/kvm ]] || load_kvm || die "/dev/kvm not found. Aborting."
168- }
You can’t perform that action at this time.
0 commit comments