* [Qemu-devel] [PATCH for-2.1 1/1] virtio-serial-bus: keep port 0 reserved for virtconsole even on unplug
@ 2014-07-15 9:23 Amit Shah
2014-07-15 9:29 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Amit Shah @ 2014-07-15 9:23 UTC (permalink / raw)
To: qemu list; +Cc: Amit Shah, Amos Kong
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>
---
hw/char/virtio-serial-bus.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 07bebc0..e1808b0 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -800,7 +800,14 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)
unsigned int i;
i = port_id / 32;
- vser->ports_map[i] &= ~(1U << (port_id % 32));
+ if (port_id) {
+ /*
+ * Don't mark port 0 removed -- we explicitly reserve it for
+ * backward compat with older guests, and a device unplug of
+ * virtconsole removes the reservation.
+ */
+ vser->ports_map[i] &= ~(1U << (port_id % 32));
+ }
port = find_port_by_id(vser, port_id);
/*
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.1 1/1] virtio-serial-bus: keep port 0 reserved for virtconsole even on unplug
2014-07-15 9:23 [Qemu-devel] [PATCH for-2.1 1/1] virtio-serial-bus: keep port 0 reserved for virtconsole even on unplug Amit Shah
@ 2014-07-15 9:29 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-07-15 9:29 UTC (permalink / raw)
To: Amit Shah, qemu list; +Cc: Amos Kong
Il 15/07/2014 11:23, Amit Shah ha scritto:
> i = port_id / 32;
This can also be moved inside the if.
Paolo
> - vser->ports_map[i] &= ~(1U << (port_id % 32));
> + if (port_id) {
> + /*
> + * Don't mark port 0 removed -- we explicitly reserve it for
> + * backward compat with older guests, and a device unplug of
> + * virtconsole removes the reservation.
> + */
> + vser->ports_map[i] &= ~(1U << (port_id % 32));
> + }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-15 9:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-15 9:23 [Qemu-devel] [PATCH for-2.1 1/1] virtio-serial-bus: keep port 0 reserved for virtconsole even on unplug Amit Shah
2014-07-15 9:29 ` Paolo Bonzini
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).