hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.14k stars 3.33k forks source link

packer-builder-qemu plugin error when using cdrom: drive with bus=0, unit=0 (index=0) exists #10280

Closed tomkivlin closed 4 years ago

tomkivlin commented 4 years ago

Overview of the Issue

I am trying to use packer to build a custom ESXi image as per the configuration provided by Canonical (https://github.com/canonical/packer-maas). However I am getting a packer-builder-qemu error, which doesn't appear to be specific to their configuration as it's not even getting to their scripts.

Reproduction Steps

  1. Download ESXi ISO
  2. Download the packer-maas repo
  3. Run the command, e.g.: sudo PACKER_LOG=1 packer build -var "vmware_esxi_iso_path=../../VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso" vmware-esxi.json

Packer version

$ packer version
Packer v1.6.5

Simplified Packer Buildfile

The below is the same as the packer-maas file but without the post-processing scripts - I get the same result with both.

{
    "variables": {
        "vmware_esxi_iso_path": "{{env `VMWARE_ESXI_ISO_PATH`}}"
    },
    "builders": [
        {
            "type": "qemu",
            "communicator": "none",
            "iso_url": "{{user `vmware_esxi_iso_path`}}",
            "iso_checksum": "none",
            "boot_command": [
                "<enter><wait>",
                "<leftShift>O",
                " ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/vmware-esxi-ks.cfg",
                " com1_Port=0x3f8 tty2Port=com1",
                "<enter>"
            ],
            "boot_wait": "3s",
            "disk_interface": "ide",
            "disk_size": "10G",
            "headless": true,
            "memory": 4096,
            "http_directory": "http",
            "format": "raw",
            "net_device": "e1000",
            "qemuargs": [
                [ "-cpu", "host" ],
                [ "-smp", "2,sockets=2,cores=1,threads=1" ],
                [ "-serial", "stdio" ]
            ],
            "shutdown_timeout": "45m"
        }
    ],
    "post-processors": [
        {
            "type": "compress",
            "output": "vmware-esxi.dd.gz"
        }
    ]
}

Operating system and Environment details

Physical HPE ProLiant DL380 server running Ubuntu 20.04 with KVM installed and confirmed working (i.e. I can create and launch a VM).

Log Fragments and crash.log files

Snippet of the error:

==> qemu: Overriding default Qemu arguments with qemuargs template option...
2020/11/18 16:45:51 packer-builder-qemu plugin: Executing /usr/bin/qemu-system-x86_64: []string{"-serial", "stdio", "-m", "4096M", "-drive", "file=output-qemu/packer-qemu,if=ide,cache=writeback,discard=ignore,format=raw", "-drive", "file=/home/ubuntu/maas-esxi/VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso,index=0,media=cdrom", "-boot", "once=d", "-smp", "2,sockets=2,cores=1,threads=1", "-machine", "type=pc,accel=kvm", "-netdev", "user,id=user.0", "-vnc", "127.0.0.1:97", "-device", "e1000,netdev=user.0", "-name", "packer-qemu", "-cpu", "host"}
2020/11/18 16:45:51 packer-builder-qemu plugin: Started Qemu. Pid: 14363
2020/11/18 16:45:51 packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: -drive file=/home/ubuntu/maas-esxi/VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso,index=0,media=cdrom: drive with bus=0, unit=0 (index=0) exists
2020/11/18 16:45:51 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:5997: use of closed network connection
==> qemu: Error launching VM: Qemu failed to start. Please run with PACKER_LOG=1 to get more info.

Full output:

$ sudo PACKER_LOG=1 packer build -var "vmware_esxi_iso_path=../../VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso" vmware-esxi-new.json
2020/11/18 16:45:51 [INFO] Packer version: 1.6.5 [go1.15.3 linux amd64]
2020/11/18 16:45:51 Checking 'PACKER_CONFIG' for a config file path
2020/11/18 16:45:51 'PACKER_CONFIG' not set; checking the default config file path
2020/11/18 16:45:51 Attempting to open config file: /root/.packerconfig
2020/11/18 16:45:51 [WARN] Config file doesn't exist: /root/.packerconfig
2020/11/18 16:45:51 Setting cache directory: /home/ubuntu/maas-esxi/packer-maas-1.0.3/vmware-esxi/packer_cache
2020/11/18 16:45:51 Creating plugin client for path: /usr/bin/packer
2020/11/18 16:45:51 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-builder-qemu"}
2020/11/18 16:45:51 Waiting for RPC address for: /usr/bin/packer
2020/11/18 16:45:51 packer-builder-qemu plugin: [INFO] Packer version: 1.6.5 [go1.15.3 linux amd64]
2020/11/18 16:45:51 packer-builder-qemu plugin: Checking 'PACKER_CONFIG' for a config file path
2020/11/18 16:45:51 packer-builder-qemu plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/11/18 16:45:51 packer-builder-qemu plugin: Attempting to open config file: /root/.packerconfig
2020/11/18 16:45:51 packer-builder-qemu plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/11/18 16:45:51 packer-builder-qemu plugin: Setting cache directory: /home/ubuntu/maas-esxi/packer-maas-1.0.3/vmware-esxi/packer_cache
2020/11/18 16:45:51 packer-builder-qemu plugin: args: []string{"packer-builder-qemu"}
2020/11/18 16:45:51 packer-builder-qemu plugin: Plugin address: unix /tmp/packer-plugin279915476
2020/11/18 16:45:51 packer-builder-qemu plugin: Waiting for connection...
2020/11/18 16:45:51 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin279915476
2020/11/18 16:45:51 packer-builder-qemu plugin: Serving a plugin connection...
2020/11/18 16:45:51 Creating plugin client for path: /usr/bin/packer
2020/11/18 16:45:51 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-post-processor-compress"}
2020/11/18 16:45:51 Waiting for RPC address for: /usr/bin/packer
2020/11/18 16:45:51 packer-post-processor-compress plugin: [INFO] Packer version: 1.6.5 [go1.15.3 linux amd64]
2020/11/18 16:45:51 packer-post-processor-compress plugin: Checking 'PACKER_CONFIG' for a config file path
2020/11/18 16:45:51 packer-post-processor-compress plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/11/18 16:45:51 packer-post-processor-compress plugin: Attempting to open config file: /root/.packerconfig
2020/11/18 16:45:51 packer-post-processor-compress plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2020/11/18 16:45:51 packer-post-processor-compress plugin: Setting cache directory: /home/ubuntu/maas-esxi/packer-maas-1.0.3/vmware-esxi/packer_cache
2020/11/18 16:45:51 packer-post-processor-compress plugin: args: []string{"packer-post-processor-compress"}
2020/11/18 16:45:51 packer-post-processor-compress plugin: Plugin address: unix /tmp/packer-plugin336304772
2020/11/18 16:45:51 packer-post-processor-compress plugin: Waiting for connection...
2020/11/18 16:45:51 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin336304772
2020/11/18 16:45:51 packer-post-processor-compress plugin: Serving a plugin connection...
2020/11/18 16:45:51 Preparing build: qemu
2020/11/18 16:45:51 packer-builder-qemu plugin: use detected accelerator: kvm
2020/11/18 16:45:51 packer-builder-qemu plugin: CpuCount 0 too small, using default: 1

A checksum of 'none' was specified. Since ISO files are so big,
a checksum is highly recommended.

2020/11/18 16:45:51 Build debug mode: false
Warning: Warning when preparing build: "qemu"
2020/11/18 16:45:51 Force build: false

2020/11/18 16:45:51 On error:
2020/11/18 16:45:51 Waiting on builds to complete...
2020/11/18 16:45:51 Starting build run: qemu
2020/11/18 16:45:51 Running builder: qemu
2020/11/18 16:45:51 [INFO] (telemetry) Starting builder qemu
A checksum of 'none' was specified. Since ISO files are so big,
a checksum is highly recommended.

qemu: output will be in this color.

2020/11/18 16:45:51 packer-builder-qemu plugin: Qemu path: /usr/bin/qemu-system-x86_64, Qemu Image page: /usr/bin/qemu-img
==> qemu: Retrieving ISO
==> qemu: Trying ../../VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso
2020/11/18 16:45:51 packer-builder-qemu plugin: Acquiring lock for: ../../VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso (/home/ubuntu/maas-esxi/packer-maas-1.0.3/vmware-esxi/packer_cache/7350691bf0bf20e2fdc44420c2310c7952926490.iso.lock)
==> qemu: Trying ../../VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso
2020/11/18 16:45:51 packer-builder-qemu plugin: Leaving retrieve loop for ISO
2020/11/18 16:45:51 packer-builder-qemu plugin: No floppy files specified. Floppy disk will not be made.
2020/11/18 16:45:51 packer-builder-qemu plugin: No CD files specified. CD disk will not be made.
==> qemu: ../../VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso => /home/ubuntu/maas-esxi/VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso
2020/11/18 16:45:51 packer-builder-qemu plugin: [INFO] Creating disk with Path: output-qemu/packer-qemu and Size: 10G
2020/11/18 16:45:51 packer-builder-qemu plugin: Executing qemu-img: []string{"create", "-f", "raw", "output-qemu/packer-qemu", "10G"}
==> qemu: Creating required virtual machine disks
2020/11/18 16:45:51 packer-builder-qemu plugin: stdout: Formatting 'output-qemu/packer-qemu', fmt=raw size=10737418240
2020/11/18 16:45:51 packer-builder-qemu plugin: stderr:
2020/11/18 16:45:51 packer-builder-qemu plugin: Found available port: 8567 on IP: 0.0.0.0
==> qemu: Starting HTTP server on port 8567
    qemu: No communicator is set; skipping port forwarding setup.
==> qemu: Looking for available port between 5900 and 6000 on 127.0.0.1
2020/11/18 16:45:51 packer-builder-qemu plugin: Looking for available port between 5900 and 6000 on 127.0.0.1
2020/11/18 16:45:51 packer-builder-qemu plugin: Found available port: 5997 on IP: 127.0.0.1
2020/11/18 16:45:51 packer-builder-qemu plugin: Found available VNC port: 5997 on IP: 127.0.0.1
2020/11/18 16:45:51 packer-builder-qemu plugin: Qemu --version output: QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.8)
2020/11/18 16:45:51 packer-builder-qemu plugin: Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
2020/11/18 16:45:51 packer-builder-qemu plugin: Qemu version: 4.2.1
==> qemu: Starting VM, booting from CD-ROM
    qemu: view the screen of the VM, connect via VNC without a password to
    qemu: vnc://127.0.0.1:97
2020/11/18 16:45:51 packer-builder-qemu plugin: Qemu Builder has no floppy files, not attaching a floppy.
    qemu: The VM will be run headless, without a GUI. If you want to
    qemu: view the screen of the VM, connect via VNC without a password to
    qemu: vnc://127.0.0.1:97
==> qemu: Overriding default Qemu arguments with qemuargs template option...
2020/11/18 16:45:51 packer-builder-qemu plugin: Executing /usr/bin/qemu-system-x86_64: []string{"-serial", "stdio", "-m", "4096M", "-drive", "file=output-qemu/packer-qemu,if=ide,cache=writeback,discard=ignore,format=raw", "-drive", "file=/home/ubuntu/maas-esxi/VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso,index=0,media=cdrom", "-boot", "once=d", "-smp", "2,sockets=2,cores=1,threads=1", "-machine", "type=pc,accel=kvm", "-netdev", "user,id=user.0", "-vnc", "127.0.0.1:97", "-device", "e1000,netdev=user.0", "-name", "packer-qemu", "-cpu", "host"}
2020/11/18 16:45:51 packer-builder-qemu plugin: Started Qemu. Pid: 14363
2020/11/18 16:45:51 packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: -drive file=/home/ubuntu/maas-esxi/VMware-ESXi-6.7.0-Update3-15160138-HPE-Gen9plus.iso,index=0,media=cdrom: drive with bus=0, unit=0 (index=0) exists
2020/11/18 16:45:51 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:5997: 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...
2020/11/18 16:45:51 [INFO] (telemetry) ending qemu
==> Wait completed after 53 milliseconds 78 microseconds
2020/11/18 16:45:51 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2020/11/18 16:45:51 machine readable: qemu,error []string{"Build was halted."}
==> Builds finished but no artifacts were created.
2020/11/18 16:45:51 [INFO] (telemetry) Finalizing.
Build 'qemu' errored after 53 milliseconds 24 microseconds: Build was halted.

==> Wait completed after 53 milliseconds 78 microseconds

==> Some builds didn't complete successfully and had errors:
--> qemu: Build was halted.

==> Builds finished but no artifacts were created.
2020/11/18 16:45:52 waiting for all plugin processes to complete...
2020/11/18 16:45:52 /usr/bin/packer: plugin process exited
2020/11/18 16:45:52 /usr/bin/packer: plugin process exited
tomkivlin commented 4 years ago

OK, I clearly didn't search well enough- replica of https://github.com/hashicorp/packer/issues/10211

SwampDragons commented 4 years ago

Thanks -- we'll get to this for the next release.

ghost commented 3 years ago

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.