summaryrefslogtreecommitdiff
path: root/hw/char
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-03-19 16:46:32 +0000
committerPeter Maydell <peter.maydell@linaro.org>2015-03-19 16:46:32 +0000
commit33a8d5b72d63fe44f08614408284fa934dee1edd (patch)
tree54c471427858e1d1aa72ca188dffeeaca950bcf6 /hw/char
parent7a9a5e72e8a62395649a46c53c3c224cc73ca52f (diff)
parent4add73aa601ab42b7a9863d483fa313b06105b34 (diff)
downloadqemu-33a8d5b72d63fe44f08614408284fa934dee1edd.zip
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>
Diffstat (limited to 'hw/char')
-rw-r--r--hw/char/virtio-serial-bus.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index c86814f059..d14e872d34 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -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)