Hello, I use qemu 5.2. This expect script:
#!/usr/bin/expect -f set timeout -1 spawn qemu-system-arm -dtb ./versatile-pb-buster.dtb -kernel ./kernel-qemu-4.19.50-buster -cpu arm1176 -m 256 -M versatilepb -append "root=/dev/sda2 rootfstype=ext4 rw" -drive driver=raw,file=2021-01-11-raspios-buster-armhf.img,index=0,media=disk -nographic expect "login: " send "pi\n" expect "Password: " send "raspberry\n" expect "$ " send "sudo poweroff\n" expect "panic" exec kill -9 [exp_pid] close send_user "THE END\n" --- called with `time` ends with the text ---- [ OK ] Stopped Create System Users. [ OK ] Stopped Remount Root and Kernel File Systems. [ OK ] Reached target Shutdown. [ OK ] Reached target Final Step. [ OK ] Started Power-Off. [ OK ] Reached target Power-Off. reboot: System halted Kernel panic - not syncTHE END real 2m16.174s user 0m0.092s sys 0m5.359s ------ but the same script without the panic line, when called with `time` ends with: raspberrypi login: pi Password: Last login: Wed Jan 27 21:16:53 GMT 2021 on tty1 Linux raspberrypi 4.19.50+ #1 Tue Nov 26 01:49:16 CET 2019 armv6l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. pi@raspberrypi:~$ THE END real 2m2.526s user 0m0.083s sys 0m5.187s So my understanding is, to answer the question I raised here 22nd January, once all send commands are executed and there are no more expect commands waiting, the spawned process (here qemu-system-arm) is terminated by expect, before the qemu-process finishes voluntary. In fact, the kill and close lines are not necessary, this script: #!/usr/bin/expect -f set timeout -1 exec cp E/2021-01-11-raspios-buster-armhf.img . spawn qemu-system-arm -dtb ./versatile-pb-buster.dtb -kernel ./kernel-qemu-4.19.50-buster -cpu arm1176 -m 256 -M versatilepb -append "root=/dev/sda2 rootfstype=ext4 rw" -drive driver=raw,file=2021-01-11-raspios-buster-armhf.img,index=0,media=disk -nographic #-D qemu_log -trace file=f expect "login: " send "pi\n" expect "Password: " send "raspberry\n" expect "$ " send "sudo poweroff\n" expect "panic" send_user "THE END\n" called with time, ends in: [ OK ] Stopped Create System Users. [ OK ] Stopped Remount Root and Kernel File Systems. [ OK ] Reached target Shutdown. [ OK ] Reached target Final Step. [ OK ] Started Power-Off. [ OK ] Reached target Power-Off. reboot: System halted Kernel panic - not syncing: Attempted to kill THE END real 2m12.832s user 0m0.075s sys 0m5.102s Greetings Дилян Greetings Дилян Am Freitag, dem 22.01.2021 um 20:02 +0000 schrieb Dilyan Palauzov: > Hello Philippe, > > thanks for your answer. > > I wrote the expect script some days ago and I have not used older > versions. > > Setting `export DEBIAN_FRONTEND=noninteractive` does not help. > > I start > > time (unzip -o 2021-01-11-raspios-buster-armhf.zip && date && > ./bootstrap&& echo $? && date) > > > When I run the script below, without the `interact` command, the last > lines are: > ----------- > > EOF > root@raspberrypi:/home/pi# echo Q1 > Q1 > root@raspberrypi:/home/pi# apt-get clean > root@raspberrypi:/home/pi# echo Q2 > Q2 > root@raspberrypi:/home/pi# cat /dev/zero > zero.file > cat: write error: No space left on device > root@raspberrypi:/home/pi# sync > root@raspberrypi:/home/pi# echo Q3 > Q3 > root@raspberrypi:/home/pi# 0 > Fri Jan 22 09:24:12 PM EET 2021 > > real 25m19.685s > user 0m31.094s > sys 0m4.049s > > ------------ > So why is `echo $0` executed within the VM and why does the VM > terminate after all? Calling `sudo poweroff` causes kernel panic, but > on the output above there is no kernel panic. > > When I uncomment the 'interact' line, and rerun > > > time (unzip -o 2021-01-11-raspios-buster-armhf.zip && date && > ./bootstrap&& echo $? && date) > > the last output is: > ---------------- > cat: write error: No space left on device > root@raspberrypi:/home/pi# sync > root@raspberrypi:/home/pi# echo Q3 > Q3 > root@raspberrypi:/home/pi# rm zero.file > root@raspberrypi:/home/pi# sync > root@raspberrypi:/home/pi# sleep 3 > root@raspberrypi:/home/pi# > ---------------- > > Do you have any ideas? > > Kind regards > Dilyan > > -------------- bootstrap ----------------- > #!/usr/bin/expect -f > #TODO Set WIRELESS LAN COUNTRY > set IMG "2021-01-11-raspios-buster-armhf.img" > set lang "bg_BG" > set TZ "Europe/Sofia" > set URL "https://abc.de/t?h" > set NTP_SERVERS "0.bg.pool.ntp.org 1.bg.pool.ntp.org 2.bg.pool.ntp.org > 3.bg.pool.ntp.org" > set timeout -1 > spawn qemu-system-arm -dtb ./versatile-pb-buster.dtb -kernel > ./kernel-qemu-4.19.50-buster -cpu arm1176 -m 256 -M versatilepb > -append "root=/dev/sda2 rootfstype=ext4 rw" -drive > driver=raw,file=$IMG,index=0,media=disk -nographic > #-netdev user,id=net0,hostfwd=tcp::10022-:22 > expect "login: " > send "pi\n" > expect "Password: " > send "raspberry\n" > send "sudo bash\n" > send "export DEBIAN_FRONTEND=noninteractive\n" > send "swapoff -a\n" > send "sed -i '1 sK^{\$K{ > \"homepage\":\"$URL\",\"session\":{\"restore_on_startup\": 4, > \"startup_urls\":\[\"$URL\"\]},K' > /usr/lib/chromium-browser/master_preferences\n" > send "systemctl stop systemd-journal-flush systemd-journald\n" > send "rm -r /etc/xdg/autostart/piwiz.desktop > /etc/xdg/autostart/print-applet.desktop > /etc/xdg/autostart/pulseaudio.desktop > /etc/xdg/lxsession/LXDE-pi/autostart > /usr/share/rpd-wallpaper/\[a-sw\]* /home/pi/Bookshelf > /run/log/journal\n" > send "timedatectl set-timezone $TZ\n" > send "systemctl disable systemd-journal-flush nfs-client.target > systemd-journald apt-daily-upgrade.timer apt-daily.timer > remote-fs.target\n" > expect "# " > send "sed -i 's/#\ $lang.UTF-8 UTF-8/$lang.UTF-8 UTF-8/' > /etc/locale.gen\n" > send "echo \"$URL\" > /home/pi/Desktop/URL.txt\n" > send "locale-gen\n" > expect "Generation complete." > send "update-locale LANG=$lang.UTF-8 LC_ALL=$lang.UTF-8 > LANGUAGE=$lang.UTF-8\n" > #expect "# " > send "apt-get update\n" > send "apt-get install -V unclutter\n" > expect "Setting up unclutter " > expect "# " > send "apt-get purge -V -y --autoremove thonny lxplug-bluetooth vlc > cups cups-common cups-daemon ffmpeg gdb git gcc binutils pulseaudio > make manpages dillo galculator geany strace man-db aspell ghostscript > gpicview rp-bookshelf gstreamer1.0-alsa gstreamer1.0-plugins-good > gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-x > gstreamer1.0-omx gstreamer1.0-libav xarchiver system-config-printer > rsyslog logrotate rfkill cron bluez blt groff-base gvfs luajit > cifs-utils debian-reference-common dh-python\n" > expect "Removing thonny" > expect "# " > #send "apt-get autoremove --purge -y -V\n" > # expect "Reading package lists..." > # expect "# " > send "apt-get upgrade -y -V\n" > expect -re "The following packages will be upgraded:|0 upgraded, 0 > newly installed, 0 to remove and 0 not upgraded." > expect "# " > send "echo 'FallbackNTP=$NTP_SERVERS' >> /etc/systemd/timesyncd.conf\n" > expect "# " > send "cat > /etc/xdg/lxsession/LXDE-pi/autostart << EOF\n" > send "@lxpanel --profile LXDE-pi\n" > send "@pcmanfm --desktop --profile LXDE-pi\n" > send "#@unclutter -idle 10\n" > send "@xset s off\n" > send "@xset -dpms\n" > send "@xset s noblank\n" > send "/usr/bin/chromium-browser --no-sandbox --no-first-run --kiosk\n" > send "EOF\n" > send "echo Q1\n" > expect "Q1" > expect "# " > send "apt-get clean\n" > send "echo Q2\n" > expect "Q2" > expect "# " > send "cat /dev/zero > zero.file\n" > send "sync\n" > send "echo Q3\n" > expect "Q3" > expect "# " > send "rm zero.file\n" > #expect "# " > send "sync\n" > send "sleep 3\n" > interact > #send "poweroff\n" > > > > > > > > > > > > > > > > > > > > > > > ----- Message from Philippe Mathieu-Daudé <f4...@amsat.org> --------- > Date: Fri, 22 Jan 2021 15:26:10 +0100 > From: Philippe Mathieu-Daudé <f4...@amsat.org> > Subject: Re: qemu + expect + Raspberry Pi = sudden stop of accepting > commands > To: Dilyan Palauzov <dilyan.palau...@aegee.org>, > qemu-discuss@nongnu.org > > > > Hi Dilyan, > > > > On 1/22/21 2:01 PM, Dilyan Palauzov wrote: > > > Hello, > > > > > ... > > > > > root@raspberrypi:/home/pi# echo Q1 > > > Q1 > > > root@raspberrypi:/home/pi# apt-get clean > > > root@raspberrypi:/home/pi# > > > real 23m20.381s > > > user 0m29.330s > > > sys 0m3.832s > > > --------------- > > > > > > Thus the last commands from the expect script are not executed. > > > > > > Why are the last commands from the expect script not executed any > > > why > > > does qemu terminate? I use version 5.1.0 coming with Fedora. > > > > Was your script working before on an earlier version? > > > > > Any help will be highly appreciated, as I could not figure this out > > > myself for several days. > > > > > > Kind regards > > > Дилян > > > > > > > > > > > > -------------- bootstrap script ---------- > > > #!/usr/bin/expect -f > > > #TODO Set WIRELESS LAN COUNTRY > > > set IMG "2021-01-11-raspios-buster-armhf.img" > > > set lang "bg_BG" > > > set TZ "Europe/Sofia" > > > set URL "https://www.abc.de/t?h" > > > set NTP_SERVERS "0.bg.pool.ntp.org 1.bg.pool.ntp.org > > > 2.bg.pool.ntp.org > > > 3.bg.pool.ntp.org" > > > set timeout -1 > > > spawn qemu-system-arm -dtb ./versatile-pb-buster.dtb -kernel > > > ./kernel-qemu-4.19.50-buster -cpu arm1176 -m 256 -M versatilepb - > > > append > > > "root=/dev/sda2 rootfstype=ext4 rw" -drive > > > driver=raw,file=$IMG,index=0,media=disk -nographic > > > #-netdev user,id=net0,hostfwd=tcp::10022-:22 > > ... > > > > > send "cat > /etc/xdg/lxsession/LXDE-pi/autostart << EOF\n" > > > send "@lxpanel --profile LXDE-pi\n" > > > send "@pcmanfm --desktop --profile LXDE-pi\n" > > > send "#@unclutter -idle 10\n" > > > send "@xset s off\n" > > > send "@xset -dpms\n" > > > send "@xset s noblank\n" > > > send "/usr/bin/chromium-browser --no-sandbox --no-first-run -- > > > kiosk\n" > > > send "EOF\n" > > > send "echo Q1\n" > > > expect "Q1" > > > expect "# " > > > send "apt-get clean\n" > > > > My guess is apt-get is consuming the following console input. > > > > First it is recommended to set DEBIAN_FRONTEND=noninteractive, > > second you need to be sure your command is finished before > > going on. > > > > > send "cat /dev/zero > zero.file\n" > > > send "sync\n" > > > send "rm zero.file\n" > > > expect "# " > > > send "sync\n" > > > send "sleep 3\n" > > > send "poweroff\n" > > > > > > #set background image > > > #set plymouth image during boot > > > #disable bluetooth, if enabled > > > #disable/configure wlan > > > > I don't think this is a QEMU problem ;) > > > > Regards, > > > > Phil. > > > ----- End message from Philippe Mathieu-Daudé <f4...@amsat.org> ----- > >