mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-24 23:41:52 +08:00
fix(region): ignore params.Disks when cloning vm from snapshot
This commit is contained in:
@@ -973,6 +973,7 @@ func (self *SHost) DoCreateVM(ctx context.Context, ds *SDatastore, params SCreat
|
||||
return evm, nil
|
||||
}
|
||||
|
||||
// If snapshot is not nil, params.Disks will be ignored
|
||||
func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, snapshot *types.ManagedObjectReference, ds *SDatastore, params SCreateVMParam) (*SVirtualMachine, error) {
|
||||
ovm := from.getVmObj()
|
||||
|
||||
@@ -1027,7 +1028,7 @@ func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, snapshot
|
||||
}
|
||||
}
|
||||
|
||||
if len(params.Disks) > 0 {
|
||||
if len(params.Disks) > 0 && snapshot == nil {
|
||||
driver := params.Disks[0].Driver
|
||||
if driver == "scsi" || driver == "pvscsi" {
|
||||
scsiDevs, err := from.FindController(ctx, "scsi")
|
||||
@@ -1119,6 +1120,10 @@ func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, snapshot
|
||||
return nil, errors.Error("clone successfully but unable to NewVirtualMachine")
|
||||
}
|
||||
|
||||
if snapshot != nil {
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
deviceChange = addDeviceChange
|
||||
// adjust disk
|
||||
var i int
|
||||
|
||||
Reference in New Issue
Block a user