mirror of
https://github.com/hashicorp/packer.git
synced 2026-05-28 04:35:38 -04:00
Force qemu to use a VNC port by setting vnc_min_port == vnc_max_port
Similar to Issue #1288, this prevents a crash when we set the VNC minimum port equivalent to the VNC maximum port
This commit is contained in:
parent
b2609db395
commit
b77fcd90f3
1 changed files with 6 additions and 1 deletions
|
|
@ -32,7 +32,12 @@ func (stepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction {
|
|||
var vncPort uint
|
||||
portRange := int(config.VNCPortMax - config.VNCPortMin)
|
||||
for {
|
||||
vncPort = uint(rand.Intn(portRange)) + config.VNCPortMin
|
||||
if portRange > 0 {
|
||||
vncPort = uint(rand.Intn(portRange)) + config.VNCPortMin
|
||||
} else {
|
||||
vncPort = config.VNCPortMin
|
||||
}
|
||||
|
||||
log.Printf("Trying port: %d", vncPort)
|
||||
l, err := net.Listen("tcp", fmt.Sprintf(":%d", vncPort))
|
||||
if err == nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue