Patchwork [10/19] char: add gio watch fn for tcp backends

login
register
mail settings
Submitter Anthony Liguori
Date Feb. 18, 2013, 9:48 p.m.
Message ID <1361224096-21075-11-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/221508/
State New
Headers show

Comments

Anthony Liguori - Feb. 18, 2013, 9:48 p.m.
From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c | 7 +++++++
 1 file changed, 7 insertions(+)
Amit Shah - Feb. 19, 2013, 7:44 a.m.
On (Mon) 18 Feb 2013 [15:48:07], Anthony Liguori wrote:
> From: Amit Shah <amit.shah@redhat.com>
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  qemu-char.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index e59e580..160bcea 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -2462,6 +2462,12 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
>  }
>  #endif
>  
> +static GSource *tcp_chr_add_watch(CharDriverState *chr, GIOCondition cond)
> +{
> +    TCPCharDriver *s = chr->opaque;
> +    return g_io_create_watch(s->chan, cond);

Thanks for noticing and fixing this up!

		Amit
Anthony Liguori - Feb. 19, 2013, 1:55 p.m.
Amit Shah <amit.shah@redhat.com> writes:

> On (Mon) 18 Feb 2013 [15:48:07], Anthony Liguori wrote:
>> From: Amit Shah <amit.shah@redhat.com>
>> 
>> Signed-off-by: Amit Shah <amit.shah@redhat.com>
>> ---
>>  qemu-char.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>> 
>> diff --git a/qemu-char.c b/qemu-char.c
>> index e59e580..160bcea 100644
>> --- a/qemu-char.c
>> +++ b/qemu-char.c
>> @@ -2462,6 +2462,12 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
>>  }
>>  #endif
>>  
>> +static GSource *tcp_chr_add_watch(CharDriverState *chr, GIOCondition cond)
>> +{
>> +    TCPCharDriver *s = chr->opaque;
>> +    return g_io_create_watch(s->chan, cond);
>
> Thanks for noticing and fixing this up!

It an amazing amount of luck that the previous code worked but the
struct layouts just happened to match :-)

Regards,

Anthony Liguori

>
> 		Amit
Amit Shah - Feb. 19, 2013, 2:12 p.m.
On (Tue) 19 Feb 2013 [07:55:36], Anthony Liguori wrote:
> Amit Shah <amit.shah@redhat.com> writes:
> 
> > On (Mon) 18 Feb 2013 [15:48:07], Anthony Liguori wrote:
> >> From: Amit Shah <amit.shah@redhat.com>
> >> 
> >> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> >> ---
> >>  qemu-char.c | 7 +++++++
> >>  1 file changed, 7 insertions(+)
> >> 
> >> diff --git a/qemu-char.c b/qemu-char.c
> >> index e59e580..160bcea 100644
> >> --- a/qemu-char.c
> >> +++ b/qemu-char.c
> >> @@ -2462,6 +2462,12 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
> >>  }
> >>  #endif
> >>  
> >> +static GSource *tcp_chr_add_watch(CharDriverState *chr, GIOCondition cond)
> >> +{
> >> +    TCPCharDriver *s = chr->opaque;
> >> +    return g_io_create_watch(s->chan, cond);
> >
> > Thanks for noticing and fixing this up!
> 
> It an amazing amount of luck that the previous code worked but the
> struct layouts just happened to match :-)

Heh, yeah.  Had it not been for that luck, I'd have noticed it
easily :-)

		Amit

Patch

diff --git a/qemu-char.c b/qemu-char.c
index e59e580..160bcea 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2462,6 +2462,12 @@  static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
 }
 #endif
 
+static GSource *tcp_chr_add_watch(CharDriverState *chr, GIOCondition cond)
+{
+    TCPCharDriver *s = chr->opaque;
+    return g_io_create_watch(s->chan, cond);
+}
+
 static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
 {
     CharDriverState *chr = opaque;
@@ -2676,6 +2682,7 @@  static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
     chr->chr_close = tcp_chr_close;
     chr->get_msgfd = tcp_get_msgfd;
     chr->chr_add_client = tcp_chr_add_client;
+    chr->chr_add_watch = tcp_chr_add_watch;
 
     if (is_listen) {
         s->listen_fd = fd;