summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2010-11-22 12:27:07 -0700
committerEric Blake <eblake@redhat.com>2010-11-23 08:43:00 -0700
commit149c49213799bc0fb1b99ccd3310a932b512bc07 (patch)
treea85a7bebce3e73ee27fb8d8dddbea974a86a0849
parentc73bd6f34a03c6824543c47a1222dcc7f7a3c781 (diff)
downloadlibvirt-149c49213799bc0fb1b99ccd3310a932b512bc07.tar.gz
libvirtd: fix bug when shrinking number of clients
* daemon/libvirtd.c (qemudRunLoop): Pass allocation size, not current count, to VIR_SHRINK_N. * docs/hacking.html.in: Update doc example. * HACKING: Regenerate.
-rw-r--r--HACKING5
-rw-r--r--daemon/libvirtd.c3
-rw-r--r--docs/hacking.html.in5
3 files changed, 8 insertions, 5 deletions
diff --git a/HACKING b/HACKING
index 35ceb29822..cd7559d586 100644
--- a/HACKING
+++ b/HACKING
@@ -347,13 +347,14 @@ scales better, but requires tracking allocation separately from usage)
-- To trim an array of domains to have one less element:
+- To trim an array of domains from its allocated size down to the actual used
+size:
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);
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 2eb2374134..66f1388619 100644
--- a/daemon/libvirtd.c
+++ b/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, 0);
+ VIR_SHRINK_N(server->clients, server->nclients_max,
+ server->nclients_max - server->nclients);
goto reprocess;
}
}
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index 890692f058..ac16f411b5 100644
--- a/docs/hacking.html.in
+++ b/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>