qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/3] virtio-console: Check if chardev backends a


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 1/3] virtio-console: Check if chardev backends available before calling into them
Date: Wed, 21 Dec 2011 16:05:24 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

On 12/21/2011 12:58 AM, Amit Shah wrote:
For the callback functions invoked by the virtio-serial-bus code, check
if we have chardev backends registered before we call into the chardev
functions.

Signed-off-by: Amit Shah<address@hidden>

Applied all.  Thanks.

Regards,

Anthony Liguori

---
  hw/virtio-console.c |   11 +++++++++++
  1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index d3351c8..dbbea76 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -27,6 +27,11 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const 
uint8_t *buf, size_t len)
      VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
      ssize_t ret;

+    if (!vcon->chr) {
+        /* If there's no backend, we can just say we consumed all data. */
+        return len;
+    }
+
      ret = qemu_chr_fe_write(vcon->chr, buf, len);
      trace_virtio_console_flush_buf(port->id, len, ret);

@@ -52,6 +57,9 @@ static void guest_open(VirtIOSerialPort *port)
  {
      VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);

+    if (!vcon->chr) {
+        return;
+    }
      qemu_chr_fe_open(vcon->chr);
  }

@@ -60,6 +68,9 @@ static void guest_close(VirtIOSerialPort *port)
  {
      VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);

+    if (!vcon->chr) {
+        return;
+    }
      qemu_chr_fe_close(vcon->chr);
  }





reply via email to

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