]> git.proxmox.com Git - mirror_lxc.git/commitdiff
pass lxcpath to lxc_command
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 11 Feb 2013 20:43:41 +0000 (14:43 -0600)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 11 Feb 2013 21:42:49 +0000 (16:42 -0500)
The previous lxcpath patches added support for a custom LXCPATH set
through a system-wide configuration file.

This was also exposed through the C api, so that a custom lxcpath could
be set at the container object instanciation time, or set at runtime.

However the command sock filename was always located under the global
lxcpath, which could be confusing, and would be a problem for users
with insufficient perms to the system-wide lxc path (i.e. if setting
lxcpath to $HOME/lxcbase).  This patch changes that by passing the
lxcpath to all callers of lxc_command().

It remains to add an lxcpath command line argument to most of the
command line tools (which are not using the C api) - lxc-start,
lxc-info, lxc-stop, etc.

At this point it becomes tempting to do something like

c = lxc.Container("r1", "/var/lib/lxc")
c2 = lxc.Container("r1", "$HOME/lxcbase")

However, that's problematic - those two will use the same directory
names for cgroup directories.

What would be the best way to handle this?  One way (which I kind
of like) is to give up on naming the cgroups after the container.
use mkstemp for the cgroup name, let lxc keep track of the cgroup
name based on the command socket, and make users use lxc-cgroup to get
and change settings.

Other ideas?

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
19 files changed:
src/lxc/commands.c
src/lxc/commands.h
src/lxc/console.c
src/lxc/execute.c
src/lxc/lxc.h
src/lxc/lxc_attach.c
src/lxc/lxc_console.c
src/lxc/lxc_execute.c
src/lxc/lxc_info.c
src/lxc/lxc_kill.c
src/lxc/lxc_start.c
src/lxc/lxc_stop.c
src/lxc/lxccontainer.c
src/lxc/restart.c
src/lxc/start.c
src/lxc/start.h
src/lxc/state.c
src/lxc/state.h
src/lxc/stop.c

index 2c4d6036d4c9e603185708f0db8d3eb78710dd0f..2776f032fc304a4f7227d5236f69d26ee0923b11 100644 (file)
 
 lxc_log_define(lxc_commands, lxc);
 
-static int fill_sock_name(char *path, int len, const char *name) {
-       char *lxcpath = default_lxc_path();
+static int fill_sock_name(char *path, int len, const char *name,
+                         const char *inpath)
+{
+       char *lxcpath = NULL;
        int ret;
-       if (!lxcpath) {
-               ERROR("Out of memory getting lxcpath");
-               return -1;
+
+       if (!inpath) {
+               lxcpath = default_lxc_path();
+               if (!lxcpath) {
+                       ERROR("Out of memory getting lxcpath");
+                       return -1;
+               }
        }
-       ret = snprintf(path, len, "%s/%s/command", lxcpath, name);
+       ret = snprintf(path, len, "%s/%s/command", lxcpath ? lxcpath : inpath, name);
+       if (lxcpath)
+               free(lxcpath);
+
        if (ret < 0 || ret >= len) {
                ERROR("Name too long");
                return -1;
@@ -86,7 +95,7 @@ static int receive_answer(int sock, struct lxc_answer *answer)
 }
 
 static int __lxc_command(const char *name, struct lxc_command *command,
-                        int *stopped, int stay_connected)
+                        int *stopped, int stay_connected, const char *lxcpath)
 {
        int sock, ret = -1;
        char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 };
@@ -94,7 +103,7 @@ static int __lxc_command(const char *name, struct lxc_command *command,
        int len;
 
        len = sizeof(path)-1;
-       if (fill_sock_name(offset, len, name))
+       if (fill_sock_name(offset, len, name, lxcpath))
                return -1;
 
        sock = lxc_af_unix_connect(path);
@@ -129,19 +138,21 @@ out:
 }
 
 extern int lxc_command(const char *name,
-                      struct lxc_command *command, int *stopped)
+                      struct lxc_command *command, int *stopped,
+                      const char *lxcpath)
 {
-       return __lxc_command(name, command, stopped, 0);
+       return __lxc_command(name, command, stopped, 0, lxcpath);
 }
 
 extern int lxc_command_connected(const char *name,
-                                struct lxc_command *command, int *stopped)
+                                struct lxc_command *command, int *stopped,
+                                const char *lxcpath)
 {
-       return __lxc_command(name, command, stopped, 1);
+       return __lxc_command(name, command, stopped, 1, lxcpath);
 }
 
 
-pid_t get_init_pid(const char *name)
+pid_t get_init_pid(const char *name, const char *lxcpath)
 {
        struct lxc_command command = {
                .request = { .type = LXC_COMMAND_PID },
@@ -149,7 +160,7 @@ pid_t get_init_pid(const char *name)
 
        int ret, stopped = 0;
 
-       ret = lxc_command(name, &command, &stopped);
+       ret = lxc_command(name, &command, &stopped, lxcpath);
        if (ret < 0 && stopped)
                return -1;
 
@@ -167,7 +178,7 @@ pid_t get_init_pid(const char *name)
        return command.answer.pid;
 }
 
-int lxc_get_clone_flags(const char *name)
+int lxc_get_clone_flags(const char *name, const char *lxcpath)
 {
        struct lxc_command command = {
                .request = { .type = LXC_COMMAND_CLONE_FLAGS },
@@ -175,7 +186,7 @@ int lxc_get_clone_flags(const char *name)
 
        int ret, stopped = 0;
 
-       ret = lxc_command(name, &command, &stopped);
+       ret = lxc_command(name, &command, &stopped, lxcpath);
        if (ret < 0 && stopped)
                return -1;
 
@@ -300,7 +311,8 @@ out_close:
        goto out;
 }
 
-extern int lxc_command_init(const char *name, struct lxc_handler *handler)
+extern int lxc_command_init(const char *name, struct lxc_handler *handler,
+                           const char *lxcpath)
 {
        int fd;
        char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 };
@@ -308,7 +320,7 @@ extern int lxc_command_init(const char *name, struct lxc_handler *handler)
        int len;
 
        len = sizeof(path)-1;
-       if (fill_sock_name(offset, len, name))
+       if (fill_sock_name(offset, len, name, lxcpath))
                return -1;
 
        fd = lxc_af_unix_open(path, SOCK_STREAM, 0);
index 0e1c8f96c40e31c82c30f1e120fc4a133b768343..0b72cf13bc5a22bc8adc88a43073d93ce707d439 100644 (file)
@@ -48,19 +48,20 @@ struct lxc_command {
        struct lxc_answer answer;
 };
 
-extern pid_t get_init_pid(const char *name);
-extern int lxc_get_clone_flags(const char *name);
+extern pid_t get_init_pid(const char *name, const char *lxcpath);
+extern int lxc_get_clone_flags(const char *name, const char *lxcpath);
 
 extern int lxc_command(const char *name, struct lxc_command *command,
-                       int *stopped);
+                       int *stopped, const char *lxcpath);
 
 extern int lxc_command_connected(const char *name, struct lxc_command *command,
-                                int *stopped);
+                                int *stopped, const char *lxcpath);
 
 struct lxc_epoll_descr;
 struct lxc_handler;
 
-extern int lxc_command_init(const char *name, struct lxc_handler *handler);
+extern int lxc_command_init(const char *name, struct lxc_handler *handler,
+                           const char *lxcpath);
 extern int lxc_command_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
                                    struct lxc_handler *handler);
 
index 88aac846213875216697c71b177384d1d107be4a..cff7a92ef2d8e887bc94eca8df9fbbf7f9eef3e1 100644 (file)
 
 lxc_log_define(lxc_console, lxc);
 
-extern int lxc_console(const char *name, int ttynum, int *fd)
+extern int lxc_console(const char *name, int ttynum, int *fd, const char *lxcpath)
 {
        int ret, stopped = 0;
        struct lxc_command command = {
                .request = { .type = LXC_COMMAND_TTY, .data = ttynum },
        };
 
-       ret = lxc_command_connected(name, &command, &stopped);
+       ret = lxc_command_connected(name, &command, &stopped, lxcpath);
        if (ret < 0 && stopped) {
                ERROR("'%s' is stopped", name);
                return -1;
index 99800d08490108bebb44e0ecbc84335b45cadb51..18d2fb43a32d3d65a3a47c9bc118e1c5a96d9b7b 100644 (file)
@@ -127,7 +127,7 @@ static struct lxc_operations execute_start_ops = {
 };
 
 int lxc_execute(const char *name, char *const argv[], int quiet,
-               struct lxc_conf *conf)
+               struct lxc_conf *conf, const char *lxcpath)
 {
        struct execute_args args = {
                .argv = argv,
@@ -137,5 +137,5 @@ int lxc_execute(const char *name, char *const argv[], int quiet,
        if (lxc_check_inherited(conf, -1))
                return -1;
 
-       return __lxc_start(name, conf, &execute_start_ops, &args);
+       return __lxc_start(name, conf, &execute_start_ops, &args, lxcpath);
 }
index a651d04210aed24413511a7bed105f12afb275c6..0e1ce632f9cc55d53fc8e84327c873c4bd8686a2 100644 (file)
@@ -47,7 +47,8 @@ struct lxc_arguments;
  * @conf     : configuration
  * Returns 0 on sucess, < 0 otherwise
  */
-extern int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf);
+extern int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf,
+                    const char *lxcpath);
 
 /*
  * Stop the container previously started with lxc_start, all
@@ -55,7 +56,7 @@ extern int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf
  * @name : the name of the container
  * Returns 0 on success, < 0 otherwise
  */
-extern int lxc_stop(const char *name);
+extern int lxc_stop(const char *name, const char *lxcpath);
 
 /*
  * Start the specified command inside an application container
@@ -66,7 +67,7 @@ extern int lxc_stop(const char *name);
  * Returns 0 on sucess, < 0 otherwise
  */
 extern int lxc_execute(const char *name, char *const argv[], int quiet,
-                      struct lxc_conf *conf);
+                      struct lxc_conf *conf, const char *lxcpath);
 
 /*
  * Open the monitoring mechanism for a specific container
@@ -100,7 +101,7 @@ extern int lxc_monitor_close(int fd);
  * @fd   : a pointer to a tty file descriptor
  * Returns 0 on sucess, < 0 otherwise
  */
-extern int lxc_console(const char *name, int ttynum, int *fd);
+extern int lxc_console(const char *name, int ttynum, int *fd, const char *lxcpath);
 
 /*
  * Freeze all the tasks running inside the container <name>
@@ -121,7 +122,7 @@ extern int lxc_unfreeze(const char *name);
  * @name : the name of the container
  * Returns the state of the container on success, < 0 otherwise
  */
-extern lxc_state_t lxc_state(const char *name);
+extern lxc_state_t lxc_state(const char *name, const char *lxcpath);
 
 /*
  * Set a specified value for a specified subsystem. The specified
index 437a40080defa358ea8ab02c670e3709b4a94379..b4ccf44fd4978f9d71d25a2e598647b5da5f0ce7 100644 (file)
@@ -130,6 +130,8 @@ int main(int argc, char *argv[])
        void *cgroup_data = NULL;
        uid_t uid;
        char *curdir;
+       /* TODO: add cmdline arg to set lxcpath */
+       const char *lxcpath = NULL;
 
        ret = lxc_caps_init();
        if (ret)
@@ -144,7 +146,7 @@ int main(int argc, char *argv[])
        if (ret)
                return ret;
 
-       init_pid = get_init_pid(my_args.name);
+       init_pid = get_init_pid(my_args.name, lxcpath);
        if (init_pid < 0) {
                ERROR("failed to get the init pid");
                return -1;
@@ -174,7 +176,7 @@ int main(int argc, char *argv[])
         * by asking lxc-start
         */
        if (namespace_flags == -1) {
-               namespace_flags = lxc_get_clone_flags(my_args.name);
+               namespace_flags = lxc_get_clone_flags(my_args.name, lxcpath);
                /* call failed */
                if (namespace_flags == -1) {
                        ERROR("failed to automatically determine the "
index c263d0f81bc7b4468cdd8495e1ecce21147c550e..8ff3f5ac3adcd6482bac55d1d66c3be30bbb113f 100644 (file)
@@ -182,6 +182,8 @@ int main(int argc, char *argv[])
        int err, std_in = 1;
        struct lxc_epoll_descr descr;
        struct termios newtios, oldtios;
+       /* TODO: add cmdline arg to specify lxcpath */
+       char *lxcpath = NULL;
 
        err = lxc_arguments_parse(&my_args, argc, argv);
        if (err)
@@ -198,7 +200,7 @@ int main(int argc, char *argv[])
                return -1;
        }
 
-       err = lxc_console(my_args.name, my_args.ttynum, &master);
+       err = lxc_console(my_args.name, my_args.ttynum, &master, lxcpath);
        if (err)
                goto out;
 
index 7a926a274a7e1fb0c169470a763c70e056486dfe..3c76e2e93c66c6e0d95d2b6c6f4a072e781cf78c 100644 (file)
@@ -143,5 +143,5 @@ int main(int argc, char *argv[])
        if (lxc_config_define_load(&defines, conf))
                return -1;
 
-       return lxc_execute(my_args.name, my_args.argv, my_args.quiet, conf);
+       return lxc_execute(my_args.name, my_args.argv, my_args.quiet, conf, NULL);
 }
index 48c1370de32a7573dcd31d16b2f9803381608213..fb37b2f1ba95785d8a2b86837890c95068bd99b4 100644 (file)
@@ -74,6 +74,8 @@ Options :\n\
 int main(int argc, char *argv[])
 {
        int ret;
+       /* TODO: add lxcpath cmdline arg */
+       const char *lxcpath = NULL;
 
        ret = lxc_arguments_parse(&my_args, argc, argv);
        if (ret)
@@ -87,7 +89,7 @@ int main(int argc, char *argv[])
                state = pid = true;
 
        if (state || test_state) {
-               ret = lxc_getstate(my_args.name);
+               ret = lxc_getstate(my_args.name, lxcpath);
                if (ret < 0)
                        return 1;
                if (test_state)
@@ -97,7 +99,7 @@ int main(int argc, char *argv[])
        }
 
        if (pid)
-               printf("pid:%10d\n", get_init_pid(my_args.name));
+               printf("pid:%10d\n", get_init_pid(my_args.name, lxcpath));
 
        return 0;
 }
index f9bfe34b60e812b454737a10b22962ee9b3aad4a..669f469ffb6d27e7b560d953b4e6f607325aeeab 100644 (file)
@@ -56,6 +56,8 @@ int main(int argc, char *argv[], char *envp[])
        int ret;
        pid_t pid;
        int sig;
+       /* TODO: add lxcpath cmdline arg */
+       const char *lxcpath = NULL;
 
        ret = lxc_arguments_parse(&my_args, argc, argv);
        if (ret)
@@ -76,7 +78,7 @@ int main(int argc, char *argv[], char *envp[])
        } else
                sig=SIGKILL;
 
-       pid = get_init_pid(my_args.name);
+       pid = get_init_pid(my_args.name, lxcpath);
        if (pid < 0) {
                ERROR("failed to get the init pid");
                return -1;
index c50c36b7cec4748f16a08c728c90bb8cdb4a2849..aac7fe781c22ddef067b4da802da0d1eff16c69c 100644 (file)
@@ -150,6 +150,8 @@ int main(int argc, char *argv[])
                '\0',
        };
        FILE *pid_fp = NULL;
+       /* TODO: add cmdline arg to specify lxcpath */
+       char *lxcpath = NULL;
 
        lxc_list_init(&defines);
 
@@ -258,7 +260,7 @@ int main(int argc, char *argv[])
        if (my_args.close_all_fds)
                conf->close_all_fds = 1;
 
-       err = lxc_start(my_args.name, args, conf);
+       err = lxc_start(my_args.name, args, conf, lxcpath);
 
        /*
         * exec ourself, that requires to have all opened fd
index 749d78a65b97629d74e93765ac4caed9943ef79c..703726a2d1488f362ff8146ab322ebf01079a1e3 100644 (file)
@@ -50,6 +50,9 @@ Options :\n\
 
 int main(int argc, char *argv[])
 {
+       /* TODO - make lxcpath a cmdline arg */
+       const char *lxcpath = NULL;
+
        if (lxc_arguments_parse(&my_args, argc, argv))
                return -1;
 
@@ -57,5 +60,5 @@ int main(int argc, char *argv[])
                         my_args.progname, my_args.quiet))
                return -1;
 
-       return lxc_stop(my_args.name);
+       return lxc_stop(my_args.name, lxcpath);
 }
index 733cbb68cbcbad5be83864ca433f3ae28203cbca..3b816e5d0b810fee1085035d128dac95ca8ef2b7 100644 (file)
@@ -161,7 +161,7 @@ static const char *lxcapi_state(struct lxc_container *c)
                return NULL;
        if (lxclock(c->slock, 0))
                return NULL;
-       s = lxc_getstate(c->name);
+       s = lxc_getstate(c->name, c->config_path);
        ret = lxc_state2str(s);
        lxcunlock(c->slock);
 
@@ -171,7 +171,7 @@ static const char *lxcapi_state(struct lxc_container *c)
 static bool is_stopped_nolock(struct lxc_container *c)
 {
        lxc_state_t s;
-       s = lxc_getstate(c->name);
+       s = lxc_getstate(c->name, c->config_path);
        return (s == STOPPED);
 }
 
@@ -225,7 +225,7 @@ static pid_t lxcapi_init_pid(struct lxc_container *c)
 
        if (lxclock(c->slock, 0))
                return -1;
-       ret = get_init_pid(c->name);
+       ret = get_init_pid(c->name, c->config_path);
        lxcunlock(c->slock);
        return ret;
 }
@@ -324,7 +324,7 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv
        lxcunlock(c->privlock);
 
        if (useinit) {
-               ret = lxc_execute(c->name, argv, 1, conf);
+               ret = lxc_execute(c->name, argv, 1, conf, c->config_path);
                return ret == 0 ? true : false;
        }
 
@@ -386,7 +386,7 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv
 
 reboot:
        conf->reboot = 0;
-       ret = lxc_start(c->name, argv, conf);
+       ret = lxc_start(c->name, argv, conf, c->config_path);
 
        if (conf->reboot) {
                INFO("container requested reboot");
@@ -464,7 +464,7 @@ static bool lxcapi_stop(struct lxc_container *c)
        if (!c)
                return false;
 
-       ret = lxc_stop(c->name);
+       ret = lxc_stop(c->name, c->config_path);
 
        return ret == 0;
 }
index a054838641f49d3b68103d794acefe411178e281..d0b8fa8d4b7fe4dc206d74a972981d0e42320854 100644 (file)
@@ -70,9 +70,11 @@ int lxc_restart(const char *name, int sfd, struct lxc_conf *conf, int flags)
                .sfd = sfd,
                .flags = flags
        };
+       /* TODO - make lxcpath a cmdline arg */
+       const char *lxcpath = NULL;
 
        if (lxc_check_inherited(conf, sfd))
                return -1;
 
-       return __lxc_start(name, conf, &restart_ops, &restart_arg);
+       return __lxc_start(name, conf, &restart_ops, &restart_arg, lxcpath);
 }
index 5083b24c9209651d45378ee7dc37a261c8e038c6..139be0883092b7f8ee4365ba90482367d4bc374f 100644 (file)
@@ -363,7 +363,7 @@ out_sigfd:
 
 extern int lxc_caps_check(void);
 
-struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf)
+struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf, const char *lxcpath)
 {
        struct lxc_handler *handler;
 
@@ -387,7 +387,7 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf)
                goto out_free;
        }
 
-       if (lxc_command_init(name, handler))
+       if (lxc_command_init(name, handler, lxcpath))
                goto out_free_name;
 
        if (lxc_read_seccomp_config(conf) != 0) {
@@ -835,13 +835,13 @@ out_abort:
 }
 
 int __lxc_start(const char *name, struct lxc_conf *conf,
-               struct lxc_operations* ops, void *data)
+               struct lxc_operations* ops, void *data, const char *lxcpath)
 {
        struct lxc_handler *handler;
        int err = -1;
        int status;
 
-       handler = lxc_init(name, conf);
+       handler = lxc_init(name, conf, lxcpath);
        if (!handler) {
                ERROR("failed to initialize the container");
                return -1;
@@ -940,7 +940,8 @@ static struct lxc_operations start_ops = {
        .post_start = post_start
 };
 
-int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf)
+int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf,
+             const char *lxcpath)
 {
        struct start_args start_arg = {
                .argv = argv,
@@ -950,5 +951,5 @@ int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf)
                return -1;
 
        conf->need_utmp_watch = 1;
-       return __lxc_start(name, conf, &start_ops, &start_arg);
+       return __lxc_start(name, conf, &start_ops, &start_arg, lxcpath);
 }
index 27688f386e00f357fbe106742d5b2325e6b64c28..8c8cbafffa76323143fd0eded1c10b661645d21d 100644 (file)
@@ -52,7 +52,7 @@ struct lxc_handler {
        int pinfd;
 };
 
-extern struct lxc_handler *lxc_init(const char *name, struct lxc_conf *);
+extern struct lxc_handler *lxc_init(const char *name, struct lxc_conf *, const char *);
 extern int lxc_spawn(struct lxc_handler *);
 
 extern int lxc_poll(const char *name, struct lxc_handler *handler);
@@ -61,7 +61,7 @@ extern void lxc_fini(const char *name, struct lxc_handler *handler);
 extern int lxc_set_state(const char *, struct lxc_handler *, lxc_state_t);
 extern int lxc_check_inherited(struct lxc_conf *conf, int fd_to_ignore);
 int __lxc_start(const char *, struct lxc_conf *, struct lxc_operations *,
-               void *);
+               void *, const char *);
 
 #endif
 
index 7ce4b533c211fb38e17dc78229f8c86ed5c756bc..8552522dd673ff5103c00ccae110cb78bdb0b0c9 100644 (file)
@@ -97,7 +97,7 @@ static int freezer_state(const char *name)
        return lxc_str2state(status);
 }
 
-static lxc_state_t __lxc_getstate(const char *name)
+static lxc_state_t __lxc_getstate(const char *name, const char *lxcpath)
 {
        struct lxc_command command = {
                .request = { .type = LXC_COMMAND_STATE },
@@ -105,7 +105,7 @@ static lxc_state_t __lxc_getstate(const char *name)
 
        int ret, stopped = 0;
 
-       ret = lxc_command(name, &command, &stopped);
+       ret = lxc_command(name, &command, &stopped, lxcpath);
        if (ret < 0 && stopped)
                return STOPPED;
 
@@ -130,11 +130,11 @@ static lxc_state_t __lxc_getstate(const char *name)
        return command.answer.ret;
 }
 
-lxc_state_t lxc_getstate(const char *name)
+lxc_state_t lxc_getstate(const char *name, const char *lxcpath)
 {
        int state = freezer_state(name);
        if (state != FROZEN && state != FREEZING)
-               state = __lxc_getstate(name);
+               state = __lxc_getstate(name, lxcpath);
        return state;
 }
 
@@ -196,6 +196,8 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout)
        struct lxc_msg msg;
        int state, ret;
        int s[MAX_STATE] = { }, fd;
+       /* TODO: add cmdline arg to specify lxcpath */
+       char *lxcpath = NULL;
 
        if (fillwaitedstates(states, s))
                return -1;
@@ -209,7 +211,7 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout)
         * then check if already in requested state
         */
        ret = -1;
-       state = lxc_getstate(lxcname);
+       state = lxc_getstate(lxcname, lxcpath);
        if (state < 0) {
                goto out_close;
        } else if ((state >= 0) && (s[state])) {
index df8070ac230998797428476a4449be8e7ead017b..c995e55a8139e4087f4de8cacfa6bd7b55a00c89 100644 (file)
@@ -29,7 +29,7 @@ typedef enum {
 } lxc_state_t;
 
 extern int lxc_rmstate(const char *name);
-extern lxc_state_t lxc_getstate(const char *name);
+extern lxc_state_t lxc_getstate(const char *name, const char *lxcpath);
 
 extern lxc_state_t lxc_str2state(const char *state);
 extern const char *lxc_state2str(lxc_state_t state);
index 1cacdca188456f81ecbad1cd9684f18a23f4db21..fa1e3752008a9b977533217700b4d515172960bc 100644 (file)
@@ -40,7 +40,7 @@
 
 lxc_log_define(lxc_stop, lxc);
 
-int lxc_stop(const char *name)
+int lxc_stop(const char *name, const char *lxcpath)
 {
        struct lxc_command command = {
                .request = { .type = LXC_COMMAND_STOP },
@@ -48,7 +48,7 @@ int lxc_stop(const char *name)
 
        int ret, stopped = 0;
 
-       ret = lxc_command(name, &command,&stopped);
+       ret = lxc_command(name, &command,&stopped, lxcpath);
        if (ret < 0 && stopped) {
                INFO("'%s' is already stopped", name);
                return 0;