]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix the bug of can't get the desired image info
authorzhangsong <zhangsong@cmss.chinamobile.com>
Fri, 13 Nov 2015 16:44:53 +0000 (00:44 +0800)
committerzhangsong <zhangsong@cmss.chinamobile.com>
Sat, 28 Nov 2015 09:33:03 +0000 (17:33 +0800)
When we use 'qemu-img info' command to get image info, some kinds
of image may show an 'unavailable' disk size. For example:

$qemu-img info sheepdog:volume-1af1afa0-7820-4063-9b90-4fa6161a74a9
image: sheepdog:volume-1af1afa0-7820-4063-9b90-4fa6161a74a9
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: unavailable

$qemu-img info -f rbd rbd:data/foo
image: rbd:data/foo
file format: rbd
virtual size: 10G (10737418240 bytes)
disk size: unavailable
cluster_size: 4194304

The current code didn't consider 'unavailable' size, and it will
raise a ValueError in this case. This patch fixed this bug by
adding the judgment of 'unavailable' size.

Change-Id: Ic5f3b80e172baaafc07432319f8aa24bf117b392
Closes-Bug: #1516083

cinder/openstack/common/imageutils.py

index 9a85e8512106776489eb40d25c0a95a4c8524ab1..c41d896e81613a17a818e7c94fd10e8c25809843 100644 (file)
@@ -93,7 +93,7 @@ class QemuImgInfo(object):
                 real_details = backing_match.group(2).strip()
         elif root_cmd in ['virtual_size', 'cluster_size', 'disk_size']:
             # Replace it with the byte amount (if we can convert it)
-            if root_details == 'None':
+            if root_details in ('None', 'unavailable'):
                 real_details = 0
             else:
                 real_details = self._extract_bytes(root_details)