-
Notifications
You must be signed in to change notification settings - Fork 92
[Issue 276] QEMU Agent configuration settings #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| //go:generate packer-sdc struct-markdown | ||
| //go:generate packer-sdc mapstructure-to-hcl2 -type Config,NICConfig,diskConfig,rng0Config,pciDeviceConfig,vgaConfig,ISOsConfig,efiConfig,tpmConfig | ||
| //go:generate packer-sdc mapstructure-to-hcl2 -type Config,NICConfig,diskConfig,rng0Config,pciDeviceConfig,vgaConfig,ISOsConfig,efiConfig,tpmConfig,agentConfig | ||
|
|
||
| package proxmox | ||
|
|
||
|
|
@@ -158,10 +158,13 @@ type Config struct { | |
| // ] | ||
| // ``` | ||
| Serials []string `mapstructure:"serials"` | ||
| // DEPRECATED. Define QEMU Guest Agent settings in a `qemu_guest_agent` block instead. | ||
| // Enables QEMU Agent option for this VM. When enabled, | ||
| // then `qemu-guest-agent` must be installed on the guest. When disabled, then | ||
| // `ssh_host` should be used. Defaults to `true`. | ||
| Agent config.Trilean `mapstructure:"qemu_agent"` | ||
| // QEMU Guest Agent configuration. See [QEMU Guest Agent](#qemu-guest-agent) | ||
| GuestAgent agentConfig `mapstructure:"qemu_guest_agent"` | ||
| // The SCSI controller model to emulate. Can be `lsi`, | ||
| // `lsi53c810`, `virtio-scsi-pci`, `virtio-scsi-single`, `megasas`, or `pvscsi`. | ||
| // Defaults to `lsi`. | ||
|
|
@@ -207,6 +210,45 @@ type Config struct { | |
| Ctx interpolate.Context `mapstructure-to-hcl2:",skip"` | ||
| } | ||
|
|
||
| // Set the QEMU Guest Agent options. | ||
| // | ||
| // JSON Example: | ||
| // | ||
| // ```json | ||
| // | ||
| // "qemu_guest_agent": { | ||
| // "enabled": true, | ||
| // "type": "isa", | ||
| // "freeze": false, | ||
| // "fstrim": false | ||
| // } | ||
| // | ||
| // ``` | ||
| // HCL2 example: | ||
| // | ||
| // ```hcl | ||
| // | ||
| // qemu_guest_agent { | ||
| // enabled = true | ||
| // type = "isa" | ||
| // freeze = false | ||
| // fstrim = false | ||
| // } | ||
| // | ||
| // ``` | ||
| type agentConfig struct { | ||
| // Enable QEMU Agent option for this VM. When enabled | ||
| // `qemu-guest-agent` must be installed on the guest. When disabled | ||
| // `ssh_host` should be used. Defaults to `true`. | ||
| Enabled config.Trilean `mapstructure:"enabled"` | ||
| // Sets the Agent Type. Must be `isa` or `virtio`. Defaults to `virtio` | ||
| Type string `mapstructure:"type"` | ||
| // Enable freeze/thaw of guest filesystem on backup. Defaults to `true` | ||
| Freeze config.Trilean `mapstructure:"freeze"` | ||
| // Run guest-trim after a disk move or VM migration. Defaults to `false` | ||
| FsTrim bool `mapstructure:"fstrim"` | ||
| } | ||
|
|
||
| // ISO files attached to the virtual machine. | ||
| // | ||
| // JSON Example: | ||
|
|
@@ -606,7 +648,27 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st | |
|
|
||
| // Default qemu_agent to true | ||
| if c.Agent != config.TriFalse { | ||
| c.Agent = config.TriTrue | ||
| warnings = append(warnings, "qemu_agent is deprecated and will be removed in a future release. define QEMU agent settings in a qemu_guest_agent block instead") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest we only print that warning if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It occurred to me that we don't need to set a default value for |
||
| // convert to qemu_guest_agent block value | ||
| c.GuestAgent.Enabled = config.TriTrue | ||
| } | ||
|
|
||
| // Default qemu_guest_agent.enable to true | ||
| if c.GuestAgent.Enabled != config.TriFalse { | ||
| c.GuestAgent.Enabled = config.TriTrue | ||
| } | ||
| // Default qemu_guest_agent.freeze to true | ||
| if c.GuestAgent.Freeze != config.TriFalse { | ||
| c.GuestAgent.Freeze = config.TriTrue | ||
| } | ||
|
|
||
| switch c.GuestAgent.Type { | ||
| case "virtio", "isa": | ||
| case "": | ||
| log.Printf("qemu_guest_agent type not specified, defaulting to `virtio`") | ||
| c.GuestAgent.Type = "virtio" | ||
| default: | ||
| errs = packersdk.MultiErrorAppend(errs, errors.New("qemu_guest_agent type field must be `virtio` or `isa`")) | ||
| } | ||
|
|
||
| packersdk.LogSecretFilter.Set(c.Password) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an option we're introducing here, and the default is
true, in general I would suggest maybe inverting the option to something likedisable_freeze, so it's clear that we freeze by default, and only don't do it if requested.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, have rerolled with
disable_freezeas a bool