qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/8] virtio-serial-bus: Add a port 'name' proper


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 4/8] virtio-serial-bus: Add a port 'name' property for port discovery in guests
Date: Wed, 23 Dec 2009 17:15:55 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Thunderbird/3.0

On 12/23/2009 01:52 PM, Amit Shah wrote:
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;

This isn't endian-safe. The guest may have a different endianness than the host.

Regards,

Anthony Liguori




reply via email to

[Prev in Thread] Current Thread [Next in Thread]