Ricardo Marin Matinata
2010-Feb-04 19:16 UTC
[Ovirt-devel] [PATCH] Make configure_from_network function check if network is up, before touching it
This patch adds a safety verification to configure_from_network function, where
network configuration will not be performed if it is already up and running,
preventing lost of communication for connections already established.
Signed-off-by: Ricardo Marin Matinata <matinata at br.ibm.com>
---
scripts/ovirt-early | 9 ++++++---
scripts/ovirt-functions | 7 +++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index cdd4afd..dd7da00 100755
--- a/scripts/ovirt-early
+++ b/scripts/ovirt-early
@@ -32,9 +32,12 @@ configure_from_network() {
DEVICE=$1
if [ -n "$DEVICE" ]; then
- log "Configuring network Using interface $DEVICE"
- # setup temporary interface to retrieve configuration
- echo "network --device $DEVICE --bootproto dhcp" | nash
+ log "Configuring network"
+ if ! network_up ; then
+ log "Using interface $DEVICE"
+ # setup temporary interface to retrieve configuration
+ echo "network --device $DEVICE --bootproto dhcp" | nash
+ fi
if [ $? -eq 0 ]; then
# from network-scripts/ifup-post
IPADDR=$(LC_ALL=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print
$4 ; exit }')
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index fc43343..2801bd8 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -709,6 +709,13 @@ is_valid_ipv4 () {
return $result
}
+# Check if networking is already up
+network_up () {
+ UPIFS=$(/sbin/ip -o link show up | awk -F ": " '{ print $2
}' | grep -v lo | wc -l)
+ test -n "${UPIFS}" -a "${UPIFS}" -gt "0"
+ return $?
+}
+
# execute a function if called as a script, e.g.
# ovirt-functions ovirt_store_config /etc/hosts
--
1.6.6
Ricardo Marin Matinata
2010-Feb-04 19:16 UTC
[Ovirt-devel] [PATCH] Expand get_dev_name funtion to consider devices not seen by HAL
This patch augments the get_dev_name functions for devices not properly seen by
HAL.
Signed-off-by: Ricardo Marin Matinata <matinata at br.ibm.com>
---
scripts/ovirt-config-storage | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
index eed126c..74894d1 100755
--- a/scripts/ovirt-config-storage
+++ b/scripts/ovirt-config-storage
@@ -140,7 +140,8 @@ check_partition_sizes()
get_dev_name()
{
local udi_list=$(hal-find-by-capability --capability storage)
- if test -z "$udi_list"; then
+ local byid_list=$(find /dev/disk/by-id -mindepth 1| grep -v
"\-part")
+ if test -z "$udi_list" -a -z "$byid_list"; then
warn "ERROR: no usable storage devices detected"
return 1
fi
@@ -164,6 +165,10 @@ get_dev_name()
&& devices="$block_dev" \
|| devices="$devices $block_dev"
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)"
--
1.6.6
Alan Pevec
2010-Feb-05 11:12 UTC
[Ovirt-devel] [PATCH] Expand get_dev_name funtion to consider devices not seen by HAL
Pushed, thanks! Alan On Fri, Feb 5, 2010 at 11:33 AM, Ricardo Marin Matinata <matinata at br.ibm.com> wrote:> On Fri, 2010-02-05 at 00:26 +0100, Alan Pevec wrote: >> > - ? ?if test -z "$udi_list"; then >> > + ? ?local byid_list=$(find /dev/disk/by-id ?-mindepth 1| grep -v "\-part") >> >> or just: find /dev/disk/by-id ?-mindepth 1 -not -name '*-part*' >> If agreed, I'll amend and push > > Agree. > > -- > Ricardo Marin Matinata > Adv. Software Engineer | Linux Technology Center > IBM Brazil | Hortolandia | SP > matinata br ibm com > >
Alan Pevec
2010-Feb-05 11:13 UTC
[Ovirt-devel] [PATCH] Make configure_from_network function check if network is up, before touching it
Pushed, thanks! Alan On Fri, Feb 5, 2010 at 11:34 AM, Ricardo Marin Matinata <matinata at br.ibm.com> wrote:> On Fri, 2010-02-05 at 00:48 +0100, Alan Pevec wrote: >> > +# Check if networking is already up >> > +network_up () { >> > + ? ?UPIFS=$(/sbin/ip -o link show up | awk -F ": " '{ print $2 }' | grep -v lo | wc -l) >> > + ? ?test -n "${UPIFS}" -a "${UPIFS}" -gt "0" >> > + ? ?return $? >> >> or just: >> network_up () { >> ? ? test -n "$(/sbin/ip -o link show up | cut -d: -f2 | grep -v 'lo$')" >> } >> >> If you agree, I'll amend and push > > Agree. > > -- > Ricardo Marin Matinata > Adv. Software Engineer | Linux Technology Center > IBM Brazil | Hortolandia | SP > matinata br ibm com