[lxc-devel] [go-lxc/v2] Add method to support starting container with args

qq690388648 on Github lxc-bot at linuxcontainers.org
Wed Feb 15 13:51:43 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 397 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170215/ba0a0dcf/attachment.bin>
-------------- next part --------------
From 997a4f9ace443e50890b1694aea5e449a353283c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AD=99=E5=BA=9A=E6=B3=BD?= <690388648 at qq.com>
Date: Wed, 15 Feb 2017 21:50:14 +0800
Subject: [PATCH] Add method to support starting container with args

Add method `StartWithArgs` to support starting container with args.
Signed-off-by: sungengze
---
 container.go | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/container.go b/container.go
index ae09abc..4d63144 100644
--- a/container.go
+++ b/container.go
@@ -452,6 +452,20 @@ func (c *Container) Start() error {
 	return nil
 }
 
+func (c *Container) StartWithArgs(args []string) error {
+	if err := c.makeSure(isNotRunning); err != nil {
+		return err
+	}
+
+	c.mu.Lock()
+	defer c.mu.Unlock()
+
+	if !bool(C.go_lxc_start(c.container, 0, makeNullTerminatedArgs(args))) {
+		return ErrStartFailed
+	}
+	return nil
+}
+
 // Execute executes the given command in a temporary container.
 func (c *Container) Execute(args ...string) ([]byte, error) {
 	if err := c.makeSure(isNotDefined); err != nil {


More information about the lxc-devel mailing list