mirror of
https://github.com/lxc/go-lxc.git
synced 2026-02-05 15:47:17 +01:00
introduce MayControl
This commit is contained in:
@@ -90,6 +90,14 @@ func (lxc *Container) Running() bool {
|
||||
return bool(C.lxc_container_running(lxc.container))
|
||||
}
|
||||
|
||||
// MayControl returns whether the container is already running or not
|
||||
func (lxc *Container) MayControl() bool {
|
||||
lxc.RLock()
|
||||
defer lxc.RUnlock()
|
||||
|
||||
return bool(C.lxc_container_may_control(lxc.container))
|
||||
}
|
||||
|
||||
// State returns the container's state
|
||||
func (lxc *Container) State() State {
|
||||
lxc.RLock()
|
||||
|
||||
4
lxc.c
4
lxc.c
@@ -239,3 +239,7 @@ int lxc_container_attach_run_wait(struct lxc_container *c, char **argv) {
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool lxc_container_may_control(struct lxc_container *c) {
|
||||
return c->may_control(c);
|
||||
}
|
||||
|
||||
2
lxc.h
2
lxc.h
@@ -54,10 +54,10 @@ extern int lxc_container_console_getfd(struct lxc_container *, int);
|
||||
extern pid_t lxc_container_init_pid(struct lxc_container *);
|
||||
extern void lxc_container_want_daemonize(struct lxc_container *);
|
||||
extern bool lxc_container_want_close_all_fds(struct lxc_container *);
|
||||
extern bool lxc_container_may_control(struct lxc_container *);
|
||||
|
||||
//FIXME: Missing API functionality
|
||||
// snapshot
|
||||
// int (*snapshot)(struct lxc_container *c, char *commentfile);
|
||||
// int (*snapshot_list)(struct lxc_container *, struct lxc_snapshot **);
|
||||
// bool (*snapshot_restore)(struct lxc_container *c, char *snapname, char *newname);
|
||||
//
|
||||
|
||||
18
lxc_test.go
18
lxc_test.go
@@ -232,11 +232,25 @@ func TestStart(t *testing.T) {
|
||||
z.Start(false)
|
||||
|
||||
z.Wait(lxc.RUNNING, 30)
|
||||
if !z.Running() {
|
||||
t.Errorf("Starting the container failed...")
|
||||
}
|
||||
|
||||
func TestMayControl(t *testing.T) {
|
||||
z := lxc.NewContainer(ContainerName)
|
||||
defer lxc.PutContainer(z)
|
||||
|
||||
if !z.MayControl() {
|
||||
t.Errorf("Controling the container failed...")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunning(t *testing.T) {
|
||||
z := lxc.NewContainer(ContainerName)
|
||||
defer lxc.PutContainer(z)
|
||||
|
||||
if !z.Running() {
|
||||
t.Errorf("Checking the container failed...")
|
||||
}
|
||||
}
|
||||
func TestSetDaemonize(t *testing.T) {
|
||||
z := lxc.NewContainer(ContainerName)
|
||||
defer lxc.PutContainer(z)
|
||||
|
||||
Reference in New Issue
Block a user