[libvirt] [PATCH] rpc: Double buffer size instead of quadrupling buffer size.

Richard W.M. Jones posted 1 patch 6 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170526120215.29984-1-rjones@redhat.com
src/rpc/virnetmessage.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt] [PATCH] rpc: Double buffer size instead of quadrupling buffer size.
Posted by Richard W.M. Jones 6 years, 10 months ago
When increasing the buffer size up to VIR_NET_MESSAGE_MAX, we
currently quadruple it each time.  This unfortunately means that we
cannot allow certain buffer sizes -- for example the current
VIR_NET_MESSAGE_MAX == 33554432 can never be "hit" since ‘newlen’
jumps from 16MB to 64MB.

Instead of quadrupling, double it each time.

Thanks: Daniel Berrange.
---
 src/rpc/virnetmessage.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index c3a2e595c..5908b074a 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -358,7 +358,8 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
 
     /* Try to encode the payload. If the buffer is too small increase it. */
     while (!(*filter)(&xdr, data, 0)) {
-        unsigned int newlen = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4;
+        unsigned int newlen = msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX;
+        newlen *= 2;
 
         if (newlen > VIR_NET_MESSAGE_MAX) {
             virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
-- 
2.13.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: Double buffer size instead of quadrupling buffer size.
Posted by Peter Krempa 6 years, 10 months ago
On Fri, May 26, 2017 at 13:02:15 +0100, Richard W.M. Jones wrote:
> When increasing the buffer size up to VIR_NET_MESSAGE_MAX, we
> currently quadruple it each time.  This unfortunately means that we
> cannot allow certain buffer sizes -- for example the current
> VIR_NET_MESSAGE_MAX == 33554432 can never be "hit" since ‘newlen’
> jumps from 16MB to 64MB.
> 
> Instead of quadrupling, double it each time.
> 
> Thanks: Daniel Berrange.
> ---

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