Skip to content

RFC cocoa: run qemu_init in the main thread

Philippe Mathieu-Daudé qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 RFC Latest2 patches 4 repliesIn review
  2. v3 RFC2 patches 5 repliesSuperseded
  3. v2 RFC1 patch 8 repliesSuperseded

Changes in v4 from the cover letter

- Move qemu_event_init before cbowner alloc
- Reduce main_thread scope to applicationDidFinishLaunching
- Updated updateUIInfo() comment (s/cocoa_display_init/applicationDidFinishLaunching)

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2ui/cocoa: Code movementui/cocoa.m+43 -430 replies
2/2ui/cocoa: run qemu_init in the main threadsoftmmu/main.c ui/cocoa.m+60 -750 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchPeter Maydell
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [RFC PATCH-for-7.0 v4 0/2] cocoa: run qemu_init in the main thread

From: Philippe Mathieu-Daudé <[email protected]>

Posting v4 in case someone want to iterate.

Pending issue raised by Akihiko Odaki:

* this actually breaks the "runas" option with ui/cocoa.

[+NSApplication sharedApplication] calls issetugid() to see if setgid() or setuid() is called before and calls exit() if it evaluates true. It does not evaluate true without this patch since setgid() and setuid() are called after [+NSApplication sharedApplication]. This patch, however, changes the order and triggers the check.

There are two options to solve the problem:
1. Move setgid and setuid calls after [+NSApplication sharedApplication] to let NSApplication initialize as the original user.
2. Do: [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"_NSAppAllowsNonTrustedUGID"]

Option 2 would be preferred in terms of practicality since nobody would want to initialize NSApplication as the original user (usually superuser). However, _NSAppAllowsNonTrustedUGID is not documented by Apple.

* Oudated comment in main():

1970 /*

 1971   * Create the menu entries which depend on QEMU state (for consoles
 1972   * and removeable devices). These make calls back into QEMU functions,
 1973   * which is OK because at this point we know that the second thread
 1974   * holds the iothread lock and is synchronously waiting for us to
 1975   * finish.
 1976   */

(https://marc.info/?l=qemu-devel&m=164752136410805)

Since v3:
- Move qemu_event_init before cbowner alloc
- Reduce main_thread scope to applicationDidFinishLaunching
- Updated updateUIInfo() comment (s/cocoa_display_init/applicationDidFinishLaunching)

Since v2:
- Extracted code movement in preliminary patch

v3: https://lore.kernel.org/qemu-devel/[email protected]/
v2: https://lore.kernel.org/qemu-devel/[email protected]/
v1: https://lore.kernel.org/qemu-devel/[email protected]/

Paolo Bonzini (1):
ui/cocoa: run qemu_init in the main thread

Philippe Mathieu-Daudé (1):
ui/cocoa: Code movement

 softmmu/main.c |  12 ++--
 ui/cocoa.m     | 161 ++++++++++++++++++++++---------------------------
 2 files changed, 79 insertions(+), 94 deletions(-)
Signature · 1 line
2.34.1