From b31d79ca087d0de9c593c9bf32dd1723f85d3a30 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Sun, 4 Dec 2016 11:53:58 +0100 Subject: [PATCH] Only use bridge if available to prevent container startup failures LXC doesn't start the container when the configured network interface (the bridge in this case) is not available. --- src/anbox/container/lxc_container.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/anbox/container/lxc_container.cpp b/src/anbox/container/lxc_container.cpp index 33eddb1..4167a1a 100644 --- a/src/anbox/container/lxc_container.cpp +++ b/src/anbox/container/lxc_container.cpp @@ -113,9 +113,11 @@ void LxcContainer::start(const Configuration &configuration) { "lxc.logfile", utils::string_format("%s/container.log", config::log_path()).c_str()); - set_config_item("lxc.network.type", "veth"); - set_config_item("lxc.network.flags", "up"); - set_config_item("lxc.network.link", "anboxbr0"); + if (fs::exists("/sys/class/net/anboxbr0")) { + set_config_item("lxc.network.type", "veth"); + set_config_item("lxc.network.flags", "up"); + set_config_item("lxc.network.link", "anboxbr0"); + } #if 0 // Android uses namespaces as well so we have to allow nested namespaces for LXC