Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for bridged networking. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions vido
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ sp_kvm = parser.add_argument_group('KVM-only options')
sp_kvm.add_argument(
'--net', action='store_true',
help='Configure the network (unnecessary with userns)')
sp_kvm.add_argument(
'--bridge', default=[], nargs='*',
help='Bridges to use for virtual NICs')
# qemu needs this to catch crashes (unnecessary with uml)
sp_kvm.add_argument(
'--watchdog', action='store_true',
Expand Down Expand Up @@ -267,8 +270,10 @@ if args.watchdog and args.virt != 'kvm':
fatal('--watchdog is not supported with {}'.format(args.virt))
if args.qemu_9p_workaround and args.virt != 'kvm':
fatal('--qemu-9p-workaround is not supported with {}'.format(args.virt))
if args.net and args.virt != 'kvm':
fatal('--net is not supported with {}'.format(args.virt))
if (args.net or args.bridge) and args.virt != 'kvm':
fatal('--net and --bridge not supported with {}'.format(args.virt))
if args.net and args.bridge:
fatal('--net and --bridge cannot be active at the same time')
if args.run_as and args.virt not in 'kvm uml'.split():
fatal('--run-as is not supported with {}'.format(args.virt))
if args.gdb and args.virt not in 'kvm uml'.split():
Expand Down Expand Up @@ -348,6 +353,12 @@ if args.virt == 'kvm':
# Not passing dns, sharing the host's resolv.conf
# Suggest a port-forward for the local resolver case
conf.net = dict(host='10.0.2.15/24', router='10.0.2.2')
elif args.bridge:
for i, bridge in enumerate(args.bridge):
qcmd += ['-net', 'nic,vlan=%d' % i, '-net',
'bridge,vlan=%d,br=%s' % (i, bridge)]
conf.bridge = len(args.bridge)


if args.watchdog:
qcmd += ['-watchdog', 'ib700', '-watchdog-action', 'poweroff']
Expand Down Expand Up @@ -452,4 +463,3 @@ else:
if not exitstr:
fatal('virt-stub crashed')
sys.exit(int(exitstr))

4 changes: 3 additions & 1 deletion virt-stub
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ if hasattr(conf, 'net'):
subprocess.check_call(
'ip route add default via'.split() + [conf.net.router]
+ 'dev eth0'.split())
elif hasattr(conf, 'bridge'):
for i in range(conf.bridge):
subprocess.check_call(['/usr/bin/dhcpcd', '--noarp', '-b', 'eth%d' % i])

for i, disk in enumerate(conf.disks):
env['VIDO_DISK{}'.format(i)] = disk
Expand All @@ -201,4 +204,3 @@ exit_status_file.write('%d' % rcode)
exit_status_file.close()
if conf.virt != 'userns':
subprocess.check_call('/sbin/poweroff -f'.split())