From: Amos Kong <akong@redhat.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu list <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v3 for-2.1 1/1] virtio-serial-bus: keep port 0 reserved for virtconsole even on unplug
Date: Wed, 16 Jul 2014 07:56:54 +0800 [thread overview]
Message-ID: <20140715235654.GB20389@z.redhat.com> (raw)
In-Reply-To: <ef9d322b3faa0792f27bd512b8867c2b993ecda1.1405418492.git.amit.shah@redhat.com>
On Tue, Jul 15, 2014 at 03:31:32PM +0530, Amit Shah wrote:
> We keep port 0 reserved for compat with older guests, where only
> virtio-console was expected. Even if a system is started without a
> virtio-console port, port #0 is kept aside. However, after a
> virtconsole port is unplugged, port id 0 became available, and the next
> hotplug of a virtserialport caused failure due to it not being a console
> port.
>
> Steps to reproduce:
>
> $ ./x86_64-softmmu/qemu-system-x86_64 -m 512 -cpu host -enable-kvm -device virtio-serial-pci -monitor stdio -vnc :1
> QEMU 2.0.91 monitor - type 'help' for more information
> (qemu) device_add virtconsole,id=p1
> (qemu) device_del p1
> (qemu) device_add virtserialport,id=p1
> Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility.
> Device 'virtserialport' could not be initialized
> (qemu) quit
>
> Reported-by: dengmin <mdeng@redhat.com>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Amos Kong <akong@redhat.com>
> ---
> v2:
> - move calculation of 'i' inside if stmt too (Paolo)
> - re-word comment
>
> v3:
> - fix typo in comment
> ---
> hw/char/virtio-serial-bus.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index 07bebc0..23123b7 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -797,10 +797,18 @@ static void add_port(VirtIOSerial *vser, uint32_t port_id)
> static void remove_port(VirtIOSerial *vser, uint32_t port_id)
> {
> VirtIOSerialPort *port;
> - unsigned int i;
>
> - i = port_id / 32;
> - vser->ports_map[i] &= ~(1U << (port_id % 32));
> + /*
> + * Don't mark port 0 removed -- we explicitly reserve it for
> + * backward compat with older guests, ensure a virtconsole device
> + * unplug retains the reservation.
> + */
> + if (port_id) {
> + unsigned int i;
> +
> + i = port_id / 32;
> + vser->ports_map[i] &= ~(1U << (port_id % 32));
> + }
>
> port = find_port_by_id(vser, port_id);
> /*
> --
> 1.9.3
--
Amos.
prev parent reply other threads:[~2014-07-15 23:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 10:01 [Qemu-devel] [PATCH v3 for-2.1 1/1] virtio-serial-bus: keep port 0 reserved for virtconsole even on unplug Amit Shah
2014-07-15 23:56 ` Amos Kong [this message]
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=20140715235654.GB20389@z.redhat.com \
--to=akong@redhat.com \
--cc=amit.shah@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).