yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
#! /bin/bash
26ba25
26ba25
kvm_setup_powerpc () {
26ba25
    if grep '^platform[[:space:]]*:[[:space:]]*PowerNV' /proc/cpuinfo > /dev/null; then
26ba25
	# PowerNV platform, which is KVM HV capable
26ba25
26ba25
	if [ -z "$SUBCORES" ]; then
26ba25
	    SUBCORES=1
26ba25
	fi
26ba25
26ba25
	# Step 1. Load the KVM HVmodule
26ba25
	if ! modprobe -b kvm_hv; then
26ba25
	    return
26ba25
	fi
26ba25
26ba25
	# On POWER8 a host core can only run threads of a single
26ba25
	# guest, meaning that SMT must be disabled on the host in
26ba25
	# order to run KVM guests. (Also applieds to POWER7, but we
26ba25
	# don't support that).
26ba25
	#
26ba25
	# POWER9 doesn't have this limitation (though it will for hash
26ba25
	# guests on radix host when that's implemented).  So, only set
26ba25
	# up subcores and disable SMT for POWER*.
26ba25
	if grep '^cpu[[:space:]]*:[[:space:]]*POWER8' /proc/cpuinfo > /dev/null; then
26ba25
	    # Step 2. Configure subcore mode
26ba25
	    /usr/sbin/ppc64_cpu --subcores-per-core=$SUBCORES
26ba25
26ba25
	    # Step 3. Disable SMT (multithreading)
26ba25
	    /usr/sbin/ppc64_cpu --smt=off
26ba25
	fi
26ba25
    fi
26ba25
}
26ba25
Pablo Greco e6a3ae
kvm_setup_s390x () {
Pablo Greco e6a3ae
    if grep -q "^features.*sie" /proc/cpuinfo; then
Pablo Greco e6a3ae
        modprobe kvm
Pablo Greco e6a3ae
    fi
Pablo Greco e6a3ae
}
Pablo Greco e6a3ae
26ba25
case $(uname -m) in
26ba25
    ppc64|ppc64le)
26ba25
	kvm_setup_powerpc
26ba25
	;;
Pablo Greco e6a3ae
    s390x)
Pablo Greco e6a3ae
	kvm_setup_s390x
Pablo Greco e6a3ae
	;;
26ba25
esac
26ba25
26ba25
exit 0