MCPcopy
hub / github.com/firecracker-microvm/firecracker-containerd / AttachIO

Method AttachIO

internal/vm/task.go:345–369  ·  view source on GitHub ↗
(_ context.Context, taskID, execID string, proxy IOProxy)

Source from the content-addressed store, hash-verified

343}
344
345func (m *taskManager) AttachIO(_ context.Context, taskID, execID string, proxy IOProxy) error {
346 m.mu.Lock()
347 defer m.mu.Unlock()
348
349 proc, err := m.findProc(taskID, execID)
350 if err != nil {
351 return err
352 }
353
354 initDone, copyDone := proxy.start(proc)
355 proc.proxy = proxy
356 proc.ioCopyDone = copyDone
357
358 // This must be in a goroutine. Otherwise, sending to initDone channel blocks forever.
359 go func() {
360 e := <-initDone
361 if e != nil {
362 proc.logger.Error("failed to initialize an io proxy")
363 proxy.Close()
364 }
365 }()
366 go monitorIO(copyDone, proc)
367
368 return nil
369}
370
371func monitorIO(done <-chan error, proc *vmProc) {
372 <-done

Callers

nothing calls this directly

Calls 5

findProcMethod · 0.95
monitorIOFunction · 0.85
ErrorMethod · 0.80
startMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected