[lxc-devel] [go-lxc/v2] Fix execute check
tych0 on Github
lxc-bot at linuxcontainers.org
Mon Dec 4 22:17:40 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 329 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171204/c774985e/attachment.bin>
-------------- next part --------------
From 9d2976b398263e72e96ebc88c2ae325102300c75 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho at tycho.ws>
Date: Mon, 4 Dec 2017 15:02:57 -0700
Subject: [PATCH 1/2] fix execute defined check
Execute() really just does exec("lxc-execute", "-P", c.configPath()); the
problem here is that if c is undefined, then it doesn't have an on-disk
config path, and this lxc-execute invocation won't work.
I think there's a think-o here, and we really mean "is this container
defined", since it will thusly have a config and this little hack will
work.
Signed-off-by: Tycho Andersen <tycho at tycho.ws>
---
container.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/container.go b/container.go
index 8e9ba73..690988b 100644
--- a/container.go
+++ b/container.go
@@ -495,7 +495,7 @@ func (c *Container) Execute(args ...string) ([]byte, error) {
c.mu.Lock()
defer c.mu.Unlock()
- if err := c.makeSure(isNotDefined); err != nil {
+ if err := c.makeSure(isDefined); err != nil {
return nil, err
}
From 67d98dfe09e9e6dde9cd48cf48a6b1d997418e73 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho at tycho.ws>
Date: Mon, 4 Dec 2017 15:04:29 -0700
Subject: [PATCH 2/2] remove some commented out code
With the immanent arrival of StartExecute(), Execute() is probably going to
be enshrined in hackery-whackery for the rest of time. So let's get rid of
this commented out code.
Signed-off-by: Tycho Andersen <tycho at tycho.ws>
---
container.go | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/container.go b/container.go
index 690988b..09cbe15 100644
--- a/container.go
+++ b/container.go
@@ -517,18 +517,6 @@ func (c *Container) Execute(args ...string) ([]byte, error) {
}
return output, nil
- /*
- cargs := makeNullTerminatedArgs(args)
- if cargs == nil {
- return ErrAllocationFailed
- }
- defer freeNullTerminatedArgs(cargs, len(args))
-
- if !bool(C.go_lxc_start(c.container, 1, cargs)) {
- return ErrExecuteFailed
- }
- return nil
- */
}
// Stop stops the container.
More information about the lxc-devel
mailing list