@@ -458,7 +458,7 @@ func (o *Orchestrator) LoadSnapshot(ctx context.Context, originVmID string, vmID
458458		loadSnapshotMetric    * metrics.Metric  =  metrics .NewMetric ()
459459		tStart                time.Time 
460460		loadErr , activateErr  error 
461- 		loadDone              =  make (chan  int )
461+ 		//  loadDone             = make(chan int)
462462	)
463463
464464	logger  :=  log .WithFields (log.Fields {"vmID" : vmID })
@@ -505,9 +505,12 @@ func (o *Orchestrator) LoadSnapshot(ctx context.Context, originVmID string, vmID
505505		BackendType : fileBackend ,
506506		BackendPath : snap .GetMemFilePath (),
507507	}
508+ 	conf .ResumeVM  =  true 
509+ 	conf .EnableDiffSnapshots  =  false 
508510
509511	var  sendfdConn  * net.UnixConn 
510- 	uffdListenerCh  :=  make (chan  struct {}, 1 )
512+ 	// uffdListenerCh := make(chan struct{}, 1) 
513+ 	var  listener  net.Listener 
511514
512515	if  o .GetUPFEnabled () {
513516		logger .Debug ("TEST: UPF is enabled" )
@@ -527,73 +530,76 @@ func (o *Orchestrator) LoadSnapshot(ctx context.Context, originVmID string, vmID
527530			os .Remove (conf .MemBackend .BackendPath )
528531		}
529532
530- 		go   func () { 
531- 			 listener , err  : =net .Listen ("unix" , conf .MemBackend .BackendPath )
532- 			 if  err  !=  nil  {
533- 				 logger .Error ("failed to listen to uffd socket" )
534- 				 return 
535- 			 }
536- 			 defer  listener .Close ()
533+ 		// =============================================================== 
534+ 		listener , err  =  net .Listen ("unix" , conf .MemBackend .BackendPath )
535+ 		if  err  !=  nil  {
536+ 			logger .Error ("failed to listen to uffd socket" )
537+ 			return 
538+ 		}
539+ 		//  defer listener.Close()
537540
538- 			 logger .Debug ("Listening ..." )
539- 			 conn , err  :=  listener .Accept ()
540- 			 if  err  !=  nil  {
541- 			 	logger .Error ("failed to accept connection to uffd socket" )
542- 			 	return 
543- 			 }
541+ 		//  logger.Debug("Listening ...")
542+ 		//  conn, err := listener.Accept()
543+ 		//  if err != nil {
544+ 		//  	logger.Error("failed to accept connection to uffd socket")
545+ 		//  	return
546+ 		//  }
544547
545- 			sendfdConn , _  =  conn .(* net.UnixConn )
546- 			close (uffdListenerCh )
547- 		}()
548+ 		// sendfdConn, _ = conn.(*net.UnixConn) 
549+ 		// close(uffdListenerCh) 
548550
549- 		time .Sleep (10  *  time .Second ) // TODO: sleep for 10 seconds to wait for the uffd socket to be ready 
551+ 		//  time.Sleep(10 * time.Second) // TODO: sleep for 10 seconds to wait for the uffd socket to be ready
550552	}
551553
552554	tStart  =  time .Now ()
553555
554- 	go  func () {
555- 		defer  close (loadDone )
556- 
557- 		confStr , _  :=  json .Marshal (conf )
558- 		logger .Debugf ("TEST: CreateVM request: %s" , confStr )
556+ 	confStr , _  :=  json .Marshal (conf )
557+ 	logger .Debugf ("TEST: CreateVM request: %s" , confStr )
559558
560- 		if  _ , loadErr  :=  o .fcClient .CreateVM (ctx , conf ); loadErr  !=  nil  {
561- 			logger .Error ("Failed to load snapshot of the VM: " , loadErr )
562- 			logger .Errorf ("snapFilePath: %s, memFilePath: %s, newSnapshotPath: %s" , snap .GetSnapshotFilePath (), snap .GetMemFilePath (), containerSnap .GetDevicePath ())
563- 			files , err  :=  os .ReadDir (filepath .Dir (snap .GetSnapshotFilePath ()))
564- 			if  err  !=  nil  {
565- 				logger .Error (err )
566- 			}
567- 
568- 			snapFiles  :=  "" 
569- 			for  _ , f  :=  range  files  {
570- 				snapFiles  +=  f .Name () +  ", " 
571- 			}
559+ 	if  _ , loadErr  :=  o .fcClient .CreateVM (ctx , conf ); loadErr  !=  nil  {
560+ 		logger .Error ("Failed to load snapshot of the VM: " , loadErr )
561+ 		logger .Errorf ("snapFilePath: %s, memFilePath: %s, newSnapshotPath: %s" , snap .GetSnapshotFilePath (), snap .GetMemFilePath (), containerSnap .GetDevicePath ())
562+ 		files , err  :=  os .ReadDir (filepath .Dir (snap .GetSnapshotFilePath ()))
563+ 		if  err  !=  nil  {
564+ 			logger .Error (err )
565+ 		}
572566
573- 			logger .Error (snapFiles )
567+ 		snapFiles  :=  "" 
568+ 		for  _ , f  :=  range  files  {
569+ 			snapFiles  +=  f .Name () +  ", " 
570+ 		}
574571
575- 			files , _  =  os .ReadDir (filepath .Dir (containerSnap .GetDevicePath ()))
576- 			if  err  !=  nil  {
577- 				logger .Error (err )
578- 			}
572+ 		logger .Error (snapFiles )
579573
580- 			snapFiles  =  "" 
581- 			for  _ , f  :=  range  files  {
582- 				snapFiles  +=  f .Name () +  ", " 
583- 			}
584- 			logger .Error (snapFiles )
574+ 		files , _  =  os .ReadDir (filepath .Dir (containerSnap .GetDevicePath ()))
575+ 		if  err  !=  nil  {
576+ 			logger .Error (err )
585577		}
586- 	}()
587578
579+ 		snapFiles  =  "" 
580+ 		for  _ , f  :=  range  files  {
581+ 			snapFiles  +=  f .Name () +  ", " 
582+ 		}
583+ 		logger .Error (snapFiles )
584+ 	}
588585	logger .Debug ("TEST: CreatVM request sent" )
589586
590- 	<- loadDone 
587+ 	//  <-loadDone
591588
592589	if  o .GetUPFEnabled () {
590+ 		logger .Debug ("Listening ..." )
591+ 		conn , err  :=  listener .Accept () // TODO: a question, must accept() first before connect()? 
592+ 		if  err  !=  nil  {
593+ 			logger .Error ("failed to accept connection to uffd socket" )
594+ 			return 
595+ 		}
596+ 		sendfdConn , _  =  conn .(* net.UnixConn )
597+ 		listener .Close ()
598+ 		// close(uffdListenerCh) 
593599
594600		logger .Debug ("TEST: Registering VM with snap with the memory manager" )
595601
596- 		<- uffdListenerCh 
602+ 		//  <-uffdListenerCh
597603
598604		stateCfg  :=  manager.SnapshotStateCfg {
599605			VMID :             vmID ,
@@ -613,6 +619,8 @@ func (o *Orchestrator) LoadSnapshot(ctx context.Context, originVmID string, vmID
613619		if  activateErr  =  o .memoryManager .Activate (originVmID , sendfdConn ); activateErr  !=  nil  {
614620			logger .Warn ("Failed to activate VM in the memory manager" , activateErr )
615621		}
622+ 
623+ 		// time.Sleep(30 * time.Minute) // pause to see fc logs 
616624	}
617625
618626	// <-loadDone 
0 commit comments