[Ovirt-devel] [PATCH] Make configure_from_network function check if network is up, before touching it

Ricardo Marin Matinata matinata at br.ibm.com
Thu Feb 4 19:16:47 UTC 2010


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




More information about the ovirt-devel mailing list