diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index 74db88a15..f6697d567 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -19,11 +19,12 @@ type stepRun struct { } type qemuArgsTemplateData struct { - HTTPIP string - HTTPPort uint - HTTPDir string - OutputDir string - Name string + HTTPIP string + HTTPPort uint + HTTPDir string + OutputDir string + Name string + SSHHostPort uint } func (s *stepRun) Run(state multistep.StateBag) multistep.StepAction { @@ -148,6 +149,7 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error config.HTTPDir, config.OutputDir, config.VMName, + sshHostPort, } newQemuArgs, err := processArgs(config.QemuArgs, &ctx) if err != nil { diff --git a/website/source/docs/builders/qemu.html.markdown b/website/source/docs/builders/qemu.html.markdown index 7f1d9573c..366913189 100644 --- a/website/source/docs/builders/qemu.html.markdown +++ b/website/source/docs/builders/qemu.html.markdown @@ -253,6 +253,25 @@ builder and not otherwise conflicting with the qemuargs):
qemu-system-x86 -m 1024m --no-acpi -netdev user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport -device virtio-net,netdev=mynet0"+ +You can also use the `SSHHostPort` template variable to produce a packer +template that can be invoked by `make` in parallel: + +``` {.javascript} + // ... + "qemuargs": [ + [ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"], + [ "-device", "virtio-net,netdev=forward,id=net0"], + ... + ] + // ... +``` +`make -j 3 my-awesome-packer-templates` spawns 3 packer processes, each of which +will bind to their own SSH port as determined by each process. This will also +work with WinRM, just change the port forward in `qemuargs` to map to WinRM's +default port of `5985` or whatever value you have the service set to listen on. + + - `shutdown_command` (string) - The command to use to gracefully shut down the machine once all the provisioning is done. By default this is an empty string, which tells Packer to just forcefully shut down the machine.