From f305a2f4c22330c8283995b4388003f7c0140acf Mon Sep 17 00:00:00 2001 From: Andrew Pennebaker Date: Wed, 7 Mar 2018 10:59:02 -0600 Subject: [PATCH] send multibyte scancodes accurately to virtualbox --- builder/virtualbox/common/step_type_boot_command.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/builder/virtualbox/common/step_type_boot_command.go b/builder/virtualbox/common/step_type_boot_command.go index cb5b43648..77a82fb4b 100644 --- a/builder/virtualbox/common/step_type_boot_command.go +++ b/builder/virtualbox/common/step_type_boot_command.go @@ -91,7 +91,16 @@ func (s *StepTypeBootCommand) Run(_ context.Context, state multistep.StateBag) m return multistep.ActionHalt } - if err := driver.VBoxManage("controlvm", vmName, "keyboardputscancode", code); err != nil { + var codes []string + + for i := 0; i < len(code)/2; i++ { + codes = append(codes, code[i*2:i*2+2]) + } + + args := []string{"controlvm", vmName, "keyboardputscancode"} + args = append(args, codes...) + + if err := driver.VBoxManage(args...); err != nil { err := fmt.Errorf("Error sending boot command: %s", err) state.Put("error", err) ui.Error(err.Error())