The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/go-lxc/pull/90
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 455e6233ce2e4d58ef3828f465f9b80fa9fc2195 Mon Sep 17 00:00:00 2001 From: Christian Brauner <[email protected]> Date: Thu, 12 Oct 2017 17:39:01 +0200 Subject: [PATCH 1/2] binginds: add missing import Signed-off-by: Christian Brauner <[email protected]> --- lxc-binding.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lxc-binding.go b/lxc-binding.go index 29aaf80..2fb4fd9 100644 --- a/lxc-binding.go +++ b/lxc-binding.go @@ -19,6 +19,7 @@ import "C" import ( "fmt" "runtime" + "strings" "unsafe" ) @@ -67,7 +68,7 @@ func Version() string { // New liblxc versions append "-devel" when LXC_DEVEL is set. if strings.HasSuffix(version, "-devel") { - return fmt.Sprintf("%s (devel)", version[:(len(version) - len("-devel"))]) + return fmt.Sprintf("%s (devel)", version[:(len(version)-len("-devel"))]) } else if C.LXC_DEVEL == 1 { version = fmt.Sprintf("%s (devel)", version) } From 5646c1b2c23ada2cc2657423987aa3429f5136cd Mon Sep 17 00:00:00 2001 From: Christian Brauner <[email protected]> Date: Thu, 12 Oct 2017 17:39:21 +0200 Subject: [PATCH 2/2] bindings: support set_running_config_item() Signed-off-by: Christian Brauner <[email protected]> --- container.go | 18 ++++++++++++++++++ lxc-binding.c | 8 ++++++++ lxc-binding.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/container.go b/container.go index bbcfa1d..f859d3d 100644 --- a/container.go +++ b/container.go @@ -1707,3 +1707,21 @@ func (c *Container) DetachInterfaceRename(source, target string) error { } return nil } + +// SetRunningConfigItem sets the value of the given config item in the +// container's in-memory config. +func (c *Container) SetRunningConfigItem(key string, value string) error { + c.mu.Lock() + defer c.mu.Unlock() + + ckey := C.CString(key) + defer C.free(unsafe.Pointer(ckey)) + + cvalue := C.CString(value) + defer C.free(unsafe.Pointer(cvalue)) + + if !bool(C.go_lxc_set_running_config_item(c.container, ckey, cvalue)) { + return ErrSettingConfigItemFailed + } + return nil +} diff --git a/lxc-binding.c b/lxc-binding.c index 406801c..60206b9 100644 --- a/lxc-binding.c +++ b/lxc-binding.c @@ -455,3 +455,11 @@ bool go_lxc_config_item_is_supported(const char *key) return false; #endif } + +bool go_lxc_set_running_config_item(struct lxc_container *c, const char *key, const char *value) { +#if VERSION_AT_LEAST(2, 1, 0) + return c->set_running_config_item(c, key, value); +#else + return false; +#endif +} diff --git a/lxc-binding.h b/lxc-binding.h index 11a22df..cbf9ce2 100644 --- a/lxc-binding.h +++ b/lxc-binding.h @@ -78,6 +78,8 @@ extern pid_t go_lxc_init_pid(struct lxc_container *c); extern bool go_lxc_checkpoint(struct lxc_container *c, char *directory, bool stop, bool verbose); extern bool go_lxc_restore(struct lxc_container *c, char *directory, bool verbose); extern bool go_lxc_config_item_is_supported(const char *key); +extern bool go_lxc_set_running_config_item(struct lxc_container *c, + const char *key, const char *value); /* n.b. that we're just adding the fields here to shorten the definition * of go_lxc_migrate; in the case where we don't have the ->migrate API call,
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
