mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
qemu: print virtiofsd logs when debug is on
To help trace virtiofsd issues. Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
90539ac31b
commit
d0aae80f55
@ -598,10 +598,16 @@ func (q *qemu) startSandbox(timeout int) error {
|
|||||||
// connection with QEMU closes. Therefore we do not keep track
|
// connection with QEMU closes. Therefore we do not keep track
|
||||||
// of this child process after returning from this function.
|
// of this child process after returning from this function.
|
||||||
sourcePath := filepath.Join(kataHostSharedDir, q.id)
|
sourcePath := filepath.Join(kataHostSharedDir, q.id)
|
||||||
cmd := exec.Command(q.config.VirtioFSDaemon,
|
args := []string{
|
||||||
"-o", "vhost_user_socket="+sockPath,
|
"-o", "vhost_user_socket=" + sockPath,
|
||||||
"-o", "source="+sourcePath,
|
"-o", "source=" + sourcePath,
|
||||||
"-o", "cache="+q.config.VirtioFSCache)
|
"-o", "cache=" + q.config.VirtioFSCache}
|
||||||
|
if q.config.Debug {
|
||||||
|
args = append(args, "-d")
|
||||||
|
} else {
|
||||||
|
args = append(args, "-f")
|
||||||
|
}
|
||||||
|
cmd := exec.Command(q.config.VirtioFSDaemon, args...)
|
||||||
stderr, err := cmd.StderrPipe()
|
stderr, err := cmd.StderrPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -621,16 +627,24 @@ func (q *qemu) startSandbox(timeout int) error {
|
|||||||
timeStart := time.Now()
|
timeStart := time.Now()
|
||||||
go func() {
|
go func() {
|
||||||
scanner := bufio.NewScanner(stderr)
|
scanner := bufio.NewScanner(stderr)
|
||||||
|
var sent bool
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
if strings.Contains(scanner.Text(), "Waiting for vhost-user socket connection...") {
|
if q.config.Debug {
|
||||||
|
q.Logger().WithField("source", "virtiofsd").Debug(scanner.Text())
|
||||||
|
}
|
||||||
|
if !sent && strings.Contains(scanner.Text(), "Waiting for vhost-user socket connection...") {
|
||||||
sockReady <- nil
|
sockReady <- nil
|
||||||
return
|
sent = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := scanner.Err(); err != nil {
|
if !sent {
|
||||||
sockReady <- err
|
if err := scanner.Err(); err != nil {
|
||||||
|
sockReady <- err
|
||||||
|
} else {
|
||||||
|
sockReady <- fmt.Errorf("virtiofsd did not announce socket connection")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sockReady <- fmt.Errorf("virtiofsd did not announce socket connection")
|
q.Logger().Info("virtiofsd quits")
|
||||||
}()
|
}()
|
||||||
timeoutDuration := time.Duration(timeout) * time.Second
|
timeoutDuration := time.Duration(timeout) * time.Second
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user