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

Re: [Xen-devel] Re: [PATCH] libxenlight: fix multiple xenstore watches p

To: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] Re: [PATCH] libxenlight: fix multiple xenstore watches problem
From: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Date: Wed, 02 Dec 2009 18:26:32 +0000
Cc:
Delivery-date: Wed, 02 Dec 2009 10:27:03 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4B16AD18.6070609@xxxxxxxxxxxxxxxx>
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcpzeJ6ZzPMXV9e9QwSDJAo1BsqwiAABFolD
Thread-topic: [Xen-devel] Re: [PATCH] libxenlight: fix multiple xenstore watches problem
User-agent: Microsoft-Entourage/12.23.0.091001
I will apply Stefano's patches now, then you can see what bits you need to
re-send. Stefano or Vincent will want to ack/nack your patches before I try
to apply them anyway.

 -- Keir

On 02/12/2009 18:08, "Andres Lagar-Cavilla" <andres@xxxxxxxxxxxxxxxx> wrote:

> mmm,
> most likely the first two patches in my latest resend clash against
> this. Yikes
> Andres
>> Message: 3
>> Date: Wed, 2 Dec 2009 15:01:32 +0000
>> From: Stefano Stabellini<stefano.stabellini@xxxxxxxxxxxxx>
>> Subject: [Xen-devel] [PATCH] libxenlight: fix multiple xenstore
>> watches problem
>> To: xen-devel@xxxxxxxxxxxxxxxxxxx
>> Message-ID:<alpine.DEB.2.00.0912021455450.26846@kaball-desktop>
>> Content-Type: text/plain; charset="US-ASCII"
>> 
>> Hi all,
>> this patch fixes the multiple xenstore watches problem in libxenlight
>> opening a new xenstore connection to set and read temporary watches on
>> the device state nodes.
>> This way they don't interfere with other long running watches.
>> 
>> Signed-off-by: Stefano Stabellini<stefano.stabellini@xxxxxxxxxxxxx>
>> 
>> ---
>> 
>> diff -r 96a9740f4f33 tools/libxl/libxl_device.c
>> --- a/tools/libxl/libxl_device.c Wed Dec 02 14:29:24 2009 +0000
>> +++ b/tools/libxl/libxl_device.c Wed Dec 02 14:43:06 2009 +0000
>> @@ -212,47 +212,50 @@
>>       fd_set rfds;
>>       struct timeval tv;
>>       flexarray_t *toremove;
>> +    struct libxl_ctx clone = *ctx;
>> 
>> +    clone.xsh = xs_daemon_open();
>>       toremove = flexarray_make(16, 1);
>> -    path = libxl_sprintf(ctx, "/local/domain/%d/device", domid);
>> -    l1 = libxl_xs_directory(ctx, XBT_NULL, path,&num1);
>> +    path = libxl_sprintf(&clone, "/local/domain/%d/device", domid);
>> +    l1 = libxl_xs_directory(&clone, XBT_NULL, path,&num1);
>>       if (!l1) {
>> -        XL_LOG(ctx, XL_LOG_ERROR, "%s is empty", path);
>> +        XL_LOG(&clone, XL_LOG_ERROR, "%s is empty", path);
>> +        xs_daemon_close(clone.xsh);
>>           return -1;
>>       }
>>       for (i = 0; i<  num1; i++) {
>> -        path = libxl_sprintf(ctx, "/local/domain/%d/device/%s", domid,
>> l1[i]);
>> -        l2 = libxl_xs_directory(ctx, XBT_NULL, path,&num2);
>> +        path = libxl_sprintf(&clone, "/local/domain/%d/device/%s", domid,
>> l1[i]);
>> +        l2 = libxl_xs_directory(&clone, XBT_NULL, path,&num2);
>>           if (!l2)
>>               continue;
>>           for (j = 0; j<  num2; j++) {
>> -            fe_path = libxl_sprintf(ctx, "/local/domain/%d/device/%s/%s",
>> domid, l1[i], l2[j]);
>> -            be_path = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx,
>> "%s/backend", fe_path));
>> +            fe_path = libxl_sprintf(&clone, "/local/domain/%d/device/%s/%s",
>> domid, l1[i], l2[j]);
>> +            be_path = libxl_xs_read(&clone, XBT_NULL, libxl_sprintf(&clone,
>> "%s/backend", fe_path));
>>               if (be_path != NULL) {
>> -                if (libxl_device_destroy(ctx, be_path, force)>  0)
>> +                if (libxl_device_destroy(&clone, be_path, force)>  0)
>>                       n_watches++;
>> -                flexarray_set(toremove, n++, libxl_dirname(ctx, be_path));
>> +                flexarray_set(toremove, n++, libxl_dirname(&clone,
>> be_path));
>>               } else {
>> -                xs_rm(ctx->xsh, XBT_NULL, path);
>> +                xs_rm(clone.xsh, XBT_NULL, path);
>>               }
>>           }
>>       }
>>       if (!force) {
>> -        nfds = xs_fileno(ctx->xsh) + 1;
>> +        nfds = xs_fileno(clone.xsh) + 1;
>>           /* Linux-ism */
>>           tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
>>           tv.tv_usec = 0;
>>           while (n_watches>  0&&  tv.tv_sec>  0) {
>>               FD_ZERO(&rfds);
>> -            FD_SET(xs_fileno(ctx->xsh),&rfds);
>> +            FD_SET(xs_fileno(clone.xsh),&rfds);
>>               if (select(nfds,&rfds, NULL, NULL,&tv)>  0) {
>> -                l1 = xs_read_watch(ctx->xsh,&num1);
>> +                l1 = xs_read_watch(clone.xsh,&num1);
>>                   if (l1 != NULL) {
>> -                    char *state = libxl_xs_read(ctx, XBT_NULL, l1[0]);
>> +                    char *state = libxl_xs_read(&clone, XBT_NULL, l1[0]);
>>                       if (!state || atoi(state) == 6) {
>> -                        xs_unwatch(ctx->xsh, l1[0], l1[1]);
>> -                        xs_rm(ctx->xsh, XBT_NULL, l1[1]);
>> -                        XL_LOG(ctx, XL_LOG_DEBUG, "Destroyed device backend
>> at %s", l1[1]);
>> +                        xs_unwatch(clone.xsh, l1[0], l1[1]);
>> +                        xs_rm(clone.xsh, XBT_NULL, l1[1]);
>> +                        XL_LOG(&clone, XL_LOG_DEBUG, "Destroyed device
>> backend at %s", l1[1]);
>>                           n_watches--;
>>                       }
>>                       free(l1);
>> @@ -263,9 +266,10 @@
>>       }
>>       for (i = 0; i<  n; i++) {
>>           flexarray_get(toremove, i, (void**)&path);
>> -        xs_rm(ctx->xsh, XBT_NULL, path);
>> +        xs_rm(clone.xsh, XBT_NULL, path);
>>       }
>>       flexarray_free(toremove);
>> +    xs_daemon_close(clone.xsh);
>>       return 0;
>>   }
>> 
>>    
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



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

<Prev in Thread] Current Thread [Next in Thread>