diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 7f404a566..301884ed0 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -67,6 +67,7 @@ type config struct { ISOChecksum string `mapstructure:"iso_checksum"` ISOChecksumType string `mapstructure:"iso_checksum_type"` ISOUrls []string `mapstructure:"iso_urls"` + MachineType string `mapstructure:"machine_type"` NetDevice string `mapstructure:"net_device"` OutputDir string `mapstructure:"output_directory"` QemuArgs [][]string `mapstructure:"qemuargs"` @@ -127,6 +128,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { b.config.HTTPPortMax = 9000 } + if b.config.MachineType == "" { + b.config.MachineType = "pc-1.0" + } + if b.config.OutputDir == "" { b.config.OutputDir = fmt.Sprintf("output-%s", b.config.PackerBuildName) } @@ -205,6 +210,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { "shutdown_timeout": &b.config.RawShutdownTimeout, "ssh_wait_timeout": &b.config.RawSSHWaitTimeout, "accelerator": &b.config.Accelerator, + "machine_type": &b.config.MachineType, "net_device": &b.config.NetDevice, "disk_interface": &b.config.DiskInterface, } diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index 858c8424c..649ba63ee 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -76,7 +76,7 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error defaultArgs := make(map[string]string) defaultArgs["-name"] = vmName - defaultArgs["-machine"] = fmt.Sprintf("type=pc-1.0,accel=%s", config.Accelerator) + defaultArgs["-machine"] = fmt.Sprintf("type=%s,accel=%s", config.MachineType, config.Accelerator) defaultArgs["-display"] = guiArgument defaultArgs["-netdev"] = "user,id=user.0" defaultArgs["-device"] = fmt.Sprintf("%s,netdev=user.0", config.NetDevice)