[PATCH] partitions: Fix when disk does not have extended partition

From: Royce Lv <lvroyce@linux.vnet.ibm.com> Disk may just have primary partitions, this makes getExtendedPartition return none and throw exception when refer to extended partition path. Fix this by check whether extended partition exists. Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com> --- src/kimchi/disks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kimchi/disks.py b/src/kimchi/disks.py index cada869..ce0c5bb 100644 --- a/src/kimchi/disks.py +++ b/src/kimchi/disks.py @@ -86,8 +86,8 @@ def _is_dev_extended_partition(devType, devNodePath): return False diskPath = devNodePath.rstrip('0123456789') device = PDevice(diskPath) - disk = PDisk(device) - if disk.getExtendedPartition().path == devNodePath: + extended_part = PDisk(device).getExtendedPartition() + if extended_part and extended_part.path == devNodePath: return True return False -- 1.8.3.2

Reviewed-By: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Thanks to fix this! on 2014/03/23 22:09, lvroyce@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@linux.vnet.ibm.com>
Disk may just have primary partitions, this makes getExtendedPartition return none and throw exception when refer to extended partition path. Fix this by check whether extended partition exists.
Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com> --- src/kimchi/disks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/disks.py b/src/kimchi/disks.py index cada869..ce0c5bb 100644 --- a/src/kimchi/disks.py +++ b/src/kimchi/disks.py @@ -86,8 +86,8 @@ def _is_dev_extended_partition(devType, devNodePath): return False diskPath = devNodePath.rstrip('0123456789') device = PDevice(diskPath) - disk = PDisk(device) - if disk.getExtendedPartition().path == devNodePath: + extended_part = PDisk(device).getExtendedPartition() + if extended_part and extended_part.path == devNodePath: return True return False
-- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397
participants (3)
-
Aline Manera
-
lvroyce@linux.vnet.ibm.com
-
Zhou Zheng Sheng