77 "fmt"
88
99 "github.com/Microsoft/hcsshim/internal/cmd"
10- "github.com/Microsoft/hcsshim/internal/cow"
1110 "github.com/Microsoft/hcsshim/internal/gcs"
1211
1312 "github.com/Microsoft/go-winio/pkg/guid"
@@ -26,10 +25,6 @@ type Manager interface {
2625 // Once the container is created, it can be managed using the returned `gcs.Container` interface.
2726 // `gcs.Container` uses the underlying guest connection to issue commands to the guest.
2827 CreateContainer (ctx context.Context , cid string , config interface {}) (* gcs.Container , error )
29- // CreateProcess creates a process in the guest.
30- // Once the process is created, it can be managed using the returned `cow.Process` interface.
31- // `cow.Process` uses the underlying guest connection to issue commands to the guest.
32- CreateProcess (ctx context.Context , settings interface {}) (cow.Process , error )
3328 // DumpStacks requests a stack dump from the guest and returns it as a string.
3429 DumpStacks (ctx context.Context ) (string , error )
3530 // DeleteContainerState removes persisted state for the container identified by `cid` from the guest.
@@ -42,11 +37,17 @@ var _ Manager = (*Guest)(nil)
4237
4338// Capabilities returns the capabilities of the guest connection.
4439func (gm * Guest ) Capabilities () gcs.GuestDefinedCapabilities {
40+ gm .mu .RLock ()
41+ defer gm .mu .RUnlock ()
42+
4543 return gm .gc .Capabilities ()
4644}
4745
4846// CreateContainer creates a container in the guest with the given ID and config.
4947func (gm * Guest ) CreateContainer (ctx context.Context , cid string , config interface {}) (* gcs.Container , error ) {
48+ gm .mu .Lock ()
49+ defer gm .mu .Unlock ()
50+
5051 c , err := gm .gc .CreateContainer (ctx , cid , config )
5152 if err != nil {
5253 return nil , fmt .Errorf ("failed to create container %s: %w" , cid , err )
@@ -55,18 +56,11 @@ func (gm *Guest) CreateContainer(ctx context.Context, cid string, config interfa
5556 return c , nil
5657}
5758
58- // CreateProcess creates a process in the guest using the provided settings.
59- func (gm * Guest ) CreateProcess (ctx context.Context , settings interface {}) (cow.Process , error ) {
60- p , err := gm .gc .CreateProcess (ctx , settings )
61- if err != nil {
62- return nil , fmt .Errorf ("failed to create process: %w" , err )
63- }
64-
65- return p , nil
66- }
67-
6859// DumpStacks requests a stack dump from the guest and returns it as a string.
6960func (gm * Guest ) DumpStacks (ctx context.Context ) (string , error ) {
61+ gm .mu .Lock ()
62+ defer gm .mu .Unlock ()
63+
7064 dump , err := gm .gc .DumpStacks (ctx )
7165 if err != nil {
7266 return "" , fmt .Errorf ("failed to dump stacks: %w" , err )
@@ -77,6 +71,9 @@ func (gm *Guest) DumpStacks(ctx context.Context) (string, error) {
7771
7872// DeleteContainerState removes persisted state for the container identified by cid from the guest.
7973func (gm * Guest ) DeleteContainerState (ctx context.Context , cid string ) error {
74+ gm .mu .Lock ()
75+ defer gm .mu .Unlock ()
76+
8077 err := gm .gc .DeleteContainerState (ctx , cid )
8178 if err != nil {
8279 return fmt .Errorf ("failed to delete container state for container %s: %w" , cid , err )
0 commit comments