Re: [PATCH] libvirtd: fix bug when shrinking number of clients

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

 



On 11/23/2010 04:45 AM, Stefan Berger wrote:
> On 11/22/2010 02:34 PM, Eric Blake wrote:
>> * daemon/libvirtd.c (qemudRunLoop): Pass allocation size, not
>> current count, to VIR_SHRINK_N.
>> ---
>>
>> Found the cause of the crash; when the first loop completed, it was
>> freeing the array but not reflecting that in the allocation count;
>> the second time then saw the non-zero allocation count and didn't
>> think it had to allocate anything.
>>
>>   daemon/libvirtd.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
>> index e544c48..7f75096 100644
>> --- a/daemon/libvirtd.c
>> +++ b/daemon/libvirtd.c
>> @@ -2362,2 +2362,2 @@ static void *qemudRunLoop(void *opaque) {
>>                               server->clients + i + 1,
>>                               sizeof (*server->clients) *
>> (server->nclients - i));
>>
>> -                VIR_SHRINK_N(server->clients, server->nclients, 0);
>> +                VIR_SHRINK_N(server->clients, server->nclients_max, 1);
>>                   goto reprocess;
>>               }
>>           }
> Solves the problem for me.
> 
> ACK.

Thanks.  On reflection, I'm actually going to squash this in before
pushing, since it is a more accurate description of what is going on.

diff --git i/daemon/libvirtd.c w/daemon/libvirtd.c
index aa2f6ec..66f1388 100644
--- i/daemon/libvirtd.c
+++ w/daemon/libvirtd.c
@@ -2362,7 +2362,8 @@ static void *qemudRunLoop(void *opaque) {
                             server->clients + i + 1,
                             sizeof (*server->clients) *
(server->nclients - i));

-                VIR_SHRINK_N(server->clients, server->nclients_max, 1);
+                VIR_SHRINK_N(server->clients, server->nclients_max,
+                             server->nclients_max - server->nclients);
                 goto reprocess;
             }
         }
diff --git i/docs/hacking.html.in w/docs/hacking.html.in
index 890692f..ac16f41 100644
--- i/docs/hacking.html.in
+++ w/docs/hacking.html.in
@@ -426,14 +426,15 @@
 </pre>
       </li>

-      <li><p>To trim an array of domains to have one less element:</p>
+      <li><p>To trim an array of domains from its allocated size down
+      to the actual used size:</p>

 <pre>
   virDomainPtr domains;
   size_t ndomains = x;
   size_t ndomains_max = y;

-  VIR_SHRINK_N(domains, ndomains_max, 1);
+  VIR_SHRINK_N(domains, ndomains_max, ndomains_max - ndomains);
 </pre></li>

       <li><p>To free an array of domains:</p>


-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]