Commit 6e590161 by dlezcano

Add the framework for a console

From: Daniel Lezcano <dlezcano@fr.ibm.com> Add the setup information to create a console. This temporary code will be improved to take into account ttys and console. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 4c92bdfc
...@@ -666,6 +666,19 @@ static int setup_rootfs(const char *name) ...@@ -666,6 +666,19 @@ static int setup_rootfs(const char *name)
return 0; return 0;
} }
static int setup_console(const char *name, const char *tty)
{
if (access("/dev/console", R_OK|W_OK))
return 0;
if (mount(tty, "/dev/console", "none", MS_BIND, 0)) {
lxc_log_error("failed to mount the console");
return -1;
}
return 0;
}
static int setup_cgroup_cb(void* buffer, void *data) static int setup_cgroup_cb(void* buffer, void *data)
{ {
char *key = buffer, *value; char *key = buffer, *value;
...@@ -1363,15 +1376,16 @@ static int delete_netdev(const char *name) ...@@ -1363,15 +1376,16 @@ static int delete_netdev(const char *name)
int conf_destroy_network(const char *name) int conf_destroy_network(const char *name)
{ {
#ifdef NETWORK_DESTROY
if (delete_netdev(name)) { if (delete_netdev(name)) {
lxc_log_error("failed to remove the network devices"); lxc_log_error("failed to remove the network devices");
return -1; return -1;
} }
#endif
return 0; return 0;
} }
int lxc_setup(const char *name) int lxc_setup(const char *name, const char *tty)
{ {
if (conf_has_utsname(name) && setup_utsname(name)) { if (conf_has_utsname(name) && setup_utsname(name)) {
lxc_log_error("failed to setup the utsname for '%s'", name); lxc_log_error("failed to setup the utsname for '%s'", name);
...@@ -1389,7 +1403,7 @@ int lxc_setup(const char *name) ...@@ -1389,7 +1403,7 @@ int lxc_setup(const char *name)
} }
if (conf_has_fstab(name) && setup_mount(name)) { if (conf_has_fstab(name) && setup_mount(name)) {
lxc_log_error("failed to setup the mount points for '%s'", name); lxc_log_error("failed to setup the mounts for '%s'", name);
return -LXC_ERROR_SETUP_MOUNT; return -LXC_ERROR_SETUP_MOUNT;
} }
...@@ -1398,5 +1412,10 @@ int lxc_setup(const char *name) ...@@ -1398,5 +1412,10 @@ int lxc_setup(const char *name)
return -LXC_ERROR_SETUP_ROOTFS; return -LXC_ERROR_SETUP_ROOTFS;
} }
if (tty[0] && setup_console(name, tty)) {
lxc_log_error("failed to setup the console for '%s'", name);
return -LXC_ERROR_SETUP_CONSOLE;
}
return 0; return 0;
} }
...@@ -139,7 +139,7 @@ extern int conf_destroy_network(const char *name); ...@@ -139,7 +139,7 @@ extern int conf_destroy_network(const char *name);
/* /*
* Configure the container from inside * Configure the container from inside
*/ */
extern int lxc_setup(const char *name); extern int lxc_setup(const char *name, const char *tty);
extern int conf_has(const char *name, const char *info); extern int conf_has(const char *name, const char *info);
...@@ -147,6 +147,7 @@ extern int conf_has(const char *name, const char *info); ...@@ -147,6 +147,7 @@ extern int conf_has(const char *name, const char *info);
#define conf_has_rootfs(__name) conf_has(__name, "rootfs") #define conf_has_rootfs(__name) conf_has(__name, "rootfs")
#define conf_has_utsname(__name) conf_has(__name, "utsname") #define conf_has_utsname(__name) conf_has(__name, "utsname")
#define conf_has_network(__name) conf_has(__name, "network") #define conf_has_network(__name) conf_has(__name, "network")
#define conf_has_console(__name) conf_has(__name, "console")
#define conf_has_cgroup(__name) conf_has(__name, "cgroup") #define conf_has_cgroup(__name) conf_has(__name, "cgroup")
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment