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.07k stars 3.33k forks source link

CentOS (2.6.32-431.23.3.el6.x86_64) Qemu stderr: qemu-kvm: -display: invalid option #1387

Closed listuser closed 10 years ago

listuser commented 10 years ago

Hi,

Packer newbie here. Just running through the Packer docs and trying it for the 1st time.

I am following the docs for the 1st timers.

http://www.packer.io/intro/getting-started/build-image.html

But using the QEMU Builder instead of Amazon AMI.

http://www.packer.io/docs/builders/qemu.html

This is the template I created based off the example.

{ "builders": [ { "type": "qemu", "qemu_binary" : "/usr/libexec/qemu-kvm", "iso_url": "http://127.0.0.1/iso/CentOS-6.5-x86_64-minimal.iso", "iso_checksum": "0d9dc37b5dd4befa1c440d2174e88a87", "iso_checksum_type": "md5", "output_directory": "/var/tmp/output_centos_tdhtest", "ssh_wait_timeout": "30s", "shutdown_command": "shutdown -P now", "disk_size": 5000, "format": "qcow2", "headless": false, "accelerator": "kvm", "http_directory": "", "http_port_min": 8000, "http_port_max": 8000, "ssh_host_port_min": 2222, "ssh_host_port_max": 2223, "ssh_username": "root", "ssh_password": "deeznuts", "ssh_port": 22, "ssh_wait_timeout": "90m", "vm_name": "tdhtest", "net_device": "virtio-net", "disk_interface": "virtio", "boot_wait": "5s", "boot_command": [ " text ks=http://127.0.0.1:80/pub/ks/nms.cfg" ] } ] }

But the build process fails because the qemu-kvm that is available by default with this system does not appear to have a "-display" option.

2014/08/05 01:59:08 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:08 Qemu stderr: qemu-kvm: -display: invalid option

Here is the full log/debug output

export PACKER_LOG="yes"; /usr/local/packer/packer build -debug example.json 2014/08/05 01:58:56 Packer Version: 0.6.1 8b24d990943ff496a3bd951cb63f5fa03cff1c2f 2014/08/05 01:58:56 Packer Target OS/Arch: linux amd64 2014/08/05 01:58:56 Built with Go Version: go1.3 2014/08/05 01:58:56 Detected home directory from env var: /backup/home/testuser 2014/08/05 01:58:56 Attempting to open config file: /backup/home/testuser/.packerconfig 2014/08/05 01:58:56 File doesn't exist, but doesn't need to. Ignoring. 2014/08/05 01:58:56 Packer config: &{PluginMinPort:0 PluginMaxPort:0 Builders:map[digitalocean:packer-builder-digitalocean openstack:packer-builder-openstack vmware-iso:packer-builder-vmware-iso parallels-pvm:packer-builder-parallels-pvm vmware-vmx:packer-builder-vmware-vmx virtualbox-iso:packer-builder-virtualbox-iso virtualbox-ovf:packer-builder-virtualbox-ovf null:packer-builder-null amazon-ebs:packer-builder-amazon-ebs amazon-chroot:packer-builder-amazon-chroot amazon-instance:packer-builder-amazon-instance docker:packer-builder-docker googlecompute:packer-builder-googlecompute qemu:packer-builder-qemu parallels-iso:packer-builder-parallels-iso] Commands:map[build:packer-command-build fix:packer-command-fix inspect:packer-command-inspect validate:packer-command-validate] PostProcessors:map[docker-push:packer-post-processor-docker-push docker-import:packer-post-processor-docker-import vagrant-cloud:packer-post-processor-vagrant-cloud vagrant:packer-post-processor-vagrant vsphere:packer-post-processor-vsphere] Provisioners:map[puppet-masterless:packer-provisioner-puppet-masterless puppet-server:packer-provisioner-puppet-server shell:packer-provisioner-shell salt-masterless:packer-provisioner-salt-masterless ansible-local:packer-provisioner-ansible-local chef-client:packer-provisioner-chef-client chef-solo:packer-provisioner-chef-solo file:packer-provisioner-file]} 2014/08/05 01:58:56 Setting cache directory: /var/tmp/packer_cache 2014/08/05 01:58:56 Environment.Cli: []string{"build", "-debug", "example.json"} 2014/08/05 01:58:56 command + args: []string{"build", "-debug", "example.json"} 2014/08/05 01:58:56 Loading command: build 2014/08/05 01:58:56 Plugin could not be found. Checking same directory as executable. 2014/08/05 01:58:56 Current exe path: /usr/local/packer/packer 2014/08/05 01:58:56 Creating plugin client for path: /usr/local/packer/packer-command-build 2014/08/05 01:58:56 Starting plugin: /usr/local/packer/packer-command-build []string{"/usr/local/packer/packer-command-build"} 2014/08/05 01:58:56 Waiting for RPC address for: /usr/local/packer/packer-command-build 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Plugin build against Packer '8b24d990943ff496a3bd951cb63f5fa03cff1c2f' 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Plugin minimum port: 10000 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Plugin maximum port: 25000 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Plugin address: unix /tmp/packer-plugin987228379 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Waiting for connection... 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Serving a plugin connection... 2014/08/05 01:58:56 Executing command: build 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Reading template: example.json 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Creating build: qemu 2014/08/05 01:58:56 Loading builder: qemu 2014/08/05 01:58:56 Plugin could not be found. Checking same directory as executable. 2014/08/05 01:58:56 Current exe path: /usr/local/packer/packer 2014/08/05 01:58:56 Creating plugin client for path: /usr/local/packer/packer-builder-qemu 2014/08/05 01:58:56 Starting plugin: /usr/local/packer/packer-builder-qemu []string{"/usr/local/packer/packer-builder-qemu"} 2014/08/05 01:58:56 Waiting for RPC address for: /usr/local/packer/packer-builder-qemu 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Plugin build against Packer '8b24d990943ff496a3bd951cb63f5fa03cff1c2f' 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Plugin minimum port: 10000 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Plugin maximum port: 25000 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Plugin address: unix /tmp/packer-plugin930855028 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Waiting for connection... 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Serving a plugin connection... Debug mode enabled. Builds will not be parallelized. 2014/08/05 01:58:56 ui: Debug mode enabled. Builds will not be parallelized. qemu output will be in this color. 2014/08/05 01:58:56 ui: qemu output will be in this color.

2014/08/05 01:58:56 ui: 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Build debug mode: true 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Force build: false 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Preparing build: qemu 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Debug enabled, so waiting for build to finish: qemu 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Starting build run: qemu 2014/08/05 01:58:56 /usr/local/packer/packer-command-build: 2014/08/05 01:58:56 Running builder: qemu 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Qemu path: /usr/libexec/qemu-kvm, Qemu Image page: /usr/bin/qemu-img ==> qemu: Downloading or copying ISO 2014/08/05 01:58:56 ui: ==> qemu: Downloading or copying ISO qemu: Downloading or copying: http://127.0.0.1/iso/CentOS-6.5-x86_64-minimal.iso 2014/08/05 01:58:56 ui: qemu: Downloading or copying: http://127.0.0.1/iso/CentOS-6.5-x86_64-minimal.iso 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Acquiring lock to download: http://127.0.0.1/iso/CentOS-6.5-x86_64-minimal.iso 2014/08/05 01:58:56 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:56 Verifying checksum of /var/tmp/packer_cache/36df08c5b42147b206407d7b584307c5b485318805ef72945e0d3e868584c0e3.iso 2014/08/05 01:58:57 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:58:57 Initial checksum matched, no download needed. ==> qemu: Pausing after run of step 'StepDownload'. Press enter to continue. 2014/08/05 01:58:57 ui: ask: ==> qemu: Pausing after run of step 'StepDownload'. Press enter to continue.

2014/08/05 01:58:59 ui: scan err: unexpected newline ==> qemu: Pausing after run of step 'stepPrepareOutputDir'. Press enter to continue. 2014/08/05 01:58:59 ui: ask: ==> qemu: Pausing after run of step 'stepPrepareOutputDir'. Press enter to continue.

2014/08/05 01:59:00 ui: scan err: unexpected newline 2014/08/05 01:59:00 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:00 No floppy files specified. Floppy disk will not be made. ==> qemu: Pausing after run of step 'StepCreateFloppy'. Press enter to continue. 2014/08/05 01:59:00 ui: ask: ==> qemu: Pausing after run of step 'StepCreateFloppy'. Press enter to continue.

2014/08/05 01:59:00 ui: scan err: unexpected newline ==> qemu: Creating hard drive... 2014/08/05 01:59:00 ui: ==> qemu: Creating hard drive... 2014/08/05 01:59:00 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:00 Executing qemu-img: []string{"create", "-f", "qcow2", "/var/tmp/output_centos_tdhtest/tdhtest.qcow2", "5000M"} 2014/08/05 01:59:00 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:00 stdout: Formatting '/var/tmp/output_centos_tdhtest/tdhtest.qcow2', fmt=qcow2 size=5242880000 encryption=off cluster_size=65536 2014/08/05 01:59:00 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:00 stderr: ==> qemu: Pausing after run of step 'stepCreateDisk'. Press enter to continue. 2014/08/05 01:59:00 ui: ask: ==> qemu: Pausing after run of step 'stepCreateDisk'. Press enter to continue.

2014/08/05 01:59:01 ui: scan err: unexpected newline ==> qemu: Pausing after run of step 'stepHTTPServer'. Press enter to continue. 2014/08/05 01:59:01 ui: ask: ==> qemu: Pausing after run of step 'stepHTTPServer'. Press enter to continue.

2014/08/05 01:59:06 ui: scan err: unexpected newline 2014/08/05 01:59:06 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:06 Looking for available SSH port between 2222 and 2223 2014/08/05 01:59:06 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:06 Trying port: 2222 ==> qemu: Found port for SSH: 2222. 2014/08/05 01:59:06 ui: ==> qemu: Found port for SSH: 2222. ==> qemu: Pausing after run of step 'stepForwardSSH'. Press enter to continue. 2014/08/05 01:59:06 ui: ask: ==> qemu: Pausing after run of step 'stepForwardSSH'. Press enter to continue.

2014/08/05 01:59:07 ui: scan err: unexpected newline ==> qemu: Looking for available port between 5900 and 6000 2014/08/05 01:59:07 ui: ==> qemu: Looking for available port between 5900 and 6000 2014/08/05 01:59:07 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:07 Looking for available port between 5900 and 6000 2014/08/05 01:59:07 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:07 Trying port: 5987 ==> qemu: Found available VNC port: 5987 2014/08/05 01:59:07 ui: ==> qemu: Found available VNC port: 5987 ==> qemu: Pausing after run of step 'stepConfigureVNC'. Press enter to continue. 2014/08/05 01:59:07 ui: ask: ==> qemu: Pausing after run of step 'stepConfigureVNC'. Press enter to continue.

2014/08/05 01:59:08 ui: scan err: unexpected newline ==> qemu: Starting VM, booting from CD-ROM 2014/08/05 01:59:08 ui: ==> qemu: Starting VM, booting from CD-ROM 2014/08/05 01:59:08 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:08 Qemu Builder has no floppy files, not attaching a floppy. 2014/08/05 01:59:08 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:08 Executing /usr/libexec/qemu-kvm: []string{"-machine", "type=pc-1.0,accel=kvm", "-vnc", "0.0.0.0:87", "-boot", "once=d", "-display", "sdl", "-netdev", "user,id=user.0", "-device", "virtio-net,netdev=user.0", "-drive", "file=/var/tmp/output_centos_tdhtest/tdhtest.qcow2,if=virtio", "-cdrom", "/var/tmp/packer_cache/36df08c5b42147b206407d7b584307c5b485318805ef72945e0d3e868584c0e3.iso", "-m", "512m", "-name", "tdhtest", "-redir", "tcp:2222::22"} 2014/08/05 01:59:08 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:08 Started Qemu. Pid: 15068 2014/08/05 01:59:08 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:59:08 Qemu stderr: qemu-kvm: -display: invalid option ==> qemu: Error launching VM: Qemu failed to start. Please run with logs to get more info. 2014/08/05 01:59:08 ui error: ==> qemu: Error launching VM: Qemu failed to start. Please run with logs to get more info. ==> qemu: Pausing before cleanup of step 'stepConfigureVNC'. Press enter to continue. 2014/08/05 01:59:08 ui: ask: ==> qemu: Pausing before cleanup of step 'stepConfigureVNC'. Press enter to continue.

2014/08/05 02:06:23 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepForwardSSH'. Press enter to continue. 2014/08/05 02:06:23 ui: ask: ==> qemu: Pausing before cleanup of step 'stepForwardSSH'. Press enter to continue.

2014/08/05 02:06:24 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepHTTPServer'. Press enter to continue. 2014/08/05 02:06:24 ui: ask: ==> qemu: Pausing before cleanup of step 'stepHTTPServer'. Press enter to continue.

2014/08/05 02:06:24 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepCreateDisk'. Press enter to continue. 2014/08/05 02:06:24 ui: ask: ==> qemu: Pausing before cleanup of step 'stepCreateDisk'. Press enter to continue.

2014/08/05 02:06:25 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'StepCreateFloppy'. Press enter to continue. 2014/08/05 02:06:25 ui: ask: ==> qemu: Pausing before cleanup of step 'StepCreateFloppy'. Press enter to continue.

2014/08/05 02:06:25 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepPrepareOutputDir'. Press enter to continue. 2014/08/05 02:06:25 ui: ask: ==> qemu: Pausing before cleanup of step 'stepPrepareOutputDir'. Press enter to continue.

2014/08/05 02:06:25 ui: scan err: unexpected newline ==> qemu: Deleting output directory... 2014/08/05 02:06:25 ui: ==> qemu: Deleting output directory... ==> qemu: Pausing before cleanup of step 'StepDownload'. Press enter to continue. 2014/08/05 02:06:25 ui: ask: ==> qemu: Pausing before cleanup of step 'StepDownload'. Press enter to continue.

2014/08/05 02:06:25 ui: scan err: unexpected newline Build 'qemu' errored: Build was halted. 2014/08/05 02:06:25 ui error: Build 'qemu' errored: Build was halted. 2014/08/05 02:06:25 /usr/local/packer/packer-command-build: 2014/08/05 02:06:25 Waiting on builds to complete... 2014/08/05 02:06:25 /usr/local/packer/packer-command-build: 2014/08/05 02:06:25 Builds completed. Waiting on interrupt barrier... 2014/08/05 02:06:25 machine readable: error-count []string{"1"}

==> Some builds didn't complete successfully and had errors: 2014/08/05 02:06:25 ui error: ==> Some builds didn't complete successfully and had errors: 2014/08/05 02:06:25 machine readable: qemu,error []string{"Build was halted."} --> qemu: Build was halted. 2014/08/05 02:06:25 ui error: --> qemu: Build was halted.

==> Builds finished but no artifacts were created. 2014/08/05 02:06:25 ui: ==> Builds finished but no artifacts were created. 2014/08/05 02:06:25 waiting for all plugin processes to complete... 2014/08/05 02:06:25 [ERR] Error reading stream direction: EOF 2014/08/05 02:06:25 [INFO] Mux connection loop exiting 2014/08/05 02:06:25 [ERR] Error reading stream direction: EOF 2014/08/05 02:06:25 [INFO] Mux connection loop exiting 2014/08/05 02:06:25 /usr/local/packer/packer-command-build: plugin process exited 2014/08/05 02:06:25 /usr/local/packer/packer-builder-qemu: plugin process exited

listuser commented 10 years ago

So then I thought, may as well download and compile the latest QEMU with the --enable-sdl option to see if that works. But, no dice. Failed with a different error.

2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Qemu stderr: qemu-system-x86_64: -m 512m: Parameter 'size' expects a size

Here is the full log/debug output

export PACKER_LOG="yes"; /usr/local/packer/packer build -debug example.json 2014/08/05 01:57:27 Packer Version: 0.6.1 8b24d990943ff496a3bd951cb63f5fa03cff1c2f 2014/08/05 01:57:27 Packer Target OS/Arch: linux amd64 2014/08/05 01:57:27 Built with Go Version: go1.3 2014/08/05 01:57:27 Detected home directory from env var: /backup/home/testuser 2014/08/05 01:57:27 Attempting to open config file: /backup/home/testuser/.packerconfig 2014/08/05 01:57:27 File doesn't exist, but doesn't need to. Ignoring. 2014/08/05 01:57:27 Packer config: &{PluginMinPort:0 PluginMaxPort:0 Builders:map[googlecompute:packer-builder-googlecompute virtualbox-iso:packer-builder-virtualbox-iso virtualbox-ovf:packer-builder-virtualbox-ovf amazon-instance:packer-builder-amazon-instance docker:packer-builder-docker vmware-iso:packer-builder-vmware-iso parallels-pvm:packer-builder-parallels-pvm null:packer-builder-null amazon-ebs:packer-builder-amazon-ebs digitalocean:packer-builder-digitalocean openstack:packer-builder-openstack qemu:packer-builder-qemu vmware-vmx:packer-builder-vmware-vmx amazon-chroot:packer-builder-amazon-chroot parallels-iso:packer-builder-parallels-iso] Commands:map[inspect:packer-command-inspect validate:packer-command-validate build:packer-command-build fix:packer-command-fix] PostProcessors:map[vagrant-cloud:packer-post-processor-vagrant-cloud vagrant:packer-post-processor-vagrant vsphere:packer-post-processor-vsphere docker-push:packer-post-processor-docker-push docker-import:packer-post-processor-docker-import] Provisioners:map[ansible-local:packer-provisioner-ansible-local chef-client:packer-provisioner-chef-client chef-solo:packer-provisioner-chef-solo file:packer-provisioner-file puppet-masterless:packer-provisioner-puppet-masterless puppet-server:packer-provisioner-puppet-server shell:packer-provisioner-shell salt-masterless:packer-provisioner-salt-masterless]} 2014/08/05 01:57:27 Setting cache directory: /var/tmp/packer_cache 2014/08/05 01:57:27 Environment.Cli: []string{"build", "-debug", "example.json"} 2014/08/05 01:57:27 command + args: []string{"build", "-debug", "example.json"} 2014/08/05 01:57:27 Loading command: build 2014/08/05 01:57:27 Plugin could not be found. Checking same directory as executable. 2014/08/05 01:57:27 Current exe path: /usr/local/packer/packer 2014/08/05 01:57:27 Creating plugin client for path: /usr/local/packer/packer-command-build 2014/08/05 01:57:27 Starting plugin: /usr/local/packer/packer-command-build []string{"/usr/local/packer/packer-command-build"} 2014/08/05 01:57:27 Waiting for RPC address for: /usr/local/packer/packer-command-build 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Plugin build against Packer '8b24d990943ff496a3bd951cb63f5fa03cff1c2f' 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Plugin minimum port: 10000 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Plugin maximum port: 25000 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Plugin address: unix /tmp/packer-plugin913273734 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Waiting for connection... 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Serving a plugin connection... 2014/08/05 01:57:27 Executing command: build 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Reading template: example.json 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Creating build: qemu 2014/08/05 01:57:27 Loading builder: qemu 2014/08/05 01:57:27 Plugin could not be found. Checking same directory as executable. 2014/08/05 01:57:27 Current exe path: /usr/local/packer/packer 2014/08/05 01:57:27 Creating plugin client for path: /usr/local/packer/packer-builder-qemu 2014/08/05 01:57:27 Starting plugin: /usr/local/packer/packer-builder-qemu []string{"/usr/local/packer/packer-builder-qemu"} 2014/08/05 01:57:27 Waiting for RPC address for: /usr/local/packer/packer-builder-qemu 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Plugin build against Packer '8b24d990943ff496a3bd951cb63f5fa03cff1c2f' 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Plugin minimum port: 10000 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Plugin maximum port: 25000 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Plugin address: unix /tmp/packer-plugin172014307 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Waiting for connection... 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Serving a plugin connection... Debug mode enabled. Builds will not be parallelized. 2014/08/05 01:57:27 ui: Debug mode enabled. Builds will not be parallelized. qemu output will be in this color. 2014/08/05 01:57:27 ui: qemu output will be in this color.

2014/08/05 01:57:27 ui: 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Build debug mode: true 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Force build: false 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Preparing build: qemu 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Debug enabled, so waiting for build to finish: qemu 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Starting build run: qemu 2014/08/05 01:57:27 /usr/local/packer/packer-command-build: 2014/08/05 01:57:27 Running builder: qemu 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Qemu path: /var/tmp/qemu/bin/debug/native/x86_64-softmmu/qemu-system-x86_64, Qemu Image page: /usr/bin/qemu-img ==> qemu: Downloading or copying ISO 2014/08/05 01:57:27 ui: ==> qemu: Downloading or copying ISO qemu: Downloading or copying: http://127.0.0.1/iso/CentOS-6.5-x86_64-minimal.iso 2014/08/05 01:57:27 ui: qemu: Downloading or copying: http://127.0.0.1/iso/CentOS-6.5-x86_64-minimal.iso 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Acquiring lock to download: http://127.0.0.1/iso/CentOS-6.5-x86_64-minimal.iso 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Verifying checksum of /var/tmp/packer_cache/36df08c5b42147b206407d7b584307c5b485318805ef72945e0d3e868584c0e3.iso 2014/08/05 01:57:27 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:27 Initial checksum matched, no download needed. ==> qemu: Pausing after run of step 'StepDownload'. Press enter to continue. 2014/08/05 01:57:27 ui: ask: ==> qemu: Pausing after run of step 'StepDownload'. Press enter to continue.

2014/08/05 01:57:28 ui: scan err: unexpected newline ==> qemu: Pausing after run of step 'stepPrepareOutputDir'. Press enter to continue. 2014/08/05 01:57:28 ui: ask: ==> qemu: Pausing after run of step 'stepPrepareOutputDir'. Press enter to continue.

2014/08/05 01:57:29 ui: scan err: unexpected newline 2014/08/05 01:57:29 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:29 No floppy files specified. Floppy disk will not be made. ==> qemu: Pausing after run of step 'StepCreateFloppy'. Press enter to continue. 2014/08/05 01:57:29 ui: ask: ==> qemu: Pausing after run of step 'StepCreateFloppy'. Press enter to continue.

2014/08/05 01:57:29 ui: scan err: unexpected newline ==> qemu: Creating hard drive... 2014/08/05 01:57:29 ui: ==> qemu: Creating hard drive... 2014/08/05 01:57:29 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:29 Executing qemu-img: []string{"create", "-f", "qcow2", "/var/tmp/output_centos_tdhtest/tdhtest.qcow2", "5000M"} 2014/08/05 01:57:29 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:29 stdout: Formatting '/var/tmp/output_centos_tdhtest/tdhtest.qcow2', fmt=qcow2 size=5242880000 encryption=off cluster_size=65536 2014/08/05 01:57:29 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:29 stderr: ==> qemu: Pausing after run of step 'stepCreateDisk'. Press enter to continue. 2014/08/05 01:57:29 ui: ask: ==> qemu: Pausing after run of step 'stepCreateDisk'. Press enter to continue.

2014/08/05 01:57:29 ui: scan err: unexpected newline ==> qemu: Pausing after run of step 'stepHTTPServer'. Press enter to continue. 2014/08/05 01:57:29 ui: ask: ==> qemu: Pausing after run of step 'stepHTTPServer'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Looking for available SSH port between 2222 and 2223 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Trying port: 2222 ==> qemu: Found port for SSH: 2222. 2014/08/05 01:57:30 ui: ==> qemu: Found port for SSH: 2222. ==> qemu: Pausing after run of step 'stepForwardSSH'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing after run of step 'stepForwardSSH'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Looking for available port between 5900 and 6000 2014/08/05 01:57:30 ui: ==> qemu: Looking for available port between 5900 and 6000 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Looking for available port between 5900 and 6000 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Trying port: 5987 ==> qemu: Found available VNC port: 5987 2014/08/05 01:57:30 ui: ==> qemu: Found available VNC port: 5987 ==> qemu: Pausing after run of step 'stepConfigureVNC'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing after run of step 'stepConfigureVNC'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Starting VM, booting from CD-ROM 2014/08/05 01:57:30 ui: ==> qemu: Starting VM, booting from CD-ROM 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Qemu Builder has no floppy files, not attaching a floppy. 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Executing /var/tmp/qemu/bin/debug/native/x86_64-softmmu/qemu-system-x86_64: []string{"-cdrom", "/var/tmp/packer_cache/36df08c5b42147b206407d7b584307c5b485318805ef72945e0d3e868584c0e3.iso", "-machine", "type=pc-1.0,accel=kvm", "-boot", "once=d", "-m", "512m", "-vnc", "0.0.0.0:87", "-name", "tdhtest", "-display", "sdl", "-netdev", "user,id=user.0", "-device", "virtio-net,netdev=user.0", "-drive", "file=/var/tmp/output_centos_tdhtest/tdhtest.qcow2,if=virtio", "-redir", "tcp:2222::22"} 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Started Qemu. Pid: 14940 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: 2014/08/05 01:57:30 Qemu stderr: qemu-system-x86_64: -m 512m: Parameter 'size' expects a size ==> qemu: Error launching VM: Qemu failed to start. Please run with logs to get more info. 2014/08/05 01:57:30 ui error: ==> qemu: Error launching VM: Qemu failed to start. Please run with logs to get more info. ==> qemu: Pausing before cleanup of step 'stepConfigureVNC'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing before cleanup of step 'stepConfigureVNC'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepForwardSSH'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing before cleanup of step 'stepForwardSSH'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepHTTPServer'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing before cleanup of step 'stepHTTPServer'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepCreateDisk'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing before cleanup of step 'stepCreateDisk'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'StepCreateFloppy'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing before cleanup of step 'StepCreateFloppy'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Pausing before cleanup of step 'stepPrepareOutputDir'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing before cleanup of step 'stepPrepareOutputDir'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline ==> qemu: Deleting output directory... 2014/08/05 01:57:30 ui: ==> qemu: Deleting output directory... ==> qemu: Pausing before cleanup of step 'StepDownload'. Press enter to continue. 2014/08/05 01:57:30 ui: ask: ==> qemu: Pausing before cleanup of step 'StepDownload'. Press enter to continue.

2014/08/05 01:57:30 ui: scan err: unexpected newline Build 'qemu' errored: Build was halted. 2014/08/05 01:57:30 ui error: Build 'qemu' errored: Build was halted. 2014/08/05 01:57:30 /usr/local/packer/packer-command-build: 2014/08/05 01:57:30 Waiting on builds to complete... 2014/08/05 01:57:30 /usr/local/packer/packer-command-build: 2014/08/05 01:57:30 Builds completed. Waiting on interrupt barrier... 2014/08/05 01:57:30 machine readable: error-count []string{"1"}

==> Some builds didn't complete successfully and had errors: 2014/08/05 01:57:30 ui error: ==> Some builds didn't complete successfully and had errors: 2014/08/05 01:57:30 machine readable: qemu,error []string{"Build was halted."} --> qemu: Build was halted. 2014/08/05 01:57:30 ui error: --> qemu: Build was halted.

==> Builds finished but no artifacts were created. 2014/08/05 01:57:30 ui: ==> Builds finished but no artifacts were created. 2014/08/05 01:57:30 waiting for all plugin processes to complete... 2014/08/05 01:57:30 [ERR] Error reading stream direction: EOF 2014/08/05 01:57:30 [INFO] Mux connection loop exiting 2014/08/05 01:57:30 /usr/local/packer/packer-builder-qemu: plugin process exited 2014/08/05 01:57:30 [ERR] Error reading stream direction: EOF 2014/08/05 01:57:30 [INFO] Mux connection loop exiting 2014/08/05 01:57:30 /usr/local/packer/packer-command-build: plugin process exited

listuser commented 10 years ago

I am not sure if I just need to change an option in my template or what I might try next. Thanks for your help.

listuser commented 10 years ago

After I compiled the current version of QEMU with --enable-sdl, I was able to get packer rolling again by overriding the QEMU default arg for memory in my template with

  "qemuargs": [ [ "-m", "size=1024" ] ],

Is there a way to override the "-display" option using the template so that it doesn't get passed at all? I would like to use the default qemu-kvm that is provided with the system instead of the version I compiled. Thank you.

listuser commented 10 years ago

I ended up scripting a workaround for the qemu-kvm that is provided with the system. I created a shell script, /usr/libexec/qemu-kvm.sh, with the following to remove the "-display" and "-redir" options.

!/bin/bash

ARGS=echo $@ | sed -e 's|-display||g' -e 's|-redir||g'

exec /usr/libexec/qemu-kvm $ARGS

And I ended up using vncviewer instead of SDL to connect to check the status of the build. Here is my template using the system provided qemu-kvm binary.

{ "builders": [ { "type": "qemu", "qemu_binary" : "/usr/libexec/qemu-kvm.sh", "qemuargs": [ [ "-m", "1024m" ], [ "-enable-kvm", "" ], [ "-display", "" ], [ "-redir", "" ], [ "-machine", "type=pc,accel=kvm" ], [ "-netdev", "user,id=mynet0,hostfwd=tcp::2222-:22" ], [ "-vnc", "127.0.0.1:87" ], [ "-device", "virtio-net-pci,netdev=mynet0" ] ], "iso_url": "http://127.0.0.1/pub/centos/6/iso/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso", "iso_checksum": "83221db52687c7b857e65bfe60787838", "iso_checksum_type": "md5", "output_directory": "/var/tmp/output_centos_tdhtest", "ssh_wait_timeout": "10000s", "shutdown_command": "shutdown -P now", "disk_size": 10000, "format": "qcow2", "headless": false, "accelerator": "kvm", "http_directory": "/var/ftp/pub/ks", "http_port_min": 8000, "http_port_max": 8000, "ssh_host_port_min": 2222, "ssh_host_port_max": 2223, "ssh_username": "root", "ssh_password": "deeznuts", "ssh_port": 22, "ssh_wait_timeout": "90m", "vm_name": "tdhtest", "disk_interface": "virtio", "boot_wait": "5s", "boot_command": [ " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/tdhtest.cfg" ] } ] }

kholloway commented 10 years ago

For anyone else running into this issue or the other issues related to building with the default RHEL/Qemu-kvm binaries please see below:

  1. To fix the '-display sdl' problem simply use "headless": true, in your builder .json file to disable that entire option from being passed to qemu.
  2. -redir is deprecated for most versions of qemu now so I patched the code to append that info to the -netdev option instead which is what qemu now recommends you use.
  3. The -m 512m has been fixed as shown above but I also patched the default to just remove the M entirely since qemu assumes your memory size is in MB anyway.
  4. You may also run into a machine type issue when building with the RHEL default qemu-kvm binary. You can fix that one of 3 ways:
    1. When calling packer build mybuild.json pass an environment variable to set the machine type: MachineType=pc packer build mybuild.json
    2. You can change the global setting in ~/.packer config file
    3. You can update 'b.config.MachineType = "pc-1.0"' line in packer/builder/qemu/builder.go (Note I am submitting a patch for this shortly).

Some QEMU binaries support pc-1.0 but ALL of them seem to support 'pc' and it's often just an alias back to what pc-1.0 was anyway so it seems like a more sane default value (tested on OS X, Ubuntu 14, RHEL 6.5)

My fork with these patches is available here: https://github.com/kholloway/packer I'm going to submit a PR shortly with these changes and hopefully it's rolled into the main packer repo since trying to build on RHEL6 right now is currently impossible without these patches.

Thanks and good luck!

listuser commented 10 years ago

Thank you for addressing the issues. Of note, I ran into the machine type issue as well. At the time, I used similar to the following to override the default (see config above).

[ "-machine", "type=pc" ]

Thanks again

kholloway commented 10 years ago

Yes that's another option as well but then you miss the accelerator part of the line.. :) The full line as passed by packer when using KVM as your accelerator would be:

"-machine", "type=pc,accel=kvm",.

jfbibeau commented 9 years ago

@kholloway did you end up making a PR? These issues all still seem to be present today affecting qemu-kvm. Thanks!

kholloway commented 9 years ago

Yep PR #1561 was merged back in October 2014 and with my changes/fixes. Here is a portion of my config used for building RHEL65 VM's on a RHEL6 global, adjust values as needed.

{
  "variables": {
    "hostname": "yourfqdn",
    "qemu_path": "{{env `PWD`}}"
  },
  "builders":
  [
    {
      "type": "qemu",
      "accelerator": "kvm",
      "qemu_binary": "/usr/libexec/qemu-kvm",
      "qemuargs": [
         [ "-m", "4096" ],
         [ "-smp", "2,sockets=2,cores=1,threads=1" ]
      ],
   }
]