diff --git a/cmd/virt-v2v-monitor/virt-v2v-monitor.go b/cmd/virt-v2v-monitor/virt-v2v-monitor.go index 43b4dd45e..5e4a8fbf2 100644 --- a/cmd/virt-v2v-monitor/virt-v2v-monitor.go +++ b/cmd/virt-v2v-monitor/virt-v2v-monitor.go @@ -91,6 +91,7 @@ func main() { err := scanner.Err() if err != nil { fmt.Println("virt-v2v monitoring: Output monitoring failed! ", err) + os.Exit(1) } if match := COPY_DISK_RE.FindSubmatch(line); match != nil { @@ -120,5 +121,6 @@ func main() { err := scanner.Err() if err != nil { fmt.Println("virt-v2v monitoring: Output monitoring failed! ", err) + os.Exit(1) } } diff --git a/virt-v2v/cold/entrypoint.go b/virt-v2v/cold/entrypoint.go index be2a37667..2b74eb345 100644 --- a/virt-v2v/cold/entrypoint.go +++ b/virt-v2v/cold/entrypoint.go @@ -207,36 +207,47 @@ 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 if err = virtV2vMonitorCmd.Start(); err != nil { fmt.Printf("Error executing monitor command: %v\n", err) return } - 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" + 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 err = scanner.Err(); err != nil { - fmt.Println("Output query failed:", err) - return err + if err := scanner.Err(); err != nil { + fmt.Println("Output query failed:", err) + done <- 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 }