Skip to content
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

[Issue 276] QEMU Agent configuration settings #287

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mpywell
Copy link
Contributor

@mpywell mpywell commented Oct 4, 2024

Extend QEMU agent handling by introducing the qemu_quest_agent block

qemu_guest_agent adds the ability to set each of the QEMU Guest Agent's available settings:

  • Enable/Disable the agent (replaces the qemu_agent bool)
  • Setting the agent type
  • Toggling freeze/thaw filesystems on backup
  • Toggling fstrim after disk move or VM migration

Each added setting defaults to Proxmox's backend defaults when not configured.

Closes #276

@mpywell mpywell requested a review from a team as a code owner October 4, 2024 13:34
@mpywell mpywell changed the title [Issue 276}: QEMU Agent configuration settings [Issue 276] QEMU Agent configuration settings Oct 4, 2024
- Extend QEMU agent handling by introducing qemu_quest_agent block, deprecating qemu_agent bool
- Enable setting the agent type
- Enable toggling freeze/thaw filesystems on backup
- Enable toggling fstrim after disk move or VM migration
- Each added setting defaults to Proxmox's backend defaults when not configured.
@mpywell mpywell force-pushed the feat/276_agent_settings branch from b3848f4 to 0b738ef Compare October 28, 2024 22:30
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this one @mpywell!

Overall LGTM, I left a couple of suggestions, feel free to address them and I'll come back for another round of review after that.

// 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"`
Copy link
Contributor

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 like disable_freeze, so it's clear that we freeze by default, and only don't do it if requested.

Copy link
Contributor Author

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_freeze as a bool

@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we only print that warning if qemu_agent is unset here, not if it's not explicitly false, otherwise we'll see it all the time unless we add qemu_agent = false to the template.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 c.Agent given the replacement c.GuestAgent.Enabled has a default set further down, so I've changed the logic to warn and convert the value only if the c.Agent is not Unset.

@@ -103,8 +103,8 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) {
if b.config.Disks[0].CacheMode != "none" {
t.Errorf("Expected disk cache mode to be 'none', got %s", b.config.Disks[0].CacheMode)
}
if b.config.Agent.True() != true {
t.Errorf("Expected Agent to be true, got %t", b.config.Agent.True())
if b.config.GuestAgent.Enabled.True() != true {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest simplifying this one;

Suggested change
if b.config.GuestAgent.Enabled.True() != true {
if !b.config.GuestAgent.Enabled.True() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added to reroll

- fix qemu_agent deprecation warnings and conversion
- invert freeze config option for qemu_guest_agent
- simplify test logic for TestBasicExampleFromDocsIsValid
@mpywell
Copy link
Contributor Author

mpywell commented Oct 30, 2024

Hi @lbajolet-hashicorp have rerolled this one and added comments in the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent type selection (virtIO or ISA)
2 participants