Skip to content

Commit

Permalink
fix TeeReader for firmware from OVA
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed May 20, 2024
1 parent be9cc05 commit 133a960
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions virt-v2v/cold/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,16 @@ func executeVirtV2v(source string, args []string) (err error) {

virtV2vMonitorCmd := exec.Command("/usr/local/bin/virt-v2v-monitor")
virtV2vMonitorCmd.Stdin = r
virtV2vMonitorCmd.Stdout = os.Stdout
virtV2vMonitorCmd.Stderr = os.Stderr

var teeErr io.Reader
var teeOut io.Reader
if source == OVA {
virtV2vStderrPipe, err := virtV2vMonitorCmd.StderrPipe()
virtV2vStdoutPipe, err := virtV2vMonitorCmd.StdoutPipe()
if err != nil {
fmt.Printf("Error setting up stdout pipe: %v\n", err)
return err
}
teeErr = io.TeeReader(virtV2vStderrPipe, os.Stdout)
teeOut = io.TeeReader(virtV2vStdoutPipe, os.Stdout)
}

if err = virtV2vMonitorCmd.Start(); err != nil {
Expand All @@ -225,7 +224,7 @@ func executeVirtV2v(source string, args []string) (err error) {
}

if source == OVA {
scanner := bufio.NewScanner(teeErr)
scanner := bufio.NewScanner(teeOut)
const maxCapacity = 1024 * 1024
buf := make([]byte, 0, 64*1024)
scanner.Buffer(buf, maxCapacity)
Expand Down

0 comments on commit 133a960

Please sign in to comment.