All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: xen-devel@lists.xensource.com
Subject: PATCH: Prevent XenD touching externally managed bridges
Date: Fri, 14 Dec 2007 22:10:05 +0000	[thread overview]
Message-ID: <20071214221005.GM9211@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]

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@redhat.com>

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-network-unmanaged.patch --]
[-- Type: text/plain, Size: 2233 bytes --]

diff -rup xen-unstable-16606.orig/tools/python/xen/xend/XendNetwork.py xen-unstable-16606.new/tools/python/xen/xend/XendNetwork.py
--- xen-unstable-16606.orig/tools/python/xen/xend/XendNetwork.py	2007-12-13 04:31:03.000000000 -0500
+++ xen-unstable-16606.new/tools/python/xen/xend/XendNetwork.py	2007-12-14 13:51:08.000000000 -0500
@@ -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
 
@@ -143,7 +148,13 @@ class XendNetwork(XendBase):
     create            = classmethod(create)
     get_by_name_label = classmethod(get_by_name_label)
         
-    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)
         
     #
@@ -177,6 +188,9 @@ class XendNetwork(XendBase):
         self.name_description = new_desc
         XendNode.instance().save_networks()
 
+    def get_managed(self):
+        return self.managed
+
     def get_VIFs(self):
         result = []
         vms = XendDomain.instance().get_all_vms()

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

                 reply	other threads:[~2007-12-14 22:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071214221005.GM9211@redhat.com \
    --to=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.