From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Emanuele Giuseppe Esposito" <eesposit@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Akihiko Odaki" <akihiko.odaki@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [RFC PATCH-for-7.0 v3 2/2] ui/cocoa: run qemu_init in the main thread
Date: Thu, 17 Mar 2022 13:02:20 +0100 [thread overview]
Message-ID: <3c581089-9abb-6576-1c94-28108206ebff@gmail.com> (raw)
In-Reply-To: <20220317115644.37276-3-philippe.mathieu.daude@gmail.com>
On 17/3/22 12:56, Philippe Mathieu-Daudé wrote:
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> Simplify the initialization dance by running qemu_init() in the main
> thread before the Cocoa event loop starts. The cocoa_display_init()
> code that is post-applicationDidFinishLaunching: moves to the
> application delegate itself, and the secondary thread only runs
> the rest of qemu_main(), namely qemu_main_loop() and qemu_cleanup().
>
> This fixes a case where addRemovableDevicesMenuItems() calls
> qmp_query_block() while expecting the main thread to still hold
> the BQL. The newly-introduced assertions in the block layer
> complain about this.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Message-Id: <20220307151004.578069-1-pbonzini@redhat.com>
> [PMD: Fixed trivial build failures & rebased]
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> softmmu/main.c | 12 +++---
> ui/cocoa.m | 114 ++++++++++++++++++++-----------------------------
> 2 files changed, 54 insertions(+), 72 deletions(-)
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 027c3053f7..2e5130d805 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -100,14 +100,13 @@ static int last_buttons;
> static int cursor_hide = 1;
> static int left_command_key_enabled = 1;
> static bool swap_opt_cmd;
> +static bool full_screen;
> +static bool full_grab;
> +static bool have_cocoa_ui;
>
> -static int gArgc;
> -static char **gArgv;
> static bool stretch_video;
> static NSTextField *pauseLabel;
>
> -static QemuSemaphore display_init_sem;
> -static QemuSemaphore app_started_sem;
> static bool allow_events;
>
> static NSInteger cbchangecount = -1;
> @@ -115,6 +114,7 @@ static QemuClipboardInfo *cbinfo;
> static QemuClipboardPeer cbpeer;
> static QemuCocoaPasteboardTypeOwner *cbowner;
> static QemuEvent cbevent;
> +static QemuThread main_thread;
This variable doesn't need to be in global scope, I'll
move it to applicationDidFinishLaunching().
> @@ -1323,8 +1310,22 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
> {
> COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n");
> allow_events = true;
> - /* Tell cocoa_display_init to proceed */
> - qemu_sem_post(&app_started_sem);
> +
> + // register vga output callbacks
> + register_displaychangelistener(&dcl);
> +
> + qemu_clipboard_peer_register(&cbpeer);
> + qemu_mutex_unlock_iothread();
> + qemu_thread_create(&main_thread, "qemu_main_loop", call_qemu_main_loop,
> + NULL, QEMU_THREAD_DETACHED);
> +
> + if (full_screen) {
> + [NSApp activateIgnoringOtherApps: YES];
> + [self toggleFullScreen: nil];
> + }
> + if (full_grab) {
> + [self setFullGrab: nil];
> + }
> }
next prev parent reply other threads:[~2022-03-17 12:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 11:56 [RFC PATCH-for-7.0 v3 0/2] cocoa: run qemu_init in the main thread Philippe Mathieu-Daudé
2022-03-17 11:56 ` [RFC PATCH-for-7.0 v3 1/2] ui/cocoa: Code movement Philippe Mathieu-Daudé
2022-03-17 11:58 ` Peter Maydell
2022-03-17 11:56 ` [RFC PATCH-for-7.0 v3 2/2] ui/cocoa: run qemu_init in the main thread Philippe Mathieu-Daudé
2022-03-17 12:02 ` Philippe Mathieu-Daudé [this message]
2022-03-17 12:04 ` Peter Maydell
2022-03-17 12:48 ` Akihiko Odaki
2022-03-17 12: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=3c581089-9abb-6576-1c94-28108206ebff@gmail.com \
--to=philippe.mathieu.daude@gmail.com \
--cc=akihiko.odaki@gmail.com \
--cc=eesposit@redhat.com \
--cc=f4bug@amsat.org \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.