Skip to content

Instantly share code, notes, and snippets.

@sfan5 sfan5/build_qemu.sh

Last active Aug 3, 2020
Embed
What would you like to do?
#!/bin/bash -e
prefix=/opt/qemu
qemuver=5.0.0
targets=('x86_64' 'i386')
# install dependencies
which apt-get &>/dev/null && apt-get install -y --no-install-recommends \
gcc make python3 pkg-config bison flex \
lib{jpeg,png,aio,jemalloc,cap-ng,glib2.0,pixman-1}-dev
which pacman &>/dev/null && pacman -S --needed \
gcc make python pkg-config bison flex \
lib{jpeg-turbo,png,aio,cap-ng} jemalloc glib2 pixman
cd /var/tmp
# download
wget https://download.qemu.org/qemu-${qemuver}.tar.xz -O qemu.tar.xz
tar -xJf qemu.tar.xz
rm qemu.tar.xz
# build it!
pushd "qemu-${qemuver}"
target_list=""
for t in ${targets[@]}; do
target_list="$target_list${t}-softmmu,${t}-linux-user,"
done
./configure --prefix=$prefix \
--audio-drv-list= --enable-pie --extra-ldflags=-s \
--enable-{vnc-jpeg,vnc-png,linux-aio,jemalloc,cap-ng} \
--target-list=$target_list
nice make -j$(nproc)
# install it
make install
chmod u+s $prefix/libexec/qemu-bridge-helper
mkdir -p $prefix/etc/qemu
echo "allow all" >$prefix/etc/qemu/bridge.conf
# cleanup
popd
rm -rf "qemu-${qemuver}"
echo "Done, qemu has been installed to $prefix"
echo
echo "Example command line:"
echo "qemu-system-x86_64 -enable-kvm -drive file=disk.img,if=virtio -netdev bridge,id=net0 -device virtio-net,netdev=net0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.