提交 e04dd4bc 编写于 作者: S Simon Fels 提交者: GitHub

Merge pull request #241 from lag-linaro/master

cmds: session_manager: Provide an option to use any container
......@@ -106,6 +106,12 @@ 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_));
flag(cli::make_flag(cli::Name{"experimental"},
cli::Description{"Allows users to use experimental features"},
experimental_));
action([this](const cli::Command::Context &) {
auto trap = core::posix::trap_signals_for_process(
......@@ -115,6 +121,11 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
trap->stop();
});
if (standalone_ && !experimental_) {
ERROR("Experimental features selected, but --experimental flag not set");
return EXIT_FAILURE;
}
if (!fs::exists("/dev/binder") || !fs::exists("/dev/ashmem")) {
ERROR("Failed to start as either binder or ashmem kernel drivers are not loaded");
return EXIT_FAILURE;
......@@ -135,11 +146,13 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
auto rt = Runtime::create();
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_ = std::make_shared<container::Client>(rt);
container_->register_terminate_handler([&]() {
WARNING("Lost connection to container manager, terminating.");
trap->stop();
});
}
auto input_manager = std::make_shared<input::Manager>(rt);
......@@ -213,7 +226,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 +235,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 +248,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();
......
......@@ -30,6 +30,9 @@
#include "anbox/graphics/rect.h"
namespace anbox {
namespace container {
class Client;
} // namespace container
namespace cmds {
class SessionManager : public cli::CommandWithFlagsAndAction {
public:
......@@ -40,11 +43,14 @@ class SessionManager : public cli::CommandWithFlagsAndAction {
SessionManager(const BusFactory& bus_factory = session_bus_factory());
private:
std::shared_ptr<container::Client> container_;
BusFactory bus_factory_;
std::string desktop_file_hint_;
graphics::GLRendererServer::Config::Driver gles_driver_;
bool single_window_ = false;
graphics::Rect window_size_;
bool standalone_ = false;
bool experimental_ = false;
};
} // namespace cmds
} // namespace anbox
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册