diff --git a/proxmox/config_qemu_guestagent.go b/proxmox/config_qemu_guestagent.go index d528a9b3..7337985c 100644 --- a/proxmox/config_qemu_guestagent.go +++ b/proxmox/config_qemu_guestagent.go @@ -38,7 +38,9 @@ func (newSetting QemuGuestAgent) mapToAPI(currentSettings *QemuGuestAgent) strin params += ",fstrim_cloned_disks=" + boolToIntString(*currentSettings.FsTrim) } if newSetting.Type != nil { - params += ",type=" + strings.ToLower(string(*newSetting.Type)) + if *newSetting.Type != QemuGuestAgentType_None { + params += ",type=" + strings.ToLower(string(*newSetting.Type)) + } } else if currentSettings != nil && currentSettings.Type != nil { params += ",type=" + strings.ToLower(string(*currentSettings.Type)) } diff --git a/proxmox/config_qemu_test.go b/proxmox/config_qemu_test.go index 77d36ec3..a5e15358 100644 --- a/proxmox/config_qemu_test.go +++ b/proxmox/config_qemu_test.go @@ -49,7 +49,10 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { {name: `Create Agent.Enable`, config: &ConfigQemu{Agent: &QemuGuestAgent{Enable: util.Pointer(true)}}, output: map[string]interface{}{"agent": "1"}}, - {name: `Create Agent.Type`, + {name: `Create Agent.Type=""`, + config: &ConfigQemu{Agent: &QemuGuestAgent{Type: util.Pointer(QemuGuestAgentType_None)}}, + output: map[string]interface{}{"agent": "0"}}, + {name: `Create Agent.Type="virtio"`, config: &ConfigQemu{Agent: &QemuGuestAgent{Type: util.Pointer(QemuGuestAgentType_VirtIO)}}, output: map[string]interface{}{"agent": "0,type=virtio"}}, {name: `Create Agent.Freeze`, @@ -1346,6 +1349,14 @@ func Test_ConfigQemu_mapToApiValues(t *testing.T) { config: &ConfigQemu{Agent: &QemuGuestAgent{Type: util.Pointer(QemuGuestAgentType_VirtIO)}}, currentConfig: ConfigQemu{Agent: &QemuGuestAgent{}}, output: map[string]interface{}{"agent": "0,type=virtio"}}, + {name: `Update Agent.Type "" !nil`, + config: &ConfigQemu{Agent: &QemuGuestAgent{Type: util.Pointer(QemuGuestAgentType_None)}}, + currentConfig: ConfigQemu{Agent: &QemuGuestAgent{}}, + output: map[string]interface{}{"agent": "0"}}, + {name: `Update Agent.Type "" nil`, + config: &ConfigQemu{Agent: &QemuGuestAgent{Type: util.Pointer(QemuGuestAgentType_None)}}, + currentConfig: ConfigQemu{Agent: &QemuGuestAgent{Type: util.Pointer(QemuGuestAgentType_VirtIO)}}, + output: map[string]interface{}{"agent": "0"}}, {name: `Update Agent.Type nil !nil`, config: &ConfigQemu{Agent: &QemuGuestAgent{}}, currentConfig: ConfigQemu{Agent: &QemuGuestAgent{Type: util.Pointer(QemuGuestAgentType_VirtIO)}},