From: "Cédric Le Goater" <clg@kaod.org>
To: Thomas Huth <thuth@redhat.com>, Amit Shah <amit@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<virtualization@lists.linux-foundation.org>,
<linux-kernel@vger.kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2] virtio_console: Introduce an ID allocator for virtual console numbers
Date: Tue, 22 Nov 2022 14:45:44 +0100 [thread overview]
Message-ID: <9a59c0da-cdf2-d97f-2520-3cb803089bca@kaod.org> (raw)
In-Reply-To: <81612d82-7fc1-e2be-38a2-0db8314248cc@redhat.com>
On 11/22/22 12:12, Thomas Huth wrote:
> On 14/11/2022 18.38, Cédric Le Goater wrote:
>> When a virtio console port is initialized, it is registered as an hvc
>> console using a virtual console number. If a KVM guest is started with
>> multiple virtio console devices, the same vtermno (or virtual console
>> number) can be used to allocate different hvc consoles, which leads to
>> various communication problems later on.
>>
>> This is also reported in debugfs :
>>
>> # grep vtermno /sys/kernel/debug/virtio-ports/*
>> /sys/kernel/debug/virtio-ports/vport1p1:console_vtermno: 1
>> /sys/kernel/debug/virtio-ports/vport2p1:console_vtermno: 1
>> /sys/kernel/debug/virtio-ports/vport3p1:console_vtermno: 2
>> /sys/kernel/debug/virtio-ports/vport4p1:console_vtermno: 3
>>
>> Replace the next_vtermno global with an ID allocator and start the
>> allocation at 1 as it is today. Also recycle IDs when a console port
>> is removed.
>
> Sounds like a good idea!
>
>> @@ -1244,8 +1236,11 @@ static int init_port_console(struct port *port)
>> * pointers. The final argument is the output buffer size: we
>> * can do any size, so we put PAGE_SIZE here.
>> */
>> - port->cons.vtermno = pdrvdata.next_vtermno;
>> + ret = ida_alloc_range(&vtermno_ida, 1, ~0, GFP_KERNEL);
>
> Just cosmetics: I think you could use ida_alloc_min() instead.
>
>> + if (ret < 0)
>> + return ret;
>> + port->cons.vtermno = ret;
>> port->cons.hvc = hvc_alloc(port->cons.vtermno, 0, &hv_ops, PAGE_SIZE);
>> if (IS_ERR(port->cons.hvc)) {
>> ret = PTR_ERR(port->cons.hvc);
>
> What if this if (IS_ERR()) error happens? The code seems to return early in this case - shouldn't the ID be freed again in this case?
Oh yes. I forgot that.
Thanks,
C.
next prev parent reply other threads:[~2022-11-22 13:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 17:38 Cédric Le Goater
2022-11-22 11:12 ` Thomas Huth
2022-11-22 13:45 ` Cédric Le Goater [this message]
2022-11-22 17:03 ` Amit Shah
2022-11-23 10:17 ` Cédric Le Goater
2022-11-23 10:36 ` Amit Shah
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=9a59c0da-cdf2-d97f-2520-3cb803089bca@kaod.org \
--to=clg@kaod.org \
--cc=amit@kernel.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=thuth@redhat.com \
--cc=virtualization@lists.linux-foundation.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
all inboxes | Powered by JetHome®