Skip to content

Commit

Permalink
Merge pull request #3 from Tinyblargon/backport-BugFix-Qemu-Pool
Browse files Browse the repository at this point in the history
Bug fix: ConfigQemu. `Node`, `Pool`, `VmID`
  • Loading branch information
Tinyblargon authored Nov 27, 2023
2 parents 3f4f21f + 796c3d7 commit 21595de
Show file tree
Hide file tree
Showing 2 changed files with 2,112 additions and 2,047 deletions.
10 changes: 8 additions & 2 deletions proxmox/config_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func (config ConfigQemu) mapToApiValues(currentConfig ConfigQemu) (rebootRequire
return
}

func (ConfigQemu) mapToStruct(params map[string]interface{}) (*ConfigQemu, error) {
func (ConfigQemu) mapToStruct(vmr *VmRef, params map[string]interface{}) (*ConfigQemu, error) {
// vmConfig Sample: map[ cpu:host
// net0:virtio=62:DF:XX:XX:XX:XX,bridge=vmbr0
// ide2:local:iso/xxx-xx.iso,media=cdrom memory:2048
Expand All @@ -469,6 +469,12 @@ func (ConfigQemu) mapToStruct(params map[string]interface{}) (*ConfigQemu, error

config := ConfigQemu{}

if vmr != nil {
config.Node = vmr.node
config.Pool = vmr.pool
config.VmID = vmr.vmId
}

if _, isSet := params["agent"]; isSet {
switch params["agent"].(type) {
case float64:
Expand Down Expand Up @@ -1204,7 +1210,7 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
if vmConfig["lock"] != nil {
return nil, fmt.Errorf("vm locked, could not obtain config")
}
config, err = ConfigQemu{}.mapToStruct(vmConfig)
config, err = ConfigQemu{}.mapToStruct(vmr, vmConfig)
if err != nil {
return
}
Expand Down
Loading

0 comments on commit 21595de

Please sign in to comment.