You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
packer/website/source/docs/builders/qemu.html.md.erb

135 lines
4.1 KiB

---
modeline: |
vim: set ft=pandoc:
description: |
The Qemu Packer builder is able to create KVM and Xen virtual machine images.
layout: docs
page_title: 'QEMU - Builders'
sidebar_current: 'docs-builders-qemu'
---
# QEMU Builder
Type: `qemu`
The Qemu Packer builder is able to create [KVM](http://www.linux-kvm.org) and
[Xen](http://www.xenproject.org) virtual machine images.
The builder builds a virtual machine by creating a new virtual machine from
scratch, booting it, installing an OS, rebooting the machine with the boot media
as the virtual hard drive, provisioning software within the OS, then shutting it
down. The result of the Qemu builder is a directory containing the image file
necessary to run the virtual machine on KVM or Xen.
## Basic Example
Here is a basic example. This example is functional so long as you fixup paths
to files, URLS for ISOs and checksums.
``` json
{
"builders":
[
{
"type": "qemu",
"iso_url": "http://mirror.raystedman.net/centos/6/isos/x86_64/CentOS-6.9-x86_64-minimal.iso",
"iso_checksum": "af4a1640c0c6f348c6c41f1ea9e192a2",
"iso_checksum_type": "md5",
"output_directory": "output_centos_tdhtest",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
"disk_size": 5000,
"format": "qcow2",
"accelerator": "kvm",
"http_directory": "path/to/httpdir",
"ssh_username": "root",
"ssh_password": "s0m3password",
"ssh_timeout": "20m",
"vm_name": "tdhtest",
"net_device": "virtio-net",
"disk_interface": "virtio",
"boot_wait": "10s",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg<enter><wait>"
]
}
]
}
```
This is an example only, and will time out waiting for SSH because we have not
provided a kickstart file. You must add a valid kickstart file to the
"http_directory" and then provide the file in the "boot_command" in order for
this build to run. We recommend you check out the
[Community Templates](https://www.packer.io/community-tools.html#templates)
for a practical usage example.
## Configuration Reference
There are many configuration options available for the Qemu builder. They are
organized below into two categories: required and optional. Within each
category, the available options are alphabetized and described.
In addition to the options listed here, a
[communicator](/docs/templates/communicator.html) can be configured for this
builder.
Note that you will need to set `"headless": true` if you are running Packer
on a Linux server without X11; or if you are connected via ssh to a remote
Linux server and have not enabled X11 forwarding (`ssh -X`).
## ISO Configuration Reference
<%= partial "partials/common/ISOConfig" %>
### Required:
<%= partial "partials/common/ISOConfig-required" %>
### Optional:
<%= partial "partials/common/ISOConfig-not-required" %>
## Http directory configuration reference
<%= partial "partials/common/HTTPConfig" %>
### Optional:
<%= partial "partials/common/HTTPConfig-not-required" %>
## Floppy configuration reference
<%= partial "partials/common/FloppyConfig" %>
### Optional:
<%= partial "partials/common/FloppyConfig-not-required" %>
## Qemu Configuration Reference
### Optional:
<%= partial "partials/builder/qemu/Config-not-required" %>
## Boot Configuration Reference
<%= partial "partials/common/bootcommand/VNCConfig" %>
<%= partial "partials/common/bootcommand/BootConfig" %>
### Optional:
<%= partial "partials/common/bootcommand/VNCConfig-not-required" %>
<%= partial "partials/common/bootcommand/BootConfig-not-required" %>
### Troubleshooting
Some users have experienced errors complaining about invalid keymaps. This
seems to be related to having a `common` directory or file in the directory
they've run Packer in, like the packer source directory. This appears to be an
upstream bug with qemu, and the best solution for now is to remove the
file/directory or run in another directory.
Some users have reported issues with incorrect keymaps using qemu version 2.11.
This is a bug with qemu, and the solution is to upgrade, or downgrade to 2.10.1
or earlier.