Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: change pass by value to pass by reference
Browse files Browse the repository at this point in the history
container.config does not point to sandbox.config.Containers.ContainerConfig
which caused the ContainerConfig not sync.

Fixes: #2129

Signed-off-by: Wang Liang <wangliangzz@inspur.com>
  • Loading branch information
Wang Liang committed Oct 12, 2019
1 parent c7b4c5e commit b6f9f26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ func (c *Container) createBlockDevices() error {
}

// newContainer creates a Container structure from a sandbox and a container configuration.
func newContainer(sandbox *Sandbox, contConfig ContainerConfig) (*Container, error) {
func newContainer(sandbox *Sandbox, contConfig *ContainerConfig) (*Container, error) {
span, _ := sandbox.trace("newContainer")
defer span.Finish()

Expand All @@ -729,7 +729,7 @@ func newContainer(sandbox *Sandbox, contConfig ContainerConfig) (*Container, err
id: contConfig.ID,
sandboxID: sandbox.id,
rootFs: contConfig.RootFs,
config: &contConfig,
config: contConfig,
sandbox: sandbox,
runPath: store.ContainerRuntimeRootPath(sandbox.id, contConfig.ID),
configPath: store.ContainerConfigurationRootPath(sandbox.id, contConfig.ID),
Expand Down Expand Up @@ -785,7 +785,7 @@ func newContainer(sandbox *Sandbox, contConfig ContainerConfig) (*Container, err
return nil, err
}

if err = c.createDevices(contConfig); err != nil {
if err = c.createDevices(*contConfig); err != nil {
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ func (s *Sandbox) fetchContainers() error {
contConfig.Spec = &spec
s.config.Containers[i] = contConfig

c, err := newContainer(s, contConfig)
c, err := newContainer(s, &s.config.Containers[i])
if err != nil {
return err
}
Expand All @@ -1118,7 +1118,7 @@ func (s *Sandbox) fetchContainers() error {
func (s *Sandbox) CreateContainer(contConfig ContainerConfig) (VCContainer, error) {
storeAlreadyExists := store.VCContainerStoreExists(s.ctx, s.id, contConfig.ID)
// Create the container.
c, err := newContainer(s, contConfig)
c, err := newContainer(s, &contConfig)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1417,7 +1417,7 @@ func (s *Sandbox) createContainers() error {

for _, contConfig := range s.config.Containers {

c, err := newContainer(s, contConfig)
c, err := newContainer(s, &contConfig)
if err != nil {
return err
}
Expand Down

0 comments on commit b6f9f26

Please sign in to comment.