Skip to content

Instantly share code, notes, and snippets.

@sfan5 sfan5/build_qemu.sh
Last active Aug 13, 2019

Embed
What would you like to do?
#!/bin/bash -e
prefix=/opt/qemu
qemuver=4.0.0
targets=('x86_64' 'i386')
# install dependencies
apt-get install -y --no-install-recommends \
gcc make python pkg-config \
lib{gnutls28,jpeg,png,aio,jemalloc,cap-ng,glib2.0,pixman-1}-dev
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-{gnutls,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 /opt/qemu/etc/qemu
echo "allow all" >/opt/qemu/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-pci,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.