Packer qemu vm shutdown after Ubuntu installation not reboot

Hello everyone,

Packer version: 1.11.2
Qemu : 9.2
Ubuntu : ubuntu-20.04.3-live-server-amd64

When we start the packer build, we can start the ISO and the quemu arguments and get a display with the VGA option. So far so good.
After installing the user data options, the VM shuts down automatically (poweroff) even though the shutdown_command = “reboot” or “none”.
We actually want to do an automatic reboot after the OS installation, which then automatically calls up our other tasks via ssh.

hcl:

cat << EOF > "${PACKER_HCL}"

packer {
 required_plugins {
 qemu = {
 version=">=1.1.0"
 source="github.com/hashicorp/qemu"
 }
 }
}


source "qemu" "ubuntu-server-amd" {
 boot_command = [
 " <up><wait>",
 " <up><wait><esc><wait>",
 "<f6><wait><esc><wait>",
 "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
 "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
 "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
 "/casper/vmlinuz ",
 "initrd=/casper/initrd ",
 "autoinstall",
 "ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ ",
 "<enter>"
 ]
 http_directory = "../config/httpamd"
 iso_checksum = "${UBUNTU_ISO_CHECKSUM}"
 iso_urls = ["${UBUNTU_ISO_NAME}"]
 output_directory = "${OUTPUT_DIR}"
 shutdown_command = "reboot"
 disk_size = "60000"
 communicator = "ssh"
 format = "qcow2"
 ssh_handshake_attempts = "1200"
 ssh_password = "ubuntu"
 ssh_pty = "true"
 ssh_timeout = "1200m"
 ssh_username = "ubuntu"
 vm_name = "${VM_NAME}"
 net_device = "virtio-net"
 disk_interface = "virtio"
 boot_wait = "5s"
 boot_key_interval = "50ms"
 headless = ${VM_HEADLESS}
 cpus = 8
 memory = 8192
 qemu_binary = "${VM_BINARY}"
 qemuargs = [
 [ "-L", "${VM_BINARY_PATH}" ],
 [ "-machine", "type=pc,accel=${VM_VIRTUALIZATION}" ],
 [ "-m", "8192" ],
 [ "-smp", "8" ],
 [ "-device", "qemu-xhci" ],
 [ "-device", "virtio-gpu-pci" ],
 [ "-device", "usb-tablet" ],
 [ "-device", "usb-kbd" ],
 [ "-net", "nic" ],
 [ "-net", "user" ],

 ]
}

user data:


#cloud-config
 autoinstall:
 version: 1
 early commands:
 - systemctl stop ssh
 locale: en_US
 apt:
 geoip: true
 locale: en_US.UTF-8
 keyboard:
 layout: us
 networks:
 version: 2
 renderer: networkd
 ethernet:
 enp0s2:
 dhcp4: no
 enp0s5:
 dhcp4: no
 storage:
 grub:
 reorder_uefi: False
 storage:
 layout:
 name: direct
 identity:
 hostname: xxxxxxx
 username: xxxxxxxx
 # pass is ubuntu
 xxxxxxxx
 ssh:
 install server: yes
 packages:
 -vim
 - tmux
 package_update: false
 package_upgrade: false
 user data:
 disable_root: false
 late commands:
 # Changing from networkd to NetworkManager
 # move existing config out of the way
 - find /target/etc/netplan/ -name "*.yaml" -exec sh -c 'mv "$1" "$1-orig"' _ {} \;
 # Create a new netplan and enable it
 - |
 cat <<EOF | sudo tee /target/etc/netplan/01-netcfg.yaml
 networks:
 version: 2
 renderer: networkd
 ethernet:
 enp0s1:
 dhcp4: yes
 enp0s2:
 dhcp4: yes
 enp0s3:
 dhcp4: yes
 enp0s5:
 dhcp4: yes
 ens3:
 dhcp4: yes
 ens4:
 dhcp4: yes
 ens6:
 dhcp4: yes
 EOF
 - curtin in-target --target /target netplan generate
 - curtin in-target --target /target netplan apply
 - echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu