]> git.proxmox.com Git - qemu.git/commitdiff
virtio-serial: Let virtio-serial-bus know if all data was consumed
authorAmit Shah <amit.shah@redhat.com>
Mon, 13 Dec 2010 12:20:07 +0000 (17:50 +0530)
committerAmit Shah <amit.shah@redhat.com>
Thu, 20 Jan 2011 09:08:22 +0000 (14:38 +0530)
The have_data() API to hand off guest data to apps using virtio-serial
so far assumed all the data was consumed.  Relax this assumption.
Future commits will allow for incomplete writes.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
hw/virtio-console.c
hw/virtio-serial.h

index d0b935491d3229200ff52fdf869c5fa0431cd7a2..62624ec7802ee843df47fbe605c6ee6cd328d514 100644 (file)
@@ -20,11 +20,11 @@ typedef struct VirtConsole {
 
 
 /* Callback function that's called when the guest sends us data */
-static void flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
+static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
 {
     VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
 
-    qemu_chr_write(vcon->chr, buf, len);
+    return qemu_chr_write(vcon->chr, buf, len);
 }
 
 /* Readiness of the guest to accept data on a port */
index ff08c406819bfa62ea63ed81cd1d32e9fe18fec4..9cc0fb3543ebf02008b8dd3a284ed1e861c8c5ff 100644 (file)
@@ -137,10 +137,11 @@ struct VirtIOSerialPortInfo {
 
     /*
      * Guest wrote some data to the port. This data is handed over to
-     * the app via this callback.  The app is supposed to consume all
-     * the data that is presented to it.
+     * the app via this callback.  The app can return a size less than
+     * 'len'.  In this case, throttling will be enabled for this port.
      */
-    void (*have_data)(VirtIOSerialPort *port, const uint8_t *buf, size_t len);
+    ssize_t (*have_data)(VirtIOSerialPort *port, const uint8_t *buf,
+                         size_t len);
 };
 
 /* Interface to the virtio-serial bus */