virtio-serial api: guest_writable callback for users

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVCrvfAAoJEB6aO1+FQIO2RmgP/i+u6BgD7DVu8temyzYv+97s
 duuftH7IuEKbdD9CH90LMH/kTBimcjdAbE63qjlAQoP0oLq6Wf4/uDX5HE1cpijo
 44z1i02Beg5CttlptFbTSgQF4fNOjezwXQoltbKCy3H9iTHxOqllqnkWqaom1v6Z
 UHvw1RhH6QkWLRKRi6e2c/4r2k/0mvuV2zRAwr/c4kITUmi+UwM+eC3iAYjA57we
 /hSQkqBFU3M6WdaGSsVAUNH6b9nthCKcYSBwUaCXdWoLUWDk0UP1+KzllrSp/L0K
 i+Iqw3uWaLCWiJGKekEB9Em7quzvmxmjAuPO4h2RwwLO7OO/e2zysJzbSlHdBp5m
 KlhDakV8fjtdWVPdAIyP4evWqDW24Jv0+KNUIcUZjgVxVQ6yBy/NfgItPeDwjXht
 GTA6OFed5+P9j4Gi0XnRvaDdF8LmqR2qVn6ygsojCjm5JOA5NyZNvMg9kKhRWYID
 tJPa1fmOa8gx/ma3gqvZ26lpBhGp0XUW3tJYCwxqI7RygEsNTCplX2FxZXCtqIQ4
 GzCyIl+4niSPhoDXSKEwKSVRo2LZhnMQzAZe/Pcop72wszMY/sKEhUiCLkn4axtt
 CPbk8KQsqlvxYpMeuY4cIKlO80EbJ9VOeGvtyuxIrR/Z7OOq/ydIvZS1+8NCKofV
 kfPbcsMBai1g4r0sieaG
 =M9Ly
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/amit/tags/vser-for-2.3-3' into staging

virtio-serial api: guest_writable callback for users

# gpg: Signature made Thu Mar 19 12:06:55 2015 GMT using RSA key ID 854083B6
# gpg: Good signature from "Amit Shah <amit@amitshah.net>"
# gpg:                 aka "Amit Shah <amit@kernel.org>"
# gpg:                 aka "Amit Shah <amitshah@gmx.net>"

* remotes/amit/tags/vser-for-2.3-3:
  virtio: serial: expose a 'guest_writable' callback for users

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
master
Peter Maydell 2015-03-19 16:46:32 +00:00
commit 33a8d5b72d
2 changed files with 42 additions and 0 deletions

View File

@ -465,6 +465,37 @@ static void handle_output(VirtIODevice *vdev, VirtQueue *vq)
static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
{
/*
* Users of virtio-serial would like to know when guest becomes
* writable again -- i.e. if a vq had stuff queued up and the
* guest wasn't reading at all, the host would not be able to
* write to the vq anymore. Once the guest reads off something,
* we can start queueing things up again. However, this call is
* made for each buffer addition by the guest -- even though free
* buffers existed prior to the current buffer addition. This is
* done so as not to maintain previous state, which will need
* additional live-migration-related changes.
*/
VirtIOSerial *vser;
VirtIOSerialPort *port;
VirtIOSerialPortClass *vsc;
vser = VIRTIO_SERIAL(vdev);
port = find_port_by_vq(vser, vq);
if (!port) {
return;
}
vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
/*
* If guest_connected is false, this call is being made by the
* early-boot queueing up of descriptors, which is just noise for
* the host apps -- don't disturb them in that case.
*/
if (port->guest_connected && port->host_connected && vsc->guest_writable) {
vsc->guest_writable(port);
}
}
static uint32_t get_features(VirtIODevice *vdev, uint32_t features)

View File

@ -60,6 +60,17 @@ typedef struct VirtIOSerialPortClass {
/* Guest is now ready to accept data (virtqueues set up). */
void (*guest_ready)(VirtIOSerialPort *port);
/*
* Guest has enqueued a buffer for the host to write into.
* Called each time a buffer is enqueued by the guest;
* irrespective of whether there already were free buffers the
* host could have consumed.
*
* This is dependent on both the guest and host end being
* connected.
*/
void (*guest_writable)(VirtIOSerialPort *port);
/*
* Guest wrote some data to the port. This data is handed over to
* the app via this callback. The app can return a size less than