diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 7d42939a4..5ca3f555b 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -337,6 +337,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend( errs, errors.New("ssh_host_port_min must be less than ssh_host_port_max")) } + if b.config.SSHHostPortMin < 0 { + errs = packer.MultiErrorAppend( + errs, errors.New("ssh_host_port_min must be positive")) + } if b.config.VNCPortMin > b.config.VNCPortMax { errs = packer.MultiErrorAppend( diff --git a/builder/vmware/common/run_config.go b/builder/vmware/common/run_config.go index e8b6a3d37..da9581427 100644 --- a/builder/vmware/common/run_config.go +++ b/builder/vmware/common/run_config.go @@ -31,6 +31,9 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) { if c.VNCPortMin > c.VNCPortMax { errs = append(errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max")) } + if c.VNCPortMin < 0 { + errs = append(errs, fmt.Errorf("vnc_port_min must be positive")) + } return }