[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] console: make QMP screendump use coroutine
From: |
Marc-André Lureau |
Subject: |
Re: [PATCH] console: make QMP screendump use coroutine |
Date: |
Thu, 5 Mar 2020 16:08:00 +0100 |
Hi
On Thu, Mar 5, 2020 at 3:46 PM Markus Armbruster <address@hidden> wrote:
>
> I tried to observe the main loop keeps running while the screendump does
> its work.
>
> The main loop appears to lack trace points. Alright, if there's no
> hammer handy, I'll use a rock:
>
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 5549f4b619..b6561a65d7 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -1661,6 +1661,7 @@ void qemu_main_loop(void)
> #ifdef CONFIG_PROFILER
> ti = profile_getclock();
> #endif
> + printf("*** main loop\n");
> main_loop_wait(false);
> #ifdef CONFIG_PROFILER
> dev_time += profile_getclock() - ti;
>
>
> First experiment: does the main loop continue to run when writing out
> the screendump blocks / would block?
>
> Observe qmp_screendump() opens the file without O_EXCL. Great, that
> lets me block output by making it open a FIFO.
>
> Terminal#1:
>
> $ mkfifo s
>
> Terminal#2:
>
> $ upstream-qemu -S -display none -chardev
> socket,id=qmp,path=test-qmp,server=on,wait=off -mon mode=control,chardev=qmp
> *** main loop
> *** main loop
> *** main loop
>
> Keeps printing at a steady pace.
>
> Terminal#3:
>
> $ socat "READLINE,history=$HOME/.qmp_history,prompt=QMP>"
> UNIX-CONNECT:$HOME/work/images/test-qmp
> {"QMP": {"version": {"qemu": {"micro": 50, "minor": 2, "major": 4},
> "package": "v4.2.0-2069-g5e5ae6b644-dirty"}, "capabilities": ["oob"]}}
> QMP>{"execute": "qmp_capabilities"}
> {"return": {}}
> QMP>{"execute": "screendump", "arguments": {"filename": "s"}}
>
> The printing in terminal#2 stops. This is expected; qemu_open() calls
> open(), which blocks, because the FIFO has no reader.
>
> Terminal#1:
>
> $ exec 4<s
>
> Now the FIFO has a reader. Terminal#2 remains quiet.
>
> We now hang in ppm_save(). Abridged stack backtrace:
>
> #0 0x00007ffff519d0f5 in writev () at /lib64/libc.so.6
> #1 0x0000555555e15f61 in qio_channel_file_writev
> (ioc=0x5555567bf5f0, iov=0x555556a441b0, niov=1, fds=0x0, nfds=0,
> errp=0x7fffe9d81d10) at /work/armbru/qemu/io/channel-file.c:123
> #2 0x0000555555e133d3 in qio_channel_writev_full
> (ioc=0x5555567bf5f0, iov=0x555556a441b0, niov=1, fds=0x0, nfds=0,
> errp=0x7fffe9d81d10) at /work/armbru/qemu/io/channel.c:86
> #3 0x0000555555e137a2 in qio_channel_writev
> (ioc=0x5555567bf5f0, iov=0x555556a441b0, niov=1, errp=0x7fffe9d81d10)
> at /work/armbru/qemu/io/channel.c:207
> #4 0x0000555555e13696 in qio_channel_writev_all
> (ioc=0x5555567bf5f0, iov=0x7fffe9d81bd0, niov=1, errp=0x7fffe9d81d10)
> at /work/armbru/qemu/io/channel.c:171
> #5 0x0000555555e139b1 in qio_channel_write_all
> (ioc=0x5555567bf5f0, buf=0x555556b05200 "", buflen=1920,
> errp=0x7fffe9d81d10) at /work/armbru/qemu/io/channel.c:257
> #6 0x0000555555cd74ff in ppm_save
> (fd=22, image=0x5555568ffdd0, errp=0x7fffe9d81d10)
> at /work/armbru/qemu/ui/console.c:336
> #7 0x0000555555cd77e6 in qmp_screendump
> (filename=0x555556ea0900 "s", has_device=false, device=0x0,
> has_head=false, head=0, errp=0x7fffe9d81d10) at
> /work/armbru/qemu/ui/console.c:401
>
> A brief inspection of qio_channel_file_writev() and
> qio_channel_writev_all() suggests this might work if you make the output
> file descriptor non-blocking.
Right, the goal was rather originally to fix rhbz#1230527. We got
coroutine IO by accident, and I was too optimistic about default
behaviour change ;) I will update the patch.
>
> $ head -c 1 <&4 | hexdump -C
> 00000000 50 |P|
> 00000001
>
> Still quiet.
>
> $ cat <&4 >/dev/null
>
> The printing resumes.
>
> $ exec 4<&-
>
>
> Second experiment: does the main loop continue to run while we wait for
> graphic_hw_update_done()?
>
> Left as an exercise for the patch submitter ;)
>
>
With your main loop printf, one printf in graphic_hw_update() and one
in graphic_hw_update_done() ? (rather part of testing commit
4d6316218bf7bf3b8c7c7165b072cc314511a7a7, soon 4y old!)
--
Marc-André Lureau
- Re: [PATCH] console: make QMP screendump use coroutine, Markus Armbruster, 2020/03/02
- Re: [PATCH] console: make QMP screendump use coroutine, Kevin Wolf, 2020/03/02
- Re: [PATCH] console: make QMP screendump use coroutine, Markus Armbruster, 2020/03/03
- Re: [PATCH] console: make QMP screendump use coroutine, Marc-André Lureau, 2020/03/03
- Re: [PATCH] console: make QMP screendump use coroutine, Markus Armbruster, 2020/03/06
- Re: [PATCH] console: make QMP screendump use coroutine, Marc-André Lureau, 2020/03/06
- Re: [PATCH] console: make QMP screendump use coroutine, Markus Armbruster, 2020/03/11