@@ -163,8 +163,8 @@ type service struct {
163
163
fifosMu sync.Mutex
164
164
165
165
// 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
168
168
taskDrivePathOnHost string
169
169
}
170
170
@@ -503,7 +503,7 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe
503
503
s .logger .WithError (err ).Error ("failed to publish start VM event" )
504
504
}
505
505
506
- // Commented out because its execution cancels the shim, and
506
+ // Commented out because its execution cancels the shim, and
507
507
// it would get executed on Offload if we leave it, killing the shim,
508
508
// and making snapshots impossible.
509
509
//go s.monitorVMExit()
@@ -635,12 +635,14 @@ func (s *service) createVM(requestCtx context.Context, request *proto.CreateVMRe
635
635
636
636
s .createHTTPControlClient ()
637
637
638
- if pid , err := s .machine .PID (); err != nil {
638
+ pid , err := s .machine .PID ()
639
+ if err != nil {
639
640
s .logger .WithError (err ).Error ("Failed to get PID of firecracker process" )
640
641
return err
641
- } else {
642
- s .firecrackerPid = pid
643
642
}
643
+
644
+ s .firecrackerPid = pid
645
+
644
646
s .logger .Info ("successfully started the VM" )
645
647
646
648
return nil
@@ -1713,6 +1715,8 @@ func (s *service) cleanup() error {
1713
1715
}
1714
1716
1715
1717
// monitorVMExit watches the VM and cleanup resources when it terminates.
1718
+ // Comment out because unused
1719
+ /*
1716
1720
func (s *service) monitorVMExit() {
1717
1721
// Block until the VM exits
1718
1722
if err := s.machine.Wait(s.shimCtx); err != nil && err != context.Canceled {
@@ -1723,6 +1727,7 @@ func (s *service) monitorVMExit() {
1723
1727
s.logger.WithError(err).Error("failed to clean up the VM")
1724
1728
}
1725
1729
}
1730
+ */
1726
1731
1727
1732
func (s * service ) createHTTPControlClient () {
1728
1733
u := & httpunix.Transport {
@@ -1837,20 +1842,20 @@ func formCreateSnapReq(snapshotPath, memPath string) (*http.Request, error) {
1837
1842
return req , nil
1838
1843
}
1839
1844
1840
- func formPatchDriveReq (drive_id , path_on_host string ) (* http.Request , error ) {
1845
+ func formPatchDriveReq (driveID , pathOnHost string ) (* http.Request , error ) {
1841
1846
var req * http.Request
1842
1847
1843
1848
data := map [string ]string {
1844
- "drive_id" : drive_id ,
1845
- "path_on_host" : path_on_host ,
1849
+ "drive_id" : driveID ,
1850
+ "path_on_host" : pathOnHost ,
1846
1851
}
1847
1852
json , err := json .Marshal (data )
1848
1853
if err != nil {
1849
1854
logrus .WithError (err ).Error ("Failed to marshal json data" )
1850
1855
return nil , err
1851
1856
}
1852
1857
1853
- req , err = http .NewRequest ("PATCH" , fmt .Sprintf ("http+unix://firecracker/drives/%s" , drive_id ), bytes .NewBuffer (json ))
1858
+ req , err = http .NewRequest ("PATCH" , fmt .Sprintf ("http+unix://firecracker/drives/%s" , driveID ), bytes .NewBuffer (json ))
1854
1859
if err != nil {
1855
1860
logrus .WithError (err ).Error ("Failed to create new HTTP request in formPauseReq" )
1856
1861
return nil , err
@@ -1869,14 +1874,13 @@ func (s *service) startFirecrackerProcess() error {
1869
1874
return err
1870
1875
}
1871
1876
1872
-
1873
1877
// TODO: Remove hardcoding and make a parameter
1874
1878
logFilePath := fmt .Sprintf ("/tmp/log_%s_after.logs" , s .vmID )
1875
1879
if err := os .RemoveAll (logFilePath ); err != nil {
1876
1880
s .logger .WithError (err ).Errorf ("Failed to delete %s" , logFilePath )
1877
1881
return err
1878
1882
}
1879
- if _ , err := os .OpenFile (logFilePath , os .O_RDONLY | os .O_CREATE , 0666 ); err != nil {
1883
+ if _ , err := os .OpenFile (logFilePath , os .O_RDONLY | os .O_CREATE , 0600 ); err != nil {
1880
1884
s .logger .WithError (err ).Errorf ("Failed to create %s" , logFilePath )
1881
1885
return err
1882
1886
}
0 commit comments