Merge pull request #194 from sameo/master

Conmon fixes
This commit is contained in:
Mrunal Patel 2016-11-15 09:47:13 -08:00 committed by GitHub
commit e790094f23
2 changed files with 29 additions and 4 deletions

View file

@ -66,11 +66,15 @@ static void tty_restore(void)
static bool terminal = false; static bool terminal = false;
static char *cid = NULL; static char *cid = NULL;
static char *runtime_path = NULL; static char *runtime_path = NULL;
static char *bundle_path = NULL;
static char *pid_file = NULL;
static GOptionEntry entries[] = static GOptionEntry entries[] =
{ {
{ "terminal", 't', 0, G_OPTION_ARG_NONE, &terminal, "Terminal", NULL }, { "terminal", 't', 0, G_OPTION_ARG_NONE, &terminal, "Terminal", NULL },
{ "cid", 'c', 0, G_OPTION_ARG_STRING, &cid, "Container ID", NULL }, { "cid", 'c', 0, G_OPTION_ARG_STRING, &cid, "Container ID", NULL },
{ "runtime", 'r', 0, G_OPTION_ARG_STRING, &runtime_path, "Runtime path", NULL }, { "runtime", 'r', 0, G_OPTION_ARG_STRING, &runtime_path, "Runtime path", NULL },
{ "bundle", 'b', 0, G_OPTION_ARG_STRING, &bundle_path, "Bundle path", NULL },
{ "pidfile", 'p', 0, G_OPTION_ARG_STRING, &pid_file, "PID file", NULL },
{ NULL } { NULL }
}; };
@ -78,6 +82,8 @@ int main(int argc, char *argv[])
{ {
int ret; int ret;
char cmd[CMD_SIZE]; char cmd[CMD_SIZE];
char cwd[PATH_MAX];
char default_pid_file[PATH_MAX];
GError *err = NULL; GError *err = NULL;
_cleanup_free_ char *contents; _cleanup_free_ char *contents;
int cpid = -1; int cpid = -1;
@ -111,6 +117,23 @@ int main(int argc, char *argv[])
if (runtime_path == NULL) if (runtime_path == NULL)
nexit("Runtime path not provided. Use --runtime"); nexit("Runtime path not provided. Use --runtime");
if (bundle_path == NULL) {
if (getcwd(cwd, sizeof(cwd)) == NULL) {
nexit("Failed to get working directory");
}
bundle_path = cwd;
}
if (pid_file == NULL) {
if (snprintf(default_pid_file, sizeof(default_pid_file),
"%s/pidfile-%s", cwd, cid) < 0) {
nexit("Failed to generate the pidfile path");
}
pid_file = default_pid_file;
}
/* Environment variables */ /* Environment variables */
sync_pipe = getenv("_OCI_SYNCPIPE"); sync_pipe = getenv("_OCI_SYNCPIPE");
if (sync_pipe) { if (sync_pipe) {
@ -155,11 +178,11 @@ int main(int argc, char *argv[])
/* Create the container */ /* Create the container */
if (terminal) { if (terminal) {
snprintf(cmd, CMD_SIZE, snprintf(cmd, CMD_SIZE,
"%s create %s --pid-file pidfile --console %s", "%s create %s --bundle %s --pid-file %s --console %s",
runtime_path, cid, slname); runtime_path, cid, bundle_path, pid_file, slname);
} else { } else {
snprintf(cmd, CMD_SIZE, "%s create %s --pid-file pidfile", snprintf(cmd, CMD_SIZE, "%s create %s --bundle %s --pid-file %s",
runtime_path, cid); runtime_path, cid, bundle_path, pid_file);
} }
ret = system(cmd); ret = system(cmd);
if (ret != 0) { if (ret != 0) {

View file

@ -102,6 +102,8 @@ func (r *Runtime) CreateContainer(c *Container) error {
args := []string{"-c", c.name} args := []string{"-c", c.name}
args = append(args, "-r", r.path) args = append(args, "-r", r.path)
args = append(args, "-b", c.bundlePath)
args = append(args, "-p", filepath.Join(c.bundlePath, "pidfile"))
if c.terminal { if c.terminal {
args = append(args, "-t") args = append(args, "-t")
} }