From 2fb5e9b0d49bb203026bf2f8cbeaa5c0aa306bb6 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 20 Jan 2016 14:01:45 +0100 Subject: vm/qemu: fix latent output reading bug --- vm/kvm/kvm.go | 6 ++++-- vm/qemu/qemu.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/vm/kvm/kvm.go b/vm/kvm/kvm.go index 40add4604..2f1fb890b 100644 --- a/vm/kvm/kvm.go +++ b/vm/kvm/kvm.go @@ -217,8 +217,10 @@ func (inst *instance) Run(timeout time.Duration, command string) (<-chan []byte, signal := func(err error) { time.Sleep(3 * time.Second) // wait for any pending output inst.mu.Lock() - inst.outputB = nil - inst.outputC = nil + if inst.outputC == outputC { + inst.outputB = nil + inst.outputC = nil + } inst.mu.Unlock() errorC <- err } diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 32af2d732..5571f2382 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -277,8 +277,10 @@ func (inst *instance) Run(timeout time.Duration, command string) (<-chan []byte, signal := func(err error) { time.Sleep(3 * time.Second) // wait for any pending output inst.mu.Lock() - inst.outputB = nil - inst.outputC = nil + if inst.outputC == outputC { + inst.outputB = nil + inst.outputC = nil + } inst.mu.Unlock() select { case errorC <- err: -- cgit mrf-deployment