[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v2 07/11] resize: calculate_target_partitions for logical partitions



Pass gap_start and nr_logical to calculate_target_partitions
when calculating logical partitions.

Signed-off-by: Chen Hanxiao <chenhanxiao cn fujitsu com>
---
 resize/resize.ml | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/resize/resize.ml b/resize/resize.ml
index 6a3d286..89bcb30 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1175,9 +1175,24 @@ read the man page virt-resize(1).
 
     calculate_target_partitions 1 start ~create_surplus:true partitions in
 
+  let logical_partitions =
+    let start = List.fold_left (
+      fun total p ->
+        match p.p_type with
+          | ContentExtendedPartition -> total +^ p.p_target_start
+          | _ -> total +^ 0L
+    ) 0L partitions in
+
+    let gap_start = (roundup64 (start +^ 1L) alignment) -^ start in
+    let nr_logical = List.length logical_partitions in
+    (* align logical partitions, too *)
+    let start = roundup64 (start +^ 1L) alignment in
+    calculate_target_partitions 5 start ~create_surplus:false ~nr_logical ~gap_start logical_partitions in
+
   if verbose () then (
     printf "After calculate target partitions:\n";
-    List.iter (debug_partition ~sectsize) partitions
+    List.iter (debug_partition ~sectsize) partitions;
+    List.iter (debug_partition ~sectsize) logical_partitions
   );
 
   let mbr_part_type x =
-- 
2.1.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]