diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 127c1d5ed..957f21fe2 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -16,29 +16,36 @@ import ( const BuilderId = "transcend.qemu" +var accels = map[string]struct{}{ + "none": struct{}{}, + "kvm": struct{}{}, + "tcg": struct{}{}, + "xen": struct{}{}, +} + var netDevice = map[string]bool{ - "ne2k_pci": true, - "i82551": true, - "i82557b": true, - "i82559er": true, - "rtl8139": true, - "e1000": true, - "pcnet": true, - "virtio": true, - "virtio-net": true, + "ne2k_pci": true, + "i82551": true, + "i82557b": true, + "i82559er": true, + "rtl8139": true, + "e1000": true, + "pcnet": true, + "virtio": true, + "virtio-net": true, "virtio-net-pci": true, - "usb-net": true, - "i82559a": true, - "i82559b": true, - "i82559c": true, - "i82550": true, - "i82562": true, - "i82557a": true, - "i82557c": true, - "i82801": true, - "vmxnet3": true, - "i82558a": true, - "i82558b": true, + "usb-net": true, + "i82559a": true, + "i82559b": true, + "i82559c": true, + "i82550": true, + "i82562": true, + "i82557a": true, + "i82557c": true, + "i82801": true, + "vmxnet3": true, + "i82558a": true, + "i82558b": true, } var diskInterface = map[string]bool{ @@ -256,9 +263,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs, errors.New("invalid format, only 'qcow2' or 'raw' are allowed")) } - if !(b.config.Accelerator == "kvm" || b.config.Accelerator == "xen" || b.config.Accelerator == "none") { + if _, ok := accels[b.config.Accelerator]; !ok { errs = packer.MultiErrorAppend( - errs, errors.New("invalid format, only 'kvm' or 'xen' or 'none' are allowed")) + errs, errors.New("invalid accelerator, only 'kvm', 'tcg', 'xen', or 'none' are allowed")) } if _, ok := netDevice[b.config.NetDevice]; !ok { diff --git a/website/source/docs/builders/qemu.html.markdown b/website/source/docs/builders/qemu.html.markdown index c9cac0a8a..f7f4314f2 100644 --- a/website/source/docs/builders/qemu.html.markdown +++ b/website/source/docs/builders/qemu.html.markdown @@ -92,8 +92,9 @@ each category, the available options are alphabetized and described. ### Optional: * `accelerator` (string) - The accelerator type to use when running the VM. - This may have a value of either "none", "kvm", or "xen" and you must have that - support in on the machine on which you run the builder. + This may have a value of either "none", "kvm", "tcg", or "xen" and you must have that + support in on the machine on which you run the builder. By default "kvm" + is used. * `boot_command` (array of strings) - This is an array of commands to type when the virtual machine is first booted. The goal of these commands should