Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:guide-user:virtualization:qemu_host [2018/07/02 08:32] – [Init script] add check before deleting pidfile, some small fixes sebastiandocs:guide-user:virtualization:qemu_host [2022/05/30 09:04] (current) – [Download installer files] use https sebastian
Line 1: Line 1:
-====== Running QEMU guests on OpenWrt ======+====== OpenWrt as QEMU/KVM host server ======
  
 ===== Introduction ===== ===== Introduction =====
-It's possible to use OpenWrt as a QEMU host and run guests on it. If you want to run OpenWrt as a QEMU guest, see [[docs:guide-user:virtualization:qemu|OpenWrt in QEMU]].+It's possible to use OpenWrt as a QEMU host and run guests on it. If you want to run OpenWrt as a QEMU guest itself, see [[docs:guide-user:virtualization:qemu|OpenWrt in QEMU]].
  
 OpenWrt provides QEMU packages for ARM and x86 platforms. This article focuses on the x86 target, the networking is done via [[https://wiki.qemu.org/Features/HelperNetworking|qemu-bridge-helper]]. OpenWrt provides QEMU packages for ARM and x86 platforms. This article focuses on the x86 target, the networking is done via [[https://wiki.qemu.org/Features/HelperNetworking|qemu-bridge-helper]].
Line 42: Line 42:
 ==== Download installer files ==== ==== Download installer files ====
 <code bash> <code bash>
-wget http://ftp.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux +wget https://ftp.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux 
-wget http://ftp.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz+wget https://ftp.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz
 </code> </code>
 Both files can be savely removed after finishing the installation. Both files can be savely removed after finishing the installation.
Line 95: Line 95:
  -daemonize &> /var/log/qemu.log  -daemonize &> /var/log/qemu.log
  
-echo $! > $qemu_pidfile+/usr/bin/pgrep qemu-system-x86_64 > $qemu_pidfile
 echo "QEMU: Started VM with PID $(cat $qemu_pidfile)." echo "QEMU: Started VM with PID $(cat $qemu_pidfile)."
 } }
Line 106: Line 106:
 QMP QMP
  
-if [ -e /proc/$(cat $qemu_pidfile) ]; then +if [ -e $qemu_pidfile ]; then 
- echo "QEMU: Waiting for VM shutdown." + if [ -e /proc/$(cat $qemu_pidfile) ]; then 
- while [ -e /proc/$(cat $qemu_pidfile) ]; do sleep 1s; done + echo "QEMU: Waiting for VM shutdown." 
- echo "QEMU: VM Process $(cat $qemu_pidfile) finished." + while [ -e /proc/$(cat $qemu_pidfile) ]; do sleep 1s; done 
-else + echo "QEMU: VM Process $(cat $qemu_pidfile) finished." 
- echo "QEMU: Error: No VM with PID $(cat $qemu_pidfile) running." + else 
-fi+ echo "QEMU: Error: No VM with PID $(cat $qemu_pidfile) running." 
 + fi
  
-if [ -e $qemu_pidfile ]; then 
  rm -f $qemu_pidfile  rm -f $qemu_pidfile
 else else
Line 124: Line 124:
 Test the the script by running ''/etc/init.d/qemu start'' and look for errors in ''/var/log/qemu.log''. Test the the script by running ''/etc/init.d/qemu start'' and look for errors in ''/var/log/qemu.log''.
 If the script works as desired, enable it for every boot: ''/etc/init.d/qemu enable'' If the script works as desired, enable it for every boot: ''/etc/init.d/qemu enable''
 +
 +FIXME This script needs to be ported to [[:docs:guide-developer:procd-init-scripts|procd]]. Problem: [[:docs:guide-developer:procd-init-scripts#stopping_services|stop_service() is called after procd killed the service]], but we must run it beforehand to let the VM shut down.
  • Last modified: 2018/07/02 08:32
  • by sebastian