From patchwork Wed Nov 3 17:05:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 516792 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp904754iml; Wed, 3 Nov 2021 10:22:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYMUwU2GQH2WuN2ToPGCUh8CBukUX2XHfq8wwbpMn9ALKHmdhCKxwcFIHNAjYSVR75Dkpk X-Received: by 2002:a05:6830:55b:: with SMTP id l27mr33773575otb.309.1635960163396; Wed, 03 Nov 2021 10:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635960163; cv=none; d=google.com; s=arc-20160816; b=CWuqXYOgitAAuvNQ0n65sMwYf4guhkRXsIXyZlgE3orUff1pKTfSJbu+9PUaeHZIVx BxDumflTDpbhBGH3qJ4mBEUkjNcLUuCI+btVKppWOa1r9jDOzCfCCgELx5CO8yC0KoEj 74dYn5/s9TjQMoNKqmYOh/3FZkkfHxHLJkQRqDsEHCoboGxxY+ap4H9jW4zks64y3kWP tio9ORIOmxdpIVR5Bmwg7+tOrHtsjdNMnIcnfD4YMVEbaDc8rio3OFS0bC53vAOCz3fL 1xkR14d52XBBCaTn8E/14twUhaGI71W01lB3kpZllg+y3R2zOaQ/M6ODX5Lslvyirpga i2bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=e6CwJoaEBKjKMYgYgC8qHcZ4bffXqP81dXgxRXrPAtQ=; b=AzSpMlPZ/fFOy8aDTIDknimSOpvnbQIYJ+TZ2RA86QHFQ9gBfhBoaeQ+kWiGikP2xi TGaO+hp/yahIC8WtvXAZXCUHKSHWJv65KloJXDEOnvg2evreDympxGmdYiPqDsIYZS7w WjjA9D2rvfUDfBZRY4pGWPkIm+0WER2OgpEYZ33PIvrYcw2TlgKqtUuewbpnsD2iii+H usycr/LHEqfpMwaTb7bY6/jk6sUS5Qg5hT2bs2hjTmbfzhEtuuYAlOmpBOc7tpwphsSc Tn7pZvM7V3sQmoI9E3rmkKohj6y8rja0LEqGlb/GuyQCiy6bTtCGGC/PkoSdkemnR+pp dP4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=evIiUVtA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y16si3435151otk.236.2021.11.03.10.22.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Nov 2021 10:22:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=evIiUVtA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miJyE-0002aV-TW for patch@linaro.org; Wed, 03 Nov 2021 13:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miJoI-0005cp-Qs for qemu-devel@nongnu.org; Wed, 03 Nov 2021 13:12:26 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:40728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1miJoG-00074t-Hg for qemu-devel@nongnu.org; Wed, 03 Nov 2021 13:12:26 -0400 Received: by mail-wr1-x42d.google.com with SMTP id r8so4632414wra.7 for ; Wed, 03 Nov 2021 10:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e6CwJoaEBKjKMYgYgC8qHcZ4bffXqP81dXgxRXrPAtQ=; b=evIiUVtAEpCKDO2ru74x1vhM30z6THoYQrEBhGxB5c93JfFR0iq/KxMmL/E8mgh/LD Tdn0L8t5IZJ2/F9lyssesxL6TowrrJSq/VZw2R30+h70TxbcO2C7ClnFMscfGc2yY8+U OoJLi9KSRzhjchUfbwpw6RlPH9ngrnUPR/Sl2ICujRWMbOakM5AnSMFozXiT+Z2pQ5Fb MEOIs80o4reFbrXzcit0eRQAx8rPK7TvJItL/kXEfjP4rlbwJw/8W7R6kSlnvo59xI/r z6sn1Q71fS/l7mP0ZEGKNB6Rv0/l2MgmShgQFqcighThtu/NTVSnQIbgaWIRXw50KJJn ntMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e6CwJoaEBKjKMYgYgC8qHcZ4bffXqP81dXgxRXrPAtQ=; b=pHhCMrYYhmMIH833wD4c6dC/0/GFkU3qXElRaETgG6hs3gEurMT/aZVervgdvm7VuX p2KmMnpkZw7J5s1Y/sxAKJ3HrpEmi6/uIoJ6RlxPAY5ma+/VoKI8L85n0puSdoqXcipk OLSVc+V30/bGEjsiTV0Uyv30OCl7dcxPU7cbPs1CgskSWfh+1ZGr3ytPL3YL+3y2t+/s dqOfxQEQULvmFuBFF1sBThBOVj88pjaYjVGWCOZH/qzBjQPrw8RbvXvunjeao3f7alte J/8aFyxGU+08pEqZNTn3TbItV6zXbOE+eeVBMOkPDrvZ0WW3pyY83CfSqXUAUJWEjwHG vdQA== X-Gm-Message-State: AOAM530iQ0eL2akph1+CxGxviV8Ku4jmknQqLldJEZ80N+UuGXHALH2x h3iUtxCOoDIUAX5bPEIDoSc/Dg== X-Received: by 2002:a05:6000:1842:: with SMTP id c2mr31651325wri.301.1635959543152; Wed, 03 Nov 2021 10:12:23 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 10sm7013942wme.27.2021.11.03.10.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 10:12:18 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C2C6D1FFAE; Wed, 3 Nov 2021 17:05:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 15/21] chardev: don't exit() straight away on C-a x Date: Wed, 3 Nov 2021 17:05:52 +0000 Message-Id: <20211103170558.717981-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211103170558.717981-1-alex.bennee@linaro.org> References: <20211103170558.717981-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, =?utf-8?q?Lukas_?= =?utf-8?q?J=C3=BCnger?= , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" While there are a number of uses in the code-base of the exit(0) pattern it gets in the way of clean exit which can do all of it's house-keeping. In particular it was reported that you can crash plugins this way because TCG can still be running on other threads when the atexit callback is called. Use qmp_quit() instead which takes care of some housekeeping before triggering the shutdown. Signed-off-by: Alex Bennée Reported-by: Lukas Jünger Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Acked-by: Paolo Bonzini Message-Id: <20211026102234.3961636-19-alex.bennee@linaro.org> -- 2.30.2 diff --git a/chardev/char-mux.c b/chardev/char-mux.c index ada0c6866f..ee2d47b20d 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -28,6 +28,7 @@ #include "qemu/option.h" #include "chardev/char.h" #include "sysemu/block-backend.h" +#include "qapi/qapi-commands-control.h" #include "chardev-internal.h" /* MUX driver for serial I/O splitting */ @@ -157,7 +158,7 @@ static int mux_proc_byte(Chardev *chr, MuxChardev *d, int ch) { const char *term = "QEMU: Terminated\n\r"; qemu_chr_write_all(chr, (uint8_t *)term, strlen(term)); - exit(0); + qmp_quit(NULL); break; } case 's': diff --git a/stubs/qmp-quit.c b/stubs/qmp-quit.c new file mode 100644 index 0000000000..a3ff47f7bd --- /dev/null +++ b/stubs/qmp-quit.c @@ -0,0 +1,8 @@ +#include "qemu/osdep.h" +#include "qapi/qapi-commands-control.h" +#include "qapi/qmp/dispatch.h" + +void qmp_quit(Error **errp) +{ + g_assert_not_reached(); +} diff --git a/stubs/meson.build b/stubs/meson.build index f6aa3aa94f..71469c1d50 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -31,6 +31,7 @@ stub_ss.add(files('pci-bus.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('qmp_memory_device.c')) stub_ss.add(files('qmp-command-available.c')) +stub_ss.add(files('qmp-quit.c')) stub_ss.add(files('qtest.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('ramfb.c'))