Skip to contentSkip to conversation

Refuse to start bridging with network root filesystem

PATCH New Mark McLoughlin 1 participant 1 message Jun 26, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Refuse to start bridging with network root filesystem

Hi,
Since setting up bridging involves bringing down the network interface,
bridging clearly isn't compatible with the likes of NFS or iSCSI root.

The attached patch makes network-bridge try to detect either of these
conditions and refuse to start, logging an error to syslog.

Thanks,
Mark.

tools/examples/network-bridge +12 -0
diff -r 3f76b2f76c2a tools/examples/network-bridge
@@ -172,9 +172,21 @@ show_status () {
     echo '============================================================'
 }
 
+is_network_root () {
+    local rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/mtab)
+    local rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab)
+
+    [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && return 0 || return 1
+}
+
 op_start () {
     if [ "${bridge}" = "null" ] ; then
 	return
+    fi
+
+    if is_network_root ; then
+        [ -x /usr/bin/logger ] && /usr/bin/logger "network-bridge: bridging not supported on network root; not starting"
+        return
     fi
 
     if link_exists "$pdev"; then

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel