1
0
mirror of https://github.com/lxc/go-lxc.git synced 2026-02-05 06:46:38 +01:00

175 Commits

Author SHA1 Message Date
Stéphane Graber
beb1045152 container: Better handle lxc_start
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-06-06 13:54:04 -04:00
Alexander Mikhalitsyn
da1d60f6ed container: add SetTimeout
Extend container API with a new method SetTimeout
which allows to set SO_RCVTIMEO for LXC client socket.

Issue #4257

Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
2023-09-26 19:04:26 +02:00
Stéphane Graber
8160599674 global: Update for gofmt
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2023-06-20 21:20:07 -04:00
Ruben Jenster
fcf7636af5 attach: Add options RemountSysProc and ElevatedPrivileges
Add attach option RemountSysProc to remount /sys and /proc for
the executed command (similar 'lxc-attach --remount-sys-proc').
Add attach option ElevatedPrivileges to elevate all privileges of the
executed command (similar to 'lxc-attach --elevated-privileges').

Signed-off-by: Ruben Jenster <r.jenster@drachenfels.de>
2021-05-06 08:19:37 +02:00
Stéphane Graber
5f45fb54e6 container: Fix 32bit build
Reduce memory allocation for snapshots to allow building on 32bit.
This will limit the total number of snapshots that this can handle but
it's still such a ludicrous number that it shouldn't be an issue until
we can fully ignore 32bit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-03-24 15:50:48 -04:00
Stéphane Graber
3eb27f7385 util/container: Fix 32bit support
Inspired by: cdde659563

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-03-23 15:49:32 -04:00
Stéphane Graber
8111478974 container/util: Avoid reflect (and fix go vet)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-03-22 21:58:26 -04:00
Ruben Jenster
cf379f8d34 attach_options: use size_t for lxc_groups_t
Signed-off-by: Ruben Jenster <r.jenster@drachenfels.de>
2021-02-05 13:43:23 +01:00
Ruben Jenster
efb71bea01 Add support for additional groups ids on attach.
Signed-off-by: Ruben Jenster <r.jenster@drachenfels.de>
2021-02-01 15:10:32 +01:00
Thomas Parrott
dd881e35ed container: Adds c.container nil checks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2021-01-15 18:47:06 +00:00
Thomas Parrott
2956fa96d6 container: Set c.container to nil after release
So it can be detected by other functions.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2021-01-15 17:50:59 +00:00
Thomas Parrott
5dd5308fff container: Fixes crash in cgroupItem()
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2020-10-12 12:09:50 +01:00
Thomas Parrott
762f161f64 container: golint
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2020-08-26 15:51:19 +01:00
Thomas Parrott
70331db540 container: Check c.container isn't nil to protect against crash
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2020-08-26 15:51:00 +01:00
Christian Brauner
95c6c82236 container: add SeccompNotifyFdActive()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-08-06 14:54:54 +02:00
Stéphane Graber
d29f22bf97 Merge pull request #139 from brauner/v2
container: implement DevptsFd()
2020-08-05 10:31:13 -04:00
Christian Brauner
0f5387bbd5 container: implement DevptsFd()
which calls into LXC to allocate a new devpts fd for the containers
devpts instance.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-08-05 16:24:07 +02:00
dinesh
029eeefcfa Support backing store options
Signed-off-by: dinesh <dinesh1042@gmail.com>
2020-08-04 17:38:39 +05:30
Christian Brauner
7dc72f0599 container: rework SeccompNotifyFd() api extension
Make it return os.File so callers can simply call defer f.Close().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-05-18 13:15:29 +02:00
Christian Brauner
aa191b81b4 container: rework InitPidFd() api extension
Make it return os.File so callers can simply call defer f.Close().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-05-18 13:12:55 +02:00
Christian Brauner
ff2170fc84 container: add SeccompNotifyFd() api extension
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-05-13 09:08:26 +02:00
Christian Brauner
a6523815bc container: add InitPidFd() api extension
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-05-13 09:08:16 +02:00
S.Çağlar Onur
aadb55d0ae Fix minor typos
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
2019-05-19 18:23:31 -07:00
S.Çağlar Onur
c60d39311a Stop using finalizers
Handling our garbage explicitly is way more simpler and idiomatic
then relying on runtime magic. Finalizers also are not guaranteed to
run so stop using them, instead Container now provides Release()
to call it via defer.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
2018-12-26 21:21:40 -08:00
Stéphane Graber
7230ea9cf0 Fix Go tip behavior change
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-12-05 19:46:03 -05:00
Stéphane Graber
ddfcfecbd8 Fix building with Go tip
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-12-05 19:26:39 -05:00
Stéphane Graber
29a9498cda Don't mask error return values from liblxc
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-09-19 16:09:40 +02:00
s3rj1k
081b7565e2 fix KernelMemoryLimit cgroup item
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2018-06-07 17:59:20 +03:00
Seth Moore
405efdef08 Do not suppress stderr if Execute command exits nonzero
Signed-off-by: Seth Moore <sethdmoore@gmail.com>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-05-26 18:29:07 -04:00
s3rj1k
6ad46b88dc fix incorrect status code from runCommandStatus
runCommandStatus should return correct status codes (use of WEXITSTATUS macro)
as lxc-execute does in https://github.com/lxc/lxc/blob/master/src/lxc/tools/lxc_execute.c#L239

Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
[christian.brauner@ubuntu.com: mirror WEXITSTATUS() correctly]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 17:33:43 +02:00
Christian Brauner
f702d2302e lxc-binding: adapt to changed liblxc console API
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-28 00:01:54 +01:00
Tycho Andersen
a5ec0bd820 add ErrorNum to return the last error from the container
As it stands right now, there is no way to figure out what the exit code of
a container spawned by StartExecute() was. liblxc stores the value in
c->error_num, so let's make that accessible.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2018-01-19 08:45:28 -07:00
Stéphane Graber
8741a7213c Revert "bindings: support set_running_config_item()"
This reverts commit 7db648afb7.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-01-08 17:40:06 -05:00
Adrian Reber
c781b5f701 migrate: add new CRIU feature check support
This adds support to use the newly added MIGRATE_FEATURE_CHECK command
in the migrate() call. With this change LXD can query LXC if CRIU
supports features like dirty memory tracking or userfaultfd based
process migration.

Signed-off-by: Adrian Reber <areber@redhat.com>
2017-12-15 17:04:54 +01:00
Stéphane Graber
1f07259d85 Merge pull request #96 from tych0/fix-execute-check
Fix execute check
2017-12-06 19:16:46 -05:00
Tycho Andersen
6fbff88a5f always create the temp config for Execute
We always need this. So let's create it.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2017-12-06 17:02:45 -07:00
Tycho Andersen
bb940623f8 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@tycho.ws>
2017-12-06 17:02:45 -07:00
Christian Brauner
c8c449179f container: add StartExecute()
This is an API-only version of Execute().

Closes #83.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-11-11 14:59:17 +01:00
Christian Brauner
00e1448836 container: add ConsoleLog() API extension
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-11-09 18:28:43 +01:00
S.Çağlar Onur
e2aed2b57d Fix the locking logic
The original code where we were doing following

func X()  {
    call makesure
	makesure locks
	...work
	makesure unlocks
    lock
    ...work
    unlock
}

was potentially racy as someone else could obtain the lock in between
makesure and mutex.Lock call.

Changes since last attempt:

- Running LXD tests locally ends up with success.

...
==> Deleting all storage pools
Storage pool lxdtest-cjU deleted
==> Checking for locked DB tables
==> Checking for leftover files
==> Checking for leftover DB entries
==> Tearing down directory backend in
/home/caglar/go/src/github.com/lxc/lxd/test/tmp.IQA/cjU

==> Test result: success
...
2017-11-02 23:49:20 -07:00
Christian Brauner
7db648afb7 bindings: support set_running_config_item()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-10-12 17:41:07 +02:00
Stéphane Graber
2c12beeab2 Revert "Fix the locking logic"
This reverts commit c57efc7ce2.

The locking change was causing LXD tests to hang so there's an issue
somewhere with the locks.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2017-10-04 23:12:38 -04:00
S.Çağlar Onur
c57efc7ce2 Fix the locking logic
The original code where we were doing following

func X()  {
    call makesure
        makesure locks
        ...work
        makesure unlocks
    lock
    ...work
    unlock
}

was potentially racy as someone else could obtain the lock in between
makesure and mutex.Lock call.

Now all exported functions are holding the lock throughout their scope.
2017-10-02 22:53:40 -07:00
Stéphane Graber
89b06ca6fa Fix Execute() on LXC 2.1
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2017-09-19 18:37:08 -04:00
Stéphane Graber
47be887744 Templates other than "download" can run unprivileged
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2017-09-17 14:49:59 -07:00
Stéphane Graber
ca597feea3 Merge pull request #86 from caglar10ur/copy
Do not copy the underlying mutex
2017-09-17 11:52:12 -07:00
S.Çağlar Onur
379087f32b Do not copy the underlying mutex
This changes the return type of 3 functions. This should be safe
assuming the expected usage of those functions in the form of;

```
c := lxc.DefinedContainers(lxcpath)
...
```

Should help to #82 as well
2017-09-16 15:27:52 -07:00
S.Çağlar Onur
7b6d52db23 Add missing comments for exported functions 2017-09-16 15:22:16 -07:00
Christian Brauner
f91d67395b liblxc: lxc.network* --> lxc.net*
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-07-11 01:16:27 +02:00
Christian Brauner
77f1e26e3d liblxc: lxc.loglevel --> lxc.log.level
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-07-11 01:16:27 +02:00