[Libguestfs] [PATCH rebase v4 11/11] resize: test: add support for resizing extended and logical partitions

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Mon Jul 6 10:14:25 UTC 2015


Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 resize/test-virt-resize.pl | 32 +++++---------------------------
 1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/resize/test-virt-resize.pl b/resize/test-virt-resize.pl
index be9c9b4..85ed1b2 100755
--- a/resize/test-virt-resize.pl
+++ b/resize/test-virt-resize.pl
@@ -75,13 +75,6 @@ if (rand () <= 0.5) {
 # an extended partition (#4) and zero or more logical partitions.
 my $nr_parts = 1 + int (rand (7));
 
-# XXX Temporarily restriction XXX
-# Currently virt-resize is broken when dealing with any extended
-# partition, so don't test this for the moment.
-if ($part_type eq "mbr" && $nr_parts >= 4) {
-    $nr_parts = 3;
-}
-
 # expand (1) or shrink (0)
 my $expand = 0;
 if (rand () >= 0.2) {
@@ -120,31 +113,16 @@ my $i;
 for ($i = 1; $i <= $nr_parts; ++$i) {
     $parts[$i] = { name => "sda".$i, resize => 0 };
 
-    if ($part_type eq "mbr") {
-        if ($i < 4) {
-            if (rand () < 0.5) {
-                $parts[$i]->{resize} = 1;
-            }
-        } elsif ($i == 4) {
+    if ($part_type eq "mbr" && $i == 4) {
             $parts[$i]->{content} = "extended";
-        }
-    } else {
-        if (rand () < 0.5) {
-            $parts[$i]->{resize} = 1;
-        }
+    }
+    if (rand () < 0.5) {
+        $parts[$i]->{resize} = 1;
     }
 }
 
 # Pick a partition at random to expand or shrink.
-if ($part_type eq "mbr") {
-    # virt-resize cannot shrink extended or logical partitions, so we
-    # set $max so that these cannot be chosen:
-    my $max = 3;
-    $max = $nr_parts if $max > $nr_parts;
-    $i = 1 + int (rand ($max));
-} else {
-    $i = 1 + int (rand ($nr_parts));
-}
+$i = 1 + int (rand ($nr_parts));
 $parts[$i]->{resize} = 0;
 $parts[$i]->{expand_shrink} = 1;
 
-- 
2.1.0




More information about the Libguestfs mailing list