From: Filip Hejsek <filip.hejsek@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 0/2] io: make sure we don't close stdio fds
Date: Tue, 13 Oct 2026 01:21:36 +0200 [thread overview]
Message-ID: <20261013-fix-stdio-close-v1-0-4ecfa416c7bc@gmail.com> (raw)
The stdio chardev currently closes the stdin and stdout fds when it is
destroyed. This means that, assuming char0 is a stdio chardev, invoking
the HMP command
chardev-change char0 null
will cause QEMU to run with descriptors 0 and 1 closed. That's not a
great situation, as:
- the stdio chardev cannot be recreated
- code assuming fds 0 and 1 are open will misbehave
- the fds 0 and 1 will get assigned to newly opened files, possibly
causing them to be confused for actual stdin/stdout
The fist patch fixes the problem by duplicating the fds before they get
passed to qio_channel_file_new_fd(), the second patch adds a warning
that is printed when qio_channel_file_new_fd() is called with a stdio
fd.
Signed-off-by: Filip Hejsek <filip.hejsek@gmail.com>
---
Filip Hejsek (2):
char-stdio: avoid closing stdio fds
io: report a warning when a file channel is created from a stdio fd
chardev/char-stdio.c | 13 ++++++++++++-
io/channel-file.c | 6 ++++++
2 files changed, 18 insertions(+), 1 deletion(-)
---
base-commit: 615ece3c406b262996e569f29ea6eed0d81c4d8d
change-id: 20261012-fix-stdio-close-98864055d473
Best regards,
--
Filip Hejsek <filip.hejsek@gmail.com>
next reply other threads:[~2026-10-12 23:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 23:21 Filip Hejsek [this message]
2026-10-12 23:21 ` [PATCH 1/2] char-stdio: avoid closing stdio fds Filip Hejsek
2026-10-13 6:26 ` marcandre.lureau
2026-10-12 23:21 ` [PATCH 2/2] io: report a warning when a file channel is created from a stdio fd Filip Hejsek
2026-10-13 6:26 ` marcandre.lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261013-fix-stdio-close-v1-0-4ecfa416c7bc@gmail.com \
--to=filip.hejsek@gmail.com \
--cc=berrange@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.