[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-3.1-testing] xend: Prevent XenD touching externally managed bridges



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1197745424 0
# Node ID 6fa132f918c356401b24a394963cdb55c67fa919
# Parent  0198241edaeb24d57c005fbcc58c59642e835c9f
xend: Prevent XenD touching externally managed bridges

With current XenD 3.0.4 or later try the following:

    brctl addbr demo
    ifconfig demo up

    /etc/init.d/xend start
    /etc/init.d/xend stop

    ifconfig demo down
    brctl delbr demo

Now, start XenD again....

    /etc/init.d/xend start

And watch in horror as it re-creates your 'demo' bridge.

The problem is that the 'XendNetwork' class does not distinguish
between bridge devices that it is managing (ie those created via
XenAPI) and those which it does not manage (ie those created by OS
distro init scripts, or by apps like  libvirt).

While initially I thought I could just make XenD ignore
externally-managed bridges completely, it seems to needs to know about
them otherwise it can't hook up guest VIFs to them correctly. So the
attached patch adds a 'managed' flag to the XendNetwork
class. Externally managed bridges have this set to False. At startup
XenD will now only re-create bridge devices which have the 'managed'
flag set to 'True'  - ie those created via XenAPI.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
xen-unstable changeset:   16625:44a98411d230b3214be49b42e66d7c42e01ab59f
xen-unstable date:        Sat Dec 15 18:26:52 2007 +0000
---
 tools/python/xen/xend/XendNetwork.py |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff -r 0198241edaeb -r 6fa132f918c3 tools/python/xen/xend/XendNetwork.py
--- a/tools/python/xen/xend/XendNetwork.py      Sat Dec 15 19:03:00 2007 +0000
+++ b/tools/python/xen/xend/XendNetwork.py      Sat Dec 15 19:03:44 2007 +0000
@@ -52,7 +52,8 @@ class XendNetwork(XendBase):
 
     def getAttrRO(self):
         attrRO =  ['VIFs',
-                   'PIFs']
+                   'PIFs',
+                   'managed']
         return XendBase.getAttrRO() + attrRO
 
     def getAttrInst(self):
@@ -88,7 +89,8 @@ class XendNetwork(XendBase):
                 'name_description': '',
                 'other_config':     {},
                 'default_gateway':  '',
-                'default_netmask':  ''
+                'default_netmask':  '',
+                'managed':          False,
             }
         network = XendNetwork(record, uuid)
 
@@ -106,7 +108,10 @@ class XendNetwork(XendBase):
 
         # Create network if it doesn't already exist
         if not bridge_exists(network.name_label):
-            Brctl.bridge_create(network.name_label)
+            if network.managed:
+                Brctl.bridge_create(network.name_label)
+            else:
+                log.info("Not recreating missing unmanaged network %s" % 
network.name_label)
 
         return uuid
 
@@ -137,7 +142,13 @@ class XendNetwork(XendBase):
     recreate    = classmethod(recreate)
     create      = classmethod(create)
         
-    def __init__(self, record, uuid):       
+    def __init__(self, record, uuid):
+        # This is a read-only attr, so we need to
+        # set it here, as super class won't try to
+        if record.has_key("managed"):
+            self.managed = record["managed"]
+        else:
+            self.managed = True
         XendBase.__init__(self, uuid, record)
         
     #
@@ -170,6 +181,9 @@ class XendNetwork(XendBase):
     def set_name_description(self, new_desc):
         self.name_description = new_desc
         XendNode.instance().save_networks()
+
+    def get_managed(self):
+        return self.managed
 
     def get_VIFs(self):
         result = []

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.