diff --git a/proxmox/config_qemu.go b/proxmox/config_qemu.go index aeedcd42..df41aa52 100644 --- a/proxmox/config_qemu.go +++ b/proxmox/config_qemu.go @@ -790,6 +790,15 @@ func (ConfigQemu) mapToStruct(params map[string]interface{}) (*ConfigQemu, error } } + // efidisk + if efidisk, isSet := params["efidisk0"].(string); isSet { + efiDiskConfMap := ParsePMConf(efidisk, "volume") + storageName, fileName := ParseSubConf(efiDiskConfMap["volume"].(string), ":") + efiDiskConfMap["storage"] = storageName + efiDiskConfMap["file"] = fileName + config.EFIDisk = efiDiskConfMap + } + return &config, nil } @@ -1208,7 +1217,26 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e if err != nil { return } + + if config.EFIDisk != nil { + storageContent, err := client.GetStorageContent(vmr, config.EFIDisk["storage"].(string)) + if err != nil { + log.Fatal(err) + return nil, err + } + + contents := storageContent["data"].([]interface{}) + for content := range contents { + storageContentMap := contents[content].(map[string]interface{}) + if storageContentMap["volid"] == config.EFIDisk["volume"].(string) { + config.EFIDisk["format"] = storageContentMap["format"].(string) + break + } + } + } + config.defaults() + // HAstate is return by the api for a vm resource type but not the HAgroup err = client.ReadVMHA(vmr) if err == nil { diff --git a/proxmox/config_qemu_test.go b/proxmox/config_qemu_test.go index 68f7a8f3..5ac514f2 100644 --- a/proxmox/config_qemu_test.go +++ b/proxmox/config_qemu_test.go @@ -4371,6 +4371,17 @@ func Test_ConfigQemu_mapToStruct(t *testing.T) { }}}}, }, }, + // EFI + {name: "EFI Disk", + input: map[string]interface{}{"efidisk0": "local-lvm:vm-1000-disk-0,efitype=2m,size=4M"}, + output: &ConfigQemu{EFIDisk: map[string]interface{}{ + "efitype": "2m", + "size": "4M", + "storage": "local-lvm", + "file": "vm-1000-disk-0", + "volume": "local-lvm:vm-1000-disk-0", + }}, + }, } for _, test := range tests { t.Run(test.name, func(*testing.T) {