Merge pull request #1238 from rneugeba/improv

Infrakit plugin improvements
This commit is contained in:
Justin Cormack 2017-03-01 18:02:25 -08:00 committed by GitHub
commit 41ec05c101
30 changed files with 349 additions and 102 deletions

View File

@ -4,14 +4,10 @@ This is a Hyper/Kit Moby instance plugin for infrakit. The instance
plugin is capable to start/manage several hyperkit instances with with
different configurations and Moby configurations.
The plugin keeps state in a local directory (default `./vms`) where
each instance keeps some state in a sub-directory. The VM state
directory can be specified at the kernel command line using the
`--vm-dir` option.
The plugin also needs to know where the kernel and `initrd` images are
located. The `--vm-lib` command line argument to the plugin specifies
the directory. Inside the VM library directory every kernel/initrd configuration should be stored in a sub-directory. The sub-directory name is used in the instance configuration.
The plugin keeps state in a local directory (default
`.infrakit/hyperkit-vms`) where each instance keeps some state in a
sub-directory. The VM state directory can be specified at the kernel
command line using the `--vm-dir` option.
## Building
@ -24,7 +20,7 @@ make
To play round with the plugin, simply follow the [infrakit tutorial](https://github.com/docker/infrakit/blob/master/docs/tutorial.md) and replace the file instance plugin with:
```
./build/infrakit-instance-hyperkit --vm-lib ./vmlib
./build/infrakit-instance-hyperkit
```
where `./vmlib` contains a sub-directory named `default` with a `vmlinuz64` and `initrd.img` image.

View File

@ -10,25 +10,27 @@ import (
"os/exec"
"path"
"strconv"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/docker/infrakit/pkg/spi/instance"
"github.com/docker/infrakit/pkg/template"
"github.com/docker/infrakit/pkg/types"
)
// NewHyperKitPlugin creates an instance plugin for hyperkit.
func NewHyperKitPlugin(vmLib, vmDir, hyperkit, vpnkitSock string) instance.Plugin {
return &hyperkitPlugin{VMLib: vmLib,
VMDir: vmDir,
func NewHyperKitPlugin(vmDir, hyperkit, vpnkitSock string, thyper, tkern *template.Template) instance.Plugin {
return &hyperkitPlugin{VMDir: vmDir,
HyperKit: hyperkit,
VPNKitSock: vpnkitSock}
VPNKitSock: vpnkitSock,
HyperKitTmpl: thyper,
KernelTmpl: tkern,
}
}
type hyperkitPlugin struct {
// VMLib is the path to a directory where each sub-directory
// contains a vmlinuz and a initrd image
VMLib string
// VMDir is the path to a directory where per VM state is kept
VMDir string
@ -37,6 +39,9 @@ type hyperkitPlugin struct {
// VPNKitSock is the path to the VPNKit Unix domain socket.
VPNKitSock string
HyperKitTmpl *template.Template
KernelTmpl *template.Template
}
const (
@ -62,41 +67,30 @@ func (v hyperkitPlugin) Provision(spec instance.Spec) (*instance.ID, error) {
if properties["Moby"] == nil {
return nil, errors.New("Property 'Moby' must be set")
}
mobyStr, ok := properties["Moby"].(string)
if !ok {
return nil, errors.New("Property 'Moby' must be a string")
}
if properties["CPUs"] == nil {
properties["CPUs"] = 1
}
numCPUs, ok := properties["CPUs"].(int)
if !ok {
return nil, errors.New("Property 'CPUs' must be a integer")
}
if properties["Memory"] == nil {
properties["Memory"] = 512
}
memSz, ok := properties["Memory"].(int)
if !ok {
return nil, errors.New("Property 'Memory' must be a integer")
}
if properties["Disk"] == nil {
properties["Disk"] = 256
}
diskSz, ok := properties["Disk"].(int)
if !ok {
return nil, errors.New("Property 'Disk' must be a integer")
properties["Disk"] = float64(256)
}
instanceDir, err := ioutil.TempDir(v.VMDir, "infrakit-")
if err != nil {
return nil, err
}
id := instance.ID(path.Base(instanceDir))
err = v.execHyperKit(instanceDir, mobyStr, numCPUs, memSz, diskSz)
// Apply parameters
params := map[string]interface{}{
"VMLocation": instanceDir,
"VPNKitSock": v.VPNKitSock,
"Properties": properties,
}
err = v.execHyperKit(params)
if err != nil {
v.Destroy(id)
return nil, err
@ -155,12 +149,12 @@ func (v hyperkitPlugin) Destroy(id instance.ID) error {
p, err := getProcess(instanceDir)
if err != nil {
log.Warningln("Can't find processes: ", err)
return err
}
err = p.Kill()
if err != nil {
log.Warningln("Can't kill processes with pid: ", p.Pid, err)
return err
} else {
err = p.Kill()
if err != nil {
log.Warningln("Can't kill processes with pid: ", p.Pid, err)
return err
}
}
if err := os.RemoveAll(instanceDir); err != nil {
@ -211,10 +205,12 @@ func (v hyperkitPlugin) DescribeInstances(tags map[string]string) ([]instance.De
if allMatched {
var logicalID *instance.LogicalID
id := instance.ID(file.Name())
pidData, err := ioutil.ReadFile(path.Join(instanceDir, hyperkitPid))
if err == nil {
id := instance.LogicalID(pidData)
logicalID = &id
lid := instance.LogicalID(pidData)
logicalID = &lid
} else {
if !os.IsNotExist(err) {
return nil, err
@ -223,17 +219,13 @@ func (v hyperkitPlugin) DescribeInstances(tags map[string]string) ([]instance.De
// Check if process is running
if _, err := getProcess(instanceDir); err != nil {
log.Warningln("Process not running: Instance ", file.Name())
if err := os.RemoveAll(instanceDir); err != nil {
log.Warningln("Can't remove instance dir ", instanceDir, " error ", err)
}
log.Warningln("Process not running: Instance ", id)
v.Destroy(id)
continue
}
descriptions = append(descriptions, instance.Description{
ID: instance.ID(file.Name()),
ID: id,
LogicalID: logicalID,
Tags: instanceTags,
})
@ -243,42 +235,49 @@ func (v hyperkitPlugin) DescribeInstances(tags map[string]string) ([]instance.De
return descriptions, nil
}
func (v hyperkitPlugin) execHyperKit(instanceDir, moby string, cpus, memSz, diskSz int) error {
err := createDisk(instanceDir, diskSz)
const hyperkitArgs = "-A -u -F {{.VMLocation}}/hyperkit.pid " +
"-c {{.Properties.CPUs}} -m {{.Properties.Memory}}M " +
"-s 0:0,hostbridge -s 31,lpc -s 5,virtio-rnd " +
"-s 4,virtio-blk,{{.VMLocation}}/disk.img " +
"-s 2:0,virtio-vpnkit,path={{.VPNKitSock}} " +
"-l com1,autopty={{.VMLocation}}/tty,log={{.VMLocation}}/console-ring"
const hyperkitKernArgs = "kexec," +
"{{.Properties.Moby}}/vmlinuz64," +
"{{.Properties.Moby}}/initrd.img," +
"earlyprintk=serial console=ttyS0 panic=1 vsyscall=emulate page_poison=1 ntp=gateway"
func (v hyperkitPlugin) execHyperKit(params map[string]interface{}) error {
instanceDir := params["VMLocation"].(string)
args, err := v.HyperKitTmpl.Render(params)
if err != nil {
return err
}
kernArgs, err := v.KernelTmpl.Render(params)
if err != nil {
return err
}
id := path.Base(instanceDir)
// Build arguments
c := []string{v.HyperKit}
c = append(c, strings.Split(args, " ")...)
c = append(c, "-f", kernArgs)
c := []string{v.HyperKit, "-A", "-u"}
// Write command line to state
if err := ioutil.WriteFile(path.Join(instanceDir, "cmdline"), []byte(strings.Join(c, " ")), 0666); err != nil {
return err
}
// Pid file
c = append(c, "-F", path.Join(instanceDir, hyperkitPid))
// CPU and Memory
c = append(c, "-c", fmt.Sprintf("%d", cpus))
c = append(c, "-m", fmt.Sprintf("%dM", memSz))
// Devices
c = append(c, "-s", "0:0,hostbridge")
c = append(c, "-s", "31,lpc")
c = append(c, "-s", "5,virtio-rnd")
c = append(c, "-s", fmt.Sprintf("4,virtio-blk,%s", path.Join(instanceDir, "disk.img")))
c = append(c, "-s", fmt.Sprintf("2:0,virtio-vpnkit,path=%s", v.VPNKitSock))
c = append(c, "-l", fmt.Sprintf("com1,autopty=%s,log=%s",
path.Join(instanceDir, "tty"),
path.Join(instanceDir, "console-ring")))
// Kernel command line
// Note, it is important that the kernel is one argv, not multiple
kernStr := fmt.Sprintf("kexec,%s,%s,",
path.Join(v.VMLib, moby, "vmlinuz64"),
path.Join(v.VMLib, moby, "initrd.img"))
kernStr += "earlyprintk=serial console=ttyS0"
kernStr += " panic=1 vsyscall=emulate page_poison=1"
kernStr += " ntp=gateway "
c = append(c, "-f", kernStr)
prop := params["Properties"].(map[string]interface{})
sz, ok := prop["Disk"].(float64)
if !ok {
return fmt.Errorf("Unable to extract Disk Size: %s", prop["Disk"])
}
err = createDisk(instanceDir, int(sz))
if err != nil {
return err
}
cmd := exec.Command(c[0], c[1:]...)
cmd.Env = os.Environ()
@ -304,18 +303,19 @@ func (v hyperkitPlugin) execHyperKit(instanceDir, moby string, cpus, memSz, disk
for {
select {
case stderrl := <-stderrChan:
log.Warningln("HyperKit ", id, " STDERR: ", stderrl)
log.Warningln("HyperKit STDERR: ", stderrl)
case stdoutl := <-stdoutChan:
log.Infoln("HyperKit ", id, " STDOUT: ", stdoutl)
log.Infoln("HyperKit STDOUT: ", stdoutl)
case <-done:
return
}
}
}()
log.Infoln("Starting ", id, ": ", c)
log.Infoln("Starting: ", c)
err = cmd.Start()
return err
}

View File

@ -4,15 +4,20 @@ import (
"encoding/json"
"fmt"
"os"
"os/user"
"path"
"path/filepath"
log "github.com/Sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/docker/infrakit/pkg/cli"
"github.com/docker/infrakit/pkg/discovery"
"github.com/docker/infrakit/pkg/plugin/metadata"
instance_plugin "github.com/docker/infrakit/pkg/rpc/instance"
metadata_plugin "github.com/docker/infrakit/pkg/rpc/metadata"
instance_spi "github.com/docker/infrakit/pkg/spi/instance"
"github.com/spf13/cobra"
"github.com/docker/infrakit/pkg/template"
)
const (
@ -37,28 +42,36 @@ func main() {
Use: os.Args[0],
Short: "HyperKit instance plugin",
}
defaultVMDir, err := os.Getwd()
if err != nil {
log.Error(err)
os.Exit(1)
}
defaultVMDir = path.Join(defaultVMDir, "vms")
homeDir := os.Getenv("HOME")
defaultVPNKitSock = path.Join(homeDir, defaultVPNKitSock)
defaultVMDir := filepath.Join(getHome(), ".infrakit/hyperkit-vms")
defaultVPNKitSock = path.Join(getHome(), defaultVPNKitSock)
name := cmd.Flags().String("name", "instance-hyperkit", "Plugin name to advertise for discovery")
logLevel := cmd.Flags().Int("log", cli.DefaultLogLevel, "Logging level. 0 is least verbose. Max is 5")
vmLib := cmd.Flags().String("vm-lib", "", "Directory with subdirectories of kernels/initrds combinations")
vmDir := cmd.Flags().String("vm-dir", defaultVMDir, "Directory where to store VM state")
hyperkit := cmd.Flags().String("hyperkit", defaultHyperKit, "Path to HyperKit executable")
vpnkitSock := cmd.Flags().String("vpnkit-sock", defaultVPNKitSock, "Path to VPNKit UNIX domain socket")
cmd.RunE = func(c *cobra.Command, args []string) error {
opts := template.Options{
SocketDir: discovery.Dir(),
}
thyper, err := template.NewTemplate("str://"+hyperkitArgs, opts)
if err != nil {
return err
}
tkern, err := template.NewTemplate("str://"+hyperkitKernArgs, opts)
if err != nil {
return err
}
os.MkdirAll(*vmDir, os.ModePerm)
cli.SetLogLevel(*logLevel)
cli.RunPlugin(*name,
instance_plugin.PluginServer(NewHyperKitPlugin(*vmLib, *vmDir, *hyperkit, *vpnkitSock)),
instance_plugin.PluginServer(NewHyperKitPlugin(*vmDir, *hyperkit, *vpnkitSock, thyper, tkern)),
metadata_plugin.PluginServer(metadata.NewPluginFromData(
map[string]interface{}{
"version": Version,
@ -91,3 +104,10 @@ func main() {
os.Exit(1)
}
}
func getHome() string {
if usr, err := user.Current(); err == nil {
return usr.HomeDir
}
return os.Getenv("HOME")
}

View File

@ -7,8 +7,10 @@
"Instance": {
"Plugin": "instance-hyperkit",
"Properties": {
"Moby": "default",
"Note": "Instance properties version 1.0"
"Moby": "./vms/default",
"Disk" : 512,
"CPUs" : 2,
"Memory" : 1024
}
},
"Flavor": {

View File

@ -1,7 +1,7 @@
github.com/Masterminds/sprig 2d2df7bd8bda53b5a55ed04422173cedd50500ea
github.com/Sirupsen/logrus 0208149b40d863d2c1a2f8fe5753096a9cf2cc8b
github.com/aokoli/goutils 9c37978a95bd5c709a15883b6242714ea6709e64
github.com/docker/infrakit 594813c1dc9b1b617cd8d1527c51390c76c0feaa
github.com/docker/infrakit ecc0561f7bd44e832ce7dc07222b913082aeff6e
github.com/gorilla/context 08b5f424b9271eedf6f9f0ce86cb9396ed337a42
github.com/gorilla/mux 599cba5e7b6137d46ddf58fb1765f5d928e69604
github.com/gorilla/rpc 22c016f3df3febe0c1f6727598b6389507e03a18
@ -11,5 +11,5 @@ github.com/satori/go.uuid b061729afc07e77a8aa4fad0a2fd840958f1942a
github.com/spf13/cobra fcd0c5a1df88f5d6784cb4feead962c3f3d0b66c
github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7
golang.org/x/crypto 453249f01cfeb54c3d549ddb75ff152ca243f9d8
golang.org/x/sys 21f2569f6feb83b68a25c98c1b20eca5d4e1e6ae
golang.org/x/sys 76cc09b634294339fa19ec41b5f2a0b3932cea8b
gopkg.in/tylerb/graceful.v1 4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb

View File

@ -1038,6 +1038,7 @@ func Getpgrp() (pid int) {
//sysnb Getpid() (pid int)
//sysnb Getppid() (ppid int)
//sys Getpriority(which int, who int) (prio int, err error)
//sys Getrandom(buf []byte, flags int) (n int, err error)
//sysnb Getrusage(who int, rusage *Rusage) (err error)
//sysnb Getsid(pid int) (sid int, err error)
//sysnb Gettid() (tid int)

View File

@ -437,6 +437,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -437,6 +437,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -422,6 +422,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -451,6 +451,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -427,6 +427,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -426,6 +426,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
ICANON = 0x2
ICMPV6_FILTER = 0x1

View File

@ -426,6 +426,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
ICANON = 0x2
ICMPV6_FILTER = 0x1

View File

@ -466,6 +466,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -456,6 +456,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x4000
IBSHIFT = 0x10
ICANON = 0x100

View File

@ -449,6 +449,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x4000
IBSHIFT = 0x10
ICANON = 0x100

View File

@ -462,6 +462,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x2
F_WRLCK = 0x1
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -470,6 +470,8 @@ const (
F_ULOCK = 0x0
F_UNLCK = 0x3
F_WRLCK = 0x2
GRND_NONBLOCK = 0x1
GRND_RANDOM = 0x2
HUPCL = 0x400
IBSHIFT = 0x10
ICANON = 0x2

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {

View File

@ -1,7 +1,7 @@
// mksyscall.pl syscall_linux.go syscall_linux_sparc64.go
// mksyscall.pl -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// +build
// +build linux,sparc64
package unix
@ -543,6 +543,23 @@ func Getpriority(which int, who int) (prio int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {