Merge pull request #241 from lag-linaro/master
cmds: session_manager: Provide an option to use any container
This commit is contained in:
commit
e04dd4bcf6
2 changed files with 34 additions and 11 deletions
|
|
@ -106,6 +106,12 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
||||||
flag(cli::make_flag(cli::Name{"window-size"},
|
flag(cli::make_flag(cli::Name{"window-size"},
|
||||||
cli::Description{"Size of the window in single window mode, e.g. --window-size=1024,768"},
|
cli::Description{"Size of the window in single window mode, e.g. --window-size=1024,768"},
|
||||||
window_size_));
|
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 &) {
|
action([this](const cli::Command::Context &) {
|
||||||
auto trap = core::posix::trap_signals_for_process(
|
auto trap = core::posix::trap_signals_for_process(
|
||||||
|
|
@ -115,6 +121,11 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
||||||
trap->stop();
|
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")) {
|
if (!fs::exists("/dev/binder") || !fs::exists("/dev/ashmem")) {
|
||||||
ERROR("Failed to start as either binder or ashmem kernel drivers are not loaded");
|
ERROR("Failed to start as either binder or ashmem kernel drivers are not loaded");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
@ -135,11 +146,13 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
||||||
auto rt = Runtime::create();
|
auto rt = Runtime::create();
|
||||||
auto dispatcher = anbox::common::create_dispatcher_for_runtime(rt);
|
auto dispatcher = anbox::common::create_dispatcher_for_runtime(rt);
|
||||||
|
|
||||||
container::Client container(rt);
|
if (!standalone_) {
|
||||||
container.register_terminate_handler([&]() {
|
container_ = std::make_shared<container::Client>(rt);
|
||||||
|
container_->register_terminate_handler([&]() {
|
||||||
WARNING("Lost connection to container manager, terminating.");
|
WARNING("Lost connection to container manager, terminating.");
|
||||||
trap->stop();
|
trap->stop();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
auto input_manager = std::make_shared<input::Manager>(rt);
|
auto input_manager = std::make_shared<input::Manager>(rt);
|
||||||
|
|
||||||
|
|
@ -213,6 +226,7 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
container::Configuration container_configuration;
|
container::Configuration container_configuration;
|
||||||
|
if (!standalone_) {
|
||||||
container_configuration.bind_mounts = {
|
container_configuration.bind_mounts = {
|
||||||
{qemu_pipe_connector->socket_file(), "/dev/qemu_pipe"},
|
{qemu_pipe_connector->socket_file(), "/dev/qemu_pipe"},
|
||||||
{bridge_connector->socket_file(), "/dev/anbox_bridge"},
|
{bridge_connector->socket_file(), "/dev/anbox_bridge"},
|
||||||
|
|
@ -223,7 +237,8 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
||||||
{"/dev/fuse", "/dev/fuse"},
|
{"/dev/fuse", "/dev/fuse"},
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatcher->dispatch([&]() { container.start(container_configuration); });
|
dispatcher->dispatch([&]() { container_->start(container_configuration); });
|
||||||
|
}
|
||||||
|
|
||||||
auto bus = bus_factory_();
|
auto bus = bus_factory_();
|
||||||
bus->install_executor(core::dbus::asio::make_executor(bus, rt->service()));
|
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();
|
rt->start();
|
||||||
trap->run();
|
trap->run();
|
||||||
|
|
||||||
|
if (!standalone_) {
|
||||||
// Stop the container which should close all open connections we have on
|
// Stop the container which should close all open connections we have on
|
||||||
// our side and should terminate all services.
|
// our side and should terminate all services.
|
||||||
container.stop();
|
container_->stop();
|
||||||
|
}
|
||||||
|
|
||||||
rt->stop();
|
rt->stop();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@
|
||||||
#include "anbox/graphics/rect.h"
|
#include "anbox/graphics/rect.h"
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
|
namespace container {
|
||||||
|
class Client;
|
||||||
|
} // namespace container
|
||||||
namespace cmds {
|
namespace cmds {
|
||||||
class SessionManager : public cli::CommandWithFlagsAndAction {
|
class SessionManager : public cli::CommandWithFlagsAndAction {
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,11 +43,14 @@ class SessionManager : public cli::CommandWithFlagsAndAction {
|
||||||
SessionManager(const BusFactory& bus_factory = session_bus_factory());
|
SessionManager(const BusFactory& bus_factory = session_bus_factory());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<container::Client> container_;
|
||||||
BusFactory bus_factory_;
|
BusFactory bus_factory_;
|
||||||
std::string desktop_file_hint_;
|
std::string desktop_file_hint_;
|
||||||
graphics::GLRendererServer::Config::Driver gles_driver_;
|
graphics::GLRendererServer::Config::Driver gles_driver_;
|
||||||
bool single_window_ = false;
|
bool single_window_ = false;
|
||||||
graphics::Rect window_size_;
|
graphics::Rect window_size_;
|
||||||
|
bool standalone_ = false;
|
||||||
|
bool experimental_ = false;
|
||||||
};
|
};
|
||||||
} // namespace cmds
|
} // namespace cmds
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue