[Ovirt-devel] [PATCH node] Fixes when more than one UDI is returned while getting a drive's size.

Darryl L. Pierce dpierce at redhat.com
Tue May 26 19:08:18 UTC 2009


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 |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
index 716b8fb..296ec8c 100755
--- a/scripts/ovirt-config-storage
+++ b/scripts/ovirt-config-storage
@@ -43,6 +43,21 @@ 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
+        printf "MORE THAN ONE UDI FOUND!\n"
+        udi=$(echo $udi | sed 's/\$/ /g')
+        printf "UDI is now '${udi}'\n"
+        for found in ${udi}; do
+            printf "CHECKING: ${found}\n"
+            printf "$(hal-device ${found})\n"
+            if [[ "false" == $(hal-get-property --udi $found --key block.is_volume) ]]; then
+                printf "*** BINGO! ***\n"
+                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 +65,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