Skip to content

Commit f294880

Browse files
committed
Update loadsnapshot params
Signed-off-by: char-1ee <[email protected]>
1 parent e0bef9a commit f294880

File tree

5 files changed

+65
-57
lines changed

5 files changed

+65
-57
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:9595863ca1a4903d7cd0715a5da046e1ce4d88c76bd58c9deef586b583bed79a
3-
size 36354528
2+
oid sha256:593f7fff0ae8512859e08bd129375da10c13088d836cbaeb1608847b72c1cf28
3+
size 36382664

bin/default-rootfs.img

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:7a2e7504d702db942e88158547c1076db786f861fb0b69ec96eb27716e1e37b1
3-
size 73318400
2+
oid sha256:f042d5db9797c16255db5a32d9644e8cad838a2ef46da9c08a6ae38a24111f97
3+
size 73342976

bin/firecracker-containerd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:c4450b3c8e9cb2db1a193cd2b9594eb90054cdbdae1d837a7f426b4b0d83950f
3-
size 72445304
2+
oid sha256:257ee96d4b2cd4a04f61833eafc31e2d814bb923e42ee0386077873f082aaa07
3+
size 72481176

bin/firecracker-ctr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:37487275ed6a08f4e759d9847435537bf52f20c207087e3e4226e599de8bae72
3-
size 35276648
2+
oid sha256:2f60c7f0984dfdba666c9159761fe93357d6558dbbe7c3326bc4959b3bdf72b6
3+
size 35333240

ctriface/iface.go

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)