From a5319c6be6caba40b6ca8a958121d0bf566d0605 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Tue, 15 Nov 2022 17:13:25 +0100 Subject: [PATCH] runtime: Start QEMU undaemonized QEMU has always been started daemonized since the beginning. I could not find any justification for that though, but it certainly introduces a problem : QEMU stops logging errors when started this way, which isn't accaptable from a support standpoint. The QEMU community discourages the use of -daemonize ; mostly because libvirt, QEMU's primary consummer, doesn't use this option and prefers getting errors from QEMU's stderr through a pipe in order to enforce rollover. Now that virtcontainers knows how to start QEMU with a pre- established QMP connection, let's start QEMU without -daemonize. This requires to handle the reaping of QEMU when it terminates. Since cmd.Wait() is blocking, call it from a goroutine. Signed-off-by: Greg Kurz --- src/runtime/virtcontainers/qemu.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runtime/virtcontainers/qemu.go b/src/runtime/virtcontainers/qemu.go index 8781747987..8bbba51da1 100644 --- a/src/runtime/virtcontainers/qemu.go +++ b/src/runtime/virtcontainers/qemu.go @@ -531,7 +531,7 @@ func (q *qemu) CreateVM(ctx context.Context, id string, network Network, hypervi NoDefaults: true, NoGraphic: true, NoReboot: true, - Daemonize: true, + Daemonize: false, MemPrealloc: q.config.MemPrealloc, HugePages: q.config.HugePages, IOMMUPlatform: q.config.IOMMUPlatform, @@ -951,6 +951,11 @@ func (q *qemu) StartVM(ctx context.Context, timeout int) error { // Wait for it to exit to assume that the QEMU daemon was // actually started. qemuCmd.Wait() + } else { + // Ensure the QEMU process is reaped after termination + go func() { + qemuCmd.Wait() + }() } err = q.waitVM(ctx, qmpConn, timeout)