Add machine_type option for qemu builder.

On CentOS7, ``pc-1.0'' qemu-kvm machine type are not supported.

Supported machines are:
none                 empty machine
pc                   RHEL 7.0.0 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-rhel7.0.0)
pc-i440fx-rhel7.0.0  RHEL 7.0.0 PC (i440FX + PIIX, 1996) (default)
rhel6.5.0            RHEL 6.5.0 PC
rhel6.4.0            RHEL 6.4.0 PC
rhel6.3.0            RHEL 6.3.0 PC
rhel6.2.0            RHEL 6.2.0 PC
rhel6.1.0            RHEL 6.1.0 PC
rhel6.0.0            RHEL 6.0.0 PC
q35                  RHEL-7.0.0 PC (Q35 + ICH9, 2009) (alias of pc-q35-rhel7.0.0)
pc-q35-rhel7.0.0     RHEL-7.0.0 PC (Q35 + ICH9, 2009)
This commit is contained in:
Hiroyuki Sato 2014-08-12 16:02:03 +09:00
parent a5bc5beccb
commit 965d273907
2 changed files with 7 additions and 1 deletions

View File

@ -67,6 +67,7 @@ type config struct {
ISOChecksum string `mapstructure:"iso_checksum"` ISOChecksum string `mapstructure:"iso_checksum"`
ISOChecksumType string `mapstructure:"iso_checksum_type"` ISOChecksumType string `mapstructure:"iso_checksum_type"`
ISOUrls []string `mapstructure:"iso_urls"` ISOUrls []string `mapstructure:"iso_urls"`
MachineType string `mapstructure:"machine_type"`
NetDevice string `mapstructure:"net_device"` NetDevice string `mapstructure:"net_device"`
OutputDir string `mapstructure:"output_directory"` OutputDir string `mapstructure:"output_directory"`
QemuArgs [][]string `mapstructure:"qemuargs"` QemuArgs [][]string `mapstructure:"qemuargs"`
@ -127,6 +128,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
b.config.HTTPPortMax = 9000 b.config.HTTPPortMax = 9000
} }
if b.config.MachineType == "" {
b.config.MachineType = "pc-1.0"
}
if b.config.OutputDir == "" { if b.config.OutputDir == "" {
b.config.OutputDir = fmt.Sprintf("output-%s", b.config.PackerBuildName) 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, "shutdown_timeout": &b.config.RawShutdownTimeout,
"ssh_wait_timeout": &b.config.RawSSHWaitTimeout, "ssh_wait_timeout": &b.config.RawSSHWaitTimeout,
"accelerator": &b.config.Accelerator, "accelerator": &b.config.Accelerator,
"machine_type": &b.config.MachineType,
"net_device": &b.config.NetDevice, "net_device": &b.config.NetDevice,
"disk_interface": &b.config.DiskInterface, "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 := make(map[string]string)
defaultArgs["-name"] = vmName 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["-display"] = guiArgument
defaultArgs["-netdev"] = "user,id=user.0" defaultArgs["-netdev"] = "user,id=user.0"
defaultArgs["-device"] = fmt.Sprintf("%s,netdev=user.0", config.NetDevice) defaultArgs["-device"] = fmt.Sprintf("%s,netdev=user.0", config.NetDevice)