add kvm for ppc64
authorDinar Valeev <dvaleev@suse.de>
Mon, 26 Sep 2011 20:45:17 +0000 (22:45 +0200)
committerAdrian Schröter <adrian@suse.de>
Thu, 29 Sep 2011 16:22:33 +0000 (18:22 +0200)
build

diff --git a/build b/build
index abad54e..3edbccd 100755 (executable)
--- a/build
+++ b/build
@@ -40,6 +40,9 @@ kvm_bin=/usr/bin/qemu-kvm
 # whether we have virtio support
 kvm_virtio=
 
+# guest visible console device name
+console=ttyS0
+
 # need to restore build root owner for non-root builds
 browner=0
 
@@ -84,6 +87,7 @@ RSYNCSRC=
 RSYNCDEST=
 RSYNCDONE=
 SIGNDUMMY=
+HOST_ARCH=
 
 # list of archs which need emulator initialization
 : ${EMULATOR_ARCHS:="armv4l armv5el armv6el armv7el armv7hl armv8el mips mipsel mips64 mips64el ppc ppc64 sh4 sparc sparc64 s390 s390x"}
@@ -680,6 +684,29 @@ linux64()
        perl -e 'syscall('$PERSONALITY_SYSCALL', 0); exec(@ARGV) || die("$ARGV[0]: $!\n")' "$@"
 }
 
+check_for_ppc()
+{
+    local uname
+
+    uname=$(uname -m)
+
+    if [ "$uname" != "ppc" -a "$uname" != "ppc64" ]; then
+        return
+    fi
+
+    export HOST_ARCH=ppc
+
+    # XXX is this ok for ppc32 hosts? do we care?
+    export kvm_bin="/usr/bin/qemu-system-ppc64"
+    export console=hvc0
+    # XXX check host CPU and adjust guest CPU accordingly
+    export KVM_OPTIONS="-enable-kvm -M pseries -cpu 970mp -m 512 -mem-path /hugetlbfs"
+    export VM_KERNEL=/root/obs_kernel/vmlinux
+    export VM_INITRD=/root/obs_kernel/initrd
+
+    # XXX complain when hugetlbfs is not mounted
+}
+
 #### main ####
 
 trap fail_exit EXIT
@@ -689,6 +716,8 @@ case `perl -V:archname` in
     *i?86*)   PERSONALITY_SYSCALL=136 ;;
 esac
 
+check_for_ppc
+
 shopt -s nullglob
 
 if detect_vm_2nd_stage ; then
@@ -1043,7 +1072,7 @@ if [ "$VM_TYPE" = 'xen' -a -z "$RUNNING_IN_VM" ]; then
 fi
 
 if [ "$VM_TYPE" = 'kvm' -a -z "$RUNNING_IN_VM" ]; then
-    if [ ! -r /dev/kvm -o ! -x "$qemu_bin"-kvm ]; then
+    if [ ! -r /dev/kvm -o ! -x "$kvm_bin" ]; then
        echo "host doesn't support kvm"
        echo "either the kvm kernel-module is not loaded or kvm is not installed or hardware virtualization is deactivated in the BIOS."
        cleanup_and_exit 3
@@ -1100,6 +1129,11 @@ if [ "$VM_TYPE" = 'kvm' -a -z "$RUNNING_IN_VM" ]; then
        fi
     fi
 
+    if [ "$HOST_ARCH" = ppc ]; then
+        # KVM on PPC can not run virtio yet, so we need to use the default vio
+        kvm_virtio=
+    fi
+
     if [ "$kvm_virtio" = 1 ]; then
        VM_SWAPDEV=/dev/vdb
        qemu_rootdev=/dev/vda
@@ -1522,7 +1556,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do
                set -- $qemu_bin -no-reboot -nographic -net none $KVM_OPTIONS \
                    -kernel $vm_kernel \
                    -initrd $vm_initrd \
-                   -append "root=$qemu_rootdev panic=1 quiet no-kvmclock rw elevator=noop console=ttyS0 init=$vm_init_script" \
+                   -append "root=$qemu_rootdev panic=1 quiet no-kvmclock rw elevator=noop console=$console init=$vm_init_script" \
                    ${MEMSIZE:+-m $MEMSIZE} \
                    "${qemu_args[@]}"