[libvirt] [PATCH] libvirtd: fix bug when shrinking number of clients
Eric Blake
eblake at redhat.com
Tue Nov 23 15:47:14 UTC 2010
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 at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101123/d5976b7a/attachment-0001.sig>
More information about the libvir-list
mailing list