[Qemu-devel] [PATCH v4 02/29] chardev: remove qemu_chr_fe_read_all() counter

Marc-André Lureau posted 29 patches 7 years, 3 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v4 02/29] chardev: remove qemu_chr_fe_read_all() counter
Posted by Marc-André Lureau 7 years, 3 months ago
There is no obvious reason to have a loop counter. This limits from
reading several megabytes large buffers in one go, since socket
read/write usually have a limit.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 chardev/char-fe.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index b1f228e8b5..f158f158f8 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -56,7 +56,7 @@ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len)
 int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len)
 {
     Chardev *s = be->chr;
-    int offset = 0, counter = 10;
+    int offset = 0;
     int res;
 
     if (!s || !CHARDEV_GET_CLASS(s)->chr_sync_read) {
@@ -88,10 +88,6 @@ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len)
         }
 
         offset += res;
-
-        if (!counter--) {
-            break;
-        }
     }
 
     if (qemu_chr_replay(s) && replay_mode == REPLAY_MODE_RECORD) {
-- 
2.18.0.129.ge3331758f1


Re: [Qemu-devel] [PATCH v4 02/29] chardev: remove qemu_chr_fe_read_all() counter
Posted by Daniel P. Berrangé 7 years, 2 months ago
On Fri, Jul 13, 2018 at 03:08:49PM +0200, Marc-André Lureau wrote:
> There is no obvious reason to have a loop counter. This limits from
> reading several megabytes large buffers in one go, since socket
> read/write usually have a limit.

The counter was there since this method's introduction in
7b0bfdf52d694c9a3a96505aa42ce3f8d63acd35, and no obvious
indication of its purpose in that commit.

I can imagine maybe it was a misguided attempt to prevent
QEMU blocking forever if no data was pending, but it does
not in fact achieve that.

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  chardev/char-fe.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)


Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|