Skip to content

Commit 69504c8

Browse files
committed
Altered buildVMConfiguration tests
Signed-off-by: Plamen Petrov <[email protected]>
1 parent 672c33d commit 69504c8

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

firecracker-control/local.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,4 +688,3 @@ func (s *local) Offload(ctx context.Context, req *proto.OffloadRequest) (*empty.
688688

689689
return resp, nil
690690
}
691-

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7
865865
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
866866
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
867867
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
868+
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
868869
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
869870
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
870871
>>>>>>> Implemented resume and pause call chain.
@@ -1081,10 +1082,19 @@ golang.org/x/tools v0.0.0-20200615222825-6aa8f57aacd9 h1:cwgUY+1ja2qxWb2dyaCoixa
10811082
golang.org/x/tools v0.0.0-20200615222825-6aa8f57aacd9/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
10821083
golang.org/x/tools v0.0.0-20200708183856-df98bc6d456c h1:Jt8nybBNSGn80qEV8fQLwCam6RQeX4dsxit8if67Sfc=
10831084
golang.org/x/tools v0.0.0-20200708183856-df98bc6d456c/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
1085+
golang.org/x/tools v0.0.0-20200710042808-f1c4188a97a1 h1:rD1FcWVsRaMY+l8biE9jbWP5MS/CJJ/90a9TMkMgNrM=
1086+
golang.org/x/tools v0.0.0-20200710042808-f1c4188a97a1/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
10841087
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
10851088
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
1089+
<<<<<<< HEAD
10861090
>>>>>>> Implemented resume and pause call chain.
1091+
<<<<<<< HEAD
10871092
>>>>>>> Implemented resume and pause call chain.
1093+
=======
1094+
=======
1095+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
1096+
>>>>>>> Altered buildVMConfiguration tests
1097+
>>>>>>> Altered buildVMConfiguration tests
10881098
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
10891099
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
10901100
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

runtime/service.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ type service struct {
163163
fifosMu sync.Mutex
164164

165165
// httpControlClient is to send pause/resume/snapshot commands to the microVM
166-
httpControlClient *http.Client
167-
firecrackerPid int
166+
httpControlClient *http.Client
167+
firecrackerPid int
168168
taskDrivePathOnHost string
169169
}
170170

@@ -503,7 +503,7 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe
503503
s.logger.WithError(err).Error("failed to publish start VM event")
504504
}
505505

506-
// Commented out because its execution cancels the shim, and
506+
// Commented out because its execution cancels the shim, and
507507
// it would get executed on Offload if we leave it, killing the shim,
508508
// and making snapshots impossible.
509509
//go s.monitorVMExit()
@@ -635,12 +635,14 @@ func (s *service) createVM(requestCtx context.Context, request *proto.CreateVMRe
635635

636636
s.createHTTPControlClient()
637637

638-
if pid, err := s.machine.PID(); err != nil {
638+
pid, err := s.machine.PID()
639+
if err != nil {
639640
s.logger.WithError(err).Error("Failed to get PID of firecracker process")
640641
return err
641-
} else {
642-
s.firecrackerPid = pid
643642
}
643+
644+
s.firecrackerPid = pid
645+
644646
s.logger.Info("successfully started the VM")
645647

646648
return nil
@@ -1690,6 +1692,8 @@ func (s *service) cleanup() error {
16901692
}
16911693

16921694
// monitorVMExit watches the VM and cleanup resources when it terminates.
1695+
// Comment out because unused
1696+
/*
16931697
func (s *service) monitorVMExit() {
16941698
// Block until the VM exits
16951699
if err := s.machine.Wait(s.shimCtx); err != nil && err != context.Canceled {
@@ -1700,6 +1704,7 @@ func (s *service) monitorVMExit() {
17001704
s.logger.WithError(err).Error("failed to clean up the VM")
17011705
}
17021706
}
1707+
*/
17031708

17041709
func (s *service) createHTTPControlClient() {
17051710
u := &httpunix.Transport{
@@ -1814,20 +1819,20 @@ func formCreateSnapReq(snapshotPath, memPath string) (*http.Request, error) {
18141819
return req, nil
18151820
}
18161821

1817-
func formPatchDriveReq(drive_id, path_on_host string) (*http.Request, error) {
1822+
func formPatchDriveReq(driveID, pathOnHost string) (*http.Request, error) {
18181823
var req *http.Request
18191824

18201825
data := map[string]string{
1821-
"drive_id": drive_id,
1822-
"path_on_host": path_on_host,
1826+
"drive_id": driveID,
1827+
"path_on_host": pathOnHost,
18231828
}
18241829
json, err := json.Marshal(data)
18251830
if err != nil {
18261831
logrus.WithError(err).Error("Failed to marshal json data")
18271832
return nil, err
18281833
}
18291834

1830-
req, err = http.NewRequest("PATCH", fmt.Sprintf("http+unix://firecracker/drives/%s", drive_id), bytes.NewBuffer(json))
1835+
req, err = http.NewRequest("PATCH", fmt.Sprintf("http+unix://firecracker/drives/%s", driveID), bytes.NewBuffer(json))
18311836
if err != nil {
18321837
logrus.WithError(err).Error("Failed to create new HTTP request in formPauseReq")
18331838
return nil, err
@@ -1846,14 +1851,13 @@ func (s *service) startFirecrackerProcess() error {
18461851
return err
18471852
}
18481853

1849-
18501854
// TODO: Remove hardcoding and make a parameter
18511855
logFilePath := fmt.Sprintf("/tmp/log_%s_after.logs", s.vmID)
18521856
if err := os.RemoveAll(logFilePath); err != nil {
18531857
s.logger.WithError(err).Errorf("Failed to delete %s", logFilePath)
18541858
return err
18551859
}
1856-
if _, err := os.OpenFile(logFilePath, os.O_RDONLY|os.O_CREATE, 0666); err != nil {
1860+
if _, err := os.OpenFile(logFilePath, os.O_RDONLY|os.O_CREATE, 0600); err != nil {
18571861
s.logger.WithError(err).Errorf("Failed to create %s", logFilePath)
18581862
return err
18591863
}

0 commit comments

Comments
 (0)