From nobody Tue Feb 10 06:52:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646420490; cv=none; d=zohomail.com; s=zohoarc; b=UQpfjXm9mRi4P4PzHW0vG5uCY3pLp/qFw+xvyLYGkI5JFglNIBBdTIdTODUbQcu/xzAfBBrGeBqpPZfZMDl0OHR0QLRE5zEqdVnFCBv8DsoiL+7ZmR/6rP0Ddvi1U6aKJJPjt5Y9zZzRBKVPH9nwAbMU8ig8TtFVV9Ri4qzygQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646420490; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YPLLuTRTyOTntH+3PhTuadV8ba4sTU1iWiZPc25GVYk=; b=lzHMY5ad45oevUGqn3UUDN+2aGsYOjwXIGJpnpzym+HbWd0aevbMHZmP89u7+Xx64P3L0CPtzoDVY8sL2sig/T+tE00JxN4QxBQJWFDdUU2Bv9SgvaxqaNlG3zhTgKxlOOVrL8s/OhsTnHeCTLQHA0Pf1LJNn02iHt6TykSYzDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1646420490959999.6890439398883; Fri, 4 Mar 2022 11:01:30 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-274-tZFoCelUPByFGUPNHLAClA-1; Fri, 04 Mar 2022 14:01:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF15F8031E1; Fri, 4 Mar 2022 19:01:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C09960853; Fri, 4 Mar 2022 19:01:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5E8231809CB5; Fri, 4 Mar 2022 19:01:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 224J1LwR032116 for ; Fri, 4 Mar 2022 14:01:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4F33160BF3; Fri, 4 Mar 2022 19:01:21 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.194.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 966B860BF1; Fri, 4 Mar 2022 19:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646420489; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YPLLuTRTyOTntH+3PhTuadV8ba4sTU1iWiZPc25GVYk=; b=UWFjf3V9YlH/2tdeoP5TUY49Kp6z+Wb4SiMsjIhnJue9OfevLLNQuvPtyaqlGEM/cVEVr4 kgBzN21/x767ceEkIWK16PnfA739EqaPqDKYDtdgHOnzkyXLFOT69worlZdeoai6htHTr6 I7P2DKW8SOotPezlRDNN4nBEtySN4as= X-MC-Unique: tZFoCelUPByFGUPNHLAClA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 6/8] chardev: add API to block use of the stdio implementation Date: Fri, 4 Mar 2022 18:56:18 +0000 Message-Id: <20220304185620.3272401-7-berrange@redhat.com> In-Reply-To: <20220304185620.3272401-1-berrange@redhat.com> References: <20220304185620.3272401-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , libvir-list@redhat.com, Stefan Weil , Hanna Reitz , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eric Blake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646420491473100001 When daemonizing QEMU it is not possible to use the stdio chardev backend because the file descriptors are connected to /dev/null. Currently the chardev checks for this scenario directly, but to decouple it from the system emulator daemonizing code, we reverse the relationship. Now the system emulator calls a helper to explicitly disable use of the stdio backend. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Eric Blake --- chardev/char-stdio.c | 12 ++++++++++-- include/chardev/char-stdio.h | 29 +++++++++++++++++++++++++++++ softmmu/vl.c | 2 ++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 include/chardev/char-stdio.h diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c index 403da308c9..bab0f5ade1 100644 --- a/chardev/char-stdio.c +++ b/chardev/char-stdio.c @@ -28,6 +28,7 @@ #include "qemu/sockets.h" #include "qapi/error.h" #include "chardev/char.h" +#include "chardev/char-stdio.h" =20 #ifdef _WIN32 #include "chardev/char-win.h" @@ -37,6 +38,13 @@ #include "chardev/char-fd.h" #endif =20 +static bool stdio_disabled; + +void qemu_chr_stdio_disable(void) +{ + stdio_disabled =3D true; +} + #ifndef _WIN32 /* init terminal so that we can grab keys */ static struct termios oldtty; @@ -90,8 +98,8 @@ static void qemu_chr_open_stdio(Chardev *chr, ChardevStdio *opts =3D backend->u.stdio.data; struct sigaction act; =20 - if (is_daemonized()) { - error_setg(errp, "cannot use stdio with -daemonize"); + if (stdio_disabled) { + error_setg(errp, "cannot use stdio with this configuration"); return; } =20 diff --git a/include/chardev/char-stdio.h b/include/chardev/char-stdio.h new file mode 100644 index 0000000000..eae93a2900 --- /dev/null +++ b/include/chardev/char-stdio.h @@ -0,0 +1,29 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#ifndef CHAR_STDIO_H +#define CHAR_STDIO_H + +void qemu_chr_stdio_disable(void); + +#endif /* CHAR_STDIO_H */ diff --git a/softmmu/vl.c b/softmmu/vl.c index 30342b9df2..12b714795d 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -69,6 +69,7 @@ #include "exec/gdbstub.h" #include "qemu/timer.h" #include "chardev/char.h" +#include "chardev/char-stdio.h" #include "qemu/bitmap.h" #include "qemu/log.h" #include "sysemu/blockdev.h" @@ -3667,6 +3668,7 @@ void qemu_init(int argc, char **argv, char **envp) } if (is_daemonized()) { qemu_log_stdio_disable(); + qemu_chr_stdio_disable(); } } } --=20 2.34.1