[Ovirt-devel] [PATCH node] Replace the HAL calls with udev/systool calls.

Joey Boggs jboggs at redhat.com
Thu May 13 19:57:37 UTC 2010


On 05/13/2010 11:12 AM, Darryl L. Pierce wrote:
> HAL has been deprecated, and this patch removes all HAL specific calls
> from the configuration scripts.
>
> HAL is still present in the Python scripts, but will be removed in a
> different patch.
>
> Signed-off-by: Darryl L. Pierce<dpierce at redhat.com>
> ---
>   ChangeLog                       |    3 +
>   configure.ac                    |    2 -
>   ovirt-node.spec.in              |    1 -
>   scripts/ovirt-config-networking |   18 ++++----
>   scripts/ovirt-config-storage    |   99 ++++++++++++++-------------------------
>   5 files changed, 48 insertions(+), 75 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 49d57ad..b57763a 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,6 +1,9 @@
>   CHANGELOG
>   =========
>
> +Version 1.9.3:
> + * Removed HAL dependencies from the firstboot scripts.
> +
>   Version 1.9.2:
>    * Fixed the autoconf setup to cover more prerequisites.
>
> diff --git a/configure.ac b/configure.ac
> index abe97cc..18cf789 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -10,9 +10,7 @@ fi
>
>   # TODO need a way to check for python-setuptools
>
> -AC_CHECK_LIB(dbus-1, main, , AC_MSG_ERROR([Cannot find DBus development libraries.]))
>   AC_CHECK_LIB(virt, main, , AC_MSG_ERROR([Cannot find libvirt development libraries.]))
> -AC_CHECK_LIB(hal, main, , AC_MSG_ERROR([Cannot find HAL development libraries.]))
>   AC_CHECK_LIB(python2.6, main, , AC_MSG_ERROR([Cannot find python development libraries.]))
>
>   AC_CONFIG_HEADERS([config.h])
> diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
> index 28d8719..45de24c 100644
> --- a/ovirt-node.spec.in
> +++ b/ovirt-node.spec.in
> @@ -17,7 +17,6 @@ URL:            http://www.ovirt.org/
>   Requires(post):  /sbin/chkconfig
>   Requires(preun): /sbin/chkconfig
>   BuildRequires:  libvirt-devel>= 0.5.1
> -BuildRequires:  dbus-devel hal-devel
>   BuildRequires:  python-devel
>   BuildRequires:  python-setuptools
>   Requires:       libvirt>= 0.6.3
> diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
> index 4d412ac..1cfc2db 100755
> --- a/scripts/ovirt-config-networking
> +++ b/scripts/ovirt-config-networking
> @@ -460,16 +460,16 @@ set ${ntproot}/keys /etc/ntp/keys\n\
>   function setup_menu
>   {
>       NICS=""
> -    udi_list=$(hal-find-by-capability --capability net.80203)
> -    if [ -n "$udi_list" ]; then
> -        for d in $udi_list; do
> -	    if [[ ! "$(hal-get-property --udi $d --key net.physical_device)" =~ computer ]]; then
> -		NICS="$NICS $(hal-get-property --udi "$d" --key net.interface)"
> -	    fi
> -        done
> -    fi
> +    nics=$(ls -bd /sys/class/net/*)
> +    for nic in $nics; do
> +        nic=$(basename $nic)
> +        address=$(systool -c net -d $nic -A address | awk '/address\ += "(.*)"/ { print $3; }')
> +        if [[ ! "$address" =~ '00:00:00:00' ]]; then
> +            NICS="$NICS $nic"
> +        fi
> +    done
>
> -    # Add virtio NICs that were possibly not detected by hal
> +    # Add virtio NICs that were possibly not detected by other means
>       NICS="$(ifconfig -a | awk '/Ethernet/ {print $1}'|xargs)"
>       NICS=$(echo $NICS | tr ' ' '\n' | sort -u | xargs)
>
> diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
> index ce9707c..5b2c1e9 100755
> --- a/scripts/ovirt-config-storage
> +++ b/scripts/ovirt-config-storage
> @@ -111,41 +111,11 @@ get_drive_size()
>       local drive="$1"
>       local space_var="$2"
>
> -    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
> -        # or a multipath device
> -        # In this case, use sfdisk -s to get the size
> -        size=$(sfdisk -s "$drive" 2>/dev/null)
> -        if [ -z "$size" ]; then
> -            size=0
> -        fi
> -        size=$(echo "scale=0; $size * 1024" | bc -l)
> -    else
> -        size=$(hal-get-property --udi "$udi" --key storage.size)
> -        if [[ "${size}" == "0" ]]; then
> -            # disk is probably hot-swappable, use different HAL key
> -            # but first check that it is removeable media and that  media is present
> -            if [[ "true" == "$(hal-get-property --udi "$udi" --key storage.removable.media_available)" ]]; then
> -                size=$(hal-get-property --udi "$udi" --key storage.removable.media_size)
> -            fi
> -        fi
> -    fi
> +    local size=$(sfdisk -s $drive)
> +    size=$(echo "scale=0; $size / 1024" | bc -l)
>
> -    size=$(echo "scale=0; $size / (1024 * 1024)" | bc -l)
>       echo "$drive ($size MB)"
> -    test -z "$udi" || echo "Disk Identifier: $(basename "$udi")"
> +    echo "Disk Identifier: $drive"
>       if [ -n "$space_var" ]; then
>           eval $space_var="$size"
>       fi
> @@ -210,8 +180,10 @@ check_partition_sizes()
>               printf "\n"
>               printf "There appears to already be an installation on another device:\n"
>               for device in $devices; do
> -                udi=$(hal-find-by-property --key block.device --string $device)
> -                printf "\t$device ($(basename "$udi"))\n"
> +                local uuid
> +
> +                get_uuid $device uuid
> +                printf "\t$device ${uuid}\n"
>               done
>               printf "We cannot proceed until either device is removed from the system\n"
>               printf "or until the HostVG volume group is removed.\n"
> @@ -260,40 +232,19 @@ manual_input()
>   # Sample output: /dev/sda
>   get_dev_name()
>   {
> -    local udi_list=$(hal-find-by-capability --capability storage)
>       local byid_list=$(find /dev/disk/by-id -mindepth 1 -not -name '*-part*' 2>/dev/null)
> -    if test -z "$udi_list" -a -z "$byid_list"; then
> -        warn "ERROR: no usable storage devices detected"
> -        return 1
> -    fi
> +    local devices=""
>
> -    local d devices sizes
> -    for d in $udi_list; do
> -        local drive_type=$(hal-get-property --udi "$d" --key storage.drive_type)
> -        test "X$drive_type" = Xdisk || continue
> -        local block_dev=$(hal-get-property --udi "$d" --key block.device)
> -        # Must start with a '/'.
> -        case "$block_dev" in
> -            *' '*)
> -                # we use space as separator
> -                warn "block device name '$block_dev' contains space; skipping";
> -                continue;;
> -            /*) ;;
> -            *) warn "block device name $block_dev doesn't start with '/';" \
> -                " skipping"; continue;;
> -        esac
> -        test -z "$devices" \
> -&&  devices="$block_dev" \
> -            || devices="$devices $block_dev"
> +    for drive in $(ls -db /sys/block/[hsv]d*); do
> +        drive="/dev/$(basename $drive)"
> +        test -z "$devices"&&  devices="$drive" || devices="$devices $drive"
>       done
> +
>       d=""
>       for d in $byid_list; do
>           devices="$devices $(readlink -f "$d")";
>       done
>
> -    # FIXME: workaround for detecting virtio block devices
> -    devices="$devices $(ls /dev/vd? 2>  /dev/null | xargs)"
> -
>       # FIXME: workaround for detecting cciss devices
>       for dev in $(ls /dev/cciss 2>/dev/null); do
>           if [[ ! "$dev" =~ p[0-9]+\$ ]]; then
> @@ -518,6 +469,26 @@ EOF
>       return ${is_negative-0}
>   }
>
> +# Retrieves the UUID for the specified device.
> +# $1 - the device
> +# $2 - the variable to be set
> +get_uuid()
> +{
> +    local device=${1-}
> +    local envvar=${2-}
> +    local rootname
> +
> +    if [[ "$device" =~ "^.*[0-9]?$" ]]; then
> +        rootname="${device:0:${#device}-1}"
> +    fi
> +    local uuid=$(
> +        udevadm info --path=/sys/block/$rootname/$device --query=property |
> +        awk '/ID_FS_UUID=/ { match($0, "ID_FS_UUID=(.*)", data); print  data[1]; }'
> +    )
> +
> +    eval $envvar="$uuid"
> +}
> +
>   #Check for an existing HostVG on any device on the system.
>   # Return 0 if then is a HostVG found, unless only one found is on $1
>   # Return 1 if no HostVG found or only found on $1
> @@ -537,10 +508,12 @@ check_existing_hostvg()
>           printf "\n"
>           printf "There appears to already be an installation on another device:\n"
>           for device in $devices; do
> +            local uuid
> +
>               get_multipath_devices ${device%p[0-9]} sd_dev
>               sd_dev=$(echo "$sd_dev" | awk '{print $1}')
> -            udi=$(hal-find-by-property --key block.device --string /dev/${sd_dev})
> -            printf "\t$device ($(basename "$udi"))\n"
> +            get_uuid $sd_dev uuid
> +            printf "\t$device ($uuid)\n"
>           done
>           printf "The installation cannot proceed until the device is removed\n"
>           printf "from the system of the HostVG volume group is removed.\n"
>    
ACK, only issue was the dm-X devices showing up in the device list




More information about the ovirt-devel mailing list