OSInside / kiwi

KIWI - Appliance Builder Next Generation
https://osinside.github.io/kiwi
GNU General Public License v3.0
303 stars 152 forks source link

oem-shutdown doesn't shutdown but reboot the machine #2474

Closed ampresent closed 8 months ago

ampresent commented 8 months ago

Problem description

<oem-shutdown>true</oem-shutdown> doesn't really shutdown but reboot the machine.

Expected behaviour

The machine is to be shutdown after installation.

Steps to reproduce the behaviour

  1. Create a hybrid iso image. With "oem-shutdown" set to true.
        <type image="oem" filesystem="ext4" installiso="true" installboot="install" firmware="uefi" kernelcmdline="console=ttyS0">
            <bootloader name="grub2" console="serial" timeout="10"/>
            <oemconfig>
                <oem-systemsize>2048</oem-systemsize>
                <oem-unattended>true</oem-unattended>
                <oem-swap>true</oem-swap>
                <oem-swapsize>200</oem-swapsize>
                <oem-multipath-scan>false</oem-multipath-scan>
                <oem-shutdown>true</oem-shutdown>
            </oemconfig>
        </type>
  2. kiwi build
  3. Start a virtual machine with qemu
    sudo /usr/libexec/qemu-kvm -m 20480 -drive file=./xxx.qcow2,format=qcow2  -cdrom ./build/xxx.x86_64-1.0.0.install.iso -net nic -net user --enable-kvm -cpu host -boot d -serial mon:stdio
  4. Waiting for it to finish installation
  5. It reboots

OS and Software information

I suspect the issue is resulted from this line, where reboot -p might mean reboot rather than poweroff. https://github.com/OSInside/kiwi/blob/5e40229b1c75d0a36df17c2565bd23304168ad81/dracut/modules.d/99kiwi-dump-reboot/kiwi-dump-reboot-system.sh#L33

schaefi commented 8 months ago

Yeah looks like a bug. I think we should even consider to call

systemctl halt

as we have a running systemd inside of the initrd

schaefi commented 8 months ago

I tested an image with the provided PR, after deploy you will see messages like

[  OK  ] Reached target System Shutdown.
[  OK  ] Reached target Late Shutdown Services.
[  OK  ] Finished System Halt.
[  OK  ] Reached target System Halt.
[   30.313607][    T1] reboot: System halted

I think this is the expected behavior. Please comment on the PR in case there are objections.

Thanks much