Skip to content

Commit

Permalink
Merge pull request #8892 from zaventh/feature/vga-adapter
Browse files Browse the repository at this point in the history
feat(proxmox): add ability to specify vga adapter
  • Loading branch information
SwampDragons authored Mar 17, 2020
2 parents 0d454f1 + e503afb commit dc9259f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
7 changes: 6 additions & 1 deletion builder/proxmox/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate mapstructure-to-hcl2 -type Config,nicConfig,diskConfig
//go:generate mapstructure-to-hcl2 -type Config,nicConfig,diskConfig,vgaConfig

package proxmox

Expand Down Expand Up @@ -45,6 +45,7 @@ type Config struct {
CPUType string `mapstructure:"cpu_type"`
Sockets int `mapstructure:"sockets"`
OS string `mapstructure:"os"`
VGA vgaConfig `mapstructure:"vga"`
NICs []nicConfig `mapstructure:"network_adapters"`
Disks []diskConfig `mapstructure:"disks"`
ISOFile string `mapstructure:"iso_file"`
Expand Down Expand Up @@ -75,6 +76,10 @@ type diskConfig struct {
CacheMode string `mapstructure:"cache_mode"`
DiskFormat string `mapstructure:"format"`
}
type vgaConfig struct {
Type string `mapstructure:"type"`
Memory int `mapstructure:"memory"`
}

func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Agent defaults to true
Expand Down
29 changes: 28 additions & 1 deletion builder/proxmox/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions builder/proxmox/step_start_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist
QemuCores: c.Cores,
QemuSockets: c.Sockets,
QemuOs: c.OS,
QemuVga: generateProxmoxVga(c.VGA),
QemuIso: isoFile,
QemuNetworks: generateProxmoxNetworkAdapters(c.NICs),
QemuDisks: generateProxmoxDisks(c.Disks),
Expand Down Expand Up @@ -118,6 +119,15 @@ func generateProxmoxDisks(disks []diskConfig) proxmox.QemuDevices {
}
return devs
}
func generateProxmoxVga(vga vgaConfig) proxmox.QemuDevice {
dev := make(proxmox.QemuDevice)
setDeviceParamIfDefined(dev, "type", vga.Type)

if vga.Memory > 0 {
dev["memory"] = vga.Memory
}
return dev
}

func setDeviceParamIfDefined(dev proxmox.QemuDevice, key, value string) {
if value != "" {
Expand Down
15 changes: 15 additions & 0 deletions website/source/docs/builders/proxmox.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ builder.
`wvista`, `win7`, `win8`, `win10`, `l24` (Linux 2.4), `l26` (Linux 2.6+),
`solaris` or `other`. Defaults to `other`.

- `vga` (object) - The graphics adapter to use. Example:

```json
{
"type": "vmware",
"memory": 32
}
```

- `type` (string) - Can be `cirrus`, `none`, `qxl`,`qxl2`, `qxl3`,
`qxl4`, `serial0`, `serial1`, `serial2`, `serial3`, `std`, `virtio`, `vmware`.
Defaults to `std`.

- `memory` (int) - How much memory to assign.

- `network_adapters` (array of objects) - Network adapters attached to the
virtual machine. Example:

Expand Down

0 comments on commit dc9259f

Please sign in to comment.