[Ovirt-devel] [PATCH node] Fixes when more than one UDI is returned while getting a drive's size.
Alan Pevec
apevec at redhat.com
Wed May 27 14:39:51 UTC 2009
From: Darryl L. Pierce <dpierce at redhat.com>
If more than one UDI is returned, they are delimited by a carriage
return. That is changed to a space, then the lot is iterated over. Each
UDI is tested to see if it has the property "block.is_volume=false". If
so then that UDI is for the underlying block device and not a logical
volume on the device.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-config-storage | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
index 7efa299..cc9248b 100755
--- a/scripts/ovirt-config-storage
+++ b/scripts/ovirt-config-storage
@@ -43,6 +43,16 @@ get_drive_size()
local size=
local udi=$(hal-find-by-property --key block.device --string $drive)
+ # if more than one UDI was found then iterate over them to find the base device
+ if [[ "${udi}" =~ \$ ]]; then
+ udi=$(echo $udi | sed 's/\$/ /g')
+ for found in ${udi}; do
+ if [[ "false" == $(hal-get-property --udi $found --key block.is_volume) ]]; then
+ udi=$found
+ break
+ fi
+ done
+ fi
if [ -z "$udi" ]; then
# If hal didn't find the device, it could be a virtio block device
# In this case, use sfdisk -s to get the size
@@ -50,7 +60,7 @@ get_drive_size()
size=$(echo "scale=0; $size * 1024" | bc -l)
else
size=$(hal-get-property --udi "$udi" --key storage.size)
- if [ $size -eq 0 ]; then
+ if [[ "${size}" == "0" ]]; then
# disk is probably hot-swappable, use different HAL key
size=$(hal-get-property --udi "$udi" --key storage.removable.media_size)
fi
--
1.6.0.6
More information about the ovirt-devel
mailing list