mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
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>
70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- mode: python; -*-
|
|
#============================================================================
|
|
# Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
|
|
#============================================================================
|
|
# Move the IP address from eth0 onto the Xen bridge (xenbr0).
|
|
# Only works if the bridge control utils (brctl) have been installed.
|
|
#============================================================================
|
|
|
|
from getopt import getopt
|
|
|
|
# add fallback path for non-native python path installs if needed
|
|
sys.path.append('/usr/lib/python')
|
|
sys.path.append('/usr/lib64/python')
|
|
from xen.util.Brctl import *
|
|
|
|
short_options = 'hvqni:b:c'
|
|
long_options = ['help', 'verbose', 'quiet',
|
|
'interface=', 'bridge=', 'create']
|
|
|
|
defaults['interface'] = 'eth0'
|
|
defaults['bridge'] = 'xenbr0'
|
|
|
|
def usage():
|
|
print """Usage:
|
|
%s [options]
|
|
|
|
Reconfigure routing so that <bridge> has the IP address from
|
|
<interface>. This lets IP carry on working when <interface>
|
|
is attached to <bridge> for virtual networking.
|
|
Uses brctl to add <interface> to <bridge>,
|
|
so this can be run before any domains have been created.
|
|
""" % sys.argv[0]
|
|
print """
|
|
-i, --interface <interface> interface, default %(interface)s.
|
|
-b, --bridge <bridge> bridge, default %(bridge)s.
|
|
-c, --create create the bridge.
|
|
-v, --verbose Print commands.
|
|
-q, --quiet Don't print commands.
|
|
-n, --dry-run Don't execute commands.
|
|
-h, --help Print this help.
|
|
""" % defaults
|
|
sys.exit(1)
|
|
|
|
|
|
def main():
|
|
lopts = set_opts(Opts(defaults))
|
|
lopts.dryrun = 0
|
|
(options, args) = getopt(sys.argv[1:], short_options, long_options)
|
|
if args: usage()
|
|
for k, v in options:
|
|
if k in ['-h', '--help']:
|
|
usage()
|
|
elif k in ['-c', '--create']:
|
|
lopts.create = 1
|
|
elif k in ['-i', '--interface']:
|
|
lopts.interface = v
|
|
elif k in ['-b', '--bridge']:
|
|
lopts.bridge = v
|
|
elif k in ['-q', '--quiet']:
|
|
lopts.verbose = 0
|
|
elif k in ['-v', '--verbose']:
|
|
lopts.verbose = 1
|
|
elif k in ['-n', '--dry-run']:
|
|
lopts.dryrun = 1
|
|
reconfigure(lopts.interface, lopts.bridge)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|