Skip to content

Commit 8f47a36

Browse files
authored
Merge pull request #2727 from zli/CA-218221
CA-218221: make sure SXM destination VDI has the same size as the source
2 parents 8ad77ec + 33f0e84 commit 8f47a36

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ocaml/xapi/storage_migrate.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,12 @@ let receive_start ~dbg ~sr ~vdi_info ~id ~similar =
670670
| Some vdi ->
671671
debug "Cloning VDI %s" vdi.vdi;
672672
let vdi = add_to_sm_config vdi "base_mirror" id in
673-
Local.VDI.clone ~dbg ~sr ~vdi_info:vdi
673+
let vdi_clone = Local.VDI.clone ~dbg ~sr ~vdi_info:vdi in
674+
if vdi_clone.virtual_size <> vdi_info.virtual_size then begin
675+
let new_size = Local.VDI.resize ~dbg ~sr ~vdi:vdi_clone.vdi ~new_size:vdi_info.virtual_size in
676+
debug "Resize local VDI %s to %Ld: result %Ld" vdi_clone.vdi vdi_info.virtual_size new_size;
677+
end;
678+
vdi_clone
674679
| None ->
675680
debug "Creating a blank remote VDI";
676681
Local.VDI.create ~dbg ~sr ~vdi_info
@@ -826,7 +831,12 @@ let copy ~task ~dbg ~sr ~vdi ~dp ~url ~dest =
826831
let remote_base = match nearest with
827832
| Some vdi ->
828833
debug "Cloning VDI %s" vdi.vdi;
829-
Remote.VDI.clone ~dbg ~sr:dest ~vdi_info:vdi
834+
let vdi_clone = Remote.VDI.clone ~dbg ~sr:dest ~vdi_info:vdi in
835+
if vdi_clone.virtual_size <> local_vdi.virtual_size then begin
836+
let new_size = Remote.VDI.resize ~dbg ~sr:dest ~vdi:vdi_clone.vdi ~new_size:local_vdi.virtual_size in
837+
debug "Resize remote VDI %s to %Ld: result %Ld" vdi_clone.vdi local_vdi.virtual_size new_size;
838+
end;
839+
vdi_clone
830840
| None ->
831841
debug "Creating a blank remote VDI";
832842
Remote.VDI.create ~dbg ~sr:dest ~vdi_info:{ local_vdi with sm_config = [] } in

0 commit comments

Comments
 (0)