And introduce parameter create_surplus to indicate whether to create surplus partition or not. Later this parameter will be used by logical partitions.
Signed-off-by: Hu Tao <[email protected]> --- resize/resize.ml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/resize/resize.ml b/resize/resize.ml index 37e4087..2ffd26e 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -1025,11 +1025,10 @@ read the man page virt-resize(1). * the final list just contains partitions that need to be created * on the target. *) - let partitions = - let rec loop partnum start = function + let rec loop partnum start create_surplus = function | p :: ps -> (match p.p_operation with - | OpDelete -> loop partnum start ps (* skip p *) + | OpDelete -> loop partnum start create_surplus ps (* skip p *) | OpIgnore | OpCopy -> (* same size *) (* Size in sectors. *) @@ -1043,7 +1042,7 @@ read the man page virt-resize(1). partnum start (end_ -^ 1L); { p with p_target_start = start; p_target_end = end_ -^ 1L; - p_target_partnum = partnum } :: loop (partnum+1) next ps + p_target_partnum = partnum } :: loop (partnum+1) next create_surplus ps | OpResize newsize -> (* resized partition *) (* New size in sectors. *) @@ -1057,12 +1056,12 @@ read the man page virt-resize(1). partnum newsize start (next -^ 1L); { p with p_target_start = start; p_target_end = next -^ 1L; - p_target_partnum = partnum } :: loop (partnum+1) next ps + p_target_partnum = partnum } :: loop (partnum+1) next create_surplus ps ) | [] -> (* Create the surplus partition if there is room for it. *) - if extra_partition && surplus >= min_extra_partition then ( + if create_surplus && extra_partition && surplus >= min_extra_partition then ( [ { (* Since this partition has no source, this data is * meaningless and not used since the operation is @@ -1083,6 +1082,7 @@ read the man page virt-resize(1). else [] in + let partitions = (* Choose the alignment of the first partition based on the * '--align-first' option. Old virt-resize used to always align this * to 64 sectors, but this causes boot failures unless we are able to @@ -1095,7 +1095,7 @@ read the man page virt-resize(1). (* Preserve the existing start, but convert to sectors. *) (List.hd partitions).p_part.G.part_start /^ sectsize in - loop 1 start partitions in + loop 1 start true partitions in (* Now partition the target disk. *) List.iter ( -- 1.9.3 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
