qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 11/20] qemu-char: use a glib timeout instead of


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 11/20] qemu-char: use a glib timeout instead of qemu-timer
Date: Mon, 25 Mar 2013 10:38:28 +0100

On Fri, Mar 15, 2013 at 4:44 PM, Anthony Liguori <address@hidden> wrote:
> Laurent Desnogues <address@hidden> writes:
>
>> Hello,
>>
>> On Tue, Mar 5, 2013 at 6:51 PM, Amit Shah <address@hidden> wrote:
>>> From: Anthony Liguori <address@hidden>
>>>
>>> Signed-off-by: Anthony Liguori <address@hidden>
>>> Signed-off-by: Amit Shah <address@hidden>
>>> ---
>>>  qemu-char.c | 68 
>>> ++++++++++++++++++++++++++++++++++++++++---------------------
>>>  1 file changed, 45 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/qemu-char.c b/qemu-char.c
>>> index eb0ac81..6dba943 100644
>>> --- a/qemu-char.c
>>> +++ b/qemu-char.c
>>> @@ -990,12 +990,50 @@ typedef struct {
>>>      int connected;
>>>      int polling;
>>>      int read_bytes;
>>> -    QEMUTimer *timer;
>>> +    guint timer_tag;
>>>  } PtyCharDriver;
>>>
>>>  static void pty_chr_update_read_handler(CharDriverState *chr);
>>>  static void pty_chr_state(CharDriverState *chr, int connected);
>>>
>>> +static gboolean pty_chr_timer(gpointer opaque)
>>> +{
>>> +    struct CharDriverState *chr = opaque;
>>> +    PtyCharDriver *s = chr->opaque;
>>> +
>>> +    if (s->connected) {
>>> +        goto out;
>>> +    }
>>> +    if (s->polling) {
>>> +        /* If we arrive here without polling being cleared due
>>> +         * read returning -EIO, then we are (re-)connected */
>>> +        pty_chr_state(chr, 1);
>>> +        goto out;
>>> +    }
>>> +
>>> +    /* Next poll ... */
>>> +    pty_chr_update_read_handler(chr);
>>> +
>>> +out:
>>> +    return FALSE;
>>> +}
>>> +
>>> +static void pty_chr_rearm_timer(CharDriverState *chr, int ms)
>>> +{
>>> +    PtyCharDriver *s = chr->opaque;
>>> +
>>> +    if (s->timer_tag) {
>>> +        g_source_remove(s->timer_tag);
>>> +        s->timer_tag = 0;
>>> +    }
>>> +
>>> +    if (ms == 1000) {
>>> +        s->timer_tag = g_timeout_add_seconds(1, pty_chr_timer, chr);
>>
>> It looks like g_timeout_add_seconds isn't available for
>> poor people using some old distros (glib 2.12.3 here).
>
> Can you test adding:
>
> #if !GLIB_CHECK_VERSION(2, 14, 0)
> static guint g_timeout_add_seconds(guint interval, GSourceFunc function,
>                                    gpointer data)
> {
>     return g_timeout_add(interval * 1000, function, data);
> }
> #endif
>
> We probably should introduce a glib-compat to centralize work arounds
> for older versions of glib...

Hi Anthony,
Are you sending a patch for g_timeout_add_seconds() compatibility?

The RHEL5 builds are failing because their glib is old:
http://buildbot.b1-systems.de/qemu/builders/default_x86_64_rhel5/builds/551/steps/compile/logs/stdio

Stefan



reply via email to

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