mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-10 00:55:47 +00:00
console: s/tty_info/ttys/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
2520facd01
commit
0e4be3cf03
@ -840,15 +840,15 @@ static bool append_ptyname(char **pp, char *name)
|
|||||||
static int lxc_setup_ttys(struct lxc_conf *conf)
|
static int lxc_setup_ttys(struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
const struct lxc_tty_info *tty_info = &conf->tty_info;
|
const struct lxc_tty_info *ttys = &conf->ttys;
|
||||||
char *ttydir = conf->ttydir;
|
char *ttydir = conf->ttydir;
|
||||||
char path[MAXPATHLEN], lxcpath[MAXPATHLEN];
|
char path[MAXPATHLEN], lxcpath[MAXPATHLEN];
|
||||||
|
|
||||||
if (!conf->rootfs.path)
|
if (!conf->rootfs.path)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < tty_info->nbtty; i++) {
|
for (i = 0; i < ttys->nbtty; i++) {
|
||||||
struct lxc_terminal_info *tty = &tty_info->tty[i];
|
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||||
|
|
||||||
ret = snprintf(path, sizeof(path), "/dev/tty%d", i + 1);
|
ret = snprintf(path, sizeof(path), "/dev/tty%d", i + 1);
|
||||||
if (ret < 0 || (size_t)ret >= sizeof(path))
|
if (ret < 0 || (size_t)ret >= sizeof(path))
|
||||||
@ -926,32 +926,32 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO("Finished setting up %d /dev/tty<N> device(s)", tty_info->nbtty);
|
INFO("Finished setting up %d /dev/tty<N> device(s)", ttys->nbtty);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lxc_allocate_ttys(const char *name, struct lxc_conf *conf)
|
int lxc_allocate_ttys(const char *name, struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
struct lxc_tty_info *tty_info = &conf->tty_info;
|
struct lxc_tty_info *ttys = &conf->ttys;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
/* no tty in the configuration */
|
/* no tty in the configuration */
|
||||||
if (!conf->tty)
|
if (!conf->tty)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tty_info->tty = malloc(sizeof(*tty_info->tty) * conf->tty);
|
ttys->tty = malloc(sizeof(*ttys->tty) * conf->tty);
|
||||||
if (!tty_info->tty)
|
if (!ttys->tty)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (i = 0; i < conf->tty; i++) {
|
for (i = 0; i < conf->tty; i++) {
|
||||||
struct lxc_terminal_info *tty = &tty_info->tty[i];
|
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||||
|
|
||||||
ret = openpty(&tty->master, &tty->slave,
|
ret = openpty(&tty->master, &tty->slave,
|
||||||
tty->name, NULL, NULL);
|
tty->name, NULL, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
SYSERROR("failed to create pty device number %d", i);
|
SYSERROR("failed to create pty device number %d", i);
|
||||||
tty_info->nbtty = i;
|
ttys->nbtty = i;
|
||||||
lxc_delete_tty(tty_info);
|
lxc_delete_tty(ttys);
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,33 +974,33 @@ int lxc_allocate_ttys(const char *name, struct lxc_conf *conf)
|
|||||||
tty->busy = 0;
|
tty->busy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tty_info->nbtty = conf->tty;
|
ttys->nbtty = conf->tty;
|
||||||
|
|
||||||
INFO("finished allocating %d pts devices", conf->tty);
|
INFO("finished allocating %d pts devices", conf->tty);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lxc_delete_tty(struct lxc_tty_info *tty_info)
|
void lxc_delete_tty(struct lxc_tty_info *ttys)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < tty_info->nbtty; i++) {
|
for (i = 0; i < ttys->nbtty; i++) {
|
||||||
struct lxc_terminal_info *tty = &tty_info->tty[i];
|
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||||
|
|
||||||
close(tty->master);
|
close(tty->master);
|
||||||
close(tty->slave);
|
close(tty->slave);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tty_info->tty);
|
free(ttys->tty);
|
||||||
tty_info->tty = NULL;
|
ttys->tty = NULL;
|
||||||
tty_info->nbtty = 0;
|
ttys->nbtty = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
|
static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct lxc_conf *conf = handler->conf;
|
struct lxc_conf *conf = handler->conf;
|
||||||
struct lxc_tty_info *tty_info = &conf->tty_info;
|
struct lxc_tty_info *ttys = &conf->ttys;
|
||||||
int sock = handler->data_sock[0];
|
int sock = handler->data_sock[0];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -1009,7 +1009,7 @@ static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
|
|||||||
|
|
||||||
for (i = 0; i < conf->tty; i++) {
|
for (i = 0; i < conf->tty; i++) {
|
||||||
int ttyfds[2];
|
int ttyfds[2];
|
||||||
struct lxc_terminal_info *tty = &tty_info->tty[i];
|
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||||
|
|
||||||
ttyfds[0] = tty->master;
|
ttyfds[0] = tty->master;
|
||||||
ttyfds[1] = tty->slave;
|
ttyfds[1] = tty->slave;
|
||||||
@ -1065,7 +1065,7 @@ static int lxc_create_ttys(struct lxc_handler *handler)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
lxc_delete_tty(&conf->tty_info);
|
lxc_delete_tty(&conf->ttys);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -134,8 +134,7 @@ struct id_map {
|
|||||||
unsigned long hostid, nsid, range;
|
unsigned long hostid, nsid, range;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/* Defines the number of tty configured and contains the
|
||||||
* Defines the number of tty configured and contains the
|
|
||||||
* instantiated ptys
|
* instantiated ptys
|
||||||
* @nbtty = number of configured ttys
|
* @nbtty = number of configured ttys
|
||||||
*/
|
*/
|
||||||
@ -203,7 +202,7 @@ enum {
|
|||||||
* @fstab : path to a fstab file format
|
* @fstab : path to a fstab file format
|
||||||
* @caps : list of the capabilities to drop
|
* @caps : list of the capabilities to drop
|
||||||
* @keepcaps : list of the capabilities to keep
|
* @keepcaps : list of the capabilities to keep
|
||||||
* @tty_info : tty data
|
* @ttys : tty data
|
||||||
* @console : console data
|
* @console : console data
|
||||||
* @ttydir : directory (under /dev) in which to create console and ttys
|
* @ttydir : directory (under /dev) in which to create console and ttys
|
||||||
* @lsm_aa_profile : apparmor profile to switch to or NULL
|
* @lsm_aa_profile : apparmor profile to switch to or NULL
|
||||||
@ -258,7 +257,7 @@ struct lxc_conf {
|
|||||||
struct lxc_list mount_list;
|
struct lxc_list mount_list;
|
||||||
struct lxc_list caps;
|
struct lxc_list caps;
|
||||||
struct lxc_list keepcaps;
|
struct lxc_list keepcaps;
|
||||||
struct lxc_tty_info tty_info;
|
struct lxc_tty_info ttys;
|
||||||
/* Comma-separated list of lxc.tty.max pty names. */
|
/* Comma-separated list of lxc.tty.max pty names. */
|
||||||
char *pty_names;
|
char *pty_names;
|
||||||
struct lxc_terminal console;
|
struct lxc_terminal console;
|
||||||
@ -387,7 +386,7 @@ extern void lxc_conf_free(struct lxc_conf *conf);
|
|||||||
extern int pin_rootfs(const char *rootfs);
|
extern int pin_rootfs(const char *rootfs);
|
||||||
extern int lxc_map_ids(struct lxc_list *idmap, pid_t pid);
|
extern int lxc_map_ids(struct lxc_list *idmap, pid_t pid);
|
||||||
extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
|
extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
|
||||||
extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
|
extern void lxc_delete_tty(struct lxc_tty_info *ttys);
|
||||||
extern int lxc_clear_config_caps(struct lxc_conf *c);
|
extern int lxc_clear_config_caps(struct lxc_conf *c);
|
||||||
extern int lxc_clear_config_keepcaps(struct lxc_conf *c);
|
extern int lxc_clear_config_keepcaps(struct lxc_conf *c);
|
||||||
extern int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version);
|
extern int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version);
|
||||||
|
@ -578,7 +578,7 @@ err1:
|
|||||||
int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
|
int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
|
||||||
{
|
{
|
||||||
int masterfd = -1, ttynum;
|
int masterfd = -1, ttynum;
|
||||||
struct lxc_tty_info *tty_info = &conf->tty_info;
|
struct lxc_tty_info *ttys = &conf->ttys;
|
||||||
struct lxc_terminal *terminal = &conf->console;
|
struct lxc_terminal *terminal = &conf->console;
|
||||||
|
|
||||||
if (*ttyreq == 0) {
|
if (*ttyreq == 0) {
|
||||||
@ -589,10 +589,10 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*ttyreq > 0) {
|
if (*ttyreq > 0) {
|
||||||
if (*ttyreq > tty_info->nbtty)
|
if (*ttyreq > ttys->nbtty)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (tty_info->tty[*ttyreq - 1].busy)
|
if (ttys->tty[*ttyreq - 1].busy)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* the requested tty is available */
|
/* the requested tty is available */
|
||||||
@ -601,18 +601,18 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* search for next available tty, fixup index tty1 => [0] */
|
/* search for next available tty, fixup index tty1 => [0] */
|
||||||
for (ttynum = 1; ttynum <= tty_info->nbtty && tty_info->tty[ttynum - 1].busy; ttynum++)
|
for (ttynum = 1; ttynum <= ttys->nbtty && ttys->tty[ttynum - 1].busy; ttynum++)
|
||||||
;
|
;
|
||||||
|
|
||||||
/* we didn't find any available slot for tty */
|
/* we didn't find any available slot for tty */
|
||||||
if (ttynum > tty_info->nbtty)
|
if (ttynum > ttys->nbtty)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
*ttyreq = ttynum;
|
*ttyreq = ttynum;
|
||||||
|
|
||||||
out_tty:
|
out_tty:
|
||||||
tty_info->tty[ttynum - 1].busy = sockfd;
|
ttys->tty[ttynum - 1].busy = sockfd;
|
||||||
masterfd = tty_info->tty[ttynum - 1].master;
|
masterfd = ttys->tty[ttynum - 1].master;
|
||||||
out:
|
out:
|
||||||
return masterfd;
|
return masterfd;
|
||||||
}
|
}
|
||||||
@ -620,12 +620,12 @@ out:
|
|||||||
void lxc_terminal_free(struct lxc_conf *conf, int fd)
|
void lxc_terminal_free(struct lxc_conf *conf, int fd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct lxc_tty_info *tty_info = &conf->tty_info;
|
struct lxc_tty_info *ttys = &conf->ttys;
|
||||||
struct lxc_terminal *terminal = &conf->console;
|
struct lxc_terminal *terminal = &conf->console;
|
||||||
|
|
||||||
for (i = 0; i < tty_info->nbtty; i++) {
|
for (i = 0; i < ttys->nbtty; i++) {
|
||||||
if (tty_info->tty[i].busy == fd)
|
if (ttys->tty[i].busy == fd)
|
||||||
tty_info->tty[i].busy = 0;
|
ttys->tty[i].busy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terminal->peerpty.busy == fd) {
|
if (terminal->peerpty.busy == fd) {
|
||||||
|
@ -176,7 +176,7 @@ static void exec_criu(struct criu_opts *opts)
|
|||||||
FILE *mnts;
|
FILE *mnts;
|
||||||
struct mntent mntent;
|
struct mntent mntent;
|
||||||
|
|
||||||
char buf[4096], tty_info[32];
|
char buf[4096], ttys[32];
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
/* If we are currently in a cgroup /foo/bar, and the container is in a
|
/* If we are currently in a cgroup /foo/bar, and the container is in a
|
||||||
@ -233,12 +233,12 @@ static void exec_criu(struct criu_opts *opts)
|
|||||||
*/
|
*/
|
||||||
static_args += 6;
|
static_args += 6;
|
||||||
|
|
||||||
tty_info[0] = 0;
|
ttys[0] = 0;
|
||||||
if (load_tty_major_minor(opts->user->directory, tty_info, sizeof(tty_info)))
|
if (load_tty_major_minor(opts->user->directory, ttys, sizeof(ttys)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* --inherit-fd fd[%d]:tty[%s] */
|
/* --inherit-fd fd[%d]:tty[%s] */
|
||||||
if (tty_info[0])
|
if (ttys[0])
|
||||||
static_args += 2;
|
static_args += 2;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@ -493,13 +493,13 @@ static void exec_criu(struct criu_opts *opts)
|
|||||||
DECLARE_ARG("--restore-detached");
|
DECLARE_ARG("--restore-detached");
|
||||||
DECLARE_ARG("--restore-sibling");
|
DECLARE_ARG("--restore-sibling");
|
||||||
|
|
||||||
if (tty_info[0]) {
|
if (ttys[0]) {
|
||||||
if (opts->console_fd < 0) {
|
if (opts->console_fd < 0) {
|
||||||
ERROR("lxc.console.path configured on source host but not target");
|
ERROR("lxc.console.path configured on source host but not target");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = snprintf(buf, sizeof(buf), "fd[%d]:%s", opts->console_fd, tty_info);
|
ret = snprintf(buf, sizeof(buf), "fd[%d]:%s", opts->console_fd, ttys);
|
||||||
if (ret < 0 || ret >= sizeof(buf))
|
if (ret < 0 || ret >= sizeof(buf))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
@ -824,7 +824,7 @@ int lxc_init(const char *name, struct lxc_handler *handler)
|
|||||||
out_restore_sigmask:
|
out_restore_sigmask:
|
||||||
sigprocmask(SIG_SETMASK, &handler->oldmask, NULL);
|
sigprocmask(SIG_SETMASK, &handler->oldmask, NULL);
|
||||||
out_delete_tty:
|
out_delete_tty:
|
||||||
lxc_delete_tty(&conf->tty_info);
|
lxc_delete_tty(&conf->ttys);
|
||||||
out_aborting:
|
out_aborting:
|
||||||
lxc_set_state(name, handler, ABORTING);
|
lxc_set_state(name, handler, ABORTING);
|
||||||
out_close_maincmd_fd:
|
out_close_maincmd_fd:
|
||||||
@ -951,7 +951,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
|
|||||||
WARN("%s - Failed to restore signal mask", strerror(errno));
|
WARN("%s - Failed to restore signal mask", strerror(errno));
|
||||||
|
|
||||||
lxc_terminal_delete(&handler->conf->console);
|
lxc_terminal_delete(&handler->conf->console);
|
||||||
lxc_delete_tty(&handler->conf->tty_info);
|
lxc_delete_tty(&handler->conf->ttys);
|
||||||
|
|
||||||
/* The command socket is now closed, no more state clients can register
|
/* The command socket is now closed, no more state clients can register
|
||||||
* themselves from now on. So free the list of state clients.
|
* themselves from now on. So free the list of state clients.
|
||||||
@ -1344,13 +1344,13 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
int sock = handler->data_sock[1];
|
int sock = handler->data_sock[1];
|
||||||
struct lxc_conf *conf = handler->conf;
|
struct lxc_conf *conf = handler->conf;
|
||||||
struct lxc_tty_info *tty_info = &conf->tty_info;
|
struct lxc_tty_info *ttys = &conf->ttys;
|
||||||
|
|
||||||
if (!conf->tty)
|
if (!conf->tty)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tty_info->tty = malloc(sizeof(*tty_info->tty) * conf->tty);
|
ttys->tty = malloc(sizeof(*ttys->tty) * conf->tty);
|
||||||
if (!tty_info->tty)
|
if (!ttys->tty)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < conf->tty; i++) {
|
for (i = 0; i < conf->tty; i++) {
|
||||||
@ -1360,7 +1360,7 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tty = &tty_info->tty[i];
|
tty = &ttys->tty[i];
|
||||||
tty->busy = 0;
|
tty->busy = 0;
|
||||||
tty->master = ttyfds[0];
|
tty->master = ttyfds[0];
|
||||||
tty->slave = ttyfds[1];
|
tty->slave = ttyfds[1];
|
||||||
@ -1373,7 +1373,7 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
|
|||||||
else
|
else
|
||||||
TRACE("Received %d ttys from child", conf->tty);
|
TRACE("Received %d ttys from child", conf->tty);
|
||||||
|
|
||||||
tty_info->nbtty = conf->tty;
|
ttys->nbtty = conf->tty;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user