packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:2279: use of closed network connection

Created on 5 Feb 2020  ยท  4Comments  ยท  Source: hashicorp/packer

I don't understand why I have this error:

2020/02/05 13:00:45 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:5982: use of closed network connection
2020/02/05 13:00:45 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:2279: use of closed network connection

Packer v1.5.1

KVM Version

QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.21)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

Simplified Packer Buildfile

{
    "variables": {
        "image_url": "https://ppsos-ch-dk-2.exo.io/cloud/public/fedora-coreos-31.20200118.3.0-qemu.x86_64.qcow2",
        "image_checksum_url": "https://ppsos-ch-dk-2.exo.io/cloud/public/fedora-coreos-31.20200118.3.0-qemu.x86_64.qcow2.SHA256SUM",
        "image_checksum_type": "sha256",
        "image_name": "fedora-coreos-31"
    },
    "builders": [
        {
            "type": "qemu",
            "qemuargs": [
                ["-cpu", "qemu64,rdrand=on"],
                ["-fw_cfg", "name=opt/com.coreos/config,file=fedora-coreos-31/ignition.ign"],
                ["-nographic"]
            ],
            "vm_name": "{{user `image_name`}}.qcow2",
            "disk_size": "10G",
            "iso_url": "{{user `image_url`}}",
            "iso_checksum_url": "{{user `image_checksum_url`}}",
            "iso_checksum_type": "{{user `image_checksum_type`}}",
            "disk_image": true,
            "disk_compression": true,
            "disk_interface": "virtio",
            "format": "qcow2",
            "net_device": "virtio-net",
            "communicator": "ssh",
            "ssh_username": "core",
            "ssh_password": "core",
            "ssh_timeout": "5m",
            "ssh_port": 22,
            "shutdown_command": "sudo /sbin/shutdown -P -h now",
            "boot_wait": "2m",
            "boot_command":
            [
              "core",
              "<enter>",
              "core",
              "<enter>"
            ]
        }
    ],
    "provisioners": []
}

Output

$ sudo PACKER_PRIVATE_KEY=/home/ubuntu/.ssh/packer PACKER_LOG=1 packer build fedora-coreos-31/packer.json

2020/02/05 13:00:33 [INFO] Packer version: 1.5.1 [go1.13.5 linux amd64]
2020/02/05 13:00:33 Attempting to open config file: /home/ubuntu/.packerconfig
2020/02/05 13:00:33 [WARN] Config file doesn't exist: /home/ubuntu/.packerconfig
2020/02/05 13:00:33 Setting cache directory: /home/ubuntu/go/src/github.com/exoscale/packerfiles/packer_cache
2020/02/05 13:00:33 Plugin could not be found at /usr/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-qemu (exec: "/usr/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-qemu": stat /usr/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-qemu: no such file or directory). Checking same directory as executable.
2020/02/05 13:00:33 Current exe path: /usr/bin/packer
2020/02/05 13:00:33 Creating plugin client for path: /usr/bin/packer
2020/02/05 13:00:33 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-builder-qemu"}
2020/02/05 13:00:33 Waiting for RPC address for: /usr/bin/packer
2020/02/05 13:00:33 packer-builder-qemu plugin: [INFO] Packer version: 1.5.1 [go1.13.5 linux amd64]
2020/02/05 13:00:33 packer-builder-qemu plugin: Attempting to open config file: /home/ubuntu/.packerconfig
2020/02/05 13:00:33 packer-builder-qemu plugin: [WARN] Config file doesn't exist: /home/ubuntu/.packerconfig
2020/02/05 13:00:33 packer-builder-qemu plugin: Setting cache directory: /home/ubuntu/go/src/github.com/exoscale/packerfiles/packer_cache
2020/02/05 13:00:33 packer-builder-qemu plugin: args: []string{"packer-builder-qemu"}
2020/02/05 13:00:33 packer-builder-qemu plugin: Plugin address: unix /tmp/packer-plugin835088924
2020/02/05 13:00:33 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin835088924
2020/02/05 13:00:33 packer-builder-qemu plugin: Waiting for connection...
2020/02/05 13:00:33 packer-builder-qemu plugin: Serving a plugin connection...
2020/02/05 13:00:33 Build debug mode: false
2020/02/05 13:00:33 Force build: false
2020/02/05 13:00:33 On error:
2020/02/05 13:00:33 Preparing build: qemu
qemu: output will be in this color.

2020/02/05 13:00:33 packer-builder-qemu plugin: use detected accelerator: kvm
2020/02/05 13:00:33 packer-builder-qemu plugin: MemorySize 0 is too small, using default: 512
2020/02/05 13:00:33 packer-builder-qemu plugin: CpuCount 0 too small, using default: 1
2020/02/05 13:00:34 Waiting on builds to complete...
2020/02/05 13:00:34 Starting build run: qemu
2020/02/05 13:00:34 Running builder: qemu
2020/02/05 13:00:34 [INFO] (telemetry) Starting builder qemu
2020/02/05 13:00:34 packer-builder-qemu plugin: Qemu path: /usr/bin/qemu-system-x86_64, Qemu Image page: /usr/bin/qemu-img
==> qemu: Retrieving ISO
==> qemu: Trying https://ppsos-ch-dk-2.exo.io/cloud/public/fedora-coreos-31.20200118.3.0-qemu.x86_64.qcow2
2020/02/05 13:00:34 packer-builder-qemu plugin: Acquiring lock for: https://ppsos-ch-dk-2.exo.io/cloud/public/fedora-coreos-31.20200118.3.0-qemu.x86_64.qcow2?checksum=sha256%3Acd85c4f96d3861ecf170abc51e7a06f02636258acb3ba658385951f8c31e8150 (/home/ubuntu/go/src/github.com/exoscale/packerfiles/packer_cache/b2d557d251dd53b40368ad45659a583989f21a3a.iso.lock)
==> qemu: Trying https://ppsos-ch-dk-2.exo.io/cloud/public/fedora-coreos-31.20200118.3.0-qemu.x86_64.qcow2?checksum=sha256%3Acd85c4f96d3861ecf170abc51e7a06f02636258acb3ba658385951f8c31e8150
2020/02/05 13:00:38 packer-builder-qemu plugin: Leaving retrieve loop for ISO
2020/02/05 13:00:38 packer-builder-qemu plugin: No floppy files specified. Floppy disk will not be made.
==> qemu: https://ppsos-ch-dk-2.exo.io/cloud/public/fedora-coreos-31.20200118.3.0-qemu.x86_64.qcow2?checksum=sha256%3Acd85c4f96d3861ecf170abc51e7a06f02636258acb3ba658385951f8c31e8150 => /home/ubuntu/go/src/github.com/exoscale/packerfiles/packer_cache/b2d557d251dd53b40368ad45659a583989f21a3a.iso
==> qemu: Copying hard drive...
2020/02/05 13:00:38 packer-builder-qemu plugin: Executing qemu-img: []string{"convert", "-O", "qcow2", "/home/ubuntu/go/src/github.com/exoscale/packerfiles/packer_cache/b2d557d251dd53b40368ad45659a583989f21a3a.iso", "output-qemu/fedora-coreos-31.qcow2"}
2020/02/05 13:00:41 packer-builder-qemu plugin: stdout:
2020/02/05 13:00:41 packer-builder-qemu plugin: stderr:
==> qemu: Resizing hard drive...
2020/02/05 13:00:41 packer-builder-qemu plugin: Executing qemu-img: []string{"resize", "-f", "qcow2", "output-qemu/fedora-coreos-31.qcow2", "10G"}
2020/02/05 13:00:45 packer-builder-qemu plugin: stdout: Image resized.
2020/02/05 13:00:45 packer-builder-qemu plugin: stderr:
2020/02/05 13:00:45 packer-builder-qemu plugin: Looking for available communicator (SSH, WinRM, etc) port between 2222 and 4444
2020/02/05 13:00:45 packer-builder-qemu plugin: Found available port: 2279 on IP: 127.0.0.1
==> qemu: Found port for communicator (SSH, WinRM, etc): 2279.
==> qemu: Looking for available port between 5900 and 6000 on 127.0.0.1
2020/02/05 13:00:45 packer-builder-qemu plugin: Looking for available port between 5900 and 6000 on 127.0.0.1
2020/02/05 13:00:45 packer-builder-qemu plugin: Found available port: 5982 on IP: 127.0.0.1
2020/02/05 13:00:45 packer-builder-qemu plugin: Found available VNC port: 5982 on IP: 127.0.0.1
==> qemu: Starting VM, booting disk image
2020/02/05 13:00:45 packer-builder-qemu plugin: Qemu --version output: QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.21)
2020/02/05 13:00:45 packer-builder-qemu plugin: Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
2020/02/05 13:00:45 packer-builder-qemu plugin: Qemu version: 2.11.1
2020/02/05 13:00:45 packer-builder-qemu plugin: Qemu Builder has no floppy files, not attaching a floppy.
==> qemu: Overriding defaults Qemu arguments with QemuArgs...
2020/02/05 13:00:45 packer-builder-qemu plugin: Executing /usr/bin/qemu-system-x86_64: []string{"-display", "gtk", "-vnc", "127.0.0.1:82", "-smbios", "type=1,manufacturer=Exoscale,product=Exoscale Compute Platform", "-cpu", "qemu64,rdrand=on", "-nographic", "-device", "virtio-net,netdev=user.0", "-name", "fedora-coreos-31.qcow2", "-machine", "type=pc,accel=kvm", "-fw_cfg", "name=opt/com.coreos/config,file=fedora-coreos-31/ignition.ign", "-drive", "file=output-qemu/fedora-coreos-31.qcow2,if=virtio,cache=writeback,discard=ignore,format=qcow2", "-boot", "c", "-netdev", "user,id=user.0,hostfwd=tcp::2279-:22", "-m", "512M"}
2020/02/05 13:00:45 packer-builder-qemu plugin: Started Qemu. Pid: 18157
2020/02/05 13:00:45 packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: -display gtk: GTK support is disabled
2020/02/05 13:00:45 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:5982: use of closed network connection
2020/02/05 13:00:45 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:2279: use of closed network connection
==> qemu: Error launching VM: Qemu failed to start. Please run with PACKER_LOG=1 to get more info.
==> qemu: Deleting output directory...
Build 'qemu' errored: Build was halted.

==> Some builds didn't complete successfully and had errors:
2020/02/05 13:00:45 [INFO] (telemetry) ending qemu
2020/02/05 13:00:45 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2020/02/05 13:00:45 machine readable: qemu,error []string{"Build was halted."}
--> qemu: Build was halted.
==> Builds finished but no artifacts were created.

==> Builds finished but no artifacts were created.
2020/02/05 13:00:45 [INFO] (telemetry) Finalizing.
2020/02/05 13:00:46 waiting for all plugin processes to complete...
2020/02/05 13:00:46 /usr/bin/packer: plugin process exited

packer cache

$ tree packer_cache

packer_cache
โ”œโ”€โ”€ b2d557d251dd53b40368ad45659a583989f21a3a.iso
โ”œโ”€โ”€ b2d557d251dd53b40368ad45659a583989f21a3a.iso.lock
โ””โ”€โ”€ port
    โ”œโ”€โ”€ 2279
    โ”œโ”€โ”€ 3090
    โ”œโ”€โ”€ 4230
    โ”œโ”€โ”€ 5915
    โ”œโ”€โ”€ 5916
    โ””โ”€โ”€ 5982

ignition file

{
  "ignition": {
    "config": {
      "replace": {
        "source": null,
        "verification": {}
      }
    },
    "security": {
      "tls": {}
    },
    "timeouts": {},
    "version": "3.0.0"
  },
  "passwd": {
    "users": [
      {
        "groups": [
          "wheel",
          "sudo",
          "docker"
        ],
        "name": "core",
        "passwordHash": "$1$DlXXXXXXXX5HOBim/",
        "sshAuthorizedKeys": [
          "ssh-rsa XXXXXXXXXXXX"
        ]
      }
    ]
  },
  "storage": {},
  "systemd": {}
}

Operating system and Environment details

OS Version

Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic

question

Most helpful comment

Awsome! Thank you! So as you suggest: To solve the -display error.

I fixed by adding this args ["-display", "none"] to "qemuargs" in packer config

You can close if it's ok for you

All 4 comments

Hello @pierre-emmanuelJ, thanks for opening; so apparently a close didn't work because the connection was already closed. We'll need to investigate and maybe try to not bubble down the error in that case. But I this connection is probably closed because of the following error I could see in there:

Qemu stderr: qemu-system-x86_64: -display gtk: GTK support is disabled

Have you tried fixing that one ?

Awsome! Thank you! So as you suggest: To solve the -display error.

I fixed by adding this args ["-display", "none"] to "qemuargs" in packer config

You can close if it's ok for you

Good, thanks for confirming ! I think fixing this is not necessary and we will try to keep that one in mind in case something worse happens, I think leaving it like this is fine because the error was due to another error; closing.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jesse-c picture jesse-c  ยท  3Comments

mushon4 picture mushon4  ยท  3Comments

shashanksinha89 picture shashanksinha89  ยท  3Comments

mwhooker picture mwhooker  ยท  3Comments

Nikoos picture Nikoos  ยท  3Comments