From c0393a6713c8e49357821ed4c4f85e62a6101d42 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 8 May 2017 11:00:47 +0100 Subject: [PATCH] cmds: session_manager: Provide an option to use any container Normally Anbox will use the default container provided by the Anbox Container Manager, but some users may wish to run their own container. Here we're adding a --standalone flag which tells the Session Manager not to interact (configure/start) the Container Manager. This allows the user to utilise any other bespoke container of their choosing. For instance, this new feature was tested using a Docker container running the android.img provided by Anbox. Signed-off-by: Lee Jones --- src/anbox/cmds/session_manager.cpp | 29 +++++++++++++++++++---------- src/anbox/cmds/session_manager.h | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/anbox/cmds/session_manager.cpp b/src/anbox/cmds/session_manager.cpp index 5c294d0..924eadf 100644 --- a/src/anbox/cmds/session_manager.cpp +++ b/src/anbox/cmds/session_manager.cpp @@ -106,6 +106,9 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) flag(cli::make_flag(cli::Name{"window-size"}, cli::Description{"Size of the window in single window mode, e.g. --window-size=1024,768"}, window_size_)); + flag(cli::make_flag(cli::Name{"standalone"}, + cli::Description{"Prevents the Container Manager from starting the default container (Experimental)"}, + standalone_)); action([this](const cli::Command::Context &) { auto trap = core::posix::trap_signals_for_process( @@ -136,10 +139,12 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) auto dispatcher = anbox::common::create_dispatcher_for_runtime(rt); container::Client container(rt); - container.register_terminate_handler([&]() { - WARNING("Lost connection to container manager, terminating."); - trap->stop(); - }); + if (!standalone_) { + container.register_terminate_handler([&]() { + WARNING("Lost connection to container manager, terminating."); + trap->stop(); + }); + } auto input_manager = std::make_shared(rt); @@ -213,7 +218,8 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) })); container::Configuration container_configuration; - container_configuration.bind_mounts = { + if (!standalone_) { + container_configuration.bind_mounts = { {qemu_pipe_connector->socket_file(), "/dev/qemu_pipe"}, {bridge_connector->socket_file(), "/dev/anbox_bridge"}, {audio_server->socket_file(), "/dev/anbox_audio"}, @@ -221,9 +227,10 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) {"/dev/binder", "/dev/binder"}, {"/dev/ashmem", "/dev/ashmem"}, {"/dev/fuse", "/dev/fuse"}, - }; + }; - dispatcher->dispatch([&]() { container.start(container_configuration); }); + dispatcher->dispatch([&]() { container.start(container_configuration); }); + } auto bus = bus_factory_(); bus->install_executor(core::dbus::asio::make_executor(bus, rt->service())); @@ -233,9 +240,11 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) rt->start(); trap->run(); - // Stop the container which should close all open connections we have on - // our side and should terminate all services. - container.stop(); + if (!standalone_) { + // Stop the container which should close all open connections we have on + // our side and should terminate all services. + container.stop(); + } rt->stop(); diff --git a/src/anbox/cmds/session_manager.h b/src/anbox/cmds/session_manager.h index 9ffb419..60c3d42 100644 --- a/src/anbox/cmds/session_manager.h +++ b/src/anbox/cmds/session_manager.h @@ -45,6 +45,7 @@ class SessionManager : public cli::CommandWithFlagsAndAction { graphics::GLRendererServer::Config::Driver gles_driver_; bool single_window_ = false; graphics::Rect window_size_; + bool standalone_ = false; }; } // namespace cmds } // namespace anbox