From 1e4f7faa778d85dce8aad977531b072467b5accc Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Tue, 20 Jul 2021 10:29:21 -0500 Subject: [PATCH] runtime: virtcontainers/types: fix govet fieldalignment Fix structures alignment Signed-off-by: Julio Montes --- src/runtime/virtcontainers/types/bridges.go | 6 +-- .../virtcontainers/types/bridges_test.go | 4 +- src/runtime/virtcontainers/types/fcConfig.go | 8 ++-- src/runtime/virtcontainers/types/sandbox.go | 41 ++++++++++--------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/runtime/virtcontainers/types/bridges.go b/src/runtime/virtcontainers/types/bridges.go index 7a9fbdce5c..6314e6025c 100644 --- a/src/runtime/virtcontainers/types/bridges.go +++ b/src/runtime/virtcontainers/types/bridges.go @@ -36,12 +36,12 @@ type Bridge struct { // ID is used to identify the bridge in the hypervisor ID string - // Addr is the slot of the bridge - Addr int - // Type is the type of the bridge (pci, pcie, etc) Type Type + // Addr is the slot of the bridge + Addr int + // MaxCapacity is the max capacity of the bridge MaxCapacity uint32 } diff --git a/src/runtime/virtcontainers/types/bridges_test.go b/src/runtime/virtcontainers/types/bridges_test.go index fabbb4e90d..c0899e9eef 100644 --- a/src/runtime/virtcontainers/types/bridges_test.go +++ b/src/runtime/virtcontainers/types/bridges_test.go @@ -96,7 +96,7 @@ func TestNewBridge(t *testing.T) { func TestAddRemoveDevicePCI(t *testing.T) { // create a pci bridge - bridges := []*Bridge{{make(map[uint32]string), "rgb123", 5, PCI, PCIBridgeMaxCapacity}} + bridges := []*Bridge{{make(map[uint32]string), "rgb123", PCI, 5, PCIBridgeMaxCapacity}} testAddRemoveDevice(t, bridges[0]) } @@ -104,7 +104,7 @@ func TestAddRemoveDevicePCI(t *testing.T) { func TestAddRemoveDeviceCCW(t *testing.T) { // create a CCW bridge - bridges := []*Bridge{{make(map[uint32]string), "rgb123", 5, CCW, CCWBridgeMaxCapacity}} + bridges := []*Bridge{{make(map[uint32]string), "rgb123", CCW, 5, CCWBridgeMaxCapacity}} testAddRemoveDevice(t, bridges[0]) } diff --git a/src/runtime/virtcontainers/types/fcConfig.go b/src/runtime/virtcontainers/types/fcConfig.go index 6bc1dc4942..6297c4375c 100644 --- a/src/runtime/virtcontainers/types/fcConfig.go +++ b/src/runtime/virtcontainers/types/fcConfig.go @@ -14,13 +14,13 @@ type FcConfig struct { MachineConfig *models.MachineConfiguration `json:"machine-config"` - Drives []*models.Drive `json:"drives,omitempty"` - Vsock *models.Vsock `json:"vsock,omitempty"` - NetworkInterfaces []*models.NetworkInterface `json:"network-interfaces,omitempty"` - Logger *models.Logger `json:"logger,omitempty"` Metrics *models.Metrics `json:"metrics,omitempty"` + + Drives []*models.Drive `json:"drives,omitempty"` + + NetworkInterfaces []*models.NetworkInterface `json:"network-interfaces,omitempty"` } diff --git a/src/runtime/virtcontainers/types/sandbox.go b/src/runtime/virtcontainers/types/sandbox.go index a8419be19f..902017a6fb 100644 --- a/src/runtime/virtcontainers/types/sandbox.go +++ b/src/runtime/virtcontainers/types/sandbox.go @@ -41,29 +41,29 @@ const ( // SandboxState is a sandbox state structure type SandboxState struct { - State StateString `json:"state"` - // Index map of the block device passed to hypervisor. BlockIndexMap map[int]struct{} `json:"blockIndexMap"` + // Path to all the cgroups setup for a container. Key is cgroup subsystem name + // with the value as the path. + CgroupPaths map[string]string `json:"cgroupPaths"` + + State StateString `json:"state"` + + // CgroupPath is the cgroup hierarchy where sandbox's processes + // including the hypervisor are placed. + CgroupPath string `json:"cgroupPath,omitempty"` + + // PersistVersion indicates current storage api version. + // It's also known as ABI version of kata-runtime. + // Note: it won't be written to disk + PersistVersion uint `json:"-"` + // GuestMemoryBlockSizeMB is the size of memory block of guestos GuestMemoryBlockSizeMB uint32 `json:"guestMemoryBlockSize"` // GuestMemoryHotplugProbe determines whether guest kernel supports memory hotplug probe interface GuestMemoryHotplugProbe bool `json:"guestMemoryHotplugProbe"` - - // CgroupPath is the cgroup hierarchy where sandbox's processes - // including the hypervisor are placed. - CgroupPath string `json:"cgroupPath,omitempty"` - - // Path to all the cgroups setup for a container. Key is cgroup subsystem name - // with the value as the path. - CgroupPaths map[string]string `json:"cgroupPaths"` - - // PersistVersion indicates current storage api version. - // It's also known as ABI version of kata-runtime. - // Note: it won't be written to disk - PersistVersion uint `json:"-"` } // Valid checks that the sandbox state is valid. @@ -179,9 +179,9 @@ func (v *Volumes) String() string { // the host and any process inside the VM. // This kind of socket is not supported in all hypervisors. type VSock struct { + VhostFd *os.File ContextID uint64 Port uint32 - VhostFd *os.File } func (s *VSock) String() string { @@ -281,9 +281,7 @@ type EnvVar struct { // Cmd represents a command to execute in a running container. type Cmd struct { - Args []string - Envs []EnvVar - SupplementaryGroups []string + Capabilities *specs.LinuxCapabilities // Note that these fields *MUST* remain as strings. // @@ -311,7 +309,10 @@ type Cmd struct { PrimaryGroup string WorkDir string Console string - Capabilities *specs.LinuxCapabilities + + Args []string + Envs []EnvVar + SupplementaryGroups []string Interactive bool Detach bool