Skip to content

Commit 0f3daee

Browse files
authored
Merge pull request #390 from nE0sIghT/clone-format
feat: specify target disk format upon clone
2 parents 69a4086 + 425f7f5 commit 0f3daee

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

proxmox/config_qemu.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,13 +743,17 @@ storage:xxx
743743
func (config ConfigQemu) CloneVm(ctx context.Context, sourceVmr *VmRef, vmr *VmRef, client *Client) (err error) {
744744
vmr.SetVmType("qemu")
745745
var storage string
746+
var format string
746747
fullClone := "1"
747748
if config.FullClone != nil {
748749
fullClone = strconv.Itoa(*config.FullClone)
749750
}
750751
if disk0Storage, ok := config.QemuDisks[0]["storage"].(string); ok && len(disk0Storage) > 0 {
751752
storage = disk0Storage
752753
}
754+
if disk0Format, ok := config.QemuDisks[0]["format"].(string); ok && len(disk0Format) > 0 {
755+
format = disk0Format
756+
}
753757
params := map[string]interface{}{
754758
"newid": vmr.vmId,
755759
"target": vmr.node,
@@ -760,8 +764,13 @@ func (config ConfigQemu) CloneVm(ctx context.Context, sourceVmr *VmRef, vmr *VmR
760764
params["pool"] = vmr.pool
761765
}
762766

763-
if fullClone == "1" && storage != "" {
764-
params["storage"] = storage
767+
if fullClone == "1" {
768+
if storage != "" {
769+
params["storage"] = storage
770+
}
771+
if format != "" {
772+
params["format"] = format
773+
}
765774
}
766775

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

0 commit comments

Comments
 (0)