Skip to contentSkip to conversation

virtio-console: notify chardev when writable

PATCH In review Marc-André Lureau 2 participants 3 messages May 5, 2015 – May 6, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 virtio-console: notify chardev when writable

When the virtio serial is writable, notify the chardev backend with qemu_chr_accept_input().

---
 hw/char/virtio-console.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/char/virtio-console.c +10 -0
index 752ed2c..2a867cb 100644
@@ -95,6 +95,15 @@ static void set_guest_connected(VirtIOSerialPort *port, int guest_connected)
     }
 }
 
+static void guest_writable(VirtIOSerialPort *port)
+{
+    VirtConsole *vcon = VIRTIO_CONSOLE(port);
+
+    if (vcon->chr) {
+        qemu_chr_accept_input(vcon->chr);
+    }
+}
+
 /* Readiness of the guest to accept data on a port */
 static int chr_can_read(void *opaque)
 {
@@ -188,6 +197,7 @@ static void virtserialport_class_init(ObjectClass *klass, void *data)
     k->unrealize = virtconsole_unrealize;
     k->have_data = flush_buf;
     k->set_guest_connected = set_guest_connected;
+    k->guest_writable = guest_writable;
     dc->props = virtserialport_properties;
 }
 
Signature · 1 line
2.1.0
#1 lore raw

PATCH 2/2 spice-char: notify the server when chardev is writable

The spice server is polling on write, unless SPICE_CHAR_DEVICE_NOTIFY_WRITABLE flag is set. In this case, qemu must call spice_server_char_device_wakeup() when the frontend is writable.

---
 spice-qemu-char.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
spice-qemu-char.c +11 -0
index a4f4e57..0f8903e 100644
@@ -110,6 +110,9 @@ static SpiceCharDeviceInterface vmc_interface = {
 #if SPICE_SERVER_VERSION >= 0x000c02
     .event              = vmc_event,
 #endif
+#if SPICE_SERVER_VERSION >= 0x000c06
+    .flags              = SPICE_CHAR_DEVICE_NOTIFY_WRITABLE,
+#endif
 };
 
 
@@ -260,6 +263,13 @@ static void print_allowed_subtypes(void)
     fprintf(stderr, "\n");
 }
 
+static void spice_chr_accept_input(struct CharDriverState *chr)
+{
+    SpiceCharDriver *s = chr->opaque;
+
+    spice_server_char_device_wakeup(&s->sin);
+}
+
 static CharDriverState *chr_open(const char *subtype,
     void (*set_fe_open)(struct CharDriverState *, int))
 
@@ -279,6 +289,7 @@ static CharDriverState *chr_open(const char *subtype,
     chr->chr_set_fe_open = set_fe_open;
     chr->explicit_be_open = true;
     chr->chr_fe_event = spice_chr_fe_event;
+    chr->chr_accept_input = spice_chr_accept_input;
 
     QLIST_INSERT_HEAD(&spice_chars, s, next);
 
Signature · 1 line
2.1.0
#2 lore raw
In reply to Marc-André Lureau
Quoted 2 lines · Marc-André Lureau

When the virtio serial is writable, notify the chardev backend with qemu_chr_accept_input().

added both patches to spice patch queue.

thanks,
Gerd