mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
encoding/json walked every payload on every call. ZAP reads a field at a
constant offset out of the buffer that arrived, and //tools/zap has
already stated those offsets for every payload, so the transport now asks
the payload for its own bytes and the parse step is gone.
The envelope collapses with it. clientCall and serverCall existed only
because JSON needed one type to hold an any and another to hold a
RawMessage; bytes are bytes, so one Call serves both ends. Framing comes
from the ZAP header, which declares its own length.
A payload that is nothing -- the *struct{} a method takes when it has no
argument or no result -- carries nothing. Anything else without a layout
fails the call naming the type, so a payload that would have arrived
silently empty does not arrive at all.
The methods that took a bare string or returned a bare int now take and
return named payloads, because a scalar has no layout to state and the
rest of the API was already shaped this way.
Co-authored-by: Hanzo Dev <[email protected]>
2597 lines
69 KiB
Go
2597 lines
69 KiB
Go
// Copyright 2026 The gVisor Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// Code generated by zip; DO NOT EDIT.
|
|
|
|
package control
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
zap "github.com/zap-proto/go"
|
|
log "gvisor.dev/gvisor/pkg/log"
|
|
prometheus "gvisor.dev/gvisor/pkg/prometheus"
|
|
kernel "gvisor.dev/gvisor/pkg/sentry/kernel"
|
|
auth "gvisor.dev/gvisor/pkg/sentry/kernel/auth"
|
|
limits "gvisor.dev/gvisor/pkg/sentry/limits"
|
|
)
|
|
|
|
// ---- BlockProfileOpts --------------------------------------------------
|
|
|
|
const (
|
|
blockProfileOptsFilePayloadAt = 0
|
|
blockProfileOptsDurationAt = 8
|
|
blockProfileOptsRateAt = 16
|
|
blockProfileOptsSize = 24
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*BlockProfileOpts)(nil)
|
|
|
|
// MarshalZAP writes BlockProfileOpts from constant offsets.
|
|
func (x *BlockProfileOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(blockProfileOptsSize + 256)
|
|
ob := b.StartObject(blockProfileOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(blockProfileOptsFilePayloadAt, innerFilePayload)
|
|
ob.SetInt64(blockProfileOptsDurationAt, int64(x.Duration))
|
|
ob.SetInt64(blockProfileOptsRateAt, int64(x.Rate))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads BlockProfileOpts out of the buffer that arrived.
|
|
func (x *BlockProfileOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("BlockProfileOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(blockProfileOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Duration = time.Duration(o.Int64(blockProfileOptsDurationAt))
|
|
x.Rate = int(o.Int64(blockProfileOptsRateAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- CPUProfileOpts ----------------------------------------------------
|
|
|
|
const (
|
|
cPUProfileOptsFilePayloadAt = 0
|
|
cPUProfileOptsDurationAt = 8
|
|
cPUProfileOptsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CPUProfileOpts)(nil)
|
|
|
|
// MarshalZAP writes CPUProfileOpts from constant offsets.
|
|
func (x *CPUProfileOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cPUProfileOptsSize + 256)
|
|
ob := b.StartObject(cPUProfileOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(cPUProfileOptsFilePayloadAt, innerFilePayload)
|
|
ob.SetInt64(cPUProfileOptsDurationAt, int64(x.Duration))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CPUProfileOpts out of the buffer that arrived.
|
|
func (x *CPUProfileOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CPUProfileOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(cPUProfileOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Duration = time.Duration(o.Int64(cPUProfileOptsDurationAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- CatOpts -----------------------------------------------------------
|
|
|
|
const (
|
|
catOptsFilesAt = 0
|
|
catOptsFilePayloadAt = 8
|
|
catOptsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CatOpts)(nil)
|
|
|
|
// MarshalZAP writes CatOpts from constant offsets.
|
|
func (x *CatOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(catOptsSize + 256)
|
|
filesAt, filesN := 0, len(x.Files)
|
|
if filesN > 0 {
|
|
var blob []byte
|
|
for i := range x.Files {
|
|
enc := []byte(x.Files[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
filesAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(catOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(catOptsFilePayloadAt, innerFilePayload)
|
|
if filesN > 0 {
|
|
ob.SetList(catOptsFilesAt, filesAt, filesN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CatOpts out of the buffer that arrived.
|
|
func (x *CatOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CatOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if l := o.List(catOptsFilesAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.Files = rows
|
|
}
|
|
if raw := o.Bytes(catOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- CgroupControlFile -------------------------------------------------
|
|
|
|
const (
|
|
cgroupControlFileControllerAt = 0
|
|
cgroupControlFilePathAt = 8
|
|
cgroupControlFileNameAt = 16
|
|
cgroupControlFileSize = 24
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CgroupControlFile)(nil)
|
|
|
|
// MarshalZAP writes CgroupControlFile from constant offsets.
|
|
func (x *CgroupControlFile) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cgroupControlFileSize + 256)
|
|
ob := b.StartObject(cgroupControlFileSize)
|
|
ob.SetText(cgroupControlFileControllerAt, string(x.Controller))
|
|
ob.SetText(cgroupControlFilePathAt, string(x.Path))
|
|
ob.SetText(cgroupControlFileNameAt, string(x.Name))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CgroupControlFile out of the buffer that arrived.
|
|
func (x *CgroupControlFile) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CgroupControlFile: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Controller = string(strings.Clone(o.Text(cgroupControlFileControllerAt)))
|
|
x.Path = string(strings.Clone(o.Text(cgroupControlFilePathAt)))
|
|
x.Name = string(strings.Clone(o.Text(cgroupControlFileNameAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- CgroupsReadArg ----------------------------------------------------
|
|
|
|
const (
|
|
cgroupsReadArgFileAt = 0
|
|
cgroupsReadArgSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CgroupsReadArg)(nil)
|
|
|
|
// MarshalZAP writes CgroupsReadArg from constant offsets.
|
|
func (x *CgroupsReadArg) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cgroupsReadArgSize + 256)
|
|
ob := b.StartObject(cgroupsReadArgSize)
|
|
innerFile, err := x.File.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(cgroupsReadArgFileAt, innerFile)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CgroupsReadArg out of the buffer that arrived.
|
|
func (x *CgroupsReadArg) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CgroupsReadArg: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(cgroupsReadArgFileAt); len(raw) > 0 {
|
|
if err := x.File.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- CgroupsReadArgs ---------------------------------------------------
|
|
|
|
const (
|
|
cgroupsReadArgsArgsAt = 0
|
|
cgroupsReadArgsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CgroupsReadArgs)(nil)
|
|
|
|
// MarshalZAP writes CgroupsReadArgs from constant offsets.
|
|
func (x *CgroupsReadArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cgroupsReadArgsSize + 256)
|
|
argsAt, argsN := 0, len(x.Args)
|
|
if argsN > 0 {
|
|
var blob []byte
|
|
for i := range x.Args {
|
|
enc, err := x.Args[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
argsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(cgroupsReadArgsSize)
|
|
if argsN > 0 {
|
|
ob.SetList(cgroupsReadArgsArgsAt, argsAt, argsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CgroupsReadArgs out of the buffer that arrived.
|
|
func (x *CgroupsReadArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CgroupsReadArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if l := o.List(cgroupsReadArgsArgsAt); l.Len() > 0 {
|
|
rows := make([]CgroupsReadArg, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Args = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- CgroupsResult -----------------------------------------------------
|
|
|
|
const (
|
|
cgroupsResultDataAt = 0
|
|
cgroupsResultIsErrorAt = 8
|
|
cgroupsResultSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CgroupsResult)(nil)
|
|
|
|
// MarshalZAP writes CgroupsResult from constant offsets.
|
|
func (x *CgroupsResult) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cgroupsResultSize + 256)
|
|
ob := b.StartObject(cgroupsResultSize)
|
|
ob.SetText(cgroupsResultDataAt, string(x.Data))
|
|
ob.SetBool(cgroupsResultIsErrorAt, bool(x.IsError))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CgroupsResult out of the buffer that arrived.
|
|
func (x *CgroupsResult) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CgroupsResult: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Data = string(strings.Clone(o.Text(cgroupsResultDataAt)))
|
|
x.IsError = bool(o.Bool(cgroupsResultIsErrorAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- CgroupsResults ----------------------------------------------------
|
|
|
|
const (
|
|
cgroupsResultsResultsAt = 0
|
|
cgroupsResultsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CgroupsResults)(nil)
|
|
|
|
// MarshalZAP writes CgroupsResults from constant offsets.
|
|
func (x *CgroupsResults) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cgroupsResultsSize + 256)
|
|
resultsAt, resultsN := 0, len(x.Results)
|
|
if resultsN > 0 {
|
|
var blob []byte
|
|
for i := range x.Results {
|
|
enc, err := x.Results[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
resultsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(cgroupsResultsSize)
|
|
if resultsN > 0 {
|
|
ob.SetList(cgroupsResultsResultsAt, resultsAt, resultsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CgroupsResults out of the buffer that arrived.
|
|
func (x *CgroupsResults) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CgroupsResults: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if l := o.List(cgroupsResultsResultsAt); l.Len() > 0 {
|
|
rows := make([]CgroupsResult, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Results = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- CgroupsWriteArg ---------------------------------------------------
|
|
|
|
const (
|
|
cgroupsWriteArgFileAt = 0
|
|
cgroupsWriteArgValueAt = 8
|
|
cgroupsWriteArgSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CgroupsWriteArg)(nil)
|
|
|
|
// MarshalZAP writes CgroupsWriteArg from constant offsets.
|
|
func (x *CgroupsWriteArg) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cgroupsWriteArgSize + 256)
|
|
ob := b.StartObject(cgroupsWriteArgSize)
|
|
innerFile, err := x.File.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(cgroupsWriteArgFileAt, innerFile)
|
|
ob.SetText(cgroupsWriteArgValueAt, string(x.Value))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CgroupsWriteArg out of the buffer that arrived.
|
|
func (x *CgroupsWriteArg) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CgroupsWriteArg: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(cgroupsWriteArgFileAt); len(raw) > 0 {
|
|
if err := x.File.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Value = string(strings.Clone(o.Text(cgroupsWriteArgValueAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- CgroupsWriteArgs --------------------------------------------------
|
|
|
|
const (
|
|
cgroupsWriteArgsArgsAt = 0
|
|
cgroupsWriteArgsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*CgroupsWriteArgs)(nil)
|
|
|
|
// MarshalZAP writes CgroupsWriteArgs from constant offsets.
|
|
func (x *CgroupsWriteArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(cgroupsWriteArgsSize + 256)
|
|
argsAt, argsN := 0, len(x.Args)
|
|
if argsN > 0 {
|
|
var blob []byte
|
|
for i := range x.Args {
|
|
enc, err := x.Args[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
argsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(cgroupsWriteArgsSize)
|
|
if argsN > 0 {
|
|
ob.SetList(cgroupsWriteArgsArgsAt, argsAt, argsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads CgroupsWriteArgs out of the buffer that arrived.
|
|
func (x *CgroupsWriteArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("CgroupsWriteArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if l := o.List(cgroupsWriteArgsArgsAt); l.Len() > 0 {
|
|
rows := make([]CgroupsWriteArg, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Args = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- ContainerArgs -----------------------------------------------------
|
|
|
|
const (
|
|
containerArgsContainerIDAt = 0
|
|
containerArgsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*ContainerArgs)(nil)
|
|
|
|
// MarshalZAP writes ContainerArgs from constant offsets.
|
|
func (x *ContainerArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(containerArgsSize + 256)
|
|
ob := b.StartObject(containerArgsSize)
|
|
ob.SetText(containerArgsContainerIDAt, string(x.ContainerID))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads ContainerArgs out of the buffer that arrived.
|
|
func (x *ContainerArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("ContainerArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.ContainerID = string(strings.Clone(o.Text(containerArgsContainerIDAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- Controller --------------------------------------------------------
|
|
|
|
const (
|
|
controllerNameAt = 0
|
|
controllerPathAt = 8
|
|
controllerSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Controller)(nil)
|
|
|
|
// MarshalZAP writes Controller from constant offsets.
|
|
func (x *Controller) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(controllerSize + 256)
|
|
ob := b.StartObject(controllerSize)
|
|
ob.SetText(controllerNameAt, string(x.Name))
|
|
ob.SetText(controllerPathAt, string(x.Path))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Controller out of the buffer that arrived.
|
|
func (x *Controller) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Controller: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Name = kernel.CgroupControllerType(strings.Clone(o.Text(controllerNameAt)))
|
|
x.Path = string(strings.Clone(o.Text(controllerPathAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- EventsOpts --------------------------------------------------------
|
|
|
|
const (
|
|
eventsOptsFilePayloadAt = 0
|
|
eventsOptsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*EventsOpts)(nil)
|
|
|
|
// MarshalZAP writes EventsOpts from constant offsets.
|
|
func (x *EventsOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(eventsOptsSize + 256)
|
|
ob := b.StartObject(eventsOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(eventsOptsFilePayloadAt, innerFilePayload)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads EventsOpts out of the buffer that arrived.
|
|
func (x *EventsOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("EventsOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(eventsOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- ExecArgs ----------------------------------------------------------
|
|
|
|
const (
|
|
execArgsFilenameAt = 0
|
|
execArgsArgvAt = 8
|
|
execArgsEnvvAt = 16
|
|
execArgsWorkingDirectoryAt = 24
|
|
execArgsKUIDAt = 32
|
|
execArgsKGIDAt = 36
|
|
execArgsExtraKGIDsAt = 40
|
|
execArgsNoNewPrivilegesAt = 48
|
|
execArgsCapabilitiesAt = 56
|
|
execArgsStdioIsPtyAt = 64
|
|
execArgsSupportTTYsAt = 65
|
|
execArgsFilePayloadAt = 72
|
|
execArgsContainerIDAt = 80
|
|
execArgsSize = 88
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*ExecArgs)(nil)
|
|
|
|
// MarshalZAP writes ExecArgs from constant offsets.
|
|
func (x *ExecArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(execArgsSize + 256)
|
|
argvAt, argvN := 0, len(x.Argv)
|
|
if argvN > 0 {
|
|
var blob []byte
|
|
for i := range x.Argv {
|
|
enc := []byte(x.Argv[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
argvAt = b.WriteBytes(blob)
|
|
}
|
|
envvAt, envvN := 0, len(x.Envv)
|
|
if envvN > 0 {
|
|
var blob []byte
|
|
for i := range x.Envv {
|
|
enc := []byte(x.Envv[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
envvAt = b.WriteBytes(blob)
|
|
}
|
|
extraKGIDsAt, extraKGIDsN := 0, len(x.ExtraKGIDs)
|
|
if extraKGIDsN > 0 {
|
|
var blob []byte
|
|
for i := range x.ExtraKGIDs {
|
|
var full [8]byte
|
|
binary.LittleEndian.PutUint64(full[:], uint64(x.ExtraKGIDs[i]))
|
|
enc := full[:4]
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
extraKGIDsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(execArgsSize)
|
|
ob.SetText(execArgsFilenameAt, string(x.Filename))
|
|
ob.SetText(execArgsWorkingDirectoryAt, string(x.WorkingDirectory))
|
|
ob.SetUint32(execArgsKUIDAt, uint32(x.KUID))
|
|
ob.SetUint32(execArgsKGIDAt, uint32(x.KGID))
|
|
ob.SetBool(execArgsNoNewPrivilegesAt, bool(x.NoNewPrivileges))
|
|
if x.Capabilities != nil {
|
|
innerCapabilities, err := x.Capabilities.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(execArgsCapabilitiesAt, innerCapabilities)
|
|
}
|
|
ob.SetBool(execArgsStdioIsPtyAt, bool(x.StdioIsPty))
|
|
ob.SetBool(execArgsSupportTTYsAt, bool(x.SupportTTYs))
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(execArgsFilePayloadAt, innerFilePayload)
|
|
ob.SetText(execArgsContainerIDAt, string(x.ContainerID))
|
|
if argvN > 0 {
|
|
ob.SetList(execArgsArgvAt, argvAt, argvN)
|
|
}
|
|
if envvN > 0 {
|
|
ob.SetList(execArgsEnvvAt, envvAt, envvN)
|
|
}
|
|
if extraKGIDsN > 0 {
|
|
ob.SetList(execArgsExtraKGIDsAt, extraKGIDsAt, extraKGIDsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads ExecArgs out of the buffer that arrived.
|
|
func (x *ExecArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("ExecArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Filename = string(strings.Clone(o.Text(execArgsFilenameAt)))
|
|
if l := o.List(execArgsArgvAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.Argv = rows
|
|
}
|
|
if l := o.List(execArgsEnvvAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.Envv = rows
|
|
}
|
|
x.WorkingDirectory = string(strings.Clone(o.Text(execArgsWorkingDirectoryAt)))
|
|
x.KUID = auth.KUID(o.Uint32(execArgsKUIDAt))
|
|
x.KGID = auth.KGID(o.Uint32(execArgsKGIDAt))
|
|
if l := o.List(execArgsExtraKGIDsAt); l.Len() > 0 {
|
|
rows := make([]auth.KGID, l.Len())
|
|
for i := range rows {
|
|
var full [8]byte
|
|
copy(full[:], l.BytesAt(i))
|
|
rows[i] = auth.KGID(binary.LittleEndian.Uint64(full[:]))
|
|
}
|
|
x.ExtraKGIDs = rows
|
|
}
|
|
x.NoNewPrivileges = bool(o.Bool(execArgsNoNewPrivilegesAt))
|
|
if raw := o.Bytes(execArgsCapabilitiesAt); len(raw) > 0 {
|
|
var v auth.TaskCapabilities
|
|
if err := v.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
x.Capabilities = &v
|
|
}
|
|
x.StdioIsPty = bool(o.Bool(execArgsStdioIsPtyAt))
|
|
x.SupportTTYs = bool(o.Bool(execArgsSupportTTYsAt))
|
|
if raw := o.Bytes(execArgsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.ContainerID = string(strings.Clone(o.Text(execArgsContainerIDAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- ExitStatus --------------------------------------------------------
|
|
|
|
const (
|
|
exitStatusStatusAt = 0
|
|
exitStatusSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*ExitStatus)(nil)
|
|
|
|
// MarshalZAP writes ExitStatus from constant offsets.
|
|
func (x *ExitStatus) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(exitStatusSize + 256)
|
|
ob := b.StartObject(exitStatusSize)
|
|
ob.SetUint32(exitStatusStatusAt, uint32(x.Status))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads ExitStatus out of the buffer that arrived.
|
|
func (x *ExitStatus) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("ExitStatus: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Status = uint32(o.Uint32(exitStatusStatusAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- FilePayload -------------------------------------------------------
|
|
|
|
const (
|
|
filePayloadFilePayloadAt = 0
|
|
filePayloadGuestFDsAt = 8
|
|
filePayloadSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*FilePayload)(nil)
|
|
|
|
// MarshalZAP writes FilePayload from constant offsets.
|
|
func (x *FilePayload) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(filePayloadSize + 256)
|
|
guestFDsAt, guestFDsN := 0, len(x.GuestFDs)
|
|
if guestFDsN > 0 {
|
|
var blob []byte
|
|
for i := range x.GuestFDs {
|
|
var full [8]byte
|
|
binary.LittleEndian.PutUint64(full[:], uint64(x.GuestFDs[i]))
|
|
enc := full[:8]
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
guestFDsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(filePayloadSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(filePayloadFilePayloadAt, innerFilePayload)
|
|
if guestFDsN > 0 {
|
|
ob.SetList(filePayloadGuestFDsAt, guestFDsAt, guestFDsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads FilePayload out of the buffer that arrived.
|
|
func (x *FilePayload) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("FilePayload: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(filePayloadFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if l := o.List(filePayloadGuestFDsAt); l.Len() > 0 {
|
|
rows := make([]int, l.Len())
|
|
for i := range rows {
|
|
var full [8]byte
|
|
copy(full[:], l.BytesAt(i))
|
|
rows[i] = int(int64(binary.LittleEndian.Uint64(full[:])<<0) >> 0)
|
|
}
|
|
x.GuestFDs = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- GetRegisteredMetricsOpts ------------------------------------------
|
|
|
|
const (
|
|
getRegisteredMetricsOptsSize = 0
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GetRegisteredMetricsOpts)(nil)
|
|
|
|
// MarshalZAP writes GetRegisteredMetricsOpts from constant offsets.
|
|
func (x *GetRegisteredMetricsOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(getRegisteredMetricsOptsSize + 256)
|
|
ob := b.StartObject(getRegisteredMetricsOptsSize)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GetRegisteredMetricsOpts out of the buffer that arrived.
|
|
func (x *GetRegisteredMetricsOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GetRegisteredMetricsOpts: %w", err)
|
|
}
|
|
_ = m
|
|
return nil
|
|
}
|
|
|
|
// ---- GoroutineProfileOpts ----------------------------------------------
|
|
|
|
const (
|
|
goroutineProfileOptsFilePayloadAt = 0
|
|
goroutineProfileOptsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*GoroutineProfileOpts)(nil)
|
|
|
|
// MarshalZAP writes GoroutineProfileOpts from constant offsets.
|
|
func (x *GoroutineProfileOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(goroutineProfileOptsSize + 256)
|
|
ob := b.StartObject(goroutineProfileOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(goroutineProfileOptsFilePayloadAt, innerFilePayload)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads GoroutineProfileOpts out of the buffer that arrived.
|
|
func (x *GoroutineProfileOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("GoroutineProfileOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(goroutineProfileOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- HeapProfileOpts ---------------------------------------------------
|
|
|
|
const (
|
|
heapProfileOptsFilePayloadAt = 0
|
|
heapProfileOptsDelayAt = 8
|
|
heapProfileOptsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*HeapProfileOpts)(nil)
|
|
|
|
// MarshalZAP writes HeapProfileOpts from constant offsets.
|
|
func (x *HeapProfileOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(heapProfileOptsSize + 256)
|
|
ob := b.StartObject(heapProfileOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(heapProfileOptsFilePayloadAt, innerFilePayload)
|
|
ob.SetInt64(heapProfileOptsDelayAt, int64(x.Delay))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads HeapProfileOpts out of the buffer that arrived.
|
|
func (x *HeapProfileOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("HeapProfileOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(heapProfileOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Delay = time.Duration(o.Int64(heapProfileOptsDelayAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- LoggingArgs -------------------------------------------------------
|
|
|
|
const (
|
|
loggingArgsSetLevelAt = 0
|
|
loggingArgsLevelAt = 4
|
|
loggingArgsSetLogPacketsAt = 8
|
|
loggingArgsLogPacketsAt = 9
|
|
loggingArgsSetStraceAt = 10
|
|
loggingArgsEnableStraceAt = 11
|
|
loggingArgsStraceAllowlistAt = 16
|
|
loggingArgsSetEventStraceAt = 24
|
|
loggingArgsStraceEventAllowlistAt = 32
|
|
loggingArgsSize = 40
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*LoggingArgs)(nil)
|
|
|
|
// MarshalZAP writes LoggingArgs from constant offsets.
|
|
func (x *LoggingArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(loggingArgsSize + 256)
|
|
straceAllowlistAt, straceAllowlistN := 0, len(x.StraceAllowlist)
|
|
if straceAllowlistN > 0 {
|
|
var blob []byte
|
|
for i := range x.StraceAllowlist {
|
|
enc := []byte(x.StraceAllowlist[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
straceAllowlistAt = b.WriteBytes(blob)
|
|
}
|
|
straceEventAllowlistAt, straceEventAllowlistN := 0, len(x.StraceEventAllowlist)
|
|
if straceEventAllowlistN > 0 {
|
|
var blob []byte
|
|
for i := range x.StraceEventAllowlist {
|
|
enc := []byte(x.StraceEventAllowlist[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
straceEventAllowlistAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(loggingArgsSize)
|
|
ob.SetBool(loggingArgsSetLevelAt, bool(x.SetLevel))
|
|
ob.SetUint32(loggingArgsLevelAt, uint32(x.Level))
|
|
ob.SetBool(loggingArgsSetLogPacketsAt, bool(x.SetLogPackets))
|
|
ob.SetBool(loggingArgsLogPacketsAt, bool(x.LogPackets))
|
|
ob.SetBool(loggingArgsSetStraceAt, bool(x.SetStrace))
|
|
ob.SetBool(loggingArgsEnableStraceAt, bool(x.EnableStrace))
|
|
ob.SetBool(loggingArgsSetEventStraceAt, bool(x.SetEventStrace))
|
|
if straceAllowlistN > 0 {
|
|
ob.SetList(loggingArgsStraceAllowlistAt, straceAllowlistAt, straceAllowlistN)
|
|
}
|
|
if straceEventAllowlistN > 0 {
|
|
ob.SetList(loggingArgsStraceEventAllowlistAt, straceEventAllowlistAt, straceEventAllowlistN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads LoggingArgs out of the buffer that arrived.
|
|
func (x *LoggingArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("LoggingArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.SetLevel = bool(o.Bool(loggingArgsSetLevelAt))
|
|
x.Level = log.Level(o.Uint32(loggingArgsLevelAt))
|
|
x.SetLogPackets = bool(o.Bool(loggingArgsSetLogPacketsAt))
|
|
x.LogPackets = bool(o.Bool(loggingArgsLogPacketsAt))
|
|
x.SetStrace = bool(o.Bool(loggingArgsSetStraceAt))
|
|
x.EnableStrace = bool(o.Bool(loggingArgsEnableStraceAt))
|
|
if l := o.List(loggingArgsStraceAllowlistAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.StraceAllowlist = rows
|
|
}
|
|
x.SetEventStrace = bool(o.Bool(loggingArgsSetEventStraceAt))
|
|
if l := o.List(loggingArgsStraceEventAllowlistAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.StraceEventAllowlist = rows
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- MemoryUsage -------------------------------------------------------
|
|
|
|
const (
|
|
memoryUsageUnknownAt = 0
|
|
memoryUsageSystemAt = 8
|
|
memoryUsageAnonymousAt = 16
|
|
memoryUsagePageCacheAt = 24
|
|
memoryUsageMappedAt = 32
|
|
memoryUsageTmpfsAt = 40
|
|
memoryUsageRamdiskfsAt = 48
|
|
memoryUsageTotalAt = 56
|
|
memoryUsageSize = 64
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MemoryUsage)(nil)
|
|
|
|
// MarshalZAP writes MemoryUsage from constant offsets.
|
|
func (x *MemoryUsage) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(memoryUsageSize + 256)
|
|
ob := b.StartObject(memoryUsageSize)
|
|
ob.SetUint64(memoryUsageUnknownAt, uint64(x.Unknown))
|
|
ob.SetUint64(memoryUsageSystemAt, uint64(x.System))
|
|
ob.SetUint64(memoryUsageAnonymousAt, uint64(x.Anonymous))
|
|
ob.SetUint64(memoryUsagePageCacheAt, uint64(x.PageCache))
|
|
ob.SetUint64(memoryUsageMappedAt, uint64(x.Mapped))
|
|
ob.SetUint64(memoryUsageTmpfsAt, uint64(x.Tmpfs))
|
|
ob.SetUint64(memoryUsageRamdiskfsAt, uint64(x.Ramdiskfs))
|
|
ob.SetUint64(memoryUsageTotalAt, uint64(x.Total))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MemoryUsage out of the buffer that arrived.
|
|
func (x *MemoryUsage) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MemoryUsage: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Unknown = uint64(o.Uint64(memoryUsageUnknownAt))
|
|
x.System = uint64(o.Uint64(memoryUsageSystemAt))
|
|
x.Anonymous = uint64(o.Uint64(memoryUsageAnonymousAt))
|
|
x.PageCache = uint64(o.Uint64(memoryUsagePageCacheAt))
|
|
x.Mapped = uint64(o.Uint64(memoryUsageMappedAt))
|
|
x.Tmpfs = uint64(o.Uint64(memoryUsageTmpfsAt))
|
|
x.Ramdiskfs = uint64(o.Uint64(memoryUsageRamdiskfsAt))
|
|
x.Total = uint64(o.Uint64(memoryUsageTotalAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- MemoryUsageFile ---------------------------------------------------
|
|
|
|
const (
|
|
memoryUsageFileFilePayloadAt = 0
|
|
memoryUsageFileSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MemoryUsageFile)(nil)
|
|
|
|
// MarshalZAP writes MemoryUsageFile from constant offsets.
|
|
func (x *MemoryUsageFile) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(memoryUsageFileSize + 256)
|
|
ob := b.StartObject(memoryUsageFileSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(memoryUsageFileFilePayloadAt, innerFilePayload)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MemoryUsageFile out of the buffer that arrived.
|
|
func (x *MemoryUsageFile) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MemoryUsageFile: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(memoryUsageFileFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- MemoryUsageFileOpts -----------------------------------------------
|
|
|
|
const (
|
|
memoryUsageFileOptsVersionAt = 0
|
|
memoryUsageFileOptsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MemoryUsageFileOpts)(nil)
|
|
|
|
// MarshalZAP writes MemoryUsageFileOpts from constant offsets.
|
|
func (x *MemoryUsageFileOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(memoryUsageFileOptsSize + 256)
|
|
ob := b.StartObject(memoryUsageFileOptsSize)
|
|
ob.SetUint64(memoryUsageFileOptsVersionAt, uint64(x.Version))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MemoryUsageFileOpts out of the buffer that arrived.
|
|
func (x *MemoryUsageFileOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MemoryUsageFileOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Version = uint64(o.Uint64(memoryUsageFileOptsVersionAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- MemoryUsageOpts ---------------------------------------------------
|
|
|
|
const (
|
|
memoryUsageOptsFullAt = 0
|
|
memoryUsageOptsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MemoryUsageOpts)(nil)
|
|
|
|
// MarshalZAP writes MemoryUsageOpts from constant offsets.
|
|
func (x *MemoryUsageOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(memoryUsageOptsSize + 256)
|
|
ob := b.StartObject(memoryUsageOptsSize)
|
|
ob.SetBool(memoryUsageOptsFullAt, bool(x.Full))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MemoryUsageOpts out of the buffer that arrived.
|
|
func (x *MemoryUsageOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MemoryUsageOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Full = bool(o.Bool(memoryUsageOptsFullAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- MetricsExportData -------------------------------------------------
|
|
|
|
const (
|
|
metricsExportDataSnapshotAt = 0
|
|
metricsExportDataSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MetricsExportData)(nil)
|
|
|
|
// MarshalZAP writes MetricsExportData from constant offsets.
|
|
func (x *MetricsExportData) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(metricsExportDataSize + 256)
|
|
ob := b.StartObject(metricsExportDataSize)
|
|
if x.Snapshot != nil {
|
|
innerSnapshot, err := x.Snapshot.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(metricsExportDataSnapshotAt, innerSnapshot)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MetricsExportData out of the buffer that arrived.
|
|
func (x *MetricsExportData) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MetricsExportData: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(metricsExportDataSnapshotAt); len(raw) > 0 {
|
|
var v prometheus.Snapshot
|
|
if err := v.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
x.Snapshot = &v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- MetricsExportOpts -------------------------------------------------
|
|
|
|
const (
|
|
metricsExportOptsOnlyMetricsAt = 0
|
|
metricsExportOptsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MetricsExportOpts)(nil)
|
|
|
|
// MarshalZAP writes MetricsExportOpts from constant offsets.
|
|
func (x *MetricsExportOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(metricsExportOptsSize + 256)
|
|
ob := b.StartObject(metricsExportOptsSize)
|
|
ob.SetText(metricsExportOptsOnlyMetricsAt, string(x.OnlyMetrics))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MetricsExportOpts out of the buffer that arrived.
|
|
func (x *MetricsExportOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MetricsExportOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.OnlyMetrics = string(strings.Clone(o.Text(metricsExportOptsOnlyMetricsAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- MetricsRegistrationResponse ---------------------------------------
|
|
|
|
const (
|
|
metricsRegistrationResponseRegistrationAt = 0
|
|
metricsRegistrationResponseSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MetricsRegistrationResponse)(nil)
|
|
|
|
// MarshalZAP writes MetricsRegistrationResponse from constant offsets.
|
|
func (x *MetricsRegistrationResponse) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(metricsRegistrationResponseSize + 256)
|
|
ob := b.StartObject(metricsRegistrationResponseSize)
|
|
ob.SetBytes(metricsRegistrationResponseRegistrationAt, []byte(x.Registration))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MetricsRegistrationResponse out of the buffer that arrived.
|
|
func (x *MetricsRegistrationResponse) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MetricsRegistrationResponse: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Registration = []uint8(append([]byte(nil), o.Bytes(metricsRegistrationResponseRegistrationAt)...))
|
|
return nil
|
|
}
|
|
|
|
// ---- MountOpts ---------------------------------------------------------
|
|
|
|
const (
|
|
mountOptsContainerIDAt = 0
|
|
mountOptsSourceAt = 8
|
|
mountOptsTargetAt = 16
|
|
mountOptsFSTypeAt = 24
|
|
mountOptsFlagsAt = 32
|
|
mountOptsDataAt = 40
|
|
mountOptsFilePayloadAt = 48
|
|
mountOptsSize = 56
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MountOpts)(nil)
|
|
|
|
// MarshalZAP writes MountOpts from constant offsets.
|
|
func (x *MountOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(mountOptsSize + 256)
|
|
ob := b.StartObject(mountOptsSize)
|
|
ob.SetText(mountOptsContainerIDAt, string(x.ContainerID))
|
|
ob.SetText(mountOptsSourceAt, string(x.Source))
|
|
ob.SetText(mountOptsTargetAt, string(x.Target))
|
|
ob.SetText(mountOptsFSTypeAt, string(x.FSType))
|
|
ob.SetUint64(mountOptsFlagsAt, uint64(x.Flags))
|
|
ob.SetText(mountOptsDataAt, string(x.Data))
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(mountOptsFilePayloadAt, innerFilePayload)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MountOpts out of the buffer that arrived.
|
|
func (x *MountOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MountOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.ContainerID = string(strings.Clone(o.Text(mountOptsContainerIDAt)))
|
|
x.Source = string(strings.Clone(o.Text(mountOptsSourceAt)))
|
|
x.Target = string(strings.Clone(o.Text(mountOptsTargetAt)))
|
|
x.FSType = string(strings.Clone(o.Text(mountOptsFSTypeAt)))
|
|
x.Flags = uint64(o.Uint64(mountOptsFlagsAt))
|
|
x.Data = string(strings.Clone(o.Text(mountOptsDataAt)))
|
|
if raw := o.Bytes(mountOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- MutexProfileOpts --------------------------------------------------
|
|
|
|
const (
|
|
mutexProfileOptsFilePayloadAt = 0
|
|
mutexProfileOptsDurationAt = 8
|
|
mutexProfileOptsFractionAt = 16
|
|
mutexProfileOptsSize = 24
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*MutexProfileOpts)(nil)
|
|
|
|
// MarshalZAP writes MutexProfileOpts from constant offsets.
|
|
func (x *MutexProfileOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(mutexProfileOptsSize + 256)
|
|
ob := b.StartObject(mutexProfileOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(mutexProfileOptsFilePayloadAt, innerFilePayload)
|
|
ob.SetInt64(mutexProfileOptsDurationAt, int64(x.Duration))
|
|
ob.SetInt64(mutexProfileOptsFractionAt, int64(x.Fraction))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads MutexProfileOpts out of the buffer that arrived.
|
|
func (x *MutexProfileOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("MutexProfileOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(mutexProfileOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Duration = time.Duration(o.Int64(mutexProfileOptsDurationAt))
|
|
x.Fraction = int(o.Int64(mutexProfileOptsFractionAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- Pair --------------------------------------------------------------
|
|
|
|
const (
|
|
pairKeyAt = 0
|
|
pairValueAt = 8
|
|
pairSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Pair)(nil)
|
|
|
|
// MarshalZAP writes Pair from constant offsets.
|
|
func (x *Pair) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(pairSize + 256)
|
|
ob := b.StartObject(pairSize)
|
|
ob.SetText(pairKeyAt, string(x.Key))
|
|
ob.SetText(pairValueAt, string(x.Value))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Pair out of the buffer that arrived.
|
|
func (x *Pair) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Pair: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Key = string(strings.Clone(o.Text(pairKeyAt)))
|
|
x.Value = string(strings.Clone(o.Text(pairValueAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- Process -----------------------------------------------------------
|
|
|
|
const (
|
|
processUIDAt = 0
|
|
processPIDAt = 4
|
|
processPPIDAt = 8
|
|
processPGIDAt = 12
|
|
processThreadsAt = 16
|
|
processCAt = 24
|
|
processTTYAt = 32
|
|
processSTimeAt = 40
|
|
processTimeAt = 48
|
|
processCmdAt = 56
|
|
processSize = 64
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Process)(nil)
|
|
|
|
// MarshalZAP writes Process from constant offsets.
|
|
func (x *Process) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(processSize + 256)
|
|
threadsAt, threadsN := 0, len(x.Threads)
|
|
if threadsN > 0 {
|
|
var blob []byte
|
|
for i := range x.Threads {
|
|
var full [8]byte
|
|
binary.LittleEndian.PutUint64(full[:], uint64(x.Threads[i]))
|
|
enc := full[:4]
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
threadsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(processSize)
|
|
ob.SetUint32(processUIDAt, uint32(x.UID))
|
|
ob.SetInt32(processPIDAt, int32(x.PID))
|
|
ob.SetInt32(processPPIDAt, int32(x.PPID))
|
|
ob.SetInt32(processPGIDAt, int32(x.PGID))
|
|
ob.SetInt32(processCAt, int32(x.C))
|
|
ob.SetText(processTTYAt, string(x.TTY))
|
|
ob.SetText(processSTimeAt, string(x.STime))
|
|
ob.SetText(processTimeAt, string(x.Time))
|
|
ob.SetText(processCmdAt, string(x.Cmd))
|
|
if threadsN > 0 {
|
|
ob.SetList(processThreadsAt, threadsAt, threadsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Process out of the buffer that arrived.
|
|
func (x *Process) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Process: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.UID = auth.KUID(o.Uint32(processUIDAt))
|
|
x.PID = kernel.ThreadID(o.Int32(processPIDAt))
|
|
x.PPID = kernel.ThreadID(o.Int32(processPPIDAt))
|
|
x.PGID = kernel.ThreadID(o.Int32(processPGIDAt))
|
|
if l := o.List(processThreadsAt); l.Len() > 0 {
|
|
rows := make([]kernel.ThreadID, l.Len())
|
|
for i := range rows {
|
|
var full [8]byte
|
|
copy(full[:], l.BytesAt(i))
|
|
rows[i] = kernel.ThreadID(int64(binary.LittleEndian.Uint64(full[:])<<32) >> 32)
|
|
}
|
|
x.Threads = rows
|
|
}
|
|
x.C = int32(o.Int32(processCAt))
|
|
x.TTY = string(strings.Clone(o.Text(processTTYAt)))
|
|
x.STime = string(strings.Clone(o.Text(processSTimeAt)))
|
|
x.Time = string(strings.Clone(o.Text(processTimeAt)))
|
|
x.Cmd = string(strings.Clone(o.Text(processCmdAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- PsArgs ------------------------------------------------------------
|
|
|
|
const (
|
|
psArgsJSONAt = 0
|
|
psArgsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*PsArgs)(nil)
|
|
|
|
// MarshalZAP writes PsArgs from constant offsets.
|
|
func (x *PsArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(psArgsSize + 256)
|
|
ob := b.StartObject(psArgsSize)
|
|
ob.SetBool(psArgsJSONAt, bool(x.JSON))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads PsArgs out of the buffer that arrived.
|
|
func (x *PsArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("PsArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.JSON = bool(o.Bool(psArgsJSONAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- PsResult ----------------------------------------------------------
|
|
|
|
const (
|
|
psResultTableAt = 0
|
|
psResultSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*PsResult)(nil)
|
|
|
|
// MarshalZAP writes PsResult from constant offsets.
|
|
func (x *PsResult) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(psResultSize + 256)
|
|
ob := b.StartObject(psResultSize)
|
|
ob.SetText(psResultTableAt, string(x.Table))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads PsResult out of the buffer that arrived.
|
|
func (x *PsResult) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("PsResult: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Table = string(strings.Clone(o.Text(psResultTableAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- ReadOpts ----------------------------------------------------------
|
|
|
|
const (
|
|
readOptsContainerIDAt = 0
|
|
readOptsPathAt = 8
|
|
readOptsOffsetAt = 16
|
|
readOptsSizeAt = 24
|
|
readOptsFilePayloadAt = 32
|
|
readOptsSize = 40
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*ReadOpts)(nil)
|
|
|
|
// MarshalZAP writes ReadOpts from constant offsets.
|
|
func (x *ReadOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(readOptsSize + 256)
|
|
ob := b.StartObject(readOptsSize)
|
|
ob.SetText(readOptsContainerIDAt, string(x.ContainerID))
|
|
ob.SetText(readOptsPathAt, string(x.Path))
|
|
ob.SetInt64(readOptsOffsetAt, int64(x.Offset))
|
|
ob.SetInt64(readOptsSizeAt, int64(x.Size))
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(readOptsFilePayloadAt, innerFilePayload)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads ReadOpts out of the buffer that arrived.
|
|
func (x *ReadOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("ReadOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.ContainerID = string(strings.Clone(o.Text(readOptsContainerIDAt)))
|
|
x.Path = string(strings.Clone(o.Text(readOptsPathAt)))
|
|
x.Offset = int64(o.Int64(readOptsOffsetAt))
|
|
x.Size = int64(o.Int64(readOptsSizeAt))
|
|
if raw := o.Bytes(readOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- RunningResult -----------------------------------------------------
|
|
|
|
const (
|
|
runningResultRunningAt = 0
|
|
runningResultSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*RunningResult)(nil)
|
|
|
|
// MarshalZAP writes RunningResult from constant offsets.
|
|
func (x *RunningResult) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(runningResultSize + 256)
|
|
ob := b.StartObject(runningResultSize)
|
|
ob.SetBool(runningResultRunningAt, bool(x.Running))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads RunningResult out of the buffer that arrived.
|
|
func (x *RunningResult) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("RunningResult: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Running = bool(o.Bool(runningResultRunningAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- SaveOpts ----------------------------------------------------------
|
|
|
|
const (
|
|
saveOptsKeyAt = 0
|
|
saveOptsMetadataAt = 8
|
|
saveOptsAppMFExcludeCommittedZeroPagesAt = 16
|
|
saveOptsHavePagesFileAt = 17
|
|
saveOptsFilePayloadAt = 24
|
|
saveOptsResumeAt = 32
|
|
saveOptsExecOptsAt = 40
|
|
saveOptsUseCheckpointGoferAt = 48
|
|
saveOptsCudaCheckpointPathAt = 56
|
|
saveOptsCudaCheckpointSequentialAt = 64
|
|
saveOptsSize = 72
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*SaveOpts)(nil)
|
|
|
|
// MarshalZAP writes SaveOpts from constant offsets.
|
|
func (x *SaveOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(saveOptsSize + 256)
|
|
metadataAt, metadataN := 0, len(x.Metadata)
|
|
if metadataN > 0 {
|
|
var blob []byte
|
|
for i := range x.Metadata {
|
|
enc, err := x.Metadata[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
metadataAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(saveOptsSize)
|
|
ob.SetBytes(saveOptsKeyAt, []byte(x.Key))
|
|
ob.SetBool(saveOptsAppMFExcludeCommittedZeroPagesAt, bool(x.AppMFExcludeCommittedZeroPages))
|
|
ob.SetBool(saveOptsHavePagesFileAt, bool(x.HavePagesFile))
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(saveOptsFilePayloadAt, innerFilePayload)
|
|
ob.SetBool(saveOptsResumeAt, bool(x.Resume))
|
|
innerExecOpts, err := x.ExecOpts.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(saveOptsExecOptsAt, innerExecOpts)
|
|
ob.SetBool(saveOptsUseCheckpointGoferAt, bool(x.UseCheckpointGofer))
|
|
ob.SetText(saveOptsCudaCheckpointPathAt, string(x.CudaCheckpointPath))
|
|
ob.SetBool(saveOptsCudaCheckpointSequentialAt, bool(x.CudaCheckpointSequential))
|
|
if metadataN > 0 {
|
|
ob.SetList(saveOptsMetadataAt, metadataAt, metadataN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads SaveOpts out of the buffer that arrived.
|
|
func (x *SaveOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("SaveOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Key = []uint8(append([]byte(nil), o.Bytes(saveOptsKeyAt)...))
|
|
if l := o.List(saveOptsMetadataAt); l.Len() > 0 {
|
|
rows := make([]Pair, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Metadata = rows
|
|
}
|
|
x.AppMFExcludeCommittedZeroPages = bool(o.Bool(saveOptsAppMFExcludeCommittedZeroPagesAt))
|
|
x.HavePagesFile = bool(o.Bool(saveOptsHavePagesFileAt))
|
|
if raw := o.Bytes(saveOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Resume = bool(o.Bool(saveOptsResumeAt))
|
|
if raw := o.Bytes(saveOptsExecOptsAt); len(raw) > 0 {
|
|
if err := x.ExecOpts.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.UseCheckpointGofer = bool(o.Bool(saveOptsUseCheckpointGoferAt))
|
|
x.CudaCheckpointPath = string(strings.Clone(o.Text(saveOptsCudaCheckpointPathAt)))
|
|
x.CudaCheckpointSequential = bool(o.Bool(saveOptsCudaCheckpointSequentialAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- SaveRestoreExecOpts -----------------------------------------------
|
|
|
|
const (
|
|
saveRestoreExecOptsArgvAt = 0
|
|
saveRestoreExecOptsTimeoutAt = 8
|
|
saveRestoreExecOptsContainerIDAt = 16
|
|
saveRestoreExecOptsSize = 24
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*SaveRestoreExecOpts)(nil)
|
|
|
|
// MarshalZAP writes SaveRestoreExecOpts from constant offsets.
|
|
func (x *SaveRestoreExecOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(saveRestoreExecOptsSize + 256)
|
|
ob := b.StartObject(saveRestoreExecOptsSize)
|
|
ob.SetText(saveRestoreExecOptsArgvAt, string(x.Argv))
|
|
ob.SetInt64(saveRestoreExecOptsTimeoutAt, int64(x.Timeout))
|
|
ob.SetText(saveRestoreExecOptsContainerIDAt, string(x.ContainerID))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads SaveRestoreExecOpts out of the buffer that arrived.
|
|
func (x *SaveRestoreExecOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("SaveRestoreExecOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Argv = string(strings.Clone(o.Text(saveRestoreExecOptsArgvAt)))
|
|
x.Timeout = time.Duration(o.Int64(saveRestoreExecOptsTimeoutAt))
|
|
x.ContainerID = string(strings.Clone(o.Text(saveRestoreExecOptsContainerIDAt)))
|
|
return nil
|
|
}
|
|
|
|
// ---- SignalContainerArgs -----------------------------------------------
|
|
|
|
const (
|
|
signalContainerArgsContainerIDAt = 0
|
|
signalContainerArgsSignoAt = 8
|
|
signalContainerArgsSignalAllAt = 12
|
|
signalContainerArgsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*SignalContainerArgs)(nil)
|
|
|
|
// MarshalZAP writes SignalContainerArgs from constant offsets.
|
|
func (x *SignalContainerArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(signalContainerArgsSize + 256)
|
|
ob := b.StartObject(signalContainerArgsSize)
|
|
ob.SetText(signalContainerArgsContainerIDAt, string(x.ContainerID))
|
|
ob.SetInt32(signalContainerArgsSignoAt, int32(x.Signo))
|
|
ob.SetBool(signalContainerArgsSignalAllAt, bool(x.SignalAll))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads SignalContainerArgs out of the buffer that arrived.
|
|
func (x *SignalContainerArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("SignalContainerArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.ContainerID = string(strings.Clone(o.Text(signalContainerArgsContainerIDAt)))
|
|
x.Signo = int32(o.Int32(signalContainerArgsSignoAt))
|
|
x.SignalAll = bool(o.Bool(signalContainerArgsSignalAllAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- SignalProcessArgs -------------------------------------------------
|
|
|
|
const (
|
|
signalProcessArgsSignoAt = 0
|
|
signalProcessArgsPIDAt = 8
|
|
signalProcessArgsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*SignalProcessArgs)(nil)
|
|
|
|
// MarshalZAP writes SignalProcessArgs from constant offsets.
|
|
func (x *SignalProcessArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(signalProcessArgsSize + 256)
|
|
ob := b.StartObject(signalProcessArgsSize)
|
|
ob.SetInt64(signalProcessArgsSignoAt, int64(x.Signo))
|
|
ob.SetInt64(signalProcessArgsPIDAt, int64(x.PID))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads SignalProcessArgs out of the buffer that arrived.
|
|
func (x *SignalProcessArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("SignalProcessArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Signo = int(o.Int64(signalProcessArgsSignoAt))
|
|
x.PID = int(o.Int64(signalProcessArgsPIDAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- StartContainerArgs ------------------------------------------------
|
|
|
|
const (
|
|
startContainerArgsFilenameAt = 0
|
|
startContainerArgsArgvAt = 8
|
|
startContainerArgsEnvvAt = 16
|
|
startContainerArgsSecretEnvvAt = 24
|
|
startContainerArgsWorkingDirectoryAt = 32
|
|
startContainerArgsKUIDAt = 40
|
|
startContainerArgsKGIDAt = 44
|
|
startContainerArgsUserAt = 48
|
|
startContainerArgsContainerIDAt = 56
|
|
startContainerArgsInitialCgroupsAt = 64
|
|
startContainerArgsLimitsAt = 72
|
|
startContainerArgsResolveHomeAt = 80
|
|
startContainerArgsResolveBinaryPathAt = 81
|
|
startContainerArgsDonatedFDsAt = 88
|
|
startContainerArgsFilePayloadAt = 96
|
|
startContainerArgsSize = 104
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*StartContainerArgs)(nil)
|
|
|
|
// MarshalZAP writes StartContainerArgs from constant offsets.
|
|
func (x *StartContainerArgs) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(startContainerArgsSize + 256)
|
|
argvAt, argvN := 0, len(x.Argv)
|
|
if argvN > 0 {
|
|
var blob []byte
|
|
for i := range x.Argv {
|
|
enc := []byte(x.Argv[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
argvAt = b.WriteBytes(blob)
|
|
}
|
|
envvAt, envvN := 0, len(x.Envv)
|
|
if envvN > 0 {
|
|
var blob []byte
|
|
for i := range x.Envv {
|
|
enc := []byte(x.Envv[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
envvAt = b.WriteBytes(blob)
|
|
}
|
|
secretEnvvAt, secretEnvvN := 0, len(x.SecretEnvv)
|
|
if secretEnvvN > 0 {
|
|
var blob []byte
|
|
for i := range x.SecretEnvv {
|
|
enc := []byte(x.SecretEnvv[i])
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
secretEnvvAt = b.WriteBytes(blob)
|
|
}
|
|
initialCgroupsAt, initialCgroupsN := 0, len(x.InitialCgroups)
|
|
if initialCgroupsN > 0 {
|
|
var blob []byte
|
|
for i := range x.InitialCgroups {
|
|
enc, err := x.InitialCgroups[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
initialCgroupsAt = b.WriteBytes(blob)
|
|
}
|
|
limitsAt, limitsN := 0, len(x.Limits)
|
|
if limitsN > 0 {
|
|
var blob []byte
|
|
for i := range x.Limits {
|
|
enc, err := x.Limits[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
limitsAt = b.WriteBytes(blob)
|
|
}
|
|
donatedFDsAt, donatedFDsN := 0, len(x.DonatedFDs)
|
|
if donatedFDsN > 0 {
|
|
var blob []byte
|
|
for i := range x.DonatedFDs {
|
|
var full [8]byte
|
|
binary.LittleEndian.PutUint64(full[:], uint64(x.DonatedFDs[i]))
|
|
enc := full[:8]
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
donatedFDsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(startContainerArgsSize)
|
|
ob.SetText(startContainerArgsFilenameAt, string(x.Filename))
|
|
ob.SetText(startContainerArgsWorkingDirectoryAt, string(x.WorkingDirectory))
|
|
ob.SetUint32(startContainerArgsKUIDAt, uint32(x.KUID))
|
|
ob.SetUint32(startContainerArgsKGIDAt, uint32(x.KGID))
|
|
ob.SetText(startContainerArgsUserAt, string(x.User))
|
|
ob.SetText(startContainerArgsContainerIDAt, string(x.ContainerID))
|
|
ob.SetBool(startContainerArgsResolveHomeAt, bool(x.ResolveHome))
|
|
ob.SetBool(startContainerArgsResolveBinaryPathAt, bool(x.ResolveBinaryPath))
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(startContainerArgsFilePayloadAt, innerFilePayload)
|
|
if argvN > 0 {
|
|
ob.SetList(startContainerArgsArgvAt, argvAt, argvN)
|
|
}
|
|
if envvN > 0 {
|
|
ob.SetList(startContainerArgsEnvvAt, envvAt, envvN)
|
|
}
|
|
if secretEnvvN > 0 {
|
|
ob.SetList(startContainerArgsSecretEnvvAt, secretEnvvAt, secretEnvvN)
|
|
}
|
|
if initialCgroupsN > 0 {
|
|
ob.SetList(startContainerArgsInitialCgroupsAt, initialCgroupsAt, initialCgroupsN)
|
|
}
|
|
if limitsN > 0 {
|
|
ob.SetList(startContainerArgsLimitsAt, limitsAt, limitsN)
|
|
}
|
|
if donatedFDsN > 0 {
|
|
ob.SetList(startContainerArgsDonatedFDsAt, donatedFDsAt, donatedFDsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads StartContainerArgs out of the buffer that arrived.
|
|
func (x *StartContainerArgs) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("StartContainerArgs: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Filename = string(strings.Clone(o.Text(startContainerArgsFilenameAt)))
|
|
if l := o.List(startContainerArgsArgvAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.Argv = rows
|
|
}
|
|
if l := o.List(startContainerArgsEnvvAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.Envv = rows
|
|
}
|
|
if l := o.List(startContainerArgsSecretEnvvAt); l.Len() > 0 {
|
|
rows := make([]string, l.Len())
|
|
for i := range rows {
|
|
rows[i] = string(l.BytesAt(i))
|
|
}
|
|
x.SecretEnvv = rows
|
|
}
|
|
x.WorkingDirectory = string(strings.Clone(o.Text(startContainerArgsWorkingDirectoryAt)))
|
|
x.KUID = auth.KUID(o.Uint32(startContainerArgsKUIDAt))
|
|
x.KGID = auth.KGID(o.Uint32(startContainerArgsKGIDAt))
|
|
x.User = string(strings.Clone(o.Text(startContainerArgsUserAt)))
|
|
x.ContainerID = string(strings.Clone(o.Text(startContainerArgsContainerIDAt)))
|
|
if l := o.List(startContainerArgsInitialCgroupsAt); l.Len() > 0 {
|
|
rows := make([]Controller, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.InitialCgroups = rows
|
|
}
|
|
if l := o.List(startContainerArgsLimitsAt); l.Len() > 0 {
|
|
rows := make([]limits.Rlimit, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Limits = rows
|
|
}
|
|
x.ResolveHome = bool(o.Bool(startContainerArgsResolveHomeAt))
|
|
x.ResolveBinaryPath = bool(o.Bool(startContainerArgsResolveBinaryPathAt))
|
|
if l := o.List(startContainerArgsDonatedFDsAt); l.Len() > 0 {
|
|
rows := make([]int, l.Len())
|
|
for i := range rows {
|
|
var full [8]byte
|
|
copy(full[:], l.BytesAt(i))
|
|
rows[i] = int(int64(binary.LittleEndian.Uint64(full[:])<<0) >> 0)
|
|
}
|
|
x.DonatedFDs = rows
|
|
}
|
|
if raw := o.Bytes(startContainerArgsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- TarRootfsUpperLayerOpts -------------------------------------------
|
|
|
|
const (
|
|
tarRootfsUpperLayerOptsContainerIDAt = 0
|
|
tarRootfsUpperLayerOptsFilePayloadAt = 8
|
|
tarRootfsUpperLayerOptsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*TarRootfsUpperLayerOpts)(nil)
|
|
|
|
// MarshalZAP writes TarRootfsUpperLayerOpts from constant offsets.
|
|
func (x *TarRootfsUpperLayerOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(tarRootfsUpperLayerOptsSize + 256)
|
|
ob := b.StartObject(tarRootfsUpperLayerOptsSize)
|
|
ob.SetText(tarRootfsUpperLayerOptsContainerIDAt, string(x.ContainerID))
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(tarRootfsUpperLayerOptsFilePayloadAt, innerFilePayload)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads TarRootfsUpperLayerOpts out of the buffer that arrived.
|
|
func (x *TarRootfsUpperLayerOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("TarRootfsUpperLayerOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.ContainerID = string(strings.Clone(o.Text(tarRootfsUpperLayerOptsContainerIDAt)))
|
|
if raw := o.Bytes(tarRootfsUpperLayerOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ---- TraceProfileOpts --------------------------------------------------
|
|
|
|
const (
|
|
traceProfileOptsFilePayloadAt = 0
|
|
traceProfileOptsDurationAt = 8
|
|
traceProfileOptsSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*TraceProfileOpts)(nil)
|
|
|
|
// MarshalZAP writes TraceProfileOpts from constant offsets.
|
|
func (x *TraceProfileOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(traceProfileOptsSize + 256)
|
|
ob := b.StartObject(traceProfileOptsSize)
|
|
innerFilePayload, err := x.FilePayload.MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ob.SetBytes(traceProfileOptsFilePayloadAt, innerFilePayload)
|
|
ob.SetInt64(traceProfileOptsDurationAt, int64(x.Duration))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads TraceProfileOpts out of the buffer that arrived.
|
|
func (x *TraceProfileOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("TraceProfileOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
if raw := o.Bytes(traceProfileOptsFilePayloadAt); len(raw) > 0 {
|
|
if err := x.FilePayload.UnmarshalZAP(raw); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Duration = time.Duration(o.Int64(traceProfileOptsDurationAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- UmountOpts --------------------------------------------------------
|
|
|
|
const (
|
|
umountOptsContainerIDAt = 0
|
|
umountOptsTargetAt = 8
|
|
umountOptsFlagsAt = 16
|
|
umountOptsSize = 24
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*UmountOpts)(nil)
|
|
|
|
// MarshalZAP writes UmountOpts from constant offsets.
|
|
func (x *UmountOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(umountOptsSize + 256)
|
|
ob := b.StartObject(umountOptsSize)
|
|
ob.SetText(umountOptsContainerIDAt, string(x.ContainerID))
|
|
ob.SetText(umountOptsTargetAt, string(x.Target))
|
|
ob.SetUint32(umountOptsFlagsAt, uint32(x.Flags))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads UmountOpts out of the buffer that arrived.
|
|
func (x *UmountOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("UmountOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.ContainerID = string(strings.Clone(o.Text(umountOptsContainerIDAt)))
|
|
x.Target = string(strings.Clone(o.Text(umountOptsTargetAt)))
|
|
x.Flags = uint32(o.Uint32(umountOptsFlagsAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- UsageReduceOpts ---------------------------------------------------
|
|
|
|
const (
|
|
usageReduceOptsWaitAt = 0
|
|
usageReduceOptsDoNotGCAt = 1
|
|
usageReduceOptsSize = 8
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*UsageReduceOpts)(nil)
|
|
|
|
// MarshalZAP writes UsageReduceOpts from constant offsets.
|
|
func (x *UsageReduceOpts) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(usageReduceOptsSize + 256)
|
|
ob := b.StartObject(usageReduceOptsSize)
|
|
ob.SetBool(usageReduceOptsWaitAt, bool(x.Wait))
|
|
ob.SetBool(usageReduceOptsDoNotGCAt, bool(x.DoNotGC))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads UsageReduceOpts out of the buffer that arrived.
|
|
func (x *UsageReduceOpts) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("UsageReduceOpts: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Wait = bool(o.Bool(usageReduceOptsWaitAt))
|
|
x.DoNotGC = bool(o.Bool(usageReduceOptsDoNotGCAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- UsageReduceOutput -------------------------------------------------
|
|
|
|
const (
|
|
usageReduceOutputSize = 0
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*UsageReduceOutput)(nil)
|
|
|
|
// MarshalZAP writes UsageReduceOutput from constant offsets.
|
|
func (x *UsageReduceOutput) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(usageReduceOutputSize + 256)
|
|
ob := b.StartObject(usageReduceOutputSize)
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads UsageReduceOutput out of the buffer that arrived.
|
|
func (x *UsageReduceOutput) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("UsageReduceOutput: %w", err)
|
|
}
|
|
_ = m
|
|
return nil
|
|
}
|