hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.03k stars 3.32k forks source link

windows 2016 qemu/kvm blue screen #8273

Closed bavivek2003 closed 4 years ago

bavivek2003 commented 4 years ago

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

im trying to make qcow2 image, but unfortunately for windows 2016 as soon it boot from iso, im getting BSOD.

just for testing with same code, when i boot centos or windows 2012 i don't find any issue but for win 2016, when its boot from ISO after few seconds(after passing loading file and when windows log appears) im getting BSOD.

however without packer when i use below code with same ISO, its perfectly booting like a charm.

qemu-system-x86_64 -drive file=server-2016.qcow2,if=virtio -drive file=iso/Win2016STD_DC.ISO,index=0, -m 2048 -enable-kvm -cpu host -smp cores=4,threads=1,sockets=1 media=cdrom -vnc 127.0.0.1:2 -machine type=pc,accel=kvm -netdev user,id=user.0,hostfwd=tcp::3670-:5985 -device virtio-net,netdev=user.0 -machine type=pc,accel=kvm

Reproduction Steps

Packer build win2016.json

Packer version

Packer version : tried from 1.3.5 till 1.4.4

Capture

Operating system and Environment details

Hypervisor: ESXi 6.5 VM : Red Hat Enterprise Linux Server release 7.7 (Maipo) CPU pass through : enabled at Vmware builder : qemu accelerator : KVM Guest os : win2016

Log Fragments and crash.log files

i couldnt any thing from crash.log as packer simply waiting for boot.

Code###very simple code to boot from cdrom

"builders": [{
  "type": "qemu",
  "accelerator": "kvm",
  "headless": false,

  "cpus": "2",
  "memory": "4096",
  "disk_size": "12288",
  "format": "qcow2",

  "vm_name": "windows2016-base",

  "iso_url": "iso/Win2016STD_DC.ISO",
  "iso_checksum_type": "none",

  "boot_wait": "2m",
  "vnc_port_max": 5982,
  "vnc_port_min": 5981,

  "shutdown_command": "shutdown /s /t 600 /f /d p:4:1 /c \"Packer Shutdown\"",
  "shutdown_timeout": "10m",
  "communicator": "winrm",

  "winrm_username": "{{user `winrm_user`}}",
  "winrm_password": "{{user `winrm_pass`}}",
  "winrm_timeout": "20m",

  "output_directory": "./output/win2016-base-qcow2-{{isotime \"20060102150405\"}}/"

################build log############# [root@dhcp-172-24-201-118 base]# PACKER_LOG=1 packer build win2016.json 2019/10/24 10:43:08 [INFO] Packer version: 1.3.4 ... 2019/10/24 10:43:08 Build debug mode: false 2019/10/24 10:43:08 Force build: false 2019/10/24 10:43:08 On error: 2019/10/24 10:43:08 Preparing build: qemu 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 use specified accelerator: kvm

a checksum is highly recommended. 2019/10/24 10:43:08 Waiting on builds to complete... 2019/10/24 10:43:08 Starting build run: qemu 2019/10/24 10:43:08 Running builder: qemu 2019/10/24 10:43:08 [INFO] (telemetry) Starting builder qemu

Warnings for build 'qemu':

2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Qemu path: /usr/libexec/qemu-system-x86_64, Qemu Image page: /usr/bin/qemu-img ==> qemu: Retrieving ISO 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Acquiring lock to download: file:///home/vivekb/base/iso/Win2016STD_DC.ISO qemu: Using file in-place: file:///home/vivekb/base/iso/Win2016STD_DC.ISO 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Parsed URL: &url.URL{Scheme:"file", Opaque:"", User:(*url.Userinfo)(nil), Host:"", Path:"/home/vivekb/base/iso/Win2016STD_DC.ISO", RawPath:"", ForceQuery:false, RawQuery:"", Fragment:""} 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 [DEBUG] Using local file: /home/vivekb/base/iso/Win2016STD_DC.ISO 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 No floppy files specified. Floppy disk will not be made. ==> qemu: Creating hard drive... 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Executing qemu-img: []string{"create", "-f", "qcow2", "output/win2016-base-qcow2-20191024174308/windows2016-base", "12288M"} 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 stdout: Formatting 'output/win2016-base-qcow2-20191024174308/windows2016-base', fmt=qcow2 size=12884901888 encryption=off cluster_size=65536 lazy_refcounts=off 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 stderr: 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Looking for available communicator (SSH, WinRM, etc) port between 2222 and 4444 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Trying port: 2301 ==> qemu: Found port for communicator (SSH, WinRM, etc): 2301. ==> qemu: Looking for available port between 5981 and 5982 on 127.0.0.1 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Looking for available port between 5981 and 5982 on 127.0.0.1 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Trying port: 5981 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Found available VNC port: 5981 on IP: 127.0.0.1 ==> qemu: Starting VM, booting from CD-ROM qemu: The display parameter will be ignored. qemu: WARNING: The version of qemu on your host doesn't support display mode. 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Qemu --version output: QEMU emulator version 1.5.3 (qemu-kvm-1.5.3-167.el7_7.1), Copyright (c) 2003-2008 Fabrice Bellard 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Qemu version: 1.5.3 qemu: The display parameter will be ignored. 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Qemu Builder has no floppy files, not attaching a floppy. 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Executing /usr/libexec/qemu-system-x86_64: []string{"-device", "virtio-net,netdev=user.0", "-netdev", "user,id=user.0,hostfwd=tcp::2301-:5985", "-drive", "file=output/win2016-base-qcow2-20191024174308/windows2016-base,if=virtio,cache=writeback,format=qcow2", "-cdrom", "/home/vivekb/base/iso/Win2016STD_DC.ISO", "-boot", "once=d", "-m", "4096M", "-vnc", "127.0.0.1:81", "-smp", "cpus=2,sockets=2", "-name", "windows2016-base", "-machine", "type=pc,accel=kvm"} 2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 Started Qemu. Pid: 34024 ==> qemu: Waiting 2m0s for boot... ==> qemu: Connecting to VM via VNC (127.0.0.1:5981) 2019/10/24 10:45:10 packer: 2019/10/24 10:45:10 Connected to VNC desktop: QEMU (windows2016-base) ==> qemu: Typing the boot command over VNC... ==> qemu: Using winrm communicator to connect: 127.0.0.1 ==> qemu: Waiting for WinRM to become available... 2019/10/24 10:45:10 packer: 2019/10/24 10:45:10 Waiting for WinRM, up to timeout: 20m0s 2019/10/24 10:45:15 packer: 2019/10/24 10:45:15 [INFO] Attempting WinRM connection... 2019/10/24 10:45:15 packer: 2019/10/24 10:45:15 [DEBUG] connecting to remote shell using WinRM 2019/10/24 10:46:31 packer: 2019/10/24 10:46:31 [ERROR] connection error: unknown error Post http://127.0.0.1:2301/wsman: read tcp 127.0.0.1:58186->127.0.0.1:2301: read: connection reset by peer 2019/10/24 10:46:31 packer: 2019/10/24 10:46:31 [ERROR] WinRM connection err: unknown error Post http://127.0.0.1:2301/wsman: read tcp 127.0.0.1:58186->127.0.0.1:2301: read: connection reset by peer 2019/10/24 10:46:36 packer: 2019/10/24 10:46:36 [INFO] Attempting WinRM connection... 2019/10/24 10:46:36 packer: 2019/10/24 10:46:36 [DEBUG] connecting to remote shell using WinRM ^C2019/10/24 10:46:37 packer: 2019/10/24 10:46:37 Received interrupt signal (count: 1). Ignoring. 2019/10/24 10:46:37 Stopping build: qemu 2019/10/24 10:46:37 Closing stdin because interrupt received. 2019/10/24 10:46:37 packer: 2019/10/24 10:46:37 Cancelling the step runner... 2019/10/24 10:46:37 packer: 2019/10/24 10:46:37 Qemu stderr: qemu: terminating on signal 2 2019/10/24 10:46:37 packer: 2019/10/24 10:46:37 [ERROR] connection error: unknown error Post http://127.0.0.1:2301/wsman: read tcp 127.0.0.1:58188->127.0.0.1:2301: read: connection reset by peer 2019/10/24 10:46:37 packer: 2019/10/24 10:46:37 [ERROR] WinRM connection err: unknown error Post http://127.0.0.1:2301/wsman: read tcp 127.0.0.1:58188->127.0.0.1:2301: read: connection reset by peer ==> qemu: Deleting output directory... 2019/10/24 10:46:37 packer: 2019/10/24 10:46:37 Interrupt detected, quitting waiting for WinRM. 2019/10/24 10:46:37 packer: 2019/10/24 10:46:37 [INFO] WinRM wait cancelled. Exiting loop. Build 'qemu' errored: Build was cancelled. Cleanly cancelled builds after being interrupted. 2019/10/24 10:46:37 Build cancelled: qemu 2019/10/24 10:46:37 [INFO] (telemetry) ending qemu 2019/10/24 10:46:37 ui error: Build 'qemu' errored: Build was cancelled. 2019/10/24 10:46:37 Builds completed. Waiting on interrupt barrier... 2019/10/24 10:46:37 [INFO] (telemetry) Finalizing. 2019/10/24 10:46:37 waiting for all plugin processes to complete... 2019/10/24 10:46:37 /home/vivekb/base/iso/packer: plugin process exited

SwampDragons commented 4 years ago

Hi, thanks for reaching out. I still need those logs even if they don't look interesting to you.

You may also find help on the mailing list, since it's possible that this is a configuration issue.

bavivek2003 commented 4 years ago

Hi, thanks for reaching out. I still need those logs even if they don't look interesting to you.

You may also find help on the mailing list, since it's possible that this is a configuration issue.

Thanks for checking on this, i updated the build log for reference

SwampDragons commented 4 years ago

I edited to remove some of the irrelevant loglines.

the first thing I would do is check to see if there are any major differences in how Packer is creating the base disk and how you are. Packer's call is here:

 Executing qemu-img: []string{"create", "-f", "qcow2", "output/win2016-base-qcow2-20191024174308/windows2016-base", "12288M"}
2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 stdout: Formatting 'output/win2016-base-qcow2-20191024174308/windows2016-base', fmt=qcow2 size=12884901888 encryption=off cluster_size=65536 lazy_refcounts=off

Next, I do notice some differences between how Packer is launching the VM and how you are.

Packer's:

/usr/libexec/qemu-system-x86_64 \
-device virtio-net,netdev=user.0 \
-netdev user,id=user.0,hostfwd=tcp::2301-:5985 \
-drive file=output/win2016-base-qcow2-20191024174308/windows2016-base,if=virtio,cache=writeback,format=qcow2 \
-cdrom /home/vivekb/base/iso/Win2016STD_DC.ISO \
-boot once=d \
-m 4096M \
-vnc 127.0.0.1:81 \
-smp cpus=2,sockets=2 \
-name windows2016-base \
-machine type=pc,accel=kvm 

yours:

qemu-system-x86_64 \
-drive file=server-2016.qcow2,if=virtio \
-drive file=iso/Win2016STD_DC.ISO,index=0\
-m 2048 \
-enable-kvm \
-cpu host \
-smp cores=4,threads=1,sockets=1 media=cdrom \
-vnc 127.0.0.1:2 \
-machine type=pc,accel=kvm \
-netdev user,id=user.0,hostfwd=tcp::3670-:5985 \
-device virtio-net,netdev=user.0 \
-machine type=pc,accel=kvm

If you can narrow down which difference is causing issues, it'll be easier for us to implement a fix.

bavivek2003 commented 4 years ago

I edited to remove some of the irrelevant loglines.

the first thing I would do is check to see if there are any major differences in how Packer is creating the base disk and how you are. Packer's call is here:

 Executing qemu-img: []string{"create", "-f", "qcow2", "output/win2016-base-qcow2-20191024174308/windows2016-base", "12288M"}
2019/10/24 10:43:08 packer: 2019/10/24 10:43:08 stdout: Formatting 'output/win2016-base-qcow2-20191024174308/windows2016-base', fmt=qcow2 size=12884901888 encryption=off cluster_size=65536 lazy_refcounts=off

Next, I do notice some differences between how Packer is launching the VM and how you are.

Packer's:

/usr/libexec/qemu-system-x86_64 \
-device virtio-net,netdev=user.0 \
-netdev user,id=user.0,hostfwd=tcp::2301-:5985 \
-drive file=output/win2016-base-qcow2-20191024174308/windows2016-base,if=virtio,cache=writeback,format=qcow2 \
-cdrom /home/vivekb/base/iso/Win2016STD_DC.ISO \
-boot once=d \
-m 4096M \
-vnc 127.0.0.1:81 \
-smp cpus=2,sockets=2 \
-name windows2016-base \
-machine type=pc,accel=kvm 

yours:

qemu-system-x86_64 \
-drive file=server-2016.qcow2,if=virtio \
-drive file=iso/Win2016STD_DC.ISO,index=0\
-m 2048 \
-enable-kvm \
-cpu host \
-smp cores=4,threads=1,sockets=1 media=cdrom \
-vnc 127.0.0.1:2 \
-machine type=pc,accel=kvm \
-netdev user,id=user.0,hostfwd=tcp::3670-:5985 \
-device virtio-net,netdev=user.0 \
-machine type=pc,accel=kvm

If you can narrow down which difference is causing issues, it'll be easier for us to implement a fix.

finally i found the issue. if i add the below line, its work like charm, without that its failing. is there any way we can add that in packer -cpu host

SwampDragons commented 4 years ago

I think you can add using the qemu_args option. :)

bavivek2003 commented 4 years ago

I think you can add using the qemu_args option. :)

thanks, that worked. can we except in future release will that be fixed ?

SwampDragons commented 4 years ago

Probably not; using that option isn't necessarily recommended because it can make migrations difficult: http://www.linux-kvm.org/page/Tuning_KVM, so I wouldn't want to make it a default. I think it should be up to the user to figure out how to tune their cpu usage, and tell Packer what to do. I think this issue is solved by the qemu-args workaround, since the whole purpose of that option is to allow custom configuration. Without knowledge of what guest Packer is running, it would be hard for us to know your vm's cpu requirements, so I think it makes more sense for this to be user-configured option than a Packer default.

Thanks!

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.