[Libguestfs] [PATCH v3 6/7] resize: add partition type LogicalPartition

Richard W.M. Jones rjones at redhat.com
Mon Sep 22 15:56:03 UTC 2014


On Mon, Sep 22, 2014 at 03:47:39PM +0800, Hu Tao wrote:
> Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
> ---
>  resize/resize.ml | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/resize/resize.ml b/resize/resize.ml
> index c56a91a..3f804a0 100644
> --- a/resize/resize.ml
> +++ b/resize/resize.ml
> @@ -75,6 +75,7 @@ and partition_id =
>  
>  type partition_type =
>    | PrimaryPartition
> +  | LogicalPartition
>  
>  let rec debug_partition p =
>    eprintf "%s:\n" p.p_name;
> @@ -449,13 +450,15 @@ read the man page virt-resize(1).
>    let find_partitions part_type =
>      let parts = Array.to_list (g#part_list "/dev/sda") in
>  
> -    (* Filter out logical partitions.  See note above. *)
>      let parts =
>        match part_type with
>        (* for GPT, all partitions are regarded as Primary Partition,
>         * e.g. there is no Extended Partition or Logical Partition. *)
>        | PrimaryPartition ->
>          List.filter (fun p -> parttype <> MBR || p.G.part_num <= 4_l)
> +        parts
> +      | LogicalPartition ->
> +        List.filter (fun p -> parttype = MBR && p.G.part_num >= 5_l)
>          parts in
>  
>      let partitions =
> @@ -518,10 +521,12 @@ read the man page virt-resize(1).
>      partitions in
>  
>    let partitions = find_partitions PrimaryPartition in
> +  let logical_partitions = find_partitions LogicalPartition in
>  
>    if verbose then (
> -    eprintf "%d partitions found\n" (List.length partitions);
> -    List.iter debug_partition partitions
> +    eprintf "%d partitions found\n" (List.length partitions + List.length logical_partitions);
> +    List.iter debug_partition partitions;
> +    List.iter debug_partition logical_partitions
>      );
>  
>    (* Build a data structure describing LVs on the source disk. *)
> -- 
> 1.9.3

This looks fine now.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list