Signed-off-by: Chen Hanxiao <[email protected]>
---
 resize/resize.ml | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/resize/resize.ml b/resize/resize.ml
index 6221254..218eb44 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1131,6 +1131,13 @@ read the man page virt-resize(1).
         []
   in
 
+  (* logical partitions's start have to treat specially.
+   * So we have to split partitions to two parts *)
+  let logical_partitions =
+    List.filter (fun p -> p.p_mbr_p_type = LogicalPartition) partitions in
+  let partitions =
+    List.filter (fun p -> parttype <> MBR || p.p_mbr_p_type <> 
LogicalPartition) partitions in
+
   let partitions =
     (* Choose the alignment of the first partition based on the
      * '--align-first' option.  Old virt-resize used to always align this
@@ -1146,6 +1153,18 @@ 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
+
+      (* align logical partitions, too *)
+      let start = roundup64 (start +^ 1L) alignment in
+      calculate_target_partitions 5 start ~create_surplus:false 
logical_partitions in
+
   let mbr_part_type x =
     match parttype, x.p_part.G.part_num <= 4_l, x.p_type with
     (* for GPT, all partitions are regarded as Primary Partition. *)
-- 
2.1.0

_______________________________________________
Libguestfs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to