From d3f369494a6063fdc559b11b677bb2354a92b978 Mon Sep 17 00:00:00 2001 From: Samuel Noordhuis Date: Sun, 6 Oct 2019 20:14:04 +1100 Subject: [PATCH] Add support for SCSI controller selection --- builder/proxmox/config.go | 21 ++++++++++++-------- builder/proxmox/config_test.go | 4 ++++ builder/proxmox/step_start_vm.go | 1 + website/source/docs/builders/proxmox.html.md | 4 ++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/builder/proxmox/config.go b/builder/proxmox/config.go index 6889c8c07..05dd32b66 100644 --- a/builder/proxmox/config.go +++ b/builder/proxmox/config.go @@ -37,14 +37,15 @@ type Config struct { VMName string `mapstructure:"vm_name"` VMID int `mapstructure:"vm_id"` - Memory int `mapstructure:"memory"` - Cores int `mapstructure:"cores"` - Sockets int `mapstructure:"sockets"` - OS string `mapstructure:"os"` - NICs []nicConfig `mapstructure:"network_adapters"` - Disks []diskConfig `mapstructure:"disks"` - ISOFile string `mapstructure:"iso_file"` - Agent bool `mapstructure:"qemu_agent"` + Memory int `mapstructure:"memory"` + Cores int `mapstructure:"cores"` + Sockets int `mapstructure:"sockets"` + OS string `mapstructure:"os"` + NICs []nicConfig `mapstructure:"network_adapters"` + Disks []diskConfig `mapstructure:"disks"` + ISOFile string `mapstructure:"iso_file"` + Agent bool `mapstructure:"qemu_agent"` + SCSIController string `mapstructure:"scsi_controller"` TemplateName string `mapstructure:"template_name"` TemplateDescription string `mapstructure:"template_description"` @@ -159,6 +160,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { errs = packer.MultiErrorAppend(errs, errors.New(fmt.Sprintf("disk format must be specified for pool type %q", c.Disks[idx].StoragePoolType))) } } + if c.SCSIController == "" { + log.Printf("SCSI controller not set, using default 'lsi'") + c.SCSIController = "lsi" + } errs = packer.MultiErrorAppend(errs, c.Comm.Prepare(&c.ctx)...) errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...) diff --git a/builder/proxmox/config_test.go b/builder/proxmox/config_test.go index ec654dc54..ce6041ddd 100644 --- a/builder/proxmox/config_test.go +++ b/builder/proxmox/config_test.go @@ -94,6 +94,7 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) { // NIC 0 model not set, using default 'e1000' // Disk 0 cache mode not set, using default 'none' // Agent not set, default is true + // SCSI controller not set, using default 'lsi' if b.config.Memory != 512 { t.Errorf("Expected Memory to be 512, got %d", b.config.Memory) @@ -116,6 +117,9 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) { if b.config.Agent != true { t.Errorf("Expected Agent to be true, got %t", b.config.Agent) } + if b.config.SCSIController != "lsi" { + t.Errorf("Expected SCSI controller to be 'lsi', got %s", b.config.SCSIController) + } } func TestAgentSetToFalse(t *testing.T) { diff --git a/builder/proxmox/step_start_vm.go b/builder/proxmox/step_start_vm.go index 76663b33f..71e3fa15f 100644 --- a/builder/proxmox/step_start_vm.go +++ b/builder/proxmox/step_start_vm.go @@ -40,6 +40,7 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist QemuIso: c.ISOFile, QemuNetworks: generateProxmoxNetworkAdapters(c.NICs), QemuDisks: generateProxmoxDisks(c.Disks), + Scsihw: c.SCSIController, } if c.VMID == 0 { diff --git a/website/source/docs/builders/proxmox.html.md b/website/source/docs/builders/proxmox.html.md index ca7c99ea3..3c5c8db55 100644 --- a/website/source/docs/builders/proxmox.html.md +++ b/website/source/docs/builders/proxmox.html.md @@ -152,6 +152,10 @@ builder. then `qemu-guest-agent` must be installed on the guest. When disabled, then `ssh_host` should be used. Defaults to `true`. +- `scsi_controller` (string) - The SCSI controller model to emulate. Can be `lsi`, + `lsi53c810`, `virtio-scsi-pci`, `virtio-scsi-single`, `megasas`, or `pvscsi`. + Defaults to `lsi`. + ## Example: Fedora with kickstart Here is a basic example creating a Fedora 29 server image with a Kickstart