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.06k stars 3.32k forks source link

Proxmox Error running boot command: 500 invalid parameter: leftshift #9667

Closed paginabianca closed 4 years ago

paginabianca commented 4 years ago

Overview of the Issue

When creating a Windows VM on Proxmox I wanted to use the boot_command to launch a cmd with shift+f10. Packer/Qemu returns: invalid parameter leftshift when using <leftShiftOn> or <leftShiftOff> in the boot_command.

Reproduction Steps

Using the Proxmox builder try to send <leftShiftOn> or <leftShiftOff> in the boot comand.

Packer version

From 1.6.0

Simplified Packer Buildfile

The main issue lies in the boot command:

"boot_command": [
        "<wait5><leftShiftOn><f10><leftShiftOff>",
        "<wait5>wpeinit<enter><wait2>"
      ],

The complete simplified Packer Buildfile can be found here

Operating system and Environment details

Tested on the PVE host with kernel: 5.4.44-2-pve and on Arch Linux running the same kernel since it is a LXC on the PVE host.

Log Fragments

The important part is:

==> Some builds didn't complete successfully and had errors:
--> proxmox: Error running boot command: 500 invalid parameter: leftshift

==> Builds finished but no artifacts were created.

The complete log file can be found here

carlpett commented 4 years ago

Hi @paginabianca, The correct syntax would be shift-f10, as there is no key state to turn on or off.

paginabianca commented 4 years ago

Sorry my bad, I followed the examples shows in the docs and thought that leftShift had the state to turn on and off same as for example leftCtrl.

paginabianca commented 4 years ago

I've tried switching out the leftShiftOn/Off with shfit-f10 but it does not seem to work correctly. When pressing shfit+f10 in the WinPE it should launch a cmd window where you can type out commands but when using the following boot command

"boot_command": [
    "<shift-f10><wait2>setup /unattend:d:Unattend.xml<enter><wait>"
],

no cmd window is launched and thus the installation does not start. I was, however, able to send shift+f10 to the VM by setting the Packer shorthand spacebar to the qemu keycode shift-f10 inside the bootcommand_driver.go file as such:

sMap := map[string]string{
        "spacebar": "shift-f10",
        "bs":       "backspace",
        "del":      "delete",
        "return":   "ret",
        "enter":    "ret",
        "pageUp":   "pgup",
        "pageDown": "pgdn",
    }

and then use <spacebar> inside the boot_command to launch the cmd window.

paginabianca commented 4 years ago

I had time to test your suggestion again, using the syntax <shift-f10> or shirt-f10 sends the strings shift-f10 and and does not send the key combination shift+f10. I will take a closer look at the boot command and see if i can fix it.

carlpett commented 4 years ago

Hi, I had a look deeper into how Packer generates the key sequences, and it looks like I had missed a few pieces. So what I said above isn't correct. It looks like the Proxmox bootcommand driver should handle KeyActions, but doesn't. So from there we'd need to keep track of shift-states and so on. I don't have time to look at this right away, but if you have some time, I believe that is where it needs to happen.

paginabianca commented 4 years ago

I've looked into that, but I'm not entirely sure how to keep track of what key is pressed. I added the missing packer shorthand keycodes. I'll open a WIP PR and try to figure out how to keep track of all key actions :+1:

ghost commented 3 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.