Merge pull request #1407 from hiroyuki-sato/patch_for_packer

builder/qemu: add machine_type option for qemu builder.
This commit is contained in:
Mitchell Hashimoto 2014-09-01 21:39:06 -07:00
commit 18a4a4d5ea
2 changed files with 7 additions and 1 deletions

View File

@ -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,
}

View File

@ -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)