diff --git a/virt-v2v/cold/entrypoint.go b/virt-v2v/cold/entrypoint.go index 2b74eb345..92e248534 100644 --- a/virt-v2v/cold/entrypoint.go +++ b/virt-v2v/cold/entrypoint.go @@ -209,45 +209,46 @@ func executeVirtV2v(source string, args []string) (err error) { virtV2vMonitorCmd.Stdout = os.Stdout virtV2vMonitorCmd.Stderr = os.Stderr + var teeErr io.Reader + if source == OVA { + virtV2vStderrPipe, err := virtV2vMonitorCmd.StderrPipe() + if err != nil { + fmt.Printf("Error setting up stdout pipe: %v\n", err) + return err + } + teeErr = io.TeeReader(virtV2vStderrPipe, os.Stdout) + } + if err = virtV2vMonitorCmd.Start(); err != nil { fmt.Printf("Error executing monitor command: %v\n", err) return } - done := make(chan error, 1) - go func() { - if source == OVA { - scanner := bufio.NewScanner(r) - const maxCapacity = 1024 * 1024 - buf := make([]byte, 0, 64*1024) - scanner.Buffer(buf, maxCapacity) - - for scanner.Scan() { - line := scanner.Bytes() - if match := UEFI_RE.FindSubmatch(line); match != nil { - fmt.Println("UEFI firmware detected") - firmware = "efi" - } + if source == OVA { + scanner := bufio.NewScanner(teeErr) + const maxCapacity = 1024 * 1024 + buf := make([]byte, 0, 64*1024) + scanner.Buffer(buf, maxCapacity) + + for scanner.Scan() { + line := scanner.Bytes() + if match := UEFI_RE.FindSubmatch(line); match != nil { + fmt.Println("UEFI firmware detected") + firmware = "efi" } + } - if err := scanner.Err(); err != nil { - fmt.Println("Output query failed:", err) - done <- err - return - } + if err = scanner.Err(); err != nil { + fmt.Println("Output query failed:", err) + return } - done <- nil - }() + } if err = virtV2vCmd.Wait(); err != nil { fmt.Printf("Error waiting for virt-v2v to finish: %v\n", err) return } w.Close() - - if err = <-done; err != nil { - return err - } return }