| 1 | // Copyright © 2013, 2014, The Go-LXC Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a LGPLv2.1 |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build linux && cgo |
| 6 | // +build linux,cgo |
| 7 | |
| 8 | package main |
| 9 | |
| 10 | import ( |
| 11 | "flag" |
| 12 | "log" |
| 13 | "time" |
| 14 | |
| 15 | "github.com/lxc/go-lxc" |
| 16 | ) |
| 17 | |
| 18 | var ( |
| 19 | lxcpath string |
| 20 | name string |
| 21 | ) |
| 22 | |
| 23 | func init() { |
| 24 | flag.StringVar(&lxcpath, "lxcpath", lxc.DefaultConfigPath(), "Use specified container path") |
| 25 | flag.StringVar(&name, "name", "rubik", "Name of the container") |
| 26 | flag.Parse() |
| 27 | } |
| 28 | |
| 29 | func main() { |
| 30 | c, err := lxc.NewContainer(name, lxcpath) |
| 31 | if err != nil { |
| 32 | log.Fatalf("ERROR: %s\n", err.Error()) |
| 33 | } |
| 34 | defer c.Release() |
| 35 | |
| 36 | if err := c.AddDeviceNode("/dev/network_latency"); err != nil { |
| 37 | log.Fatalf("ERROR: %s\n", err.Error()) |
| 38 | } |
| 39 | |
| 40 | time.Sleep(10000 * time.Millisecond) |
| 41 | |
| 42 | if err := c.RemoveDeviceNode("/dev/network_latency"); err != nil { |
| 43 | log.Fatalf("ERROR: %s\n", err.Error()) |
| 44 | } |
| 45 | } |