From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1] ve/vtty: fix console attach failing with EBUSY while the CT closes the tty
Date: Mon, 2 Nov 2026 16:17:25 +0100 [thread overview]
Message-ID: <ba5a9a50-77a1-4aab-9aa1-5d59a86f66ac@virtuozzo.com> (raw)
In-Reply-To: <20261029223502.1437160-1-den@openvz.org>
Hi Denis,
> Return -EAGAIN for the dying pair. Nothing else on the
> VE_CONFIGURE_OPEN_TTY path returns -EAGAIN, so it can only mean "try
> again", which is what vzctl will do.
Agreed, together with your vzctl change ("vzctl console: retry opening
a CT tty the CT is still closing") the bug is fixed. But only for the new
vzctl: every vzctl already installed tries the ioctl once and now fails
with "Resource temporarily unavailable" instead of "Device or resource
busy".
> An in-CT open of such a pair gets
> -EAGAIN from tty_reopen() and tty_open() retries it the same way.
> Retrying inside vtty_open_master() instead would have to drop tty_mutex
> for release_tty() to progress, and the global vtty context with it.
We can fix it for old and new vzctl alike by doing what mainline did
for the same window in 7f22f6c935cda ("tty: Retry failed reopen if tty
teardown in-progress"), retry in the kernel:
if (IS_ERR(tty)) {
tty_free_file(filp);
retval = PTR_ERR(tty);
if (retval != -EAGAIN || signal_pending(current))
return retval;
schedule();
goto retry_open;
}
Dropping tty_mutex and the vtty context is not a problem: err_unlock
already does exactly that. So in vtty_open_master():
retry:
mutex_lock(&tty_mutex);
vtty_set_context(veid);
...
if (!created && slave->count == 0) {
tty_unlock(slave);
vtty_drop_context();
mutex_unlock(&tty_mutex);
if (signal_pending(current)) {
ret = -EAGAIN;
goto err_free_file; /* tty_free_file() onwards */
}
schedule();
goto retry;
}
The fd and the file stay allocated across the loop, nothing else
changes.
The loop always ends: we get there only with master->count == 0 and
slave->count == 0, i.e. tty_release() has decided on the final close,
so the closer is already in tty_release_struct() on its way to
release_tty() -> vtty_shutdown() -> vtty_map_clear(). Once we drop
tty_mutex it gets through, and the next lookup misses and allocates a
fresh pair. The BSD master pty that Peter excluded from the retry in
mainline (its slave fds may stay open forever) is not our case: here
both counts are already zero.
What we get:
- old vzctl works with the kernel update alone, the vzctl change becomes
optional;
- -EBUSY keeps meaning "console attached" only, -EAGAIN is left only for
a pending signal;
- it goes on top of what is committed, no revert needed.
Could you send that as a follow-up on VSTOR-152365?
--
Konstantin
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-02 15:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 22:35 Denis V. Lunev
2026-10-29 22:38 ` no-reply
2026-11-02 10:41 ` Konstantin Khorenko
2026-11-02 10:42 ` Konstantin Khorenko
2026-11-02 15:17 ` Konstantin Khorenko [this message]
2026-11-02 17:15 ` [Devel] [PATCH hci-8.1 0/2] ve/vtty: wait for a closing CT tty in the kernel, drop the EAGAIN return Denis V. Lunev
2026-11-02 17:15 ` [Devel] [PATCH hci-8.1 1/2] Revert "ve/vtty: fix console attach failing with EBUSY while the CT closes the tty" Denis V. Lunev
2026-11-02 17:48 ` no-reply
2026-11-02 17:15 ` [Devel] [PATCH hci-8.1 2/2] ve/vtty: wait for a closing CT tty instead of failing the console attach Denis V. Lunev
2026-11-02 17:51 ` no-reply
2026-11-02 18:09 ` Vladimir Riabchun
2026-11-03 12:42 ` Denis V. Lunev
2026-11-03 15:54 ` [Devel] [PATCH hci-8.1 0/2] ve/vtty: wait for a closing CT tty in the kernel, drop the EAGAIN return Konstantin Khorenko
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=ba5a9a50-77a1-4aab-9aa1-5d59a86f66ac@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=den@openvz.org \
--cc=devel@openvz.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox