summaryrefslogtreecommitdiff
path: root/hw/virtio-serial-bus.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-01-20 00:36:54 +0530
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-20 08:25:23 -0600
commit160600fd137a3a6f0d6a09579cf2282152f842ab (patch)
treeb5cb507027f5ec5c17a6f9df9bcdc231f555b87f /hw/virtio-serial-bus.c
parent6663a1956eb628f1bddc96d2cab361e039df5571 (diff)
downloadqemu-160600fd137a3a6f0d6a09579cf2282152f842ab.tar.gz
virtio-serial-bus: Add a port 'name' property for port discovery in guests
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 <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-serial-bus.c')
-rw-r--r--hw/virtio-serial-bus.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 5bf2990476..7e100d0def 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -204,6 +204,8 @@ static void handle_control_message(VirtIOSerial *vser, void *buf)
{
struct VirtIOSerialPort *port;
struct virtio_console_control cpkt, *gcpkt;
+ uint8_t *buffer;
+ size_t buffer_len;
gcpkt = buf;
port = find_port_by_id(vser, ldl_p(&gcpkt->id));
@@ -226,6 +228,21 @@ static void handle_control_message(VirtIOSerial *vser, void *buf)
send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
}
+ if (port->name) {
+ stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME);
+ stw_p(&cpkt.value, 1);
+
+ buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
+ buffer = qemu_malloc(buffer_len);
+
+ memcpy(buffer, &cpkt, sizeof(cpkt));
+ memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
+ buffer[buffer_len - 1] = 0;
+
+ send_control_msg(port, buffer, buffer_len);
+ qemu_free(buffer);
+ }
+
if (port->host_connected) {
send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
}