On Mon, 2015-10-05 at 18:14 -0600, Mike Latimer wrote:
Libvirt commit 0282ca45 modifies the statistics reported on block
devices
to be more consistent with documentation and in sync with common statistics
seen through tools such as 'du' and 'dh'. This modification now treats
disk
allocation size as the amount of space the image occupies, rather than the
physical size of the image. The change broke 121-block-info.t, which was
expecting the two sizes to be identical.
This patch accounts for the changes in 0282ca45 by setting the expected
allocation size to be zero for all images being tested. In addition, the
physical size of the disks can vary depending on the filesystem backing the
disk image. To account for this, the physical size of the sparse raw image
and the qcow2 image is now checked to be significantly less than the size of
the fully allocated image. (The 5M and 1M values are much larger than the
empirically derived values of ~1M (sparse raw) and ~200K (qcow2)).
Signed-off-by: Mike Latimer <mlatimer(a)suse.com>
---
scripts/domain/121-block-info.t | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/scripts/domain/121-block-info.t b/scripts/domain/121-block-info.t
index e7e3491..64eeef2 100644
--- a/scripts/domain/121-block-info.t
+++ b/scripts/domain/121-block-info.t
@@ -98,18 +98,21 @@ ok_domain(sub { $dom = $conn->create_domain($xml) }, "Create
domain");
$xml = $dom->get_xml_description();
diag "Check fully allocated raw volume";
+# Capacity=50M, allocation=0M, physical>=50M
is($dom->get_block_info($dst1,0)->{capacity}, 1024*1024*50, "Get disk
capacity info");
-ok($dom->get_block_info($dst1,0)->{allocation} >= 1024*1024*50, "Get disk
allocation info");
+is($dom->get_block_info($dst1,0)->{allocation}, 0, "Get disk allocation
info");
ok($dom->get_block_info($dst1,0)->{physical} >= 1024*1024*50, "Get disk
physical info");
diag "Check sparse raw volume";
+# Capacity=50M, allocation=0M, physical<5M (10% of 50M)
is($dom->get_block_info($dst2,0)->{capacity}, 1024*1024*50, "Get disk
capacity info");
-is($dom->get_block_info($dst2,0)->{allocation}, 1024*1024, "Get disk
allocation info");
-is($dom->get_block_info($dst2,0)->{physical}, 1024*1024, "Get disk physical
info");
+is($dom->get_block_info($dst2,0)->{allocation}, 0, "Get disk allocation
info");
+ok($dom->get_block_info($dst2,0)->{physical} < 1024*1024*5, "Get disk
physical info");
diag "Check qcow2 volume";
+# Capacity=50M, allocation=0M, physical<1M
is($dom->get_block_info($dst3,0)->{capacity}, 1024*1024*50, "Get disk
capacity info");
-ok($dom->get_block_info($dst3,0)->{allocation} < 1024*1024, "Get disk
allocation info");
+is($dom->get_block_info($dst3,0)->{allocation}, 0, "Get disk allocation
info");
ok($dom->get_block_info($dst3,0)->{physical} < 1024*1024, "Get disk
physical info");
diag "Test block_resize";
@@ -118,7 +121,7 @@ $st1 = stat($path1);
is($st1->size, 512*1024*50, "size is 25M");
is($dom->get_block_info($dst1,0)->{capacity}, 1024*512*50, "Get disk capacity
info");
-ok($dom->get_block_info($dst1,0)->{allocation} >= 1024*512*50, "Get disk
allocation info");
+is($dom->get_block_info($dst1,0)->{allocation}, 0, "Get disk allocation
info");
ok($dom->get_block_info($dst1,0)->{physical} >= 1024*512*50, "Get disk
physical info");
lives_ok(sub {$dom->block_resize($dst1, 1024*50)}, "resize to 1024*50 KB");
ACK
--
Cedric