Skip to content

Commit

Permalink
feat: specify target disk format upon clone
Browse files Browse the repository at this point in the history
In case source VM disk format doesn't equal to target VM disk format
Proxmox will fail to start cloned VM with the error
`kvm: -drive file=<SPEC>: Image is not in TARGET_FORMAT format`.

Let's use `format` API parameter to fix this issue.

Signed-off-by: Yuri Konotopov <ykonotopov@gnome.org>
  • Loading branch information
nE0sIghT committed Dec 24, 2024
1 parent 976ef50 commit 425f7f5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions proxmox/config_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,13 +743,17 @@ storage:xxx
func (config ConfigQemu) CloneVm(ctx context.Context, sourceVmr *VmRef, vmr *VmRef, client *Client) (err error) {
vmr.SetVmType("qemu")
var storage string
var format string
fullClone := "1"
if config.FullClone != nil {
fullClone = strconv.Itoa(*config.FullClone)
}
if disk0Storage, ok := config.QemuDisks[0]["storage"].(string); ok && len(disk0Storage) > 0 {
storage = disk0Storage
}
if disk0Format, ok := config.QemuDisks[0]["format"].(string); ok && len(disk0Format) > 0 {
format = disk0Format
}
params := map[string]interface{}{
"newid": vmr.vmId,
"target": vmr.node,
Expand All @@ -760,8 +764,13 @@ func (config ConfigQemu) CloneVm(ctx context.Context, sourceVmr *VmRef, vmr *VmR
params["pool"] = vmr.pool
}

if fullClone == "1" && storage != "" {
params["storage"] = storage
if fullClone == "1" {
if storage != "" {
params["storage"] = storage
}
if format != "" {
params["format"] = format
}
}

_, err = client.CloneQemuVm(ctx, sourceVmr, params)
Expand Down

0 comments on commit 425f7f5

Please sign in to comment.