From patchwork Fri Aug 19 13:27:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12948828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9ACAEC32771 for ; Fri, 19 Aug 2022 13:30:34 +0000 (UTC) Received: from localhost ([::1]:46330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP253-0006pu-GG for qemu-devel@archiver.kernel.org; Fri, 19 Aug 2022 09:30:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP22r-0004gP-VO for qemu-devel@nongnu.org; Fri, 19 Aug 2022 09:28:17 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:37478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP22p-0001zV-NS for qemu-devel@nongnu.org; Fri, 19 Aug 2022 09:28:17 -0400 Received: by mail-pg1-x52f.google.com with SMTP id bh13so3711523pgb.4 for ; Fri, 19 Aug 2022 06:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MsHOELyL41xuCPGT0vkMOuAjHxEfl1oFU7luhqMaWPU=; b=GPOcZZbZEa7ZnKL69r0E7hQbHMU7iHCQR0h07pjRo2/MDNds+WktVeFULfddJ5SuLn yU8tGXjr7c9Ys8+n6O3SRikNHsiGLc+54L00diuA7Q4y8OZHTd4Bx4hqYr9ibEyHztmu vfS7101NwgZ+5DnkfxMHsCmGaAJ84265MD0XvTx/2iRU/hino/uxNIL1rN4ZSEUsVQjh yLDVS5IY6/I30cwwYPIPJxoO7m4uCjrxPwSsIBe7qQMbBJluCs66PUX12r5v5L58DWPm CroHbm9fmJCp5WFfGejco4Svl3wJnSFqhLG9KIDYkqA3x1wf7yDMhAeS+IDBH4JqVqQU uEjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MsHOELyL41xuCPGT0vkMOuAjHxEfl1oFU7luhqMaWPU=; b=DuqHofeD6tZfEyltpDaST5zX71cb1J4BTvKcOjk9FUSX8FsmkVk6YXqrUkeU2ondYS Dk6eJFbWUo/iIE9G4M40TLIUs0/r/2Z5znuzT3UA8ROPI4tO17sjEz7nQj0Xtxm1hIA5 27+maZX1hgqani6X3sMN7QhrZx92mTa8FwQJlGeb0MHyWeJdbyqOL4TQGZUVD/aYiaz2 z7Z6HUyBp6aXzK7W82KDfpaF9VaFzXS7YVd+ycP5IsPDuwCdrJjCPCjAHu1ckTx1j1zS bahcc2Q0+AfI1UAAKZsjfxFUjVzKavT5aCgYV43orAx2nU3E2h5mxxq+rbCkjT0TPJqi Js7g== X-Gm-Message-State: ACgBeo0JLEOeEyyLpK6SgWKONcS9/4v7zbp6BSpD45nK7IJ3r9NCoMaX 96ZCMretYG5/Ao7QrecWB81qi1/1iiU= X-Google-Smtp-Source: AA6agR7f7ajOq8rdDzp359pUG5mkD09bV4utIJRUUt1GLZQunRNf/2ZapyRNeLJDdxV4f9Ctfjihzw== X-Received: by 2002:a63:8143:0:b0:42a:3ec3:3b56 with SMTP id t64-20020a638143000000b0042a3ec33b56mr2394595pgd.146.1660915693911; Fri, 19 Aug 2022 06:28:13 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:c4c3:cfa3:24fd:3a7]) by smtp.gmail.com with ESMTPSA id p4-20020a1709026b8400b0016edb59f670sm3195005plk.6.2022.08.19.06.28.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Aug 2022 06:28:13 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini , Gerd Hoffmann , Emanuele Giuseppe Esposito , Kevin Wolf , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v5 1/3] ui/cocoa: Run qemu_init in the main thread Date: Fri, 19 Aug 2022 22:27:54 +0900 Message-Id: <20220819132756.74641-2-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220819132756.74641-1-akihiko.odaki@gmail.com> References: <20220819132756.74641-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=akihiko.odaki@gmail.com; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This work is based on: https://patchew.org/QEMU/20220317125534.38706-1-philippe.mathieu.daude@gmail.com/ Simplify the initialization dance by running qemu_init() in the main thread before the Cocoa event loop starts. The secondary thread only runs only 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. Overriding the code after calling qemu_init() is done by dynamically replacing a function pointer variable, qemu_main when initializing ui/cocoa, which unifies the static implementation of main() for builds with ui/cocoa and ones without ui/cocoa. Signed-off-by: Akihiko Odaki --- docs/devel/fuzzing.rst | 4 +- include/qemu-main.h | 3 +- include/sysemu/sysemu.h | 2 +- softmmu/main.c | 10 +-- softmmu/vl.c | 2 +- tests/qtest/fuzz/fuzz.c | 2 +- ui/cocoa.m | 144 ++++++++++++++-------------------------- 7 files changed, 62 insertions(+), 105 deletions(-) diff --git a/docs/devel/fuzzing.rst b/docs/devel/fuzzing.rst index 784ecb99e66..715330c8561 100644 --- a/docs/devel/fuzzing.rst +++ b/docs/devel/fuzzing.rst @@ -287,8 +287,8 @@ select the fuzz target. Then, the qtest client is initialized. If the target requires qos, qgraph is set up and the QOM/LIBQOS modules are initialized. Then the QGraph is walked and the QEMU cmd_line is determined and saved. -After this, the ``vl.c:qemu_main`` is called to set up the guest. There are -target-specific hooks that can be called before and after qemu_main, for +After this, the ``vl.c:main`` is called to set up the guest. There are +target-specific hooks that can be called before and after main, for additional setup(e.g. PCI setup, or VM snapshotting). ``LLVMFuzzerTestOneInput``: Uses qtest/qos functions to act based on the fuzz diff --git a/include/qemu-main.h b/include/qemu-main.h index 6a3e90d0ad5..940960a7dbc 100644 --- a/include/qemu-main.h +++ b/include/qemu-main.h @@ -5,6 +5,7 @@ #ifndef QEMU_MAIN_H #define QEMU_MAIN_H -int qemu_main(int argc, char **argv, char **envp); +int qemu_default_main(void); +extern int (*qemu_main)(void); #endif /* QEMU_MAIN_H */ diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 31aa45160be..6a7a31e64de 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -102,7 +102,7 @@ void qemu_boot_set(const char *boot_order, Error **errp); bool defaults_enabled(void); -void qemu_init(int argc, char **argv, char **envp); +void qemu_init(int argc, char **argv); int qemu_main_loop(void); void qemu_cleanup(void); diff --git a/softmmu/main.c b/softmmu/main.c index 1b675a8c036..694388bd7f7 100644 --- a/softmmu/main.c +++ b/softmmu/main.c @@ -30,20 +30,20 @@ #include #endif -int qemu_main(int argc, char **argv, char **envp) +int qemu_default_main(void) { int status; - qemu_init(argc, argv, envp); status = qemu_main_loop(); qemu_cleanup(); return status; } -#ifndef CONFIG_COCOA +int (*qemu_main)(void) = qemu_default_main; + int main(int argc, char **argv) { - return qemu_main(argc, argv, NULL); + qemu_init(argc, argv); + return qemu_main(); } -#endif diff --git a/softmmu/vl.c b/softmmu/vl.c index 706bd7cff79..204b0cd944b 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2603,7 +2603,7 @@ void qmp_x_exit_preconfig(Error **errp) } } -void qemu_init(int argc, char **argv, char **envp) +void qemu_init(int argc, char **argv) { QemuOpts *opts; QemuOpts *icount_opts = NULL, *accel_opts = NULL; diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 2b3bc1fb9df..eb7520544b8 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -218,7 +218,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) g_free(pretty_cmd_line); } - qemu_init(result.we_wordc, result.we_wordv, NULL); + qemu_init(result.we_wordc, result.we_wordv); /* re-enable the rcu atfork, which was previously disabled in qemu_init */ rcu_enable_atfork(); diff --git a/ui/cocoa.m b/ui/cocoa.m index 5a8bd5dd84e..660d3e09356 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -100,13 +100,9 @@ static void cocoa_switch(DisplayChangeListener *dcl, static int left_command_key_enabled = 1; static bool swap_opt_cmd; -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; @@ -597,7 +593,7 @@ - (void) updateUIInfo /* * Don't try to tell QEMU about UI information in the application * startup phase -- we haven't yet registered dcl with the QEMU UI - * layer, and also trying to take the iothread lock would deadlock. + * layer. * When cocoa_display_init() does register the dcl, the UI layer * will call cocoa_switch(), which will call updateUIInfo, so * we don't lose any information here. @@ -790,16 +786,6 @@ - (void) handleMonitorInput:(NSEvent *)event - (bool) handleEvent:(NSEvent *)event { - if(!allow_events) { - /* - * Just let OSX have all events that arrive before - * applicationDidFinishLaunching. - * This avoids a deadlock on the iothread lock, which cocoa_display_init() - * will not drop until after the app_started_sem is posted. (In theory - * there should not be any such events, but OSX Catalina now emits some.) - */ - return false; - } return bool_with_iothread_lock(^{ return [self handleEventLocked:event]; }); @@ -1287,8 +1273,6 @@ - (void)applicationDidFinishLaunching: (NSNotification *) note { COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n"); allow_events = true; - /* Tell cocoa_display_init to proceed */ - qemu_sem_post(&app_started_sem); } - (void)applicationWillTerminate:(NSNotification *)aNotification @@ -1919,92 +1903,45 @@ static void cocoa_clipboard_request(QemuClipboardInfo *info, /* * The startup process for the OSX/Cocoa UI is complicated, because * OSX insists that the UI runs on the initial main thread, and so we - * need to start a second thread which runs the vl.c qemu_main(): - * - * Initial thread: 2nd thread: + * need to start a second thread which runs the qemu_default_main(): * in main(): - * create qemu-main thread - * wait on display_init semaphore - * call qemu_main() - * ... - * in cocoa_display_init(): - * post the display_init semaphore - * wait on app_started semaphore - * create application, menus, etc - * enter OSX run loop - * in applicationDidFinishLaunching: - * post app_started semaphore - * tell main thread to fullscreen if needed - * [...] - * run qemu main-loop - * - * We do this in two stages so that we don't do the creation of the - * GUI application menus and so on for command line options like --help - * where we want to just print text to stdout and exit immediately. + * in cocoa_display_init(): + * assign cocoa_main to qemu_main + * create application, menus, etc + * in cocoa_main(): + * create qemu-main thread + * enter OSX run loop */ static void *call_qemu_main(void *opaque) { int status; - COCOA_DEBUG("Second thread: calling qemu_main()\n"); - status = qemu_main(gArgc, gArgv, *_NSGetEnviron()); - COCOA_DEBUG("Second thread: qemu_main() returned, exiting\n"); + COCOA_DEBUG("Second thread: calling qemu_default_main()\n"); + qemu_mutex_lock_iothread(); + status = qemu_default_main(); + qemu_mutex_unlock_iothread(); + COCOA_DEBUG("Second thread: qemu_default_main() returned, exiting\n"); [cbowner release]; exit(status); } -int main (int argc, char **argv) { +static int cocoa_main() +{ QemuThread thread; - COCOA_DEBUG("Entered main()\n"); - gArgc = argc; - gArgv = argv; - - qemu_sem_init(&display_init_sem, 0); - qemu_sem_init(&app_started_sem, 0); + COCOA_DEBUG("Entered %s()\n", __func__); + qemu_mutex_unlock_iothread(); qemu_thread_create(&thread, "qemu_main", call_qemu_main, NULL, QEMU_THREAD_DETACHED); - COCOA_DEBUG("Main thread: waiting for display_init_sem\n"); - qemu_sem_wait(&display_init_sem); - COCOA_DEBUG("Main thread: initializing app\n"); - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - - // Pull this console process up to being a fully-fledged graphical - // app with a menubar and Dock icon - ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - - [QemuApplication sharedApplication]; - - create_initial_menus(); - - /* - * Create the menu entries which depend on QEMU state (for consoles - * and removeable devices). These make calls back into QEMU functions, - * which is OK because at this point we know that the second thread - * holds the iothread lock and is synchronously waiting for us to - * finish. - */ - add_console_menu_entries(); - addRemovableDevicesMenuItems(); - - // Create an Application controller - QemuCocoaAppController *appController = [[QemuCocoaAppController alloc] init]; - [NSApp setDelegate:appController]; - // Start the main event loop COCOA_DEBUG("Main thread: entering OSX run loop\n"); [NSApp run]; - COCOA_DEBUG("Main thread: left OSX run loop, exiting\n"); + COCOA_DEBUG("Main thread: left OSX run loop, which should never happen\n"); - [appController release]; - [pool release]; - - return 0; + abort(); } @@ -2083,25 +2020,42 @@ static void cocoa_refresh(DisplayChangeListener *dcl) static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); - /* Tell main thread to go ahead and create the app and enter the run loop */ - qemu_sem_post(&display_init_sem); - qemu_sem_wait(&app_started_sem); - COCOA_DEBUG("cocoa_display_init: app start completed\n"); + qemu_main = cocoa_main; + + // Pull this console process up to being a fully-fledged graphical + // app with a menubar and Dock icon + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + + [QemuApplication sharedApplication]; + + create_initial_menus(); + + /* + * Create the menu entries which depend on QEMU state (for consoles + * and removeable devices). These make calls back into QEMU functions, + * which is OK because at this point we know that the second thread + * holds the iothread lock and is synchronously waiting for us to + * finish. + */ + add_console_menu_entries(); + addRemovableDevicesMenuItems(); + + // Create an Application controller + QemuCocoaAppController *controller = [[QemuCocoaAppController alloc] init]; + [NSApp setDelegate:controller]; - QemuCocoaAppController *controller = (QemuCocoaAppController *)[[NSApplication sharedApplication] delegate]; /* if fullscreen mode is to be used */ if (opts->has_full_screen && opts->full_screen) { - dispatch_async(dispatch_get_main_queue(), ^{ - [NSApp activateIgnoringOtherApps: YES]; - [controller toggleFullScreen: nil]; - }); + [NSApp activateIgnoringOtherApps: YES]; + [controller toggleFullScreen: nil]; } if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) { - dispatch_async(dispatch_get_main_queue(), ^{ - [controller setFullGrab: nil]; - }); + [controller setFullGrab: nil]; } if (opts->has_show_cursor && opts->show_cursor) { @@ -2121,6 +2075,8 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) qemu_event_init(&cbevent, false); cbowner = [[QemuCocoaPasteboardTypeOwner alloc] init]; qemu_clipboard_peer_register(&cbpeer); + + [pool release]; } static QemuDisplay qemu_display_cocoa = { From patchwork Fri Aug 19 13:27:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12948831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F9E7C32771 for ; Fri, 19 Aug 2022 13:34:35 +0000 (UTC) Received: from localhost ([::1]:51074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP28w-0003k4-Ab for qemu-devel@archiver.kernel.org; Fri, 19 Aug 2022 09:34:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP22u-0004i1-Oj for qemu-devel@nongnu.org; Fri, 19 Aug 2022 09:28:20 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:36485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP22t-0001zi-0U for qemu-devel@nongnu.org; Fri, 19 Aug 2022 09:28:20 -0400 Received: by mail-pj1-x102b.google.com with SMTP id r14-20020a17090a4dce00b001faa76931beso7546752pjl.1 for ; Fri, 19 Aug 2022 06:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=PNJRJesXZZQqJUbxS87KqUPXjO+p3EmWgOG4tm1aKkY=; b=pkFNZwOHehc/he3NZB0IPqFONEUfxekKCtt/7ye/dQQ3lLb9gHyQwr5rHMYOZpEtyE 0nEzcEd+LDAb1k95t2ZA6za6tpfmtyUPt/Aq1GoxlYUG29r91nOxi5eT8gjlWYCGaUKf /vsA7kYo7CyHBA21HA8iSPuAYyCKFBbVl4K2H2yIkxGLffOy81kNyO9R1ECSTt6Eepn7 C0pyOXym6p+F9xVVdjWkN+CmpNebs/4MlnLDKCaMegRqQJs31cs5mPP5P9NkXdfch4Rt EGdIgGX6h8NHoz94RTRq6b1QU1M/DNHp3GExaNi5gpyeKprOZ8nevtWtVG5WhlxJsIAD QaBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=PNJRJesXZZQqJUbxS87KqUPXjO+p3EmWgOG4tm1aKkY=; b=zhgveGznydrKffavqvKbLMrN/vd78Bft+RJ+UMnOJkRyNi1q6InivV++03rdnXTyU/ tuEUlQlPr1XHVE7hggURHme9HVg+mnoppoIl8Zvf1d2S50BYOaGxbdHrrWJjB0YxPrs2 vFlJTKzz7H7vGKAdJURF0WkIEoUuHfvOCoujap+jyoze0w6GmWrfVfsoTQIXe+ZnC60w PtfUDI7+SnjTChMeBLC2Q37Fsq9ZB3LGND+fc6Gg4SveGsRZPj14d5FWX0GNjWEOgzs5 F0qOwC8tBPqmf1UD/B3UUbMSzVtAt2m7FpEhiNp2jZbIxhzppZusg+ZJ/dGSWEUHtvTl vVkw== X-Gm-Message-State: ACgBeo3gk0h2O8NwUV4j+e7Xv7NMuqXVwKZr6zBjMbwQqnJQ6r0KXMS2 z+TMhv2isOlDKd5hHh/mTDj9RFw3tl8= X-Google-Smtp-Source: AA6agR7U2FJQFVp0M/EhXZIhVQcICOvVASsLd7bThn1nJWdMC1CzRAZlm96EH6+uT2qY3SnNqChHmA== X-Received: by 2002:a17:902:ef50:b0:170:9f15:b998 with SMTP id e16-20020a170902ef5000b001709f15b998mr7386591plx.102.1660915697248; Fri, 19 Aug 2022 06:28:17 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:c4c3:cfa3:24fd:3a7]) by smtp.gmail.com with ESMTPSA id p4-20020a1709026b8400b0016edb59f670sm3195005plk.6.2022.08.19.06.28.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Aug 2022 06:28:16 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini , Gerd Hoffmann , Emanuele Giuseppe Esposito , Kevin Wolf , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v5 2/3] Revert "main-loop: Disable block backend global state assertion on Cocoa" Date: Fri, 19 Aug 2022 22:27:55 +0900 Message-Id: <20220819132756.74641-3-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220819132756.74641-1-akihiko.odaki@gmail.com> References: <20220819132756.74641-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This reverts commit 47281859f66bdab1974fb122cab2cbb4a1c9af7f. Signed-off-by: Akihiko Odaki Reviewed-by: Emanuele Giuseppe Esposito Reviewed-by: Peter Maydell Reviewed-by: Paolo Bonzini --- include/qemu/main-loop.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index c50d1b7e3ab..aac707d073a 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -284,23 +284,10 @@ bool qemu_in_main_thread(void); * Please refer to include/block/block-global-state.h for more * information about GS API. */ -#ifdef CONFIG_COCOA -/* - * When using the Cocoa UI, addRemovableDevicesMenuItems() is called from - * a thread different from the QEMU main thread and can not take the BQL, - * triggering this assertions in the block layer (commit 0439c5a462). - * As the Cocoa fix is not trivial, disable this assertion for the v7.0.0 - * release (when using Cocoa); we will restore it immediately after the - * release. - * This issue is tracked as https://gitlab.com/qemu-project/qemu/-/issues/926 - */ -#define GLOBAL_STATE_CODE() -#else #define GLOBAL_STATE_CODE() \ do { \ assert(qemu_in_main_thread()); \ } while (0) -#endif /* CONFIG_COCOA */ /* * Mark and check that the function is part of the I/O API. From patchwork Fri Aug 19 13:27:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12948830 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60FCFC32771 for ; Fri, 19 Aug 2022 13:31:24 +0000 (UTC) Received: from localhost ([::1]:33834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP25r-0007SD-BC for qemu-devel@archiver.kernel.org; Fri, 19 Aug 2022 09:31:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP22x-0004nv-TE for qemu-devel@nongnu.org; Fri, 19 Aug 2022 09:28:23 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:41571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP22w-0001zt-AX for qemu-devel@nongnu.org; Fri, 19 Aug 2022 09:28:23 -0400 Received: by mail-pj1-x1032.google.com with SMTP id t2-20020a17090a4e4200b001f21572f3a4so4910951pjl.0 for ; Fri, 19 Aug 2022 06:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MPQW4Rnem4KMReYwXiEy55PhYSsQ/M3unNrHvLUzwfA=; b=TUml19oXwiREqzt7pFgdB8eacU4HUzHtxk+4APzqCZK9K10wuxzEHolNTwlwUoq4Ez jzx6BT7JcbgsSGMzk3wi3v/2hoODqfm/12n9NZyWBGt7KtXrE7RtPx6tH4VVRB/xHpe8 ZEzaIuHRFtdS//LIADr1N7gNLB541GQr9et0Ioo4ld+FAWx4a3wQhiHGp//U9Nl0YZ9k 9msBV/hXRyuIIBxQhcBxFhes9NHrm0FtREiRTvGAp/zBzMaJerhD7gFE/ZYeZQSjwwDw p824JUVc+Y8w55YHSnhmb7Y7FdIQAjSw90I+8BcYZlbo7rQQC9ERnDZB8yfZ9uPKB0Js WyPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MPQW4Rnem4KMReYwXiEy55PhYSsQ/M3unNrHvLUzwfA=; b=X+IrJUGLJ4KtKLVThvsqeyQQf/f2u7B/rGb5LSK8AP7ZyhusXgILo3iLVLbJaDBjDd Mc4gjd/CcxHP6Ah3fKcjbJDAQesupUIzc/QltZnttkXFYwz/7G+Rjq6kLqITwxjLge7w 5krs+NzDUi1EPQ9RbH4PlqT8aNwC1LgR6aK5tPMwqwjlkoBmOAxxfIRPl9EVp658UDfp Ql1pNwHlBFJMTN0DvSQHKEFtI6nNclKyl60AC7frf8NsHYfhzYdLB8OBSifS1oS2A7Sz 0hGiqj+Dy5qTgP6uB3ra7mIncNXSJUzDcbk+Vpht8R01J6ptggqEnXvqVTRh8IAYUJx9 CtAg== X-Gm-Message-State: ACgBeo1DBGnhIBHlW3RvSDcHJuExVxwJcuG0QzOVm6JcptZdZWkfvoCP RoRCfj+qS8GyUZtMx2no7h+s3gRei0c= X-Google-Smtp-Source: AA6agR7O30pC3TZVtxGOfLRcZlAoYCVv827KkXN0s8PFYXB1/fMl7QdTTNsUVbpx65L5nzwnwFTVOA== X-Received: by 2002:a17:902:dac7:b0:16f:13c6:938d with SMTP id q7-20020a170902dac700b0016f13c6938dmr7533051plx.11.1660915700630; Fri, 19 Aug 2022 06:28:20 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:c4c3:cfa3:24fd:3a7]) by smtp.gmail.com with ESMTPSA id p4-20020a1709026b8400b0016edb59f670sm3195005plk.6.2022.08.19.06.28.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Aug 2022 06:28:19 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini , Gerd Hoffmann , Emanuele Giuseppe Esposito , Kevin Wolf , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v5 3/3] meson: Allow to enable gtk and sdl while cocoa is enabled Date: Fri, 19 Aug 2022 22:27:56 +0900 Message-Id: <20220819132756.74641-4-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220819132756.74641-1-akihiko.odaki@gmail.com> References: <20220819132756.74641-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As ui/cocoa does no longer override main(), ui/gtk and ui/sdl can be enabled even ui/cocoa is enabled. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Reviewed-by: Paolo Bonzini --- meson.build | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 20fddbd707c..48b6c22aab7 100644 --- a/meson.build +++ b/meson.build @@ -589,12 +589,6 @@ endif cocoa = dependency('appleframeworks', modules: ['Cocoa', 'CoreVideo'], required: get_option('cocoa')) -if cocoa.found() and get_option('sdl').enabled() - error('Cocoa and SDL cannot be enabled at the same time') -endif -if cocoa.found() and get_option('gtk').enabled() - error('Cocoa and GTK+ cannot be enabled at the same time') -endif vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet')) if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h', @@ -921,7 +915,7 @@ if not get_option('brlapi').auto() or have_system endif sdl = not_found -if not get_option('sdl').auto() or (have_system and not cocoa.found()) +if not get_option('sdl').auto() or have_system sdl = dependency('sdl2', required: get_option('sdl'), kwargs: static_kwargs) sdl_image = not_found endif @@ -1187,7 +1181,7 @@ endif gtk = not_found gtkx11 = not_found vte = not_found -if not get_option('gtk').auto() or (have_system and not cocoa.found()) +if not get_option('gtk').auto() or have_system gtk = dependency('gtk+-3.0', version: '>=3.22.0', method: 'pkg-config', required: get_option('gtk'),