StefanScherer / packer-windows

Windows Templates for Packer: Windows 11, Windows 10, Windows Server 2022, 2019, 2016, also with Docker
MIT License
1.29k stars 434 forks source link

windows image build with kvm stuck at winrm(booting from floppy) #319

Open weinix opened 2 years ago

weinix commented 2 years ago

Thanks for your work! I am trying packer build --only=qemu --var virtio_win_iso=./virtio-win.iso ./windows_2019_docker.json and it stuck at ==> qemu: Waiting for WinRM to become available... I used vncviewer and foud the image build vm can't find the boot disk: image

Any ideas?

Thanks!

ranamuerta commented 2 years ago

The problem is qemu args and default packer behavior.

when -drive or -device qemu args are passed packer will no longer add it's default options including adding the Win install iso as a drive so it's trying to boot with no win install iso attached.

this is the original looks like

"qemuargs": [
        [
          "-drive",
          "file=windows_2019_docker-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1"
        ],
        [
          "-drive",
          "file={{ user `virtio_win_iso` }},media=cdrom,index=3"
        ]
      ],

whould need to be updated to something like this

"qemuargs": [
       [
          "-drive",
          "file=WINDOWS_INSTALL_ISO_PATH.iso,media=cdrom"
        ], 
       [
          "-drive",
          "file=windows_2019_docker-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1"
        ],
        [
          "-drive",
          "file={{ user `virtio_win_iso` }},media=cdrom,index=3"
        ]
      ],

here is the verbage from packer

" Warning: The qemu command line allows extreme flexibility, so beware of conflicting arguments causing failures of your run. For instance adding a "--drive" or "--device" override will mean that none of the default configuration Packer sets will be used. To see the defaults that Packer sets, look in your packer.log file (set PACKER_LOG=1 to get verbose logging) and search for the qemu-system-x86 command. The arguments are all printed for review, and you can use those arguments along with the template engines allowed by qemu-args to set up a working configuration that includes both the Packer defaults and your extra arguments. "