Commit 9a032c8e authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge branch 'matthbak-master'

parents fbf67587 88c186df
......@@ -26,6 +26,7 @@ var netDevice = map[string]bool{
"pcnet": true,
"virtio": true,
"virtio-net": true,
"virtio-net-pci": true,
"usb-net": true,
"i82559a": true,
"i82559b": true,
......@@ -255,9 +256,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") {
if !(b.config.Accelerator == "kvm" || b.config.Accelerator == "xen" || b.config.Accelerator == "none") {
errs = packer.MultiErrorAppend(
errs, errors.New("invalid format, only 'kvm' or 'xen' are allowed"))
errs, errors.New("invalid format, only 'kvm' or 'xen' or 'none' are allowed"))
}
if _, ok := netDevice[b.config.NetDevice]; !ok {
......
......@@ -61,23 +61,23 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error
sshHostPort := state.Get("sshHostPort").(uint)
ui := state.Get("ui").(packer.Ui)
guiArgument := "sdl"
vnc := fmt.Sprintf("0.0.0.0:%d", vncPort-5900)
vmName := config.VMName
imgPath := filepath.Join(config.OutputDir,
fmt.Sprintf("%s.%s", vmName, strings.ToLower(config.Format)))
defaultArgs := make(map[string]string)
if config.Headless == true {
ui.Message("WARNING: The VM will be started in headless mode, as configured.\n" +
"In headless mode, errors during the boot sequence or OS setup\n" +
"won't be easily visible. Use at your own discretion.")
guiArgument = "none"
} else {
defaultArgs["-display"] = "sdl"
}
defaultArgs := make(map[string]string)
defaultArgs["-name"] = vmName
defaultArgs["-machine"] = fmt.Sprintf("type=%s,accel=%s", config.MachineType, config.Accelerator)
defaultArgs["-display"] = guiArgument
defaultArgs["-machine"] = fmt.Sprintf("type=%s", config.MachineType)
defaultArgs["-netdev"] = "user,id=user.0"
defaultArgs["-device"] = fmt.Sprintf("%s,netdev=user.0", config.NetDevice)
defaultArgs["-drive"] = fmt.Sprintf("file=%s,if=%s", imgPath, config.DiskInterface)
......@@ -87,6 +87,14 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error
defaultArgs["-redir"] = fmt.Sprintf("tcp:%v::22", sshHostPort)
defaultArgs["-vnc"] = vnc
// Append the accelerator to the machine type if it is specified
if config.Accelerator != "none" {
defaultArgs["-machine"] += fmt.Sprintf(",accel=%s", config.Accelerator)
} else {
ui.Message("WARNING: The VM will be started with no hardware acceleration.\n" +
"The installation may take considerably longer to finish.\n")
}
// Determine if we have a floppy disk to attach
if floppyPathRaw, ok := state.GetOk("floppy_path"); ok {
defaultArgs["-fda"] = floppyPathRaw.(string)
......
......@@ -92,7 +92,7 @@ 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 "kvm" or "xen" and you must have that
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.
* `boot_command` (array of strings) - This is an array of commands to type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment