From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: Phil Dennis-Jordan <phil@philjordan.eu>, qemu-devel@nongnu.org
Cc: agraf@csgraf.de, peter.maydell@linaro.org, pbonzini@redhat.com,
rad@semihalf.com, quic_llindhol@quicinc.com,
marcin.juszkiewicz@linaro.org, stefanha@redhat.com,
mst@redhat.com, slp@redhat.com, richard.henderson@linaro.org,
eduardo@habkost.net, marcel.apfelbaum@gmail.com,
gaosong@loongson.cn, jiaxun.yang@flygoat.com,
chenhuacai@kernel.org, kwolf@redhat.com, hreitz@redhat.com,
philmd@linaro.org, shorne@gmail.com, palmer@dabbelt.com,
alistair.francis@wdc.com, bmeng.cn@gmail.com,
liwei1518@gmail.com, dbarboza@ventanamicro.com,
zhiwei_liu@linux.alibaba.com, jcmvbkbc@gmail.com,
marcandre.lureau@redhat.com, berrange@redhat.com,
qemu-arm@nongnu.org, qemu-block@nongnu.org,
qemu-riscv@nongnu.org
Subject: Re: [PATCH v6 01/15] ui & main loop: Redesign of system-specific main thread event handling
Date: Tue, 5 Nov 2024 16:44:49 +0900 [thread overview]
Message-ID: <fe00d848-e775-4df7-9a0f-dfbeca9118a3@daynix.com> (raw)
In-Reply-To: <20241103150037.48194-2-phil@philjordan.eu>
On 2024/11/04 0:00, Phil Dennis-Jordan wrote:
> macOS's Cocoa event handling must be done on the initial (main) thread
> of the process. Furthermore, if library or application code uses
> libdispatch, the main dispatch queue must be handling events on the main
> thread as well.
>
> So far, this has affected Qemu in both the Cocoa and SDL UIs, although
> in different ways: the Cocoa UI replaces the default qemu_main function
> with one that spins Qemu's internal main event loop off onto a
> background thread. SDL (which uses Cocoa internally) on the other hand
> uses a polling approach within Qemu's main event loop. Events are
> polled during the SDL UI's dpy_refresh callback, which happens to run
> on the main thread by default.
>
> As UIs are mutually exclusive, this works OK as long as nothing else
> needs platform-native event handling. In the next patch, a new device is
> introduced based on the ParavirtualizedGraphics.framework in macOS.
> This uses libdispatch internally, and only works when events are being
> handled on the main runloop. With the current system, it works when
> using either the Cocoa or the SDL UI. However, it does not when running
> headless. Moreover, any attempt to install a similar scheme to the
> Cocoa UI's main thread replacement fails when combined with the SDL
> UI.
>
> This change tidies up main thread management to be more flexible.
>
> * The qemu_main global function pointer is a custom function for the
> main thread, and it may now be NULL. When it is, the main thread
> runs the main Qemu loop. This represents the traditional setup.
> * When non-null, spawning the main Qemu event loop on a separate
> thread is now done centrally rather than inside the Cocoa UI code.
> * For most platforms, qemu_main is indeed NULL by default, but on
> Darwin, it defaults to a function that runs the CFRunLoop.
> * The Cocoa UI sets qemu_main to a function which runs the
> NSApplication event handling runloop, as is usual for a Cocoa app.
> * The SDL UI overrides the qemu_main function to NULL, thus
> specifying that Qemu's main loop must run on the main
> thread.
> * For other UIs, or in the absence of UIs, the platform's default
> behaviour is followed.
>
> This means that on macOS, the platform's runloop events are always
> handled, regardless of chosen UI. The new PV graphics device will
> thus work in all configurations. There is no functional change on other
> operating systems.
>
> Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
next prev parent reply other threads:[~2024-11-05 7:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-03 15:00 [PATCH v6 00/15] macOS PV Graphics and new vmapple machine type Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 01/15] ui & main loop: Redesign of system-specific main thread event handling Phil Dennis-Jordan
2024-11-05 7:44 ` Akihiko Odaki [this message]
2024-11-03 15:00 ` [PATCH v6 02/15] hw/display/apple-gfx: Introduce ParavirtualizedGraphics.Framework support Phil Dennis-Jordan
2024-11-05 8:22 ` Akihiko Odaki
2024-11-05 14:24 ` Phil Dennis-Jordan
2024-11-06 6:56 ` Akihiko Odaki
2024-11-03 15:00 ` [PATCH v6 03/15] hw/display/apple-gfx: Adds PCI implementation Phil Dennis-Jordan
2024-11-05 8:25 ` Akihiko Odaki
2024-11-03 15:00 ` [PATCH v6 04/15] hw/display/apple-gfx: Adds configurable mode list Phil Dennis-Jordan
2024-11-05 8:31 ` Akihiko Odaki
2024-11-03 15:00 ` [PATCH v6 05/15] MAINTAINERS: Add myself as maintainer for apple-gfx, reviewer for HVF Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 06/15] hw: Add vmapple subdir Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 07/15] hw/misc/pvpanic: Add MMIO interface Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 08/15] hvf: arm: Ignore writes to CNTP_CTL_EL0 Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 09/15] gpex: Allow more than 4 legacy IRQs Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 10/15] hw/vmapple/aes: Introduce aes engine Phil Dennis-Jordan
2024-11-05 8:42 ` Akihiko Odaki
2024-11-03 15:00 ` [PATCH v6 11/15] hw/vmapple/bdif: Introduce vmapple backdoor interface Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 12/15] hw/vmapple/cfg: Introduce vmapple cfg region Phil Dennis-Jordan
2024-11-05 8:46 ` Akihiko Odaki
2024-11-03 15:00 ` [PATCH v6 13/15] hw/vmapple/virtio-blk: Add support for apple virtio-blk Phil Dennis-Jordan
2024-11-05 8:47 ` Akihiko Odaki
2024-11-03 15:00 ` [PATCH v6 14/15] hw/block/virtio-blk: Replaces request free function with g_free Phil Dennis-Jordan
2024-11-03 15:00 ` [PATCH v6 15/15] hw/vmapple/vmapple: Add vmapple machine type Phil Dennis-Jordan
2024-11-05 8:51 ` Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fe00d848-e775-4df7-9a0f-dfbeca9118a3@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=agraf@csgraf.de \
--cc=alistair.francis@wdc.com \
--cc=berrange@redhat.com \
--cc=bmeng.cn@gmail.com \
--cc=chenhuacai@kernel.org \
--cc=dbarboza@ventanamicro.com \
--cc=eduardo@habkost.net \
--cc=gaosong@loongson.cn \
--cc=hreitz@redhat.com \
--cc=jcmvbkbc@gmail.com \
--cc=jiaxun.yang@flygoat.com \
--cc=kwolf@redhat.com \
--cc=liwei1518@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=marcin.juszkiewicz@linaro.org \
--cc=mst@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=phil@philjordan.eu \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=quic_llindhol@quicinc.com \
--cc=rad@semihalf.com \
--cc=richard.henderson@linaro.org \
--cc=shorne@gmail.com \
--cc=slp@redhat.com \
--cc=stefanha@redhat.com \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).