Richard W.M. Jones
2014-Sep-29 11:09 UTC
Re: [Libguestfs] [PATCH v4 3/7] resize: add function mbr_part_type
On Fri, Sep 26, 2014 at 11:04:07AM +0800, Hu Tao wrote:> Function mbr_part_type returns one of "primary", "extended" and > "logical". The type is used by parted when adding partitions. > > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> > --- > resize/resize.ml | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/resize/resize.ml b/resize/resize.ml > index b52af83..f1861d9 100644 > --- a/resize/resize.ml > +++ b/resize/resize.ml > @@ -1094,10 +1094,17 @@ read the man page virt-resize(1). > > calculate_target_partitions 1 start ~create_surplus:true partitions in > > + let mbr_part_type x > + (* for GPT, all partitions are regarded as Primary Partition. *) > + if parttype = GPT then "primary" > + else if x.p_part.G.part_num <= 4l && x.p_type <> ContentExtendedPartition then "primary" > + else if x.p_part.G.part_num <= 4l && x.p_type = ContentExtendedPartition then "extended" > + else "logical" in > + > (* Now partition the target disk. *) > List.iter ( > fun p -> > - g#part_add "/dev/sdb" "primary" p.p_target_start p.p_target_end > + g#part_add "/dev/sdb" (mbr_part_type p) p.p_target_start p.p_target_end > ) partitions; > > (* Copy over the data. *)Thanks - I will push 01-03 shortly. I'm just looking at the remaining patches now. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Richard W.M. Jones
2014-Sep-29 20:37 UTC
Re: [Libguestfs] [PATCH v4 3/7] resize: add function mbr_part_type
... and I'm *still* looking at it. Firstly I wrote a test suite (see attached) which randomly generates disk images for virt-resize to test. This reveals a bug in the way we resized the MBR extended partition. The new mbr_part_type function causes virt-resize to fail, but in fact mbr_part_type is *not* to blame - it just exposes the existing bug. Anyway, will continue looking at this tomorrow. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Richard W.M. Jones
2014-Sep-30 12:31 UTC
Re: [Libguestfs] [PATCH v4 3/7] resize: add function mbr_part_type
On Mon, Sep 29, 2014 at 09:37:30PM +0100, Richard W.M. Jones wrote:> >From bb0fa12692e839e144f5cb01d80979a3459058de Mon Sep 17 00:00:00 2001 > From: "Richard W.M. Jones" <rjones@redhat.com> > Date: Mon, 29 Sep 2014 14:45:13 +0100 > Subject: [PATCH] resize: Rewrite the tests to use a stochastic testing method.I pushed a variant of this upstream. Note that it makes your patch 06 obsolete, since this introduces more stringent testing. 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/
Apparently Analagous Threads
- Re: [PATCH v4 3/7] resize: add function mbr_part_type
- [PATCH v4 3/7] resize: add function mbr_part_type
- Re: [PATCH v2 08/13] resize: add function mbr_part_type
- Re: [PATCH v3 5/7] resize: add function mbr_part_type
- [PATCH v3 5/7] resize: add function mbr_part_type