The port 'id' or number is internal state between the guest kernel and
our bus implementation. This is invocation-dependent and isn't part of
the guest-host ABI.
To correcly enumerate and map ports between the host and the guest, the
'name' property is used.
Example:
-device virtserialport,name=org.qemu.port.0
This invocation will get us a char device in the guest at:
/dev/virtio-ports/org.qemu.port.0
which can be a symlink to
/dev/vport0p3
This 'name' property is exposed by the guest kernel in a sysfs
attribute:
/sys/kernel/virtio-ports/vport0p3/name
A simple udev script can pick up this name and create the symlink
mentioned above.
Signed-off-by: Amit Shah<address@hidden>
---
hw/virtio-serial-bus.c | 16 ++++++++++++++++
hw/virtio-serial.c | 1 +
hw/virtio-serial.h | 8 ++++++++
3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 27120da..b683109 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -236,6 +236,8 @@ static void handle_control_message(VirtIOSerial *vser, void
*buf)
{
struct VirtIOSerialPort *port;
struct virtio_console_control *cpkt;
+ uint8_t *buffer;
+ size_t buffer_len;
cpkt = buf;
port = find_port_by_id(vser, cpkt->id);
@@ -254,6 +256,20 @@ static void handle_control_message(VirtIOSerial *vser,
void *buf)
if (port->is_console) {
send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
}
+ if (port->name) {
+ cpkt->event = VIRTIO_CONSOLE_PORT_NAME;
+ cpkt->value = 1;