fix monitor
PATCH 1/1 fix monitor
chardev flow control broke monitor, fix it by adding watch support.
---
v2: fix tyops
--- monitor.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
monitor.c +21 -2
@@ -261,11 +261,30 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, } } +static gboolean monitor_unblocked (GIOChannel *chan,GIOCondition cond, +void *opaque) +{ +monitor_flush (opaque); +return FALSE; +} +void monitor_flush (Monitor *mon) { +int rc; +if (mon && mon->outbuf_index !=0 && !mon->mux_out) { -qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); - mon->outbuf_index =0 ; + rc =qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); +if (rc == mon->outbuf_index) { +/* all flushed */ + mon->outbuf_index =0 ; +return ; + } +if (rc >0 ) { +/* partial write */ +memmove (mon->outbuf, mon->outbuf + rc, mon->outbuf_index - rc); + mon->outbuf_index -= rc; + } +qemu_chr_fe_add_watch (mon->chr,G_IO_OUT , monitor_unblocked, mon); } }
Signature · 1 line
1.7.9.7
Quoted 5 lines · Gerd Hoffmann
chardev flow control broke monitor, fix it by adding watch support.
Signed-off-by Gerd Hoffmann <[email protected]>---
v2: fix tyops
Well played, Sir :)
Quoted 32 lines
--- monitor.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)monitor.c +14
-2@@ -261,11 +261,30 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, } } +static gboolean monitor_unblocked (GIOChannel *chan,GIOCondition cond, +void *opaque) +{ +monitor_flush (opaque); +return FALSE; +} +void monitor_flush (Monitor *mon) { +int rc; +if (mon && mon->outbuf_index !=0 && !mon->mux_out) { -qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); - mon->outbuf_index =0 ; + rc =qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); +if (rc == mon->outbuf_index) { +/* all flushed */ + mon->outbuf_index =0 ; +return ;
monitor.c int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, · line 290
Quoted 10 lines
monitor.c +7
-0+ } +if (rc >0 ) { +/* partial write */ +memmove (mon->outbuf, mon->outbuf + rc, mon->outbuf_index - rc); + mon->outbuf_index -= rc; + } +qemu_chr_fe_add_watch (mon->chr,G_IO_OUT , monitor_unblocked, mon); } }
Looks good to me.
Should we maybe forego (re)installing the (new) watch when rc<0? (Especially because on a persistent error the fd might immediately report writability.)
Laszlo
Quoted 54 lines · Laszlo Ersek
Quoted 5 lines · Gerd Hoffmann
chardev flow control broke monitor, fix it by adding watch support.
Signed-off-by Gerd Hoffmann <[email protected]>---
v2: fix tyopsWell played, Sir :)
Quoted 32 lines
--- monitor.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)monitor.c +14
-2@@ -261,11 +261,30 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, } } +static gboolean monitor_unblocked (GIOChannel *chan,GIOCondition cond, +void *opaque) +{ +monitor_flush (opaque); +return FALSE; +} +void monitor_flush (Monitor *mon) { +int rc; +if (mon && mon->outbuf_index !=0 && !mon->mux_out) { -qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); - mon->outbuf_index =0 ; + rc =qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); +if (rc == mon->outbuf_index) { +/* all flushed */ + mon->outbuf_index =0 ; +return ;monitor.c int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, · line 290
Quoted 10 lines
monitor.c +7
-0+ } +if (rc >0 ) { +/* partial write */ +memmove (mon->outbuf, mon->outbuf + rc, mon->outbuf_index - rc); + mon->outbuf_index -= rc; + } +qemu_chr_fe_add_watch (mon->chr,G_IO_OUT , monitor_unblocked, mon); } }Looks good to me.
Quoted 3 lines
Should we maybe forego (re)installing the (new) watch when rc<0? (Especially because on a persistent error the fd might immediately report writability.)
Yes, it is probably wise to check for errno == EAGAIN (assuming qemu_chr_fe_write makes sure errno it set to something sensible on error).
cheers,
Gerd
Quoted 6 lines · Gerd Hoffmann
chardev flow control broke monitor, fix it by adding watch support.
Signed-off-by Gerd Hoffmann <[email protected]>---
v2: fix tyops
---
Subject lacks v2. Anthony, holler if you want a respin to unconfuse your tools.
Anthony Liguori
AppliedApplied. Thanks.
Regards,
Anthony Liguori
Quoted 11 lines · Markus Armbruster
Quoted 6 lines · Gerd Hoffmann
chardev flow control broke monitor, fix it by adding watch support.
Signed-off-by Gerd Hoffmann <[email protected]>---
v2: fix tyops
---Subject lacks v2. Anthony, holler if you want a respin to unconfuse your tools.
I already processed this patch--specifically this copy of it. Newest mail always wins when there's a conflict but please don't rely on that :-)
Regards,
Anthony Liguori
Hi Gerd,
I today saw this assert when live migrating a VM. Is this related? The below patch was already applied.
qemu-1.4.5: /usr/src/qemu-1.4.5/monitor.c:297: monitor_puts: Assertion `mon->outbuf_index < sizeof(mon->outbuf) - 1' failed.
Peter
Quoted 54 lines · Gerd Hoffmann
chardev flow control broke monitor, fix it by adding watch support.
Signed-off-by Gerd Hoffmann <[email protected]>---
v2: fix tyops--- monitor.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)monitor.c +21
-2@@ -261,11 +261,30 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, } } +static gboolean monitor_unblocked (GIOChannel *chan,GIOCondition cond, +void *opaque) +{ +monitor_flush (opaque); +return FALSE; +} +void monitor_flush (Monitor *mon) { +int rc; +if (mon && mon->outbuf_index !=0 && !mon->mux_out) { -qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); - mon->outbuf_index =0 ; + rc =qemu_chr_fe_write (mon->chr, mon->outbuf, mon->outbuf_index); +if (rc == mon->outbuf_index) { +/* all flushed */ + mon->outbuf_index =0 ; +return ; + } +if (rc >0 ) { +/* partial write */ +memmove (mon->outbuf, mon->outbuf + rc, mon->outbuf_index - rc); + mon->outbuf_index -= rc; + } +qemu_chr_fe_add_watch (mon->chr,G_IO_OUT , monitor_unblocked, mon);}}
--
1.7.9.7
Quoted 7 lines · Peter Lieven
Hi Gerd,
I today saw this assert when live migrating a VM. Is this related? The below patch was already applied.
qemu-1.4.5:
/usr/src/qemu-1.4.5/monitor.c:297:monitor_puts: Assertion `mon->outbuf_index <sizeof(mon->outbuf)- 1' failed.
Probably, patches (from luiz) are on the list to make the monitor buffer size dynamic, they should fix it.
cheers,
Gerd
Quoted 11 lines · On Wed, 03 Apr 2013 14:35:46 +0200 Gerd Hoffmann <[email protected]> wrote:
Quoted 7 lines · Peter Lieven
Hi Gerd,
I today saw this assert when live migrating a VM. Is this related? The below patch was already applied.
qemu-1.4.5:
/usr/src/qemu-1.4.5/monitor.c:297:monitor_puts: Assertion `mon->outbuf_index <sizeof(mon->outbuf)- 1' failed.Probably, patches (from luiz) are on the list to make the monitor buffer size dynamic, they should fix it.
Yes.
Peter, can you please try my series and report if it really fixes the assertion for you?
http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg00369.html
Quoted 11 lines · Luiz Capitulino
Quoted 8 lines · On Wed, 03 Apr 2013 14:35:46 +0200 Gerd Hoffmann <[email protected]> wrote:
Quoted 7 lines · Peter Lieven
Hi Gerd,
I today saw this assert when live migrating a VM. Is this related? The below patch was already applied.
qemu-1.4.5:
/usr/src/qemu-1.4.5/monitor.c:297:monitor_puts: Assertion `mon->outbuf_index <sizeof(mon->outbuf)- 1' failed.
Quoted 9 lines
Quoted 2 lines
Probably, patches (from luiz) are on the list to make the monitor buffer size dynamic, they should fix it.
Yes.
Peter, can you please try my series and report if it really fixes the assertion for you?
http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg00369.html
I will do, but the assertion was not as easy triggerable for me as typing '?'. We run some tests today with the patches applied and I will let you know if there where any further assertions.
Peter