@@ -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
@@ -1690,6 +1692,8 @@ func (s *service) cleanup() error {
1690
1692
}
1691
1693
1692
1694
// monitorVMExit watches the VM and cleanup resources when it terminates.
1695
+ // Comment out because unused
1696
+ /*
1693
1697
func (s *service) monitorVMExit() {
1694
1698
// Block until the VM exits
1695
1699
if err := s.machine.Wait(s.shimCtx); err != nil && err != context.Canceled {
@@ -1700,6 +1704,7 @@ func (s *service) monitorVMExit() {
1700
1704
s.logger.WithError(err).Error("failed to clean up the VM")
1701
1705
}
1702
1706
}
1707
+ */
1703
1708
1704
1709
func (s * service ) createHTTPControlClient () {
1705
1710
u := & httpunix.Transport {
@@ -1814,20 +1819,20 @@ func formCreateSnapReq(snapshotPath, memPath string) (*http.Request, error) {
1814
1819
return req , nil
1815
1820
}
1816
1821
1817
- func formPatchDriveReq (drive_id , path_on_host string ) (* http.Request , error ) {
1822
+ func formPatchDriveReq (driveID , pathOnHost string ) (* http.Request , error ) {
1818
1823
var req * http.Request
1819
1824
1820
1825
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 ,
1823
1828
}
1824
1829
json , err := json .Marshal (data )
1825
1830
if err != nil {
1826
1831
logrus .WithError (err ).Error ("Failed to marshal json data" )
1827
1832
return nil , err
1828
1833
}
1829
1834
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 ))
1831
1836
if err != nil {
1832
1837
logrus .WithError (err ).Error ("Failed to create new HTTP request in formPauseReq" )
1833
1838
return nil , err
@@ -1846,14 +1851,13 @@ func (s *service) startFirecrackerProcess() error {
1846
1851
return err
1847
1852
}
1848
1853
1849
-
1850
1854
// TODO: Remove hardcoding and make a parameter
1851
1855
logFilePath := fmt .Sprintf ("/tmp/log_%s_after.logs" , s .vmID )
1852
1856
if err := os .RemoveAll (logFilePath ); err != nil {
1853
1857
s .logger .WithError (err ).Errorf ("Failed to delete %s" , logFilePath )
1854
1858
return err
1855
1859
}
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 {
1857
1861
s .logger .WithError (err ).Errorf ("Failed to create %s" , logFilePath )
1858
1862
return err
1859
1863
}
0 commit comments