-
Install qemu-system-x86_64
-
Download Android-x86 RPM from https://www.fosshub.com/Android-x86.html
-
Extract the RPM (I'm using rpmextract from Arch, GitHub)
-
cd
into theandroid-[version]
directory from the RPM -
Create a backing image for the USB drive:
qemu-img create -f raw USB.img 4G
-
Use my adapted QEMU launcher script
-
Once it's booted up, you can use
adb connect localhost:5555
to install and test the app
Last active
January 13, 2020 17:11
-
-
Save depau/77b06b18320f511db8fdae58e8bceead to your computer and use it in GitHub Desktop.
Libaums QEMU setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# By Chih-Wei Huang <cwhuang@linux.org.tw> | |
# License: GNU Generic Public License v2 | |
continue_or_stop() | |
{ | |
echo "Please Enter to continue or Ctrl-C to stop." | |
read | |
} | |
QEMU_ARCH=`uname -m` | |
QEMU=qemu-system-${QEMU_ARCH} | |
which $QEMU > /dev/null 2>&1 || QEMU=qemu-system-i386 | |
if ! which $QEMU > /dev/null 2>&1; then | |
echo -e "Please install $QEMU to run the program.\n" | |
exit 1 | |
fi | |
#cd ${OUT:-bliss-x86-11.7} | |
[ -e system.img ] && SYSTEMIMG=system.img || SYSTEMIMG=system.sfs | |
if [ -d data ]; then | |
if [ `id -u` -eq 0 ]; then | |
DATA="-virtfs local,id=data,path=data,security_model=passthrough,mount_tag=data" | |
DATADEV='DATA=9p' | |
else | |
echo -e "\n$(realpath data) subfolder exists.\nIf you want to save data to it, run $0 as root:\n\n$ sudo $0\n" | |
continue_or_stop | |
fi | |
elif [ -e data.img ]; then | |
if [ -w data.img ]; then | |
DATA="-drive index=2,if=virtio,id=data,file=data.img" | |
DATADEV='DATA=vdc' | |
else | |
echo -e "\n$(realpath data.img) exists but is not writable.\nPlease grant the write permission if you want to save data to it.\n" | |
continue_or_stop | |
fi | |
fi | |
run_qemu_on_port() | |
{ | |
$QEMU -enable-kvm \ | |
-kernel kernel \ | |
-append "root=/dev/ram0 androidboot.selinux=permissive androidboot.hardware=android_x86_64 console=ttyS0 RAMDISK=vdb $DATADEV" \ | |
-initrd initrd.img \ | |
-m 2048 -smp 2 -cpu host \ | |
-usb -device usb-tablet,bus=usb-bus.0 \ | |
-soundhw ac97 \ | |
-boot menu=on \ | |
-drive index=0,if=virtio,id=system,file=$SYSTEMIMG,format=raw,readonly \ | |
-drive index=1,if=virtio,id=ramdisk,file=ramdisk.img,format=raw,readonly \ | |
-netdev user,id=mynet,hostfwd=tcp::$port-:5555 -device virtio-net-pci,netdev=mynet \ | |
-device nec-usb-xhci,id=xhci \ | |
-drive if=none,id=usbstick,file=usb.img,format=raw \ | |
-device usb-storage,id=usbdrive,bus=xhci.0,drive=usbstick \ | |
$DATA $@ | |
} | |
#-machine vmport=off \ | |
#-serial mon:stdio \ | |
run_qemu() | |
{ | |
port=5555 | |
while [ $port -lt 5600 ]; do | |
run_qemu_on_port $@ && break | |
let port++ | |
done | |
} | |
# Try to run QEMU in several VGA modes | |
#run_qemu -vga virtio -display sdl,gl=on $@ || \ | |
#run_qemu -vga qxl -display sdl,gl=on $@ -serial mon:stdio || \ | |
run_qemu -vga qxl -display gtk,gl=on $@ || \ | |
run_qemu -vga std -display sdl $@ || \ | |
run_qemu $@ |
Okay, connection to "VirtWIfi" did the trick!
Great! Let me know if you manage to make some progress :)
By the way, you can use this to pass through a real USB device (replace the emulated USB lines):
-device nec-usb-xhci,id=xhci -device usb-host,bus=xhci.0,hostbus=2,hostaddr=2
Of course replace hostbus, hostaddr with the USB device values, and chown the drive in /dev/bus/usb
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I always get "failed to connect", but with telnet I can see that the port is open. Any step I might be missing?