Merge pull request #4064 from tiezhuoyu/4063/no-need-to-write-error-of-virtiofsd-to-kata-log

runtime: no need to write virtiofsd error to log
This commit is contained in:
Greg Kurz 2022-04-13 11:59:19 +02:00 committed by GitHub
commit 4443bb68a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,6 @@
package virtcontainers
import (
"bufio"
"context"
"fmt"
"net"
@ -134,24 +133,14 @@ func (v *virtiofsd) Start(ctx context.Context, onQuit onQuitFunc) (int, error) {
v.Logger().WithField("path", v.path).Info()
v.Logger().WithField("args", strings.Join(args, " ")).Info()
stderr, err := cmd.StderrPipe()
if err != nil {
return pid, err
}
if err = utils.StartCmd(cmd); err != nil {
return pid, err
}
// Monitor virtiofsd's stderr and stop sandbox if virtiofsd quits
go func() {
scanner := bufio.NewScanner(stderr)
for scanner.Scan() {
v.Logger().WithField("source", "virtiofsd").Info(scanner.Text())
}
v.Logger().Info("virtiofsd quits")
// Wait to release resources of virtiofsd process
cmd.Process.Wait()
v.Logger().Info("virtiofsd quits")
if onQuit != nil {
onQuit()
}