Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 8a8b75e

Browse files
authored
Merge pull request #506 from laijs/qemu-quit-goroutimes
force all the go routines quitting when Close() in qemu
2 parents 0be3d63 + fea4adb commit 8a8b75e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

hypervisor/qemu/qemu.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ func (qc *QemuContext) Stats(ctx *hypervisor.VmContext) (*types.PodStats, error)
191191
}
192192

193193
func (qc *QemuContext) Close() {
194+
qc.qmp <- &QmpQuit{}
194195
qc.wdt <- "quit"
195196
<-qc.waitQmp
196197
qc.qemuLogFile.Close()

hypervisor/qemu/qmp_handler.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func qmpFail(err string, respond func(err error)) *QmpFinish {
133133
}
134134
}
135135

136-
func qmpReceiver(qmp chan QmpInteraction, wait chan int, decoder *json.Decoder) {
136+
func qmpReceiver(qmp chan QmpInteraction, wait chan<- int, decoder *json.Decoder) {
137137
glog.V(3).Info("Begin receive QMP message")
138138
for {
139139
rsp := &QmpResponse{}
@@ -279,7 +279,7 @@ func qmpHandler(ctx *hypervisor.VmContext) {
279279

280280
go qmpInitializer(ctx)
281281

282-
qc := ctx.DCtx.(*QemuContext)
282+
qc := qemuContext(ctx)
283283
timer := time.AfterFunc(10*time.Second, func() {
284284
glog.Warning("Initializer Timeout.")
285285
qc.qmp <- &QmpTimeout{}
@@ -335,6 +335,7 @@ func qmpHandler(ctx *hypervisor.VmContext) {
335335
ctx.Hub <- &hypervisor.Interrupted{Reason: msg.(*QmpInternalError).cause}
336336
case QMP_QUIT:
337337
handler = nil
338+
conn.Close()
338339
}
339340
}
340341

0 commit comments

Comments
 (0)