qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: qemu-devel@nongnu.org, kvm@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Cc: Amit Shah <amit.shah@redhat.com>
Subject: [Qemu-devel] [PATCH 1/3] char: Emit 'CLOSED' events on char device close
Date: Tue, 25 Aug 2009 11:47:22 +0530	[thread overview]
Message-ID: <1251181044-3696-3-git-send-email-amit.shah@redhat.com> (raw)
In-Reply-To: <1251181044-3696-2-git-send-email-amit.shah@redhat.com>

Notify users of the char interface whenever the file / connection is
closed.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c |   10 ++++++++++
 qemu-char.h |    1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index be27994..c25ed1c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -570,6 +570,7 @@ static void fd_chr_read(void *opaque)
     if (size == 0) {
         /* FD has been closed. Remove it from the active list.  */
         qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL);
+        qemu_chr_event(chr, CHR_EVENT_CLOSED);
         return;
     }
     if (size > 0) {
@@ -602,6 +603,7 @@ static void fd_chr_close(struct CharDriverState *chr)
     }
 
     qemu_free(s);
+    qemu_chr_event(chr, CHR_EVENT_CLOSED);
 }
 
 /* open a character device to a unix fd */
@@ -690,6 +692,7 @@ static void stdio_read(void *opaque)
     if (size == 0) {
         /* stdin has been closed. Remove it from the active list.  */
         qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL);
+        qemu_chr_event(chr, CHR_EVENT_CLOSED);
         return;
     }
     if (size > 0) {
@@ -943,6 +946,7 @@ static void pty_chr_close(struct CharDriverState *chr)
     qemu_del_timer(s->timer);
     qemu_free_timer(s->timer);
     qemu_free(s);
+    qemu_chr_event(chr, CHR_EVENT_CLOSED);
 }
 
 static CharDriverState *qemu_chr_open_pty(void)
@@ -1264,6 +1268,7 @@ static void pp_close(CharDriverState *chr)
     ioctl(fd, PPRELEASE);
     close(fd);
     qemu_free(drv);
+    qemu_chr_event(chr, CHR_EVENT_CLOSED);
 }
 
 static CharDriverState *qemu_chr_open_pp(const char *filename)
@@ -1390,6 +1395,8 @@ static void win_chr_close(CharDriverState *chr)
         qemu_del_polling_cb(win_chr_pipe_poll, chr);
     else
         qemu_del_polling_cb(win_chr_poll, chr);
+
+    qemu_chr_event(chr, CHR_EVENT_CLOSED);
 }
 
 static int win_chr_init(CharDriverState *chr, const char *filename)
@@ -1779,6 +1786,7 @@ static void udp_chr_close(CharDriverState *chr)
         closesocket(s->fd);
     }
     qemu_free(s);
+    qemu_chr_event(chr, CHR_EVENT_CLOSED);
 }
 
 static CharDriverState *qemu_chr_open_udp(const char *def)
@@ -1999,6 +2007,7 @@ static void tcp_chr_read(void *opaque)
         qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
         closesocket(s->fd);
         s->fd = -1;
+        qemu_chr_event(chr, CHR_EVENT_CLOSED);
     } else if (size > 0) {
         if (s->do_telnetopt)
             tcp_chr_process_IAC_bytes(chr, s, buf, &size);
@@ -2095,6 +2104,7 @@ static void tcp_chr_close(CharDriverState *chr)
         closesocket(s->listen_fd);
     }
     qemu_free(s);
+    qemu_chr_event(chr, CHR_EVENT_CLOSED);
 }
 
 static CharDriverState *qemu_chr_open_tcp(const char *host_str,
diff --git a/qemu-char.h b/qemu-char.h
index 77d4eda..df620bc 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -11,6 +11,7 @@
 #define CHR_EVENT_RESET   2 /* new connection established */
 #define CHR_EVENT_MUX_IN  3 /* mux-focus was set to this terminal */
 #define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */
+#define CHR_EVENT_CLOSED  5 /* connection closed */
 
 
 #define CHR_IOCTL_SERIAL_SET_PARAMS   1
-- 
1.6.2.5

  reply	other threads:[~2009-08-25  6:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-25  6:17 [Qemu-devel] Extending virtio_console to support multiple ports Amit Shah
2009-08-25  6:17 ` [Qemu-devel] [PATCH] virtio_console: Add interface for guest and host communication Amit Shah
2009-08-25  6:17   ` Amit Shah [this message]
2009-08-25  6:17     ` [Qemu-devel] [PATCH 2/3] virtio-console: rename dvq to ovq Amit Shah
2009-08-25  8:16 ` [Qemu-devel] [PATCH 3/3] virtio-console: Add interface for generic guest-host communication Amit Shah
2009-08-26 11:27 ` [Qemu-devel] Re: Extending virtio_console to support multiple ports Amit Shah
2009-08-26 15:45   ` Amit Shah
2009-08-27  4:07     ` Benjamin Herrenschmidt
2009-08-27  6:51       ` Amit Shah
2009-08-27  9:08       ` Alan Cox
2009-08-27  9:27         ` Benjamin Herrenschmidt
2009-08-27 11:45           ` [Qemu-devel] [PATCH] hvc_console: provide (un)locked version for hvc_resize() Hendrik Brueckner
2009-08-29  1:15         ` [Qemu-devel] Re: Extending virtio_console to support multiple ports Jamie Lokier
2009-08-27  5:04     ` Michael Ellerman
2009-08-27  6:52       ` Amit Shah
2009-08-27 14:13         ` Ryan Arnold
2009-08-28 17:00   ` Anthony Liguori
2009-08-30 10:10     ` Amit Shah
2009-08-30 12:48       ` Anthony Liguori
2009-08-30 13:17         ` Amit Shah
2009-08-31 13:17           ` Anthony Liguori
2009-08-31 13:51             ` Amit Shah
2009-08-31 14:21               ` Anthony Liguori
2009-08-31 14:31                 ` Amit Shah
2009-08-31 15:56                   ` Anthony Liguori
2009-08-31 16:19                     ` Amit Shah
2009-08-31 16:37                       ` Anthony Liguori
2009-09-21  5:20                         ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1251181044-3696-3-git-send-email-amit.shah@redhat.com \
    --to=amit.shah@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).