Browse Source

Use lxcbr0 as bridge

lxcbr
devrandom 7 years ago
parent
commit
684f6c9427
7 changed files with 33 additions and 17 deletions
  1. 3
    3
      README.md
  2. 0
    6
      bin/make-base-vm
  3. 6
    5
      etc/lxc.config.in
  4. 9
    0
      libexec/config-lxc
  5. 1
    1
      libexec/make-clean-vm
  6. 2
    0
      libexec/on-target
  7. 12
    2
      target-bin/bootstrap-fixup

+ 3
- 3
README.md View File

@@ -76,10 +76,10 @@ Recent distributions allow lxc-start to be run by non-priviledged users, so you

If you have a runaway `lxc-start` command, just use `kill -9` on it.

The machine configuration requires access to br0 and assumes that the host address is 10.0.2.2:
The machine configuration requires access to lxcbr0 and assumes that the host address is 10.0.3.1 . If lxc does not configure lxcbr0 on boot, you can do so manually:

sudo brctl addbr br0
sudo ifconfig br0 10.0.2.2/24 up
sudo brctl addbr lxcbr0
sudo ifconfig lxcbr0 10.0.3.1/24 up

## Tests


+ 0
- 6
bin/make-base-vm View File

@@ -16,12 +16,6 @@ usage() {
--suite U build suite U instead of lucid
--arch A build architecture A (e.g. i386) instead of amd64
--lxc use lxc instead of kvm

The MIRROR_HOST environment variable can be used to change the
apt-cacher host. It should be something that the target VM can
resolve. It may be set to 127.0.0.1, in which case it will be
changed to 10.0.2.2 on the guest. 10.0.2.2 is the host IP as visible
from the guest under qemu networking.
EOF
}


+ 6
- 5
etc/lxc.config.in View File

@@ -23,10 +23,11 @@ lxc.cgroup.devices.allow = c 254:0 rwm
lxc.mount.entry=proc ROOTFS/proc proc nodev,noexec,nosuid 0 0
lxc.mount.entry=sysfs ROOTFS/sys sysfs defaults 0 0

# Container with network virtualized using a pre-configured bridge named br0 and
# veth pair virtual network devices
# On the host, run: ifconfig br0 up 10.0.2.2
# Container with network virtualized using a pre-configured bridge named lxcbr0
# and veth pair virtual network devices.
# On the host, run (lxc might already have done this):
# ifconfig lxcbr0 up 10.0.3.1
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.ipv4 = 10.0.2.5/24
lxc.network.link = lxcbr0
lxc.network.ipv4 = 10.0.3.5/24

+ 9
- 0
libexec/config-lxc View File

@@ -1,4 +1,13 @@
#!/bin/bash

set -e

if ifconfig lxcbr0 > /dev/null 2>&1; then
true
else
echo "Must configure lxcbr0 - check the README"
exit 1
fi

wd=`pwd`
sed "s;ROOTFS;$wd/target-$LXC_SUITE-$LXC_ARCH;;s;ARCH;$LXC_ARCH;g" < etc/lxc.config.in > var/lxc.config

+ 1
- 1
libexec/make-clean-vm View File

@@ -48,5 +48,5 @@ if [ -z "$USE_LXC" ]; then
qemu-img create -f qcow2 -o backing_file="$BASE.qcow2" "$OUT.qcow2"
else
cp -a $BASE $OUT
on-target -u root bash < target-bin/bootstrap-fixup
on-target -u root /root/firstboot.sh
fi

+ 2
- 0
libexec/on-target View File

@@ -1,5 +1,7 @@
#!/bin/sh

set -e

. gconfig

TUSER=ubuntu

+ 12
- 2
target-bin/bootstrap-fixup View File

@@ -2,5 +2,15 @@

set -e

echo 'deb http://10.0.2.2:3142/archive.ubuntu.com/ubuntu lucid main universe' > $1/etc/apt/sources.list
echo 'deb http://10.0.2.2:3142/archive.ubuntu.com/ubuntu lucid-updates main universe' >> $1/etc/apt/sources.list
ip=`hostname --all-ip-addresses | cut -d ' ' -f1 | cut -d. -f1-3`

if [ $ip = "10.0.3" ]; then
# LXC
MIRROR_HOST_ON_GUEST=${MIRROR_HOST_ON_GUEST:-10.0.3.1}
else
# KVM
MIRROR_HOST_ON_GUEST=${MIRROR_HOST_ON_GUEST:-10.0.2.2}
fi

echo "deb http://$MIRROR_HOST_ON_GUEST:3142/archive.ubuntu.com/ubuntu lucid main universe" > $1/etc/apt/sources.list
echo "deb http://$MIRROR_HOST_ON_GUEST:3142/archive.ubuntu.com/ubuntu lucid-updates main universe" >> $1/etc/apt/sources.list

Loading…
Cancel
Save