WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH V3] libxl, Introduce a QMP client

To: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH V3] libxl, Introduce a QMP client
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Wed, 15 Jun 2011 17:44:48 +0100
Cc: Anthony Perard <anthony.perard@xxxxxxxxxx>, Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Wed, 15 Jun 2011 09:41:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1308132267.17937.162.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1308071754-29014-1-git-send-email-anthony.perard@xxxxxxxxxx> <1308132267.17937.162.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
On Wed, 15 Jun 2011, Ian Campbell wrote:
> > +static int qmp_synchronous_send(libxl__qmp_handler *qmp, const char *cmd, 
> > qmp_callback_t callback, int ask_timeout)
> > +{
> > +    int id = 0;
> > +    int ret = 0;
> > +    fd_set rfds;
> > +    struct timeval timeout;
> > +
> > +    id = qmp_send(qmp, cmd, callback);
> > +    if (id <= 0) {
> > +        return -1;
> > +    }
> > +    qmp->wait_for_id = id;
> > +
> > +    timeout.tv_sec = ask_timeout;
> > +    timeout.tv_usec = 0;
> > +
> > +    while (qmp->wait_for_id == id) {
> > +        FD_ZERO(&rfds);
> > +        FD_SET(qmp->qmp_fd, &rfds);
> > +        ret = select(qmp->qmp_fd + 1, &rfds, NULL, NULL, &timeout);
> 
> Linux modifies timeout to reflect the amount of time left, which will
> mean that the timeout shrinks as answers which aren't for us come in.
> You need to init timeout inside the loop. select(2) recommends treating
> timeout as undefined after a select().
> 
> Do we want an overall timeout in case qemu never responds?


if qemu never responds we just need a single timeout inside the loop :)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel