mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
New network-bridge script and associated gubbins.
This is Kurt Garloff's reworked network-bridge script:
* we got rid of ifconfig
* it works for netdev != eth0
* arp on and off are symmetric as are ifdown and ifup
* ifup will be passed the ifcfg config file name if needed
(the ifup may otherwise figure that the veth0 hardware is
NOT the same as the original ${netdev} and not use the same
config -- this happens on SUSE. Charles Coffing tracked this
one down.)
Plus Kurt's avoid-dash patch:
the network setup scripts on SUSE have trouble with the bridge
name xen-br0; they don't expect the '-'.
Arguably this should be fixed.
But I assume there's more scripts out there which may not like it,
so I suggest the following patch to rename xen-br0 to xenbr0.
Plus Charles Duffy's patch to support multiple bridges:
The attached patch allows the network-bridge script to be used to
generate multiple bridges corresponding to different physical
interfaces. It adds a new parameter, "vifnum", used to refer both to
the loopback interface to be used and to set defaults regarding the
physical interface and bridge name.
Thus, if one wishes to start xenbr0 on eth0 and xenbr1 on eth1, one
need only call:
network-bridge start ## vifnum is 0 by default
network-bridge start vifnum=1
...well, that and set loopback.nloopbacks=2 in the Dom0 kernel
parameters.
Plus renaming of virtnum to vifnum in Charles' patch, as requested by Ian Pratt.
Plus a fix to DevController to allocate vif IDs starting from 0 (i.e. vif2.0
is now domain 2's first vif, as opposed to vif2.1 in the recent past).
Plus tidying up inside network-bridge using some helper variables.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
1 parent
6a227e5300
commit
a77149f8e4
12 files changed
+142
-128
No files matched your search
@@ -253,7 +253,7 @@ class XendRoot:
|
||||
return self.get_config_bool('enable-dump', 'no')
|
||||
|
||||
def get_vif_bridge(self):
|
||||
return self.get_config_value('vif-bridge', 'xen-br0')
|
||||
return self.get_config_value('vif-bridge', 'xenbr0')
|
||||
|
||||
def get_vif_script(self):
|
||||
return self.get_config_value('vif-script', 'vif-bridge')
|
||||
|
||||
@@ -160,7 +160,7 @@ class DevController:
|
||||
if result:
|
||||
result = int(result)
|
||||
else:
|
||||
result = 1
|
||||
result = 0
|
||||
t.write("nextDeviceID", str(result + 1))
|
||||
if t.commit():
|
||||
return result
|
||||
|
||||
@@ -32,34 +32,6 @@ class Daemon:
|
||||
self.traceindent = 0
|
||||
self.child = 0
|
||||
|
||||
def daemon_pids(self):
|
||||
pids = []
|
||||
pidex = '(?P<pid>\d+)'
|
||||
pythonex = '(?P<python>\S*python\S*)'
|
||||
cmdex = '(?P<cmd>.*)'
|
||||
procre = re.compile('^\s*' + pidex + '\s*' + pythonex + '\s*' + cmdex + '$')
|
||||
xendre = re.compile('^\S+/xend\s*(start|restart)\s*.*$')
|
||||
procs = os.popen('ps -e -o pid,args 2>/dev/null')
|
||||
for proc in procs:
|
||||
pm = procre.match(proc)
|
||||
if not pm: continue
|
||||
xm = xendre.match(pm.group('cmd'))
|
||||
if not xm: continue
|
||||
pids.append(int(pm.group('pid')))
|
||||
return pids
|
||||
|
||||
def new_cleanup(self, kill=0):
|
||||
err = 0
|
||||
pids = self.daemon_pids()
|
||||
if kill:
|
||||
for pid in pids:
|
||||
print "Killing daemon pid=%d" % pid
|
||||
os.kill(pid, signal.SIGHUP)
|
||||
elif pids:
|
||||
err = 1
|
||||
print "Daemon already running: ", pids
|
||||
return err
|
||||
|
||||
def read_pid(self, pidfile):
|
||||
"""Read process id from a file.
|
||||
|
||||
@@ -115,12 +87,9 @@ class Daemon:
|
||||
os.remove(pidfile)
|
||||
return running
|
||||
|
||||
def cleanup_xend(self, kill=False):
|
||||
def cleanup_xend(self, kill):
|
||||
return self.cleanup_process(XEND_PID_FILE, "xend", kill)
|
||||
|
||||
def cleanup(self, kill=False):
|
||||
self.cleanup_xend(kill=kill)
|
||||
|
||||
def status(self):
|
||||
"""Returns the status of the xend daemon.
|
||||
The return value is defined by the LSB:
|
||||
@@ -156,16 +125,13 @@ class Daemon:
|
||||
# Detach from TTY.
|
||||
os.setsid()
|
||||
|
||||
# Detach from standard file descriptors.
|
||||
# I do this at the file-descriptor level: the overlying Python file
|
||||
# objects also use fd's 0, 1 and 2.
|
||||
# Detach from standard file descriptors, and redirect them to
|
||||
# /dev/null or the log as appropriate.
|
||||
os.close(0)
|
||||
os.close(1)
|
||||
os.close(2)
|
||||
if XEND_DEBUG:
|
||||
os.open('/dev/null', os.O_RDONLY)
|
||||
# XXX KAF: Why doesn't this capture output from C extensions that
|
||||
# fprintf(stdout) or fprintf(stderr) ??
|
||||
os.open(XEND_DEBUG_LOG, os.O_WRONLY|os.O_CREAT)
|
||||
os.dup(1)
|
||||
else:
|
||||
@@ -180,7 +146,7 @@ class Daemon:
|
||||
0 Success
|
||||
4 Insufficient privileges
|
||||
"""
|
||||
xend_pid = self.cleanup_xend()
|
||||
xend_pid = self.cleanup_xend(False)
|
||||
|
||||
if self.set_user():
|
||||
return 4
|
||||
@@ -294,7 +260,10 @@ class Daemon:
|
||||
return 1
|
||||
|
||||
def stop(self):
|
||||
return self.cleanup(kill=True)
|
||||
result = self.cleanup_xend(True)
|
||||
from xen.xend import Vifctl
|
||||
Vifctl.network("stop")
|
||||
return result
|
||||
|
||||
def run(self, status):
|
||||
try:
|
||||
|
||||