Skip to content

Commit

Permalink
Move hostarch update code from build-vm-kvm to build-vm
Browse files Browse the repository at this point in the history
The code is not kvm specific...
  • Loading branch information
mlschroe committed Apr 28, 2015
1 parent 98b0eac commit 8fc795d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
29 changes: 29 additions & 0 deletions build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,30 @@ vm_setup() {
fi
}

vm_update_hostarch() {
local kernel="$vm_kernel"
local hostarchfile
local newhostarch
if test -z "$VM_KERNEL" -a -e "$BUILD_ROOT/.build.kernel.$VM_TYPE" ; then
kernel="$BUILD_ROOT/.build.kernel.$VM_TYPE"
hostarchfile="$BUILD_ROOT/.build.hostarch.$VM_TYPE"
fi
if test -n "$hostarchfile" -a -e "$hostarchfile"; then
newhostarch=`cat "$hostarchfile"`
elif test -n "$kernel" -a -e "$kernel" ; then
case `objdump -f "$kernel" | sed -ne 's/.*file format //p'` in
elf64-powerpcle) newhostarch=ppc64le ;;
elf64-powerpc) newhostarch=ppc64 ;;
esac
fi
if test -n "$newhostarch" -a "$newhostarch" != "$BUILD_HOST_ARCH" ; then
echo "setting hostarch to $newhostarch"
BUILD_HOST_ARCH="$newhostarch"
# update BUILD_INITVM_ARCH
build_host_arch
fi
}

#
# prepare for vm startup
#
Expand Down Expand Up @@ -639,6 +663,11 @@ vm_first_stage() {
# do vm specific fixups
vm_fixup

# update the hostarch
if test -n "$VM_IMAGE" ; then
vm_update_hostarch
fi

# the watchdog needs a log file
test -n "$LOGFILE" || VM_WATCHDOG=
# put our config into .build/build.data
Expand Down
11 changes: 0 additions & 11 deletions build-vm-kvm
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,6 @@ vm_fixup_kvm() {
qemu_rootdev=/dev/disk/by-id/virtio-0
VM_SWAPDEV=/dev/disk/by-id/virtio-1
fi
if test -e "$BUILD_ROOT/.build.hostarch.$VM_TYPE" ; then
BUILD_HOST_ARCH=`cat "$BUILD_ROOT/.build.hostarch.$VM_TYPE"`
else
# do autodetection for ppc/ppc64le switching, legacy
case `objdump -f "$BUILD_ROOT/.build.kernel.$VM_TYPE" | sed -ne 's/.*file format //p'` in
elf64-powerpcle) BUILD_HOST_ARCH=ppc64le ;;
elf64-powerpc) BUILD_HOST_ARCH=ppc64 ;;
esac
fi
# set BUILD_INITVM_ARCH
build_host_arch
fi
}

Expand Down

0 comments on commit 8fc795d

Please sign in to comment.