From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187212; cv=none; d=zohomail.com; s=zohoarc; b=NcXH5CqfhWMFGUAtIuWvNBbbcXlzDpRwAEgRu0FDDfmhQAHf4+aq2y91CtQv9Rpmd0sHn7lYFfCiVQyo/cBi1cQCP7g8NIEJs7ThfUJrGHVmP2BAgNVc6ZB5qQlKX5xgSOUhufgwKAkKOuSWWiN+DZ6QDmjapWoC8k7NZ0qN1OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187212; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t+8ci7yIxQ8T3QiJDY00xznjj3eoJ5YaGlNk+syamAw=; b=jm0Y+xcCo+rjhcTLXGC+DADuapWKxVHjldyueJ/8P3AxA1wPAzfDyi161aeAeWJWesZPXhJ7TpYee7/ZHEtqRgv9KHoYFtxommbr9LRg7tdPcucsjVS1HWowA9hA8/upnk3UltW1x5YDceotyizwgDNHSQi1w4DKO547ycsIJFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187212470901.656179198899; Mon, 26 Sep 2022 03:13:32 -0700 (PDT) Received: from localhost ([::1]:42420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl7D-0003nZ-0U for importer@patchew.org; Mon, 26 Sep 2022 06:13:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpd-0004o9-Qi for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpb-0003ez-4T for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-361-Ppwqmmw0Mfmjz6l-UexR_w-1; Mon, 26 Sep 2022 05:55:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 350183810780; Mon, 26 Sep 2022 09:55:12 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 873612084837; Mon, 26 Sep 2022 09:55:11 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E75C31803097; Mon, 26 Sep 2022 11:55:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t+8ci7yIxQ8T3QiJDY00xznjj3eoJ5YaGlNk+syamAw=; b=EBGgVZUKRYKASql37RteQkgNdXDtFvysiK5PuT1YVB0BSFw1+feEM/IycJ7o4EsQBJ7+B3 naxje9S1JmNPLVtZ3Vk/XMYPW0CxpIuK9N3EIRwFMiEGvlsKJDty/zhp3lrGijtUM2/kz+ gB6orwR2tFgi0Bf0fFZ7NMCNZoY/1Fg= X-MC-Unique: Ppwqmmw0Mfmjz6l-UexR_w-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Cal Peake Subject: [PULL 01/25] ui/console: Get tab completion working again in the SDL monitor vc Date: Mon, 26 Sep 2022 11:54:45 +0200 Message-Id: <20220926095509.3759409-2-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187214532100001 Content-Type: text/plain; charset="utf-8" From: Cal Peake Define a QEMU special key constant for the tab key and add an entry for it in the qcode_to_keysym table. This allows tab completion to work again in the SDL monitor virtual console, which has been broken ever since the migration from SDL1 to SDL2. Signed-off-by: Cal Peake Message-Id: <7054816e-99c-7e2-6737-7cf98cc56e2@absolutedigital.net> Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 + ui/console.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index c0520c694c23..e400ee9fa74b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -70,6 +70,7 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict); /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ #define QEMU_KEY_ESC1(c) ((c) | 0xe100) +#define QEMU_KEY_TAB 0x0009 #define QEMU_KEY_BACKSPACE 0x007f #define QEMU_KEY_UP QEMU_KEY_ESC1('A') #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B') diff --git a/ui/console.c b/ui/console.c index 765892f84f1c..243f2f6e64ae 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1368,6 +1368,7 @@ static const int qcode_to_keysym[Q_KEY_CODE__MAX] =3D= { [Q_KEY_CODE_PGUP] =3D QEMU_KEY_PAGEUP, [Q_KEY_CODE_PGDN] =3D QEMU_KEY_PAGEDOWN, [Q_KEY_CODE_DELETE] =3D QEMU_KEY_DELETE, + [Q_KEY_CODE_TAB] =3D QEMU_KEY_TAB, [Q_KEY_CODE_BACKSPACE] =3D QEMU_KEY_BACKSPACE, }; =20 --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664186314; cv=none; d=zohomail.com; s=zohoarc; b=BYheNehwMiR8QPC94aZCddCwHDEslKRhgHAV2r2eDJzyf2SKVSr/MtpzMxsdex1lrLD1gmiNC1wzF/kLOwc7Nqq/XKu5BIiDt0ZYW9+mc/xIYfmPJN+K/K3Rc/eCVouIRMflIWTP8B+4Uc2E1liExw8MUH6NaWQ0seN7HXcSQIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664186314; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/zq3OWtNsr/F8P8xBpqtvQmjLKJC+788Jtr6JhyFLLk=; b=MaJ2QhurYX3u/+kODKzLUy+K2nv3/q7FJawEdo/XP2yvo/TfkQq4u4owCBhMwwK4vdh5oL4lUOuWhzds+rnK2hlx9Kby7zr9K4aqRq5ooyHIZmMrdEIkqj7tlZANYJu5kJTdei5mWYMnkuuZCN8jBvl82zc5+hQiDW7V9koPsAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664186313949423.9632956486115; Mon, 26 Sep 2022 02:58:33 -0700 (PDT) Received: from localhost ([::1]:48500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocksi-0007di-C1 for importer@patchew.org; Mon, 26 Sep 2022 05:58:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpd-0004mj-Mm for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57569) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpa-0003fh-Vr for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-8oNYam9xNmSdlZqvc4lHSQ-1; Mon, 26 Sep 2022 05:55:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 356C5811E67; Mon, 26 Sep 2022 09:55:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A13222166B26; Mon, 26 Sep 2022 09:55:13 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0E89A18030A8; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zq3OWtNsr/F8P8xBpqtvQmjLKJC+788Jtr6JhyFLLk=; b=TOjeLB5egnejK4AQNmDn1l/lPTI+wJfs8gdX0oCTSGc8ppdZbwIbtiwP51T2FXDfxiA649 bchc0TPjRdw+QWElNmxDRXyVlmQRWToPQvwejhvsklQOc3AFN8WrTjNX+mCUlpz1mO68TJ E/sIYrgSq+5kNNvSSRk0Omo959UlUFk= X-MC-Unique: 8oNYam9xNmSdlZqvc4lHSQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth Subject: [PULL 02/25] ui/cocoa: Run qemu_init in the main thread Date: Mon, 26 Sep 2022 11:54:46 +0200 Message-Id: <20220926095509.3759409-3-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664186316370100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki This work is based on: https://patchew.org/QEMU/20220317125534.38706-1-philippe.mathieu.daude@gmai= l.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 Message-Id: <20220819132756.74641-2-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- include/qemu-main.h | 3 +- include/sysemu/sysemu.h | 2 +- softmmu/main.c | 10 +-- softmmu/vl.c | 2 +- tests/qtest/fuzz/fuzz.c | 2 +- docs/devel/fuzzing.rst | 4 +- ui/cocoa.m | 144 ++++++++++++++-------------------------- 7 files changed, 62 insertions(+), 105 deletions(-) diff --git a/include/qemu-main.h b/include/qemu-main.h index 6a3e90d0ad59..940960a7dbcb 100644 --- a/include/qemu-main.h +++ b/include/qemu-main.h @@ -5,6 +5,7 @@ #ifndef QEMU_MAIN_H #define QEMU_MAIN_H =20 -int qemu_main(int argc, char **argv, char **envp); +int qemu_default_main(void); +extern int (*qemu_main)(void); =20 #endif /* QEMU_MAIN_H */ diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 31aa45160be8..6a7a31e64dea 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= ); =20 bool defaults_enabled(void); =20 -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); =20 diff --git a/softmmu/main.c b/softmmu/main.c index 1b675a8c036f..694388bd7f7f 100644 --- a/softmmu/main.c +++ b/softmmu/main.c @@ -30,20 +30,20 @@ #include #endif =20 -int qemu_main(int argc, char **argv, char **envp) +int qemu_default_main(void) { int status; =20 - qemu_init(argc, argv, envp); status =3D qemu_main_loop(); qemu_cleanup(); =20 return status; } =20 -#ifndef CONFIG_COCOA +int (*qemu_main)(void) =3D 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 e62b9cc35d75..9abadcc15051 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2605,7 +2605,7 @@ void qmp_x_exit_preconfig(Error **errp) } } =20 -void qemu_init(int argc, char **argv, char **envp) +void qemu_init(int argc, char **argv) { QemuOpts *opts; QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 2b3bc1fb9df5..eb7520544b80 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); } =20 - qemu_init(result.we_wordc, result.we_wordv, NULL); + qemu_init(result.we_wordc, result.we_wordv); =20 /* re-enable the rcu atfork, which was previously disabled in qemu_ini= t */ rcu_enable_atfork(); diff --git a/docs/devel/fuzzing.rst b/docs/devel/fuzzing.rst index 784ecb99e667..715330c85613 100644 --- a/docs/devel/fuzzing.rst +++ b/docs/devel/fuzzing.rst @@ -287,8 +287,8 @@ select the fuzz target. Then, the qtest client is initi= alized. 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. =20 -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). =20 ``LLVMFuzzerTestOneInput``: Uses qtest/qos functions to act based on the f= uzz diff --git a/ui/cocoa.m b/ui/cocoa.m index 5a8bd5dd84e0..660d3e093569 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 =3D 1; static bool swap_opt_cmd; =20 -static int gArgc; -static char **gArgv; static bool stretch_video; static NSTextField *pauseLabel; =20 -static QemuSemaphore display_init_sem; -static QemuSemaphore app_started_sem; static bool allow_events; =20 static NSInteger cbchangecount =3D -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 =20 - (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_displa= y_init() - * will not drop until after the app_started_sem is posted. (In th= eory - * 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: (NSNotificatio= n *) note { COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n"); allow_events =3D true; - /* Tell cocoa_display_init to proceed */ - qemu_sem_post(&app_started_sem); } =20 - (void)applicationWillTerminate:(NSNotification *)aNotification @@ -1919,92 +1903,45 @@ static void cocoa_clipboard_request(QemuClipboardIn= fo *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 n= eeded - * [...] - * 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 */ =20 static void *call_qemu_main(void *opaque) { int status; =20 - COCOA_DEBUG("Second thread: calling qemu_main()\n"); - status =3D 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 =3D qemu_default_main(); + qemu_mutex_unlock_iothread(); + COCOA_DEBUG("Second thread: qemu_default_main() returned, exiting\n"); [cbowner release]; exit(status); } =20 -int main (int argc, char **argv) { +static int cocoa_main() +{ QemuThread thread; =20 - COCOA_DEBUG("Entered main()\n"); - gArgc =3D argc; - gArgv =3D argv; - - qemu_sem_init(&display_init_sem, 0); - qemu_sem_init(&app_started_sem, 0); + COCOA_DEBUG("Entered %s()\n", __func__); =20 + qemu_mutex_unlock_iothread(); qemu_thread_create(&thread, "qemu_main", call_qemu_main, NULL, QEMU_THREAD_DETACHED); =20 - 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 =3D [[NSAutoreleasePool alloc] init]; - - // Pull this console process up to being a fully-fledged graphical - // app with a menubar and Dock icon - ProcessSerialNumber psn =3D { 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 =3D [[QemuCocoaAppController all= oc] 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"); =20 - [appController release]; - [pool release]; - - return 0; + abort(); } =20 =20 @@ -2083,25 +2020,42 @@ static void cocoa_refresh(DisplayChangeListener *dc= l) =20 static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) { + NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]; + COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); =20 - /* Tell main thread to go ahead and create the app and enter the run l= oop */ - qemu_sem_post(&display_init_sem); - qemu_sem_wait(&app_started_sem); - COCOA_DEBUG("cocoa_display_init: app start completed\n"); + qemu_main =3D cocoa_main; + + // Pull this console process up to being a fully-fledged graphical + // app with a menubar and Dock icon + ProcessSerialNumber psn =3D { 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 =3D [[QemuCocoaAppController alloc]= init]; + [NSApp setDelegate:controller]; =20 - QemuCocoaAppController *controller =3D (QemuCocoaAppController *)[[NSA= pplication 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]; } =20 if (opts->has_show_cursor && opts->show_cursor) { @@ -2121,6 +2075,8 @@ static void cocoa_display_init(DisplayState *ds, Disp= layOptions *opts) qemu_event_init(&cbevent, false); cbowner =3D [[QemuCocoaPasteboardTypeOwner alloc] init]; qemu_clipboard_peer_register(&cbpeer); + + [pool release]; } =20 static QemuDisplay qemu_display_cocoa =3D { --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664186810; cv=none; d=zohomail.com; s=zohoarc; b=h+8gfvrR7kN42TO58+fRY9sO3m/dSo7IgQwS+lvEy8w5Py8cE/ytV9kdhsYXHv5HC0cQINPCCyYI8Lk7J0Q884s/ybP6aOJJn/2d+dmVg8wxPobr/oJV/Ik9+dKQ473g7afMxNAFCSEoE0yjpKHF9fpPqa5KQAZZXUw/UdVxNSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664186810; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FTKq25OCJ8Ex90En1AKkU4cElLVlu/nURiwsIyiJ+es=; b=NamdFiyjKamI3BYyTK7NcJwiEM+XIPQKxUb3oss7URs3MIUU6ShXEa33ywziB096bCDTQ1u77Uw8A/78N6sHF+8B/V8RtVJqthkOm1wPbN9o01AIwJwI398dAxVMHAof1nG0ArMOcg51XH98EJ6Uwnlgs3aGYSFIVpVDexYdXZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664186810450613.6859194913585; Mon, 26 Sep 2022 03:06:50 -0700 (PDT) Received: from localhost ([::1]:55056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl0j-000129-9a for importer@patchew.org; Mon, 26 Sep 2022 06:06:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpd-0004oe-Uj for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55231) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpb-0003fX-5j for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-339-YE7XwNbeOeiur7QAcxCYWg-1; Mon, 26 Sep 2022 05:55:15 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D0EE3810785; Mon, 26 Sep 2022 09:55:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A356B40C2064; Mon, 26 Sep 2022 09:55:13 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2139518030A9; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FTKq25OCJ8Ex90En1AKkU4cElLVlu/nURiwsIyiJ+es=; b=HJOlnUUjo2Q1p1FA3pSTq4ZDkvSLWYJaFM9E3rgYLNN6GLJN8yWCRuhMWjLrksefzAzTH/ RQD4AuvD8s90OEBxLkUpftBGdyreiM3iBsvEf5LAzT5HFEVbYTOKCgGliY6X4sC7r3llAj Sspi6eCPr4kB6Jxz0H3N9LLzJr8GYGQ= X-MC-Unique: YE7XwNbeOeiur7QAcxCYWg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Emanuele Giuseppe Esposito Subject: [PULL 03/25] Revert "main-loop: Disable block backend global state assertion on Cocoa" Date: Mon, 26 Sep 2022 11:54:47 +0200 Message-Id: <20220926095509.3759409-4-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664186811757100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki This reverts commit 47281859f66bdab1974fb122cab2cbb4a1c9af7f. Signed-off-by: Akihiko Odaki Reviewed-by: Emanuele Giuseppe Esposito Reviewed-by: Peter Maydell Reviewed-by: Paolo Bonzini Message-Id: <20220819132756.74641-3-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- 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 c50d1b7e3ab6..aac707d073a1 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 */ =20 /* * Mark and check that the function is part of the I/O API. --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187022; cv=none; d=zohomail.com; s=zohoarc; b=Z9FFzerG3xvBRxm277s8Jp0/JUrC7jJs19HI2WjlZ90knRNHbaLiFkngS0MMrJz1jsK/XqoxS8UzvNI4FmfraQYYv+VB0JsoZ+dmfQUIMDaCxa33lM7dEo+zDUampxorRF8JCGh5qeWv4VNFTH+LW6d/tcT3EUZ51GyU4KqCVFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187022; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qz6m5wNnMR4b4k9F7KgrsOGoMcMDGwawdO4N7dnhA6U=; b=St3VET/OfHoKviuF+IXsPEjSYbiOUbCUVDF6xPZu3UokoUYnc7bxI9XitbwKj4mFJc+ChikSM8hsxsG9Irr1ydC92YQ14cvesmaOS9v7kQ84SM4PIyU0SxYmhMgLCfD0Qc5k8Ba/enXUk0YkOxKF8ORyTOssXoe0gDFIRoB5f90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187022165761.9116536799753; Mon, 26 Sep 2022 03:10:22 -0700 (PDT) Received: from localhost ([::1]:43838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl49-0006VO-2I for importer@patchew.org; Mon, 26 Sep 2022 06:10:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpd-0004kh-JK for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpb-0003eo-1f for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-487-p5TWhNsrOji--ti-BX-tBA-1; Mon, 26 Sep 2022 05:55:16 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0706A101CC62; Mon, 26 Sep 2022 09:55:16 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B478B492CA2; Mon, 26 Sep 2022 09:55:15 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2DB9B18030AB; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qz6m5wNnMR4b4k9F7KgrsOGoMcMDGwawdO4N7dnhA6U=; b=F7W75dWrOC3fI06TVmw8v3bfpAEPT+gDeBeECnrzrQHGX4QErgrrWYVNq7HWH8KQZxE3q+ /rKN5Lq+mO+FGOThzuHJTrhKIu7PYf+rwjrJK3IsMXF5UqeGOhZtArcpZz8mApSVIRP1br jzOKEkTlqYhjBDpF9zqf+pQFXoRorrM= X-MC-Unique: p5TWhNsrOji--ti-BX-tBA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth Subject: [PULL 04/25] meson: Allow to enable gtk and sdl while cocoa is enabled Date: Mon, 26 Sep 2022 11:54:48 +0200 Message-Id: <20220926095509.3759409-5-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187022952100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki 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 Message-Id: <20220819132756.74641-4-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- meson.build | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 3885fc107633..d9ac91ff3659 100644 --- a/meson.build +++ b/meson.build @@ -589,12 +589,6 @@ endif =20 cocoa =3D 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 =20 vmnet =3D dependency('appleframeworks', modules: 'vmnet', required: get_op= tion('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 =20 sdl =3D 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 =3D dependency('sdl2', required: get_option('sdl'), kwargs: static_k= wargs) sdl_image =3D not_found endif @@ -1187,7 +1181,7 @@ endif gtk =3D not_found gtkx11 =3D not_found vte =3D 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 =3D dependency('gtk+-3.0', version: '>=3D3.22.0', method: 'pkg-config', required: get_option('gtk'), --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664186912; cv=none; d=zohomail.com; s=zohoarc; b=i3gfcUHD6RcB/u4lNILwoLWAtZqgWJtqd+BjHTY6F/U6DTp5mQ+fubJaMAgIMRckKFBKiWyVLPRTAZJc95Q8roJLhY5rQrJuWjcJ9nKpVOHAM9G7lzHWfsB8+tmvfHYZkWbN5+5lZ7KX070UFP/hlIyND4a9MJcwcbGE8b44/EQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664186912; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1lkEzdjW1YeSTjXm2o8kRYkVOAn224fd2T365fiA4EU=; b=W9nNEF7Z1waK0FCOSwZCF0JQkaZQkS/UkYb7d7zP0BTfMbpO01dIuExJMOc9p9f21KEZXU2S5EyQrq9TgIfKpSyiI3D2Rx52w5G9bPFGoeU17uh0obm8gYuMBP0eUvcQjk8DDD0rM7m3iLGYze37d1Dh8DB0ANkw0s7xrvrFiDM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664186912069352.6815692852325; Mon, 26 Sep 2022 03:08:32 -0700 (PDT) Received: from localhost ([::1]:40988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl2L-0002Xt-RE for importer@patchew.org; Mon, 26 Sep 2022 06:08:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpg-0004to-86 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpd-0003hu-JR for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-261-z_LGiagyN62BQTwTBW6i4g-1; Mon, 26 Sep 2022 05:55:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2515F3810785; Mon, 26 Sep 2022 09:55:16 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B28C717583; Mon, 26 Sep 2022 09:55:15 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3FEAB18030AC; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1lkEzdjW1YeSTjXm2o8kRYkVOAn224fd2T365fiA4EU=; b=AeI0wEjirnfrZCGBVuc9FarJxsRXfs4AkPNMEvjISrmGAGYI88MDou2nodrZ8iEA9Pir9j wLjahtNLHWgOhjhgbH/cK2ZSGNg6gYZ2wdZlgGCg5DDmgTgeQ8QlWOo8/2dlvKgJKcOVZY nZ9HyxpZv0pwfN0B5S5v3wjDmeEAf8g= X-MC-Unique: z_LGiagyN62BQTwTBW6i4g-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 05/25] ui: add some vdagent related traces Date: Mon, 26 Sep 2022 11:54:49 +0200 Message-Id: <20220926095509.3759409-6-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664186914315100001 From: Marc-Andr=C3=A9 Lureau This helps debugging clipboard serial sync issues. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-2-marcandre.lureau@redhat.com> [ kraxel: code style fix ] Signed-off-by: Gerd Hoffmann --- ui/clipboard.c | 11 +++++++++-- ui/vdagent.c | 4 ++++ ui/trace-events | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ui/clipboard.c b/ui/clipboard.c index 9079ef829b51..cd5382fcb0c1 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "ui/clipboard.h" +#include "trace.h" =20 static NotifierList clipboard_notifiers =3D NOTIFIER_LIST_INITIALIZER(clipboard_notifiers); @@ -43,17 +44,23 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *pee= r, =20 bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client) { + bool ok; + if (!info->has_serial || !cbinfo[info->selection] || !cbinfo[info->selection]->has_serial) { + trace_clipboard_check_serial(-1, -1, true); return true; } =20 if (client) { - return cbinfo[info->selection]->serial >=3D info->serial; + ok =3D cbinfo[info->selection]->serial >=3D info->serial; } else { - return cbinfo[info->selection]->serial > info->serial; + ok =3D cbinfo[info->selection]->serial > info->serial; } + + trace_clipboard_check_serial(cbinfo[info->selection]->serial, info->se= rial, ok); + return ok; } =20 void qemu_clipboard_update(QemuClipboardInfo *info) diff --git a/ui/vdagent.c b/ui/vdagent.c index a899eed195d3..58ce7507fddc 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -533,6 +533,8 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev = *vd, uint8_t s, uint32_t info->has_serial =3D true; info->serial =3D *(uint32_t *)data; if (info->serial < vd->last_serial[s]) { + trace_vdagent_cb_grab_discard(GET_NAME(sel_name, s), + vd->last_serial[s], info->serial= ); /* discard lower-ordering guest grab */ return; } @@ -853,6 +855,8 @@ static void vdagent_chr_accept_input(Chardev *chr) =20 static void vdagent_disconnect(VDAgentChardev *vd) { + trace_vdagent_disconnect(); + buffer_reset(&vd->outbuf); vdagent_reset_bufs(vd); vd->caps =3D 0; diff --git a/ui/trace-events b/ui/trace-events index a922f00e10b4..977577fbba58 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -127,15 +127,20 @@ xkeymap_vendor(const char *name) "vendor '%s'" xkeymap_keycodes(const char *name) "keycodes '%s'" xkeymap_keymap(const char *name) "keymap '%s'" =20 +# clipboard.c +clipboard_check_serial(int cur, int recv, bool ok) "cur:%d recv:%d %d" + # vdagent.c vdagent_open(void) "" vdagent_close(void) "" +vdagent_disconnect(void) "" vdagent_send(const char *name) "msg %s" vdagent_send_empty_clipboard(void) "" vdagent_recv_chunk(uint32_t size) "size %d" vdagent_recv_msg(const char *name, uint32_t size) "msg %s, size %d" vdagent_peer_cap(const char *name) "cap %s" vdagent_cb_grab_selection(const char *name) "selection %s" +vdagent_cb_grab_discard(const char *name, int cur, int recv) "selection %s= , cur:%d recv:%d" vdagent_cb_grab_type(const char *name) "type %s" vdagent_cb_serial_discard(uint32_t current, uint32_t received) "current=3D= %u, received=3D%u" =20 --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664186541; cv=none; d=zohomail.com; s=zohoarc; b=A0WPKZYR7/DbLR14fDnJ2O/hBf0B08ELe+kg7yFl0w82CqRASLhKfK178EMtUr+rJz3Z/fqjbAcTeMyn1FOLqLtE2lBs9ivqlGmhicx+cJDa7owH03bLX42Al4/Te1Sl8RwEXdr3V7abwqQ8GH2eYvlL2FYTDhIdW/PD2uWQIic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664186541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X8MB6qewQt3dNDFWmIT6gK9a8vJJkApS1O6Zso0beBQ=; b=X9YugCRlihn6ZG5jinkMvofoKDNbPiVBgdEfBU+WF+7OtUJd8LJiPVvD2VWLD52suVoylN7I+kjdqG2KkEpoBEkwVQyaXGeH8HxGc1TbhYWWqBpvV6DjSz1l2CPW9Xa8gQO30V84desH2U1W4SnFv4n4YB9zuWZ7QYLpjPWr2B8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664186541347222.92202893176784; Mon, 26 Sep 2022 03:02:21 -0700 (PDT) Received: from localhost ([::1]:44314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ockwO-0004xy-1O for importer@patchew.org; Mon, 26 Sep 2022 06:02:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpe-0004pq-7o for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpc-0003g6-GT for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:21 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-318-bD0SU6DZMBybMALOrt9L3A-1; Mon, 26 Sep 2022 05:55:18 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAFC03C11040; Mon, 26 Sep 2022 09:55:17 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6EFBE49BB60; Mon, 26 Sep 2022 09:55:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4D0E618030AD; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X8MB6qewQt3dNDFWmIT6gK9a8vJJkApS1O6Zso0beBQ=; b=UeCbsG1+AAd9n/gouw9UOu+JQjFQY4qlOWYIheUaVXMkAdnYmE2KcWyD1TzxeTGv3VaP8N JuMg4mh7ppkBKXH694S+1brl5F5Cv897wr6gC1gVQkfEvGazQQH1Fpp38T6pH5grKlNk5l sqV5vjUXXVnJvTG0pY472dPwrIU5B8E= X-MC-Unique: bD0SU6DZMBybMALOrt9L3A-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 06/25] ui/clipboard: fix serial priority Date: Mon, 26 Sep 2022 11:54:50 +0200 Message-Id: <20220926095509.3759409-7-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664186542211100001 From: Marc-Andr=C3=A9 Lureau The incoming grab event should have a higher serial. See also "vdagent: introduce VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL": https://gitlab.freedesktop.org/spice/spice-protocol/-/commit/045a6978d6dbbf= 7046affc5c321fa8177c8cce56 This is only a relevant fix for the -display dbus, only user of that function. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-3-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/clipboard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/clipboard.c b/ui/clipboard.c index cd5382fcb0c1..3e2d02d5490c 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -54,9 +54,9 @@ bool qemu_clipboard_check_serial(QemuClipboardInfo *info,= bool client) } =20 if (client) { - ok =3D cbinfo[info->selection]->serial >=3D info->serial; + ok =3D info->serial >=3D cbinfo[info->selection]->serial; } else { - ok =3D cbinfo[info->selection]->serial > info->serial; + ok =3D info->serial > cbinfo[info->selection]->serial; } =20 trace_clipboard_check_serial(cbinfo[info->selection]->serial, info->se= rial, ok); --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187110; cv=none; d=zohomail.com; s=zohoarc; b=Bx1qTAYQXi+oXPvNYueTBaOWYa3+2avqmrUM2KAmCip/UsLcGa409LEHUxGAEwP0lCDS3YnPvcmLdAgZDjf2N0ZvJ5AIlPzr327inbQqaaNcN3wyW16eYA1fhpwJdLLMwAXGQksIH16MFWyW7nMfPc0Dd1C1ilDiAxxHC+7qYFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187110; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y0j2Aqtnv13FSXqrmRMEFPQ/3l4+enM7Zc2eriMcTAk=; b=MJ7azEWEbXQPxKwZU1IGiq4QLlYeUvcXHiliKlw3wfns8gdKL8GVS2CCQm/ggoyQo9goJf8hWWlFn5VRiUWTgSvEgKkIWA0z09v1qA2J02JFOkuD9gGsIfzNpNk1VLHXTqJso4D5MeV0OKGfbbsSl7PNHTWbwTccmWowJZIy1x4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187110575692.787809635936; Mon, 26 Sep 2022 03:11:50 -0700 (PDT) Received: from localhost ([::1]:50800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl5Z-0000Zd-BE for importer@patchew.org; Mon, 26 Sep 2022 06:11:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpg-0004uI-CQ for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpe-0003iT-QT for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:24 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-237-zFnF1XXxPLmhJriejEAmzw-1; Mon, 26 Sep 2022 05:55:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF68185A583; Mon, 26 Sep 2022 09:55:17 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 718612166B26; Mon, 26 Sep 2022 09:55:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5A33618030AF; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y0j2Aqtnv13FSXqrmRMEFPQ/3l4+enM7Zc2eriMcTAk=; b=C4OgMLfAk/8Qp6IME3QnznWiE9ztcTcnza0SRIPI1yM0q10YLD3dcGDZ+P0BwUgOnoD9LX oPac7sm2t2VSBHRM5FZeKlb+TF0AWnHOw59pHnNEcLaNzW6Q+SxJSZA0u0SM/y/dn5KwPh 3RmtPk6CmiXkBX5T94FZVEkeANT+3Rk= X-MC-Unique: zFnF1XXxPLmhJriejEAmzw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 07/25] ui/vdagent: always reset the clipboard serial on caps Date: Mon, 26 Sep 2022 11:54:51 +0200 Message-Id: <20220926095509.3759409-8-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187111697100001 From: Marc-Andr=C3=A9 Lureau The guest agent doesn't know what is the current serial state. Reset the serial value whenever a new agent connection is established. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D2124446 Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-4-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/vdagent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 58ce7507fddc..819e0dc1435b 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -719,8 +719,10 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, = VDAgentMessage *msg) if (have_mouse(vd) && vd->mouse_hs) { qemu_input_handler_activate(vd->mouse_hs); } + + memset(vd->last_serial, 0, sizeof(vd->last_serial)); + if (have_clipboard(vd) && vd->cbpeer.notifier.notify =3D=3D NULL) { - memset(vd->last_serial, 0, sizeof(vd->last_serial)); vd->cbpeer.name =3D "vdagent"; vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify; vd->cbpeer.request =3D vdagent_clipboard_request; --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187217; cv=none; d=zohomail.com; s=zohoarc; b=ngTY2cZwVLFTbytbpF9xlbD5/os5qkJ7Kw7rKib3WmzgxhMiBCse5oPh77FK1GwaP4y4VgW3z52ABZTRRr/zEhbyf2m7b0lXgIJ9SVETTy6basOU4OINR5W8iC7doPf+qdkk0GA6t/1ieITX0NYYy5vJ4Uv+/msH3GRKQReHJD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187217; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8FOzTXJOVlAuEoG61vZulT59fd8k9A6AOrx8I9fMOQc=; b=UyxWuHRhF2jE8m9d/AO/SR/HL0h4L0jsU7ba+6wCHf8xqXHHZJu6qbwxJctz0qGw0QfDGmHkmI9PilDqtQIBMIyCxEerTjNyz7/UCePC/SUg8EW1dyrIhYlGXJ9bmdSWKOAs17MJXBIwh6rFyQz7/lNSJ853TS67ZguHkRyinpg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187217174611.1355785996033; Mon, 26 Sep 2022 03:13:37 -0700 (PDT) Received: from localhost ([::1]:42422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl7H-0003yG-VN for importer@patchew.org; Mon, 26 Sep 2022 06:13:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpj-00054N-Io for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpi-0003lV-41 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-Y8gJYKBZM42qqBYs3g3r_Q-1; Mon, 26 Sep 2022 05:55:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C615101CC67; Mon, 26 Sep 2022 09:55:19 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3084840C6EC2; Mon, 26 Sep 2022 09:55:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6773E18030B0; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8FOzTXJOVlAuEoG61vZulT59fd8k9A6AOrx8I9fMOQc=; b=ODVboMZIXre1fUtmxku3kLLjWj3/jIPAmGx0+lxy4rg8fd3jlTxO3D8YGmnAvS/dkERC/T Bx/+U3PkaE1MT2tCkuCJ3p1s9HWNSVxjpjBAjWYzj5UK+Ev8IPVuvPtrpTVgL86xCVNi8I Ttxisg1P9CRljppb9mqdMDVeZetbPHs= X-MC-Unique: Y8gJYKBZM42qqBYs3g3r_Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 08/25] ui/clipboard: reset the serial state on reset Date: Mon, 26 Sep 2022 11:54:52 +0200 Message-Id: <20220926095509.3759409-9-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187218488100001 From: Marc-Andr=C3=A9 Lureau Not only we have to reset the vdagent clipboards serial state, but also the current QEMU clipboards info serial (the value is currently used by qemu_clipboard_check_serial, only used by -display dbus). Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-5-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/clipboard.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/clipboard.c b/ui/clipboard.c index 3e2d02d5490c..3d14bffaf80f 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -139,7 +139,14 @@ void qemu_clipboard_request(QemuClipboardInfo *info, void qemu_clipboard_reset_serial(void) { QemuClipboardNotify notify =3D { .type =3D QEMU_CLIPBOARD_RESET_SERIAL= }; + int i; =20 + for (i =3D 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) { + QemuClipboardInfo *info =3D qemu_clipboard_info(i); + if (info) { + info->serial =3D 0; + } + } notifier_list_notify(&clipboard_notifiers, ¬ify); } =20 --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187320; cv=none; d=zohomail.com; s=zohoarc; b=JIO/F0+C+/L1GhdsIjIhjVoLglmLgzQUoOv6fRdtmIHWJPsEwxcHMS5a5SV2ICbblSIGR3StZ95U3K6vUErPop6QW2bYDT6NuhOPvderUcV9hrJFBGnRIV5dYNySd/n81fyDZ+qTbB3FwPs8SvJpmlETN726/AYMK3AusOJF8R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187320; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L5PZAgDZ0Zk8jlRJBwRHM6yfmEwxC0P3PBdvK/bzC34=; b=DR/SvBEvWdr3iw+AF04CnubrqHRBAXCh+2DuMppQTkyZPNuwKc5BumHuk0AKEzw1dASFCN4esVDpLOGkjIZwaefreRylB5ZY0r255g6LSfqoxxR8oHjNhsFRX9DOk5orkf+m2DIS2PTqH+rIiFND9HireynVXz7h0Xj+tOlGib8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187320368271.52620293341704; Mon, 26 Sep 2022 03:15:20 -0700 (PDT) Received: from localhost ([::1]:39586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl8x-0006US-5t for importer@patchew.org; Mon, 26 Sep 2022 06:15:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpq-0005Sv-Si for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20891) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpo-0003nF-3G for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-310-0wiUAdGiNIKKDHc1EdkYZQ-1; Mon, 26 Sep 2022 05:55:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82767185A7A4; Mon, 26 Sep 2022 09:55:19 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32E7B40C2064; Mon, 26 Sep 2022 09:55:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 742D018030B1; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L5PZAgDZ0Zk8jlRJBwRHM6yfmEwxC0P3PBdvK/bzC34=; b=SuRD+Agckaq6Llna6RQZpOoFUNnJVtiW3ikpkyJq+8rbOWVdnqaHoV25b6Cv/KxcL4tcoX 7JKq5adTaQOy+qb12yQrVPDlYNfB512ec3Ed8QNyRaIzlk+bDaUn3PO5bfZIheoXOcAL1P Vdb1ReiUpbMqPjmlrP7twB9ExyqCVeg= X-MC-Unique: 0wiUAdGiNIKKDHc1EdkYZQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 09/25] ui/vdagent: fix serial reset of guest agent Date: Mon, 26 Sep 2022 11:54:53 +0200 Message-Id: <20220926095509.3759409-10-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187321235100001 From: Marc-Andr=C3=A9 Lureau In order to reset the guest agent, we send CLOSED & OPENED events. They are correctly received by the guest kernel. However, they might not be noticed by the guest agent process, as the IO task (poll() for example) might be wake up after both CLOSED & OPENED have been processed. Wait until the guest agent is disconnected to re-open our side. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220912102455.111765-6-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/vdagent.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 819e0dc1435b..4bf50f0c4d88 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -471,7 +471,7 @@ static void vdagent_clipboard_reset_serial(VDAgentChard= ev *vd) =20 /* reopen the agent connection to reset the serial state */ qemu_chr_be_event(chr, CHR_EVENT_CLOSED); - qemu_chr_be_event(chr, CHR_EVENT_OPENED); + /* OPENED again after the guest disconnected, see set_fe_open */ } =20 static void vdagent_clipboard_notify(Notifier *notifier, void *data) @@ -875,6 +875,9 @@ static void vdagent_chr_set_fe_open(struct Chardev *chr= , int fe_open) { if (!fe_open) { trace_vdagent_close(); + /* To reset_serial, we CLOSED our side. Make sure the other end kn= ows we + * are ready again. */ + qemu_chr_be_event(chr, CHR_EVENT_OPENED); return; } =20 --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187886; cv=none; d=zohomail.com; s=zohoarc; b=dbR52DCg4/UMtvz4TfVQGHxLQ75XEHs0M5qOabS7ZI9gQjKsMoR1H71fG6yLMRvbHJ4uoUBwLup8Pm0eW3OqZnsQSvIy3K4KevG0KR7d35c8vAHUr8+qEu9ZbzAYpB3CQwDkXpluPLaWgrS4+kO4mkQdXQjLQgOgYjL7rkqpFy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187886; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HKhagRLCEtkmOiTdXQ0adfpQ5bj5UXG4kN9vlU05MwI=; b=F6FyEVYDYfhePnxytSdpm1ZhkpX895Chpzfq5/nBO3m+2K1MHcjLKAJMz2+CfCdp7GDYVXZUIdq5Wwuw+fvucASihNIQ/hGJbXa0+3KcrfSgthqKfwGXKsJvWanTgCFBSlpCZCd4re0Q2wrnChnMomqWk9PgzcDyYPD32cq0upg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187886539318.3430093572009; Mon, 26 Sep 2022 03:24:46 -0700 (PDT) Received: from localhost ([::1]:42022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclI5-0007IA-10 for importer@patchew.org; Mon, 26 Sep 2022 06:24:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpl-000596-0W for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpi-0003lz-Qt for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:28 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-f95HE11gNnqX7jnkK39Kbg-1; Mon, 26 Sep 2022 05:55:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 667B229AB3E7; Mon, 26 Sep 2022 09:55:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0DF017583; Mon, 26 Sep 2022 09:55:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8130D18030B3; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HKhagRLCEtkmOiTdXQ0adfpQ5bj5UXG4kN9vlU05MwI=; b=W+pgK7oqhvQ1LfFdp3PqrENqcljxG2fOLWt4UgQOgemyzkfJN93oYE1sOEl89wofNiqXbk 1XPrfADk0KxVsHqDWJd4bkUZZ/9fwyq0/5F8kbHCDXs7+Ol80LDVp9QnEAyO9mwoisPV8U JchWK0AXQQXfI21kPcT7VMaopEbZbfA= X-MC-Unique: f95HE11gNnqX7jnkK39Kbg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 10/25] ui/console: fix three double frees in png_save() Date: Mon, 26 Sep 2022 11:54:54 +0200 Message-Id: <20220926095509.3759409-11-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187888367100001 From: Volker R=C3=BCmelin The png_destroy_write_struct() function frees all memory used by libpng. Don't use the glib auto cleanup mechanism to free the memory allocated by libpng again. For the pixman image, use only the auto cleanup mechanism and remove the qemu_pixman_image_unref() function call to prevent another double free. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1210 Fixes: 9a0a119a38 ("Added parameter to take screenshot with screendump as P= NG") Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220919061956.30929-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- ui/console.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/console.c b/ui/console.c index 243f2f6e64ae..49da6a91df6f 100644 --- a/ui/console.c +++ b/ui/console.c @@ -304,8 +304,8 @@ static bool png_save(int fd, pixman_image_t *image, Err= or **errp) { int width =3D pixman_image_get_width(image); int height =3D pixman_image_get_height(image); - g_autofree png_struct *png_ptr =3D NULL; - g_autofree png_info *info_ptr =3D NULL; + png_struct *png_ptr; + png_info *info_ptr; g_autoptr(pixman_image_t) linebuf =3D qemu_pixman_linebuf_create(PIXMAN_a8r8g8b8, wi= dth); uint8_t *buf =3D (uint8_t *)pixman_image_get_data(linebuf); @@ -346,7 +346,6 @@ static bool png_save(int fd, pixman_image_t *image, Err= or **errp) qemu_pixman_linebuf_fill(linebuf, image, width, 0, y); png_write_row(png_ptr, buf); } - qemu_pixman_image_unref(linebuf); =20 png_write_end(png_ptr, NULL); =20 --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187588; cv=none; d=zohomail.com; s=zohoarc; b=R2/w9Zi6XuVoUA+VwhqXxKoGfSsO0EXJkDrWgmzml6bV2zTIhU1whiQ2Xqo0ZxvJYbgkROHB/zUDHBKdwAy3m5P2b/nQoXdnwdWkKPQJeqZe7mr4GA7BXgv3Yl0XoJSeSBJCBmXGrPH3NCl0xj/i90iWM6Arkw7hLGmh1DWX7Sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5nyN9zf4XTCE2tFR3Vt7TfVm0hv0qRla4YlTg9dQiCI=; b=U7zJrX5nnCoa9hU0321XaJglxRgH3yKIQJW/R7Jpi6gnXt3xV6+wITR/1rkdY3ngcHwTciJKaYeyWliBr5UlfVJoqaXODBIEOZk/h5P2RiQhiJP7z8zZgfYovwrzOu6sXARrG46gYoEi73ucLgwKpa+x5Cc8x/URGMrLwhPTnIY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187588759797.4256111382863; Mon, 26 Sep 2022 03:19:48 -0700 (PDT) Received: from localhost ([::1]:36858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclDH-0001YA-55 for importer@patchew.org; Mon, 26 Sep 2022 06:19:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpk-00056H-80 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26421) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpi-0003ln-FG for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:27 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-398-E2ufwyElPTOggB3f689lGA-1; Mon, 26 Sep 2022 05:55:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 570863C11047; Mon, 26 Sep 2022 09:55:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E28EF2084836; Mon, 26 Sep 2022 09:55:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8EEFB18030B4; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5nyN9zf4XTCE2tFR3Vt7TfVm0hv0qRla4YlTg9dQiCI=; b=dL+5d0JTiIGbsVijBMlgckdm3OL03EvrtI4E71fCTKa3TExaBB8ajYs8Wr6xVPsU9pOMoI V+wQ53v6XeufgV07ZgRpxf0wSr/1NmnUsNoeXTbLrfjcp8/4Gubi0NttAhf3zLPP0PGFr4 iC86w9uTC3wVSoQGxBZV6cOumzci8qA= X-MC-Unique: E2ufwyElPTOggB3f689lGA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth Subject: [PULL 11/25] hw/usb/hcd-xhci: Check whether DMA accesses fail Date: Mon, 26 Sep 2022 11:54:55 +0200 Message-Id: <20220926095509.3759409-12-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187589871100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth If a guest sets up bad descriptors, it could force QEMU to access non-existing memory regions. Thus we should check the return value of dma_memory_read/write() to make sure that these errors don't go unnoticed. Signed-off-by: Thomas Huth Message-Id: <20220817160016.49752-1-thuth@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 64 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 3c48b58ddeb5..acd60b1a4904 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -463,6 +463,12 @@ static void xhci_mfwrap_timer(void *opaque) xhci_mfwrap_update(xhci); } =20 +static void xhci_die(XHCIState *xhci) +{ + xhci->usbsts |=3D USBSTS_HCE; + DPRINTF("xhci: asserted controller error\n"); +} + static inline dma_addr_t xhci_addr64(uint32_t low, uint32_t high) { if (sizeof(dma_addr_t) =3D=3D 4) { @@ -488,7 +494,14 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci,= dma_addr_t addr, =20 assert((len % sizeof(uint32_t)) =3D=3D 0); =20 - dma_memory_read(xhci->as, addr, buf, len, MEMTXATTRS_UNSPECIFIED); + if (dma_memory_read(xhci->as, addr, buf, len, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + memset(buf, 0xff, len); + xhci_die(xhci); + return; + } =20 for (i =3D 0; i < (len / sizeof(uint32_t)); i++) { buf[i] =3D le32_to_cpu(buf[i]); @@ -496,7 +509,7 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci, = dma_addr_t addr, } =20 static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr, - uint32_t *buf, size_t len) + const uint32_t *buf, size_t len) { int i; uint32_t tmp[5]; @@ -508,7 +521,13 @@ static inline void xhci_dma_write_u32s(XHCIState *xhci= , dma_addr_t addr, for (i =3D 0; i < n; i++) { tmp[i] =3D cpu_to_le32(buf[i]); } - dma_memory_write(xhci->as, addr, tmp, len, MEMTXATTRS_UNSPECIFIED); + if (dma_memory_write(xhci->as, addr, tmp, len, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + xhci_die(xhci); + return; + } } =20 static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport) @@ -593,12 +612,6 @@ static inline int xhci_running(XHCIState *xhci) return !(xhci->usbsts & USBSTS_HCH); } =20 -static void xhci_die(XHCIState *xhci) -{ - xhci->usbsts |=3D USBSTS_HCE; - DPRINTF("xhci: asserted controller error\n"); -} - static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v) { XHCIInterrupter *intr =3D &xhci->intr[v]; @@ -619,7 +632,12 @@ static void xhci_write_event(XHCIState *xhci, XHCIEven= t *event, int v) ev_trb.status, ev_trb.control); =20 addr =3D intr->er_start + TRB_SIZE*intr->er_ep_idx; - dma_memory_write(xhci->as, addr, &ev_trb, TRB_SIZE, MEMTXATTRS_UNSPECI= FIED); + if (dma_memory_write(xhci->as, addr, &ev_trb, TRB_SIZE, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + xhci_die(xhci); + } =20 intr->er_ep_idx++; if (intr->er_ep_idx >=3D intr->er_size) { @@ -680,8 +698,12 @@ static TRBType xhci_ring_fetch(XHCIState *xhci, XHCIRi= ng *ring, XHCITRB *trb, =20 while (1) { TRBType type; - dma_memory_read(xhci->as, ring->dequeue, trb, TRB_SIZE, - MEMTXATTRS_UNSPECIFIED); + if (dma_memory_read(xhci->as, ring->dequeue, trb, TRB_SIZE, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\= n", + __func__); + return 0; + } trb->addr =3D ring->dequeue; trb->ccs =3D ring->ccs; le64_to_cpus(&trb->parameter); @@ -798,8 +820,14 @@ static void xhci_er_reset(XHCIState *xhci, int v) xhci_die(xhci); return; } - dma_memory_read(xhci->as, erstba, &seg, sizeof(seg), - MEMTXATTRS_UNSPECIFIED); + if (dma_memory_read(xhci->as, erstba, &seg, sizeof(seg), + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n", + __func__); + xhci_die(xhci); + return; + } + le32_to_cpus(&seg.addr_low); le32_to_cpus(&seg.addr_high); le32_to_cpus(&seg.size); @@ -2415,8 +2443,12 @@ static TRBCCode xhci_get_port_bandwidth(XHCIState *x= hci, uint64_t pctx) /* TODO: actually implement real values here */ bw_ctx[0] =3D 0; memset(&bw_ctx[1], 80, xhci->numports); /* 80% */ - dma_memory_write(xhci->as, ctx, bw_ctx, sizeof(bw_ctx), - MEMTXATTRS_UNSPECIFIED); + if (dma_memory_write(xhci->as, ctx, bw_ctx, sizeof(bw_ctx), + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory write failed!\n", + __func__); + return CC_TRB_ERROR; + } =20 return CC_SUCCESS; } --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188646; cv=none; d=zohomail.com; s=zohoarc; b=htm3ysZtZeadRcpypguWIJD89rshWQPe+r1uazWTRWDFQsPTms90D15LhSbYFmdh/sj7GT5TA5XcwrUB5q7tE9d/HhhopWrk6veXcz9yZBM11u7q5RiSeW4Iu3JITdIvv5Qjwe7dYDY9BerCSY7zt5rLhvI+3SNQhAalJGl3pFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188646; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=At+dbiBtzojIId+CkWfr7mFw/GiOsUbaxmGmx4H6iSE=; b=j5XleM7+RqNzIrQUwoL4KeLuvcyYvGnDvMpEK/vytA1zHDLqmUNJ0Tcv4QuKeRHZy6NWzYiiDRSfjdwZO5DPmTyyI5o7hov6rS3UpK4ROLUtvfJLLxCV4YuDjZ5Hz6Ecw+p3JuDmKydlbociPp08CC6ydUuEuBWw1wet6vh1pYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188646207495.2703175497944; Mon, 26 Sep 2022 03:37:26 -0700 (PDT) Received: from localhost ([::1]:38272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclUK-0008DF-Ve for importer@patchew.org; Mon, 26 Sep 2022 06:37:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpl-0005CS-RD for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpj-0003mJ-RF for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:29 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-196-3rN6RVl8Mc2Rn2mrBRyVzQ-1; Mon, 26 Sep 2022 05:55:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F2DE29AB44D; Mon, 26 Sep 2022 09:55:23 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD4572084836; Mon, 26 Sep 2022 09:55:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9C26C18030B5; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=At+dbiBtzojIId+CkWfr7mFw/GiOsUbaxmGmx4H6iSE=; b=XvPLyd9dguP4Xsn0ID8Ls5Y+YxkS0lMOzZS0vW2WblUQwOFML4W0MQRneLFsUQyAYKU9Np wSOSN67P/DH9kUCnGYhoKa2GOBwfYH7lvfFiXKgBsoAxQPmBQ6BOFaBZ4pDCzuJEJrJoLP gOs5DpvWB9U+Rw7ElUSvmbKj5e39BHQ= X-MC-Unique: 3rN6RVl8Mc2Rn2mrBRyVzQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Qiang Liu , Gaoning Pan Subject: [PULL 12/25] hcd-ohci: Drop ohci_service_iso_td() if ed->head & OHCI_DPTR_MASK is zero Date: Mon, 26 Sep 2022 11:54:56 +0200 Message-Id: <20220926095509.3759409-13-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188647334100001 Content-Type: text/plain; charset="utf-8" From: Qiang Liu An abort happens in ohci_frame_boundary() when ohci->done is 0 [1]. ``` c static void ohci_frame_boundary(void *opaque) { // ... if (ohci->done_count =3D=3D 0 && !(ohci->intr_status & OHCI_INTR_WD)) { if (!ohci->done) abort(); <----------------------------------------- [1] ``` This was reported in https://bugs.launchpad.net/qemu/+bug/1911216/, https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg03613.html, and https://gitlab.com/qemu-project/qemu/-/issues/545. I can still reproduce it= with the latest QEMU. This happends due to crafted ED with putting ISO_TD at physical address 0. Suppose ed->head & OHCI_DPTR_MASK is 0 [2], and we memset 0 to the phyiscal memory from 0 to sizeof(ohci_iso_td). Then, starting_frame [3] and frame_co= unt [4] are both 0. As we can control the value of ohci->frame_number (0 to 0x1= f, suppose 1), we then control the value of relative_frame_number to be 1 [6].= The control flow goes to [7] where ohci->done is 0. Have returned from ohci_service_iso_td(), ohci_frame_boundary() will abort() [1]. ``` c static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed) { // ... addr =3D ed->head & OHCI_DPTR_MASK; // <--------------------- [2] if (ohci_read_iso_td(ohci, addr, &iso_td)) { // <-------- [3] // ... starting_frame =3D OHCI_BM(iso_td.flags, TD_SF); // <-------- [4] frame_count =3D OHCI_BM(iso_td.flags, TD_FC); // <-------- [5] relative_frame_number =3D USUB(ohci->frame_number, starting_frame); // <-------- [6] if (relative_frame_number < 0) { return 1; } else if (relative_frame_number > frame_count) { // ... ohci->done =3D addr; // <-------- [7] // ... } ``` As only (afaik) a guest root user can manipulate ED, TD and the physical me= mory, this assertion failure is not a security bug. The idea to fix this issue is to drop ohci_service_iso_td() if ed->head & OHCI_DPTR_MASK is 0, which is similar to the drop operation for ohci_service_ed_list() when head is 0. Probably, a similar issue is in ohci_service_td(). I drop ohci_service_td() if ed->head & OHCI_DPTR_MASK is= 0. Fixes: 7bfe577702 ("OHCI USB isochronous transfers support (Arnon Gilboa)") Reported-by: Gaoning Pan Reported-by: Alexander Bulekov Reported-by: Qiang Liu Resolves: https://gitlab.com/qemu-project/qemu/-/issues/545 Buglink: https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg03613.html Buglink: https://bugs.launchpad.net/qemu/+bug/1911216 Signed-off-by: Qiang Liu Message-Id: <20220826051557.119570-1-cyruscyliu@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 895b29fb8657..72bdde92617c 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -571,6 +571,11 @@ static int ohci_service_iso_td(OHCIState *ohci, struct= ohci_ed *ed) =20 addr =3D ed->head & OHCI_DPTR_MASK; =20 + if (addr =3D=3D 0) { + ohci_die(ohci); + return 1; + } + if (ohci_read_iso_td(ohci, addr, &iso_td)) { trace_usb_ohci_iso_td_read_failed(addr); ohci_die(ohci); @@ -858,6 +863,11 @@ static int ohci_service_td(OHCIState *ohci, struct ohc= i_ed *ed) int completion; =20 addr =3D ed->head & OHCI_DPTR_MASK; + if (addr =3D=3D 0) { + ohci_die(ohci); + return 1; + } + /* See if this TD has already been submitted to the device. */ completion =3D (addr =3D=3D ohci->async_td); if (completion && !ohci->async_complete) { --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188310; cv=none; d=zohomail.com; s=zohoarc; b=H9jwb9hRktY11DoCa91qzD1aqSjQ0OYNI+mSuA4lHxiSCcaTTNc05D55mft8gWkJEd7+z2InMu7x4gDxn1K79HWZUWgVloyYYhGccfn/Fp7J1f/zET7AWCdsUK25F09vpj7ELYlHLmHC1ovJNbzfZ2eXYNlmtFAlwQyJSjIeN64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188310; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3HDfviZSfHd3D4yIqWD1Q45/1mV83e9iQ7imYYzYACY=; b=RK8ek5McxEPXfN5qNfYFJk4psk6FFWCeao3CekwZRztR2eLdSiISrQlc+I8SxNC0dlFJGB87I0MkiY85m6T4acPaHQhB/5uZA6HA+1joD2g/qFegao2Whms78XnavMz9Cqqvp7daiEZsNCkUVuQDy+h1OlT45Oweekuisge4t1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188310869984.4553309668638; Mon, 26 Sep 2022 03:31:50 -0700 (PDT) Received: from localhost ([::1]:42132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclOu-0004BF-GK for importer@patchew.org; Mon, 26 Sep 2022 06:31:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpl-0005AR-Aa for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpj-0003mF-JW for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:29 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-zQH11h1UPD6TI4H3E9QFDg-1; Mon, 26 Sep 2022 05:55:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F07D101A52A; Mon, 26 Sep 2022 09:55:23 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF0C32084837; Mon, 26 Sep 2022 09:55:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A90D518030B7; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3HDfviZSfHd3D4yIqWD1Q45/1mV83e9iQ7imYYzYACY=; b=Bgz9nJ3ycpeJNYxkLuDbP23v03gVDqFA5L739kBVXH+C6YVVQr8+tPl2CUMKIAQm3q/8Ta hUqv7F9qUPipDrwguPmNB17mU5rJAYU+E9PQPszGZBmq03fZD2IwByI5khJ0FkcpcouliY Uk8mpqTS9DtAuPvheCRGf07JUPNdu9M= X-MC-Unique: zQH11h1UPD6TI4H3E9QFDg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Qiang Liu Subject: [PULL 13/25] hcd-ohci: Fix inconsistency when resetting ohci root hubs Date: Mon, 26 Sep 2022 11:54:57 +0200 Message-Id: <20220926095509.3759409-14-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188311560100001 Content-Type: text/plain; charset="utf-8" From: Qiang Liu I found an assertion failure in usb_cancel_packet() and posted my analysis = in https://gitlab.com/qemu-project/qemu/-/issues/1180. I think this issue is because the inconsistency when resetting ohci root hubs. There are two ways to reset ohci root hubs: 1) through HcRhPortStatus, 2) through HcControl. However, when the packet's status is USB_PACKET_ASYNC, resetting through HcRhPortStatus will complete the packet and thus resetting through HcControl will fail. That is because IMO resetting through HcRhPortStatus should first detach the port and then invoked usb_device_res= et() just like through HcControl. Therefore, I change usb_device_reset() to usb_port_reset() where usb_detach() and usb_device_reset() are invoked consequently. Fixes: d28f4e2d8631 ("usb: kill USB_MSG_RESET") Reported-by: Qiang Liu Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1180 Signed-off-by: Qiang Liu Message-Id: <20220830033022.1164961-1-cyruscyliu@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 72bdde92617c..28d703481515 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1436,7 +1436,7 @@ static void ohci_port_set_status(OHCIState *ohci, int= portnum, uint32_t val) =20 if (ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PRS)) { trace_usb_ohci_port_reset(portnum); - usb_device_reset(port->port.dev); + usb_port_reset(&port->port); port->ctrl &=3D ~OHCI_PORT_PRS; /* ??? Should this also set OHCI_PORT_PESC. */ port->ctrl |=3D OHCI_PORT_PES | OHCI_PORT_PRSC; --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187641; cv=none; d=zohomail.com; s=zohoarc; b=KZw9c/f6DXcHSIKltBDrZi/cciEXc4T0TTmisWgPnNw52u8dioI3yhuh6tNh/39FHFY/9r5sjIxPkJ/yitLOxvaAOwxjXrXYJZb7xY2otHL2xMDn2VL/0otHFR9YQ7ZXZS/otdwVI88YNcJx18LbncYeExG4Oy7C/aBPTqDFvsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187641; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0m00e7GaD8cqnM2csAfgTfw2hXblEpsI8UlNCemk+ag=; b=bGZq+zgFF04dTPrRnxbEHLTNUy92XITvQJ7ZFSuc/IqonodlWJS78QeIQf2ZMmahJV16C1gIfU+3GxeFLESS+KeVKDf0H3b9MjsJdv8fC3UH8hf1XFhV6BnW8CYvnm+xqfcsXOU0Y4mlLyeSxOncGA5ihRwaS4G6mV1fvqiuB50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187641887527.1449725013993; Mon, 26 Sep 2022 03:20:41 -0700 (PDT) Received: from localhost ([::1]:47660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclE8-0002Zg-Fz for importer@patchew.org; Mon, 26 Sep 2022 06:20:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpr-0005UE-69 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpo-0003nK-Gd for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-7mTSscTjOAmwuz9ehVwhAw-1; Mon, 26 Sep 2022 05:55:25 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43CA61C13941; Mon, 26 Sep 2022 09:55:25 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 863BC49BB60; Mon, 26 Sep 2022 09:55:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B639518030B8; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0m00e7GaD8cqnM2csAfgTfw2hXblEpsI8UlNCemk+ag=; b=Wf+op7UGTc1kOqG4W3ChJfB/ITnM6W0AqbNZuH6X5eDtcwhzZ3TY8kHDaOgJ3miCfv84LT a8QuGhejkNsm7FYCuD1FeSD2mRfEA/RVYWHAC/Hcr96D551XzNJyvSmnO160DTnBkizici pgqdzKGvThQSKeTV1KnGMz922AAvfWI= X-MC-Unique: 7mTSscTjOAmwuz9ehVwhAw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth Subject: [PULL 14/25] usb/msd: move usb_msd_packet_complete() Date: Mon, 26 Sep 2022 11:54:58 +0200 Message-Id: <20220926095509.3759409-15-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187644097100001 Content-Type: text/plain; charset="utf-8" Change ordering to avoid adding forward declarations in following patches. Fix comment code style while being at it. No functional change. Signed-off-by: Gerd Hoffmann Message-Id: <20220830063827.813053-2-kraxel@redhat.com> --- hw/usb/dev-storage.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 98639696e6d8..140ef2aeaa80 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -177,6 +177,20 @@ static const USBDesc desc =3D { .str =3D desc_strings, }; =20 +static void usb_msd_packet_complete(MSDState *s) +{ + USBPacket *p =3D s->packet; + + /* + * Set s->packet to NULL before calling usb_packet_complete + * because another request may be issued before + * usb_packet_complete returns. + */ + trace_usb_msd_packet_complete(); + s->packet =3D NULL; + usb_packet_complete(&s->dev, p); +} + static void usb_msd_copy_data(MSDState *s, USBPacket *p) { uint32_t len; @@ -208,18 +222,6 @@ static void usb_msd_send_status(MSDState *s, USBPacket= *p) memset(&s->csw, 0, sizeof(s->csw)); } =20 -static void usb_msd_packet_complete(MSDState *s) -{ - USBPacket *p =3D s->packet; - - /* Set s->packet to NULL before calling usb_packet_complete - because another request may be issued before - usb_packet_complete returns. */ - trace_usb_msd_packet_complete(); - s->packet =3D NULL; - usb_packet_complete(&s->dev, p); -} - void usb_msd_transfer_data(SCSIRequest *req, uint32_t len) { MSDState *s =3D DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187086; cv=none; d=zohomail.com; s=zohoarc; b=Ffya9F3JmqXVFRfK1MKlQ0gzhsICJJ4LkTNISbudALZHdmPpbaeNwv7Vty4oEC1pQYZQyxmsg+JutLJ+KS/zCISrYEzF/8szm5J8SUtgmtXMMSLTZbaZQFVKgQ2xcixbWNJy/xghbMus9KY7sIfc+d7ykeYId6W1ZdCXJ8OXaRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187086; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1/bz0ZvfMImJCS6WH5kQCYHFBHl/aO5fDf5KXRDm0YE=; b=MEr4DvSzU7LWuPN3/JOqNc+ldca3eFHCuodY2LFjRfvrkT8DMcIaCxf0z0GeUrD5NjDomNuMpHaVnxZt9kMvkuUN1n9J7skPfh9GH2lXxPuMtfVZuwjdcQEvkqfF0UciV71D/ehdGD4cZtsfWBaPM+/7kufvM8RiXnLzJWkmWdE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187086235875.5513204693576; Mon, 26 Sep 2022 03:11:26 -0700 (PDT) Received: from localhost ([::1]:47040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl5B-0007lQ-3o for importer@patchew.org; Mon, 26 Sep 2022 06:11:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpo-0005N6-HK for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpm-0003mx-QG for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:32 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-20-pWDCk7-RNJCHJs6XoSUbRg-1; Mon, 26 Sep 2022 05:55:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D1BE3C11049; Mon, 26 Sep 2022 09:55:25 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CFC72166B26; Mon, 26 Sep 2022 09:55:25 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C7DC418030BA; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1/bz0ZvfMImJCS6WH5kQCYHFBHl/aO5fDf5KXRDm0YE=; b=UrMVqfkDaCP/Lv+Y/7EONUzkR8i0kipA00fvQthJZMGPbvchrWs8kBftVDZoy9gLuIMu0U /P8rTsGs6Bsiu/+C+xyVvfEU/T/TObLESIqhbErJH4BqQzcQB15umEA4lU3mc4jZ35MMdB 5dTvVzzaB5QJ4BvdMjKm5eCCGyG+H2s= X-MC-Unique: pWDCk7-RNJCHJs6XoSUbRg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Qiang Liu Subject: [PULL 15/25] usb/msd: add usb_msd_fatal_error() and fix guest-triggerable assert Date: Mon, 26 Sep 2022 11:54:59 +0200 Message-Id: <20220926095509.3759409-16-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187087724100003 Content-Type: text/plain; charset="utf-8" Add handler for fatal errors. Moves device into error state where it stops responding until the guest resets it. Guest can send illegal requests where scsi command and usb packet transfer directions are inconsistent. Use the new usb_msd_fatal_error() function instead of assert() in that case. Reported-by: Qiang Liu Signed-off-by: Gerd Hoffmann Tested-by: Qiang Liu Message-Id: <20220830063827.813053-3-kraxel@redhat.com> --- include/hw/usb/msd.h | 1 + hw/usb/dev-storage.c | 30 +++++++++++++++++++++++++++++- hw/usb/trace-events | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/hw/usb/msd.h b/include/hw/usb/msd.h index 54e9f38bda46..f9fd862b529a 100644 --- a/include/hw/usb/msd.h +++ b/include/hw/usb/msd.h @@ -40,6 +40,7 @@ struct MSDState { bool removable; bool commandlog; SCSIDevice *scsi_dev; + bool needs_reset; }; =20 typedef struct MSDState MSDState; diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 140ef2aeaa80..e3bcffb3e0d7 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -191,6 +191,23 @@ static void usb_msd_packet_complete(MSDState *s) usb_packet_complete(&s->dev, p); } =20 +static void usb_msd_fatal_error(MSDState *s) +{ + trace_usb_msd_fatal_error(); + + if (s->packet) { + s->packet->status =3D USB_RET_STALL; + usb_msd_packet_complete(s); + } + + /* + * Guest messed up up device state with illegal requests. Go + * ignore any requests until the guests resets the device (and + * brings it into a known state that way). + */ + s->needs_reset =3D true; +} + static void usb_msd_copy_data(MSDState *s, USBPacket *p) { uint32_t len; @@ -227,7 +244,11 @@ void usb_msd_transfer_data(SCSIRequest *req, uint32_t = len) MSDState *s =3D DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); USBPacket *p =3D s->packet; =20 - assert((s->mode =3D=3D USB_MSDM_DATAOUT) =3D=3D (req->cmd.mode =3D=3D = SCSI_XFER_TO_DEV)); + if ((s->mode =3D=3D USB_MSDM_DATAOUT) !=3D (req->cmd.mode =3D=3D SCSI_= XFER_TO_DEV)) { + usb_msd_fatal_error(s); + return; + } + s->scsi_len =3D len; s->scsi_off =3D 0; if (p) { @@ -317,6 +338,8 @@ void usb_msd_handle_reset(USBDevice *dev) =20 memset(&s->csw, 0, sizeof(s->csw)); s->mode =3D USB_MSDM_CBW; + + s->needs_reset =3D false; } =20 static void usb_msd_handle_control(USBDevice *dev, USBPacket *p, @@ -382,6 +405,11 @@ static void usb_msd_handle_data(USBDevice *dev, USBPac= ket *p) SCSIDevice *scsi_dev; uint32_t len; =20 + if (s->needs_reset) { + p->status =3D USB_RET_STALL; + return; + } + switch (p->pid) { case USB_TOKEN_OUT: if (devep !=3D 2) diff --git a/hw/usb/trace-events b/hw/usb/trace-events index 914ca7166829..b65269892c5e 100644 --- a/hw/usb/trace-events +++ b/hw/usb/trace-events @@ -263,6 +263,7 @@ usb_msd_packet_complete(void) "" usb_msd_cmd_submit(unsigned lun, unsigned tag, unsigned flags, unsigned le= n, unsigned data_len) "lun %u, tag 0x%x, flags 0x%08x, len %d, data-len %d" usb_msd_cmd_complete(unsigned status, unsigned tag) "status %d, tag 0x%x" usb_msd_cmd_cancel(unsigned tag) "tag 0x%x" +usb_msd_fatal_error(void) "" =20 # dev-uas.c usb_uas_reset(int addr) "dev %d" --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187253; cv=none; d=zohomail.com; s=zohoarc; b=VthvgZ74iWN3rbYOhS+pBoMYt88bDhx25zUHsJbh9cVh/TyWcGpO9AIFnUOf7FCyjv0mI458Gg9xt3GGUHTZ98l26oZpGBE7Aui1v6xe+zlpmW56bnZENY2gRxNdqiOT0ZbxgtZl8ufyffE6G/chBTlNal0TWYRiImXEqsYJwm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187253; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fIdR0vI29oZeRCFZBp8CQiXoR7cYaIYvZ9xzZVFSJ94=; b=cw4EVXOStc83AcjzwvtKW+Z+Z6J5eXhPVt2wmbMxmZM8u+Vp1Inh1bTo17mp+00B4Yjq4qSo7zMhcekdSSNzgR0PzUrNOteUBmPLk3lBR+yUlyAYh2VSEWk8fc8uEn9PaRAkrW9YdaoGLNio/4sXnf8bBECP2nbL5sasmwzbaog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187253143406.901263759936; Mon, 26 Sep 2022 03:14:13 -0700 (PDT) Received: from localhost ([::1]:53098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocl7r-0004sQ-Un for importer@patchew.org; Mon, 26 Sep 2022 06:14:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpq-0005Q7-B6 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpn-0003nB-N1 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-yg-xe8O6MkmeUPftbKzi0Q-1; Mon, 26 Sep 2022 05:55:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 25B5B872841; Mon, 26 Sep 2022 09:55:27 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D064540C6EC2; Mon, 26 Sep 2022 09:55:26 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D4B5518030BB; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fIdR0vI29oZeRCFZBp8CQiXoR7cYaIYvZ9xzZVFSJ94=; b=ih8k0mS/59r7VS2qmt5E6mbfH/8ZMaizYOyo778RsiRWDwToiDtwOvbmfM1/mtnlYHvj8P 28FOVtQi7/haYwHL5o2j0cuxZZztv7Q4kzdM+ugXjL9lwBBehV698pkMVNJAENuc7JR7AE l4MxdmngdCTahYCHtwMEnipUTuSeqYA= X-MC-Unique: yg-xe8O6MkmeUPftbKzi0Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Qiang Liu Subject: [PULL 16/25] hcd-xhci: drop operation with secondary stream arrays enabled Date: Mon, 26 Sep 2022 11:55:00 +0200 Message-Id: <20220926095509.3759409-17-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187254845100001 Content-Type: text/plain; charset="utf-8" From: Qiang Liu The abort() in xhci_find_stream() can be triggered via enabling the seconda= ry stream arrays by setting linear stream array (LSA) bit (in endpoint context= ) to 0. We may show warnings and drop this operation. Fixes: 024426acc0a2 ("usb-xhci: usb3 streams") Reported-by: Qiang Liu Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1192 Signed-off-by: Qiang Liu Message-Id: <20220904125926.2141607-1-cyruscyliu@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index acd60b1a4904..8299f35e6695 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1020,7 +1020,9 @@ static XHCIStreamContext *xhci_find_stream(XHCIEPCont= ext *epctx, } sctx =3D epctx->pstreams + streamid; } else { - FIXME("secondary streams not implemented yet"); + fprintf(stderr, "xhci: FIXME: secondary streams not implemented ye= t"); + *cc_error =3D CC_INVALID_STREAM_TYPE_ERROR; + return NULL; } =20 if (sctx->sct =3D=3D -1) { --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187721; cv=none; d=zohomail.com; s=zohoarc; b=DOZFy6b+UY5ofqm4DDkfqS+jPY7pvUMw0FMx0N/3crMDWQkduE/cVPYKgVu3PLLRC9tkf/AH8+7+n6acsQhLKpQEpUpr8Mp7V5/kL2XTuqizT3QrYGiLjqWKdbbDxgOvea77RPSs6vNn28fL8JYmYI97qBthfTg4erW39DWVrqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187721; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xsE9VkekNKZPttOpoOonLuBUJbPWi32PC/I2Jy8KiYE=; b=gGbTD6eq0Jhz/E/jlIoOK98dyWAxSiZTU9qPIVSIHYHoRX/WQhQKbbqiVGG5xAgjq2wjS/wc5pzv1ci3hdKnC+CV29eCDyYuRCx6o9UCmte+G1Rgq3syCPI43gP7vdokQ3nty82qMeXxlH6ggXxRwC/exsfFPrGbsqivJrXB2Fc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187721712968.7595735649971; Mon, 26 Sep 2022 03:22:01 -0700 (PDT) Received: from localhost ([::1]:35604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclFQ-0003RK-H2 for importer@patchew.org; Mon, 26 Sep 2022 06:22:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockps-0005Y4-B5 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpq-0003nj-IC for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:36 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-U6Y-w-yaO1uLaFSIeJ-Lxw-1; Mon, 26 Sep 2022 05:55:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D65629AB44C; Mon, 26 Sep 2022 09:55:27 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE5A42084836; Mon, 26 Sep 2022 09:55:26 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E18DC18030BD; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xsE9VkekNKZPttOpoOonLuBUJbPWi32PC/I2Jy8KiYE=; b=jGtxQ36rUYzME+RwsI3lgKyWdT70YbT56PdFDOLgbHgwS6t46NKsLq/DrBy5vRS4Lb29dl QSTf4Mb3QAYDX/7cI/sN5o+I9rc0fvk5vu1/aI0N7+CxjBGK93zhapT5wx+nU6R8XMqA7W igfEs58+T5RImFu4HSz1jyunz+IT1u8= X-MC-Unique: U6Y-w-yaO1uLaFSIeJ-Lxw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Michael Brown Subject: [PULL 17/25] usbnet: Add missing usb_wakeup() call in usbnet_receive() Date: Mon, 26 Sep 2022 11:55:01 +0200 Message-Id: <20220926095509.3759409-18-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187722559100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown usbnet_receive() does not currently wake up the USB endpoint, leading to a dead RX datapath when used with a host controller such as xHCI that relies on being woken up. Fix by adding a call to usb_wakeup() at the end of usbnet_receive(). Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-2-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 6c49c16015e0..61bf598870cb 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -647,6 +647,7 @@ struct USBNetState { uint8_t in_buf[2048]; =20 USBEndpoint *intr; + USBEndpoint *bulk_in; =20 char usbstring_mac[13]; NICState *nic; @@ -1317,6 +1318,7 @@ static ssize_t usbnet_receive(NetClientState *nc, con= st uint8_t *buf, size_t siz memcpy(in_buf, buf, size); s->in_len =3D total_size; s->in_ptr =3D 0; + usb_wakeup(s->bulk_in, 0); return size; } =20 @@ -1359,6 +1361,7 @@ static void usb_net_realize(USBDevice *dev, Error **e= rrp) s->filter =3D 0; s->vendorid =3D 0x1234; s->intr =3D usb_ep_get(dev, USB_TOKEN_IN, 1); + s->bulk_in =3D usb_ep_get(dev, USB_TOKEN_IN, 2); =20 qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_usbnet_info, &s->conf, --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188102; cv=none; d=zohomail.com; s=zohoarc; b=bCHANiGHhFrAs/EUnpLQBC1RopsFTU4viYa73VkTBWbHlCZG44oiv0t6RzJinzHGWyQ3fH7nTARUFkH9vopZo9LteLo767CysR/+9HN4cBeWNozte0wYXL2L3UCHCLIYVIHhVLruHWdGIi+Q59i/lSQ3WhShRik40K6bjNuDoRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188102; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RHygAolE6RYOc4/xbnRCU9F7GebT834or/LJsscBmN0=; b=DJT3b3H+k089J/8gu3k0j9ehToiiS4x6Gf1VLVE2jpS/lwOJXi1iKgjwTZ08Qt/CPUWLXne/XImyQekiAg702/Ab4eADIgERMdM8KCBaZPvcRilP62zi3pLW7rde71FygNBISjmyQlFhk9jm2aQj/388FeJyxMFge5wsABqz/iY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188102582278.02592009973523; Mon, 26 Sep 2022 03:28:22 -0700 (PDT) Received: from localhost ([::1]:48248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclLX-0000xF-V1 for importer@patchew.org; Mon, 26 Sep 2022 06:28:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpt-0005bX-EZ for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpr-0003oO-QT for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-Q0Cd-KKIMiiHNrQehSrvug-1; Mon, 26 Sep 2022 05:55:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E20BA1019C8A; Mon, 26 Sep 2022 09:55:28 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A5B41121314; Mon, 26 Sep 2022 09:55:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 000CE18030BF; Mon, 26 Sep 2022 11:55:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RHygAolE6RYOc4/xbnRCU9F7GebT834or/LJsscBmN0=; b=fXWyDskW04Y4OCpRhPXkncIjumxZL2TOIKIat6JH6iLirHlRUUVLVhZ7y3t92S+7CpQ1AE BBJiuTyUVW+EWOXpaNlLT2ErgnpUeHSCl7M5ty11W6LF4OmfkmCcR7TJAJ+4UveBtUdKVR DJkrpxC004nNNng2PafT/Nsj9BeUYVQ= X-MC-Unique: Q0Cd-KKIMiiHNrQehSrvug-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Michael Brown Subject: [PULL 18/25] usbnet: Accept mandatory USB_CDC_SET_ETHERNET_PACKET_FILTER request Date: Mon, 26 Sep 2022 11:55:02 +0200 Message-Id: <20220926095509.3759409-19-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188103858100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown The USB_CDC_SET_ETHERNET_PACKET_FILTER request is mandatory for CDC-ECM devices. Accept this request, ignoring the actual filter value (to match the existing behaviour for RNDIS). Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-3-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 61bf598870cb..155df935cd68 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1122,6 +1122,12 @@ static void usb_net_handle_control(USBDevice *dev, U= SBPacket *p, #endif break; =20 + case ClassInterfaceOutRequest | USB_CDC_SET_ETHERNET_PACKET_FILTER: + if (is_rndis(s)) { + goto fail; + } + break; + default: fail: fprintf(stderr, "usbnet: failed control transaction: " --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188808; cv=none; d=zohomail.com; s=zohoarc; b=BiTusFKpsi1dcrKPkDqIxnMQhzz60KSBy3yBnOjTjjhuDXT8ko6Y9qNxmYWp0UTUy9dklfc62UDAm4b2c9VmdzENZagTch7BZzSlNLDvPc8hEXhncpbR9BlNoMSHQzn30Ngcne2k8cjs0WTy6WpwQR7SvU8Zx+tYvctdBdj5ULk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188808; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MQSZ3YegllO8gYugV2LwNog3NGPPlbl9W71LJ6tpgkc=; b=FUWrwKFnlePqJksJGqnrGmNJKvDDyBcNXcViinSxX78rjdiJZY4PCex39H+k9RetepGI1GIjkaNGFrSL76SOPeI6e79PBP9aZRQwrmdwetUjOauRaUHDuA3STseHqirKD6+mOShB0Q/hEAg2RByEInM0obJgnEQ6wDnMQIWISjU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188808077468.1346071110297; Mon, 26 Sep 2022 03:40:08 -0700 (PDT) Received: from localhost ([::1]:55400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclWv-0003Js-Nm for importer@patchew.org; Mon, 26 Sep 2022 06:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpr-0005VR-HG for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpo-0003nM-L4 for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-vx-1sEZ2N_28NO1ZvTBTWw-1; Mon, 26 Sep 2022 05:55:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8673886463; Mon, 26 Sep 2022 09:55:28 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88646140EBF4; Mon, 26 Sep 2022 09:55:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0CBD2180A400; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MQSZ3YegllO8gYugV2LwNog3NGPPlbl9W71LJ6tpgkc=; b=RYLgegSoC9WCkwYKc8E7OwvnMdQMxlhaGivTpWIi5rznriDizahVUwk/AJ4iQ/jwne9qPP XqyBe9qbRWB+N3reiClzOWIIFK1p6kFGxbbsIlGZ3jH/aSapBtdWv+tvL6LCq6u3v+U/S/ 5kgxD1/1gE0UrwTCscBhLNoS8Th6TSc= X-MC-Unique: vx-1sEZ2N_28NO1ZvTBTWw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Michael Brown Subject: [PULL 19/25] usbnet: Detect short packets as sent by the xHCI controller Date: Mon, 26 Sep 2022 11:55:03 +0200 Message-Id: <20220926095509.3759409-20-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188809811100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown The xHCI controller will ignore the endpoint MTU and so may deliver packets of any length. Detect short packets as being any packet that has a length of zero or a length that is not a multiple of the MTU. Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-4-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 155df935cd68..9d83974ec9f0 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1211,7 +1211,7 @@ static void usb_net_handle_dataout(USBNetState *s, US= BPacket *p) s->out_ptr +=3D sz; =20 if (!is_rndis(s)) { - if (p->iov.size < 64) { + if (p->iov.size % 64 || p->iov.size =3D=3D 0) { qemu_send_packet(qemu_get_queue(s->nic), s->out_buf, s->out_pt= r); s->out_ptr =3D 0; } --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188021; cv=none; d=zohomail.com; s=zohoarc; b=M10iV1D3c2Ckh/bHWvmXKgOsOT9e9kD8Ey0YcfZkacNhT+s7c9Oct4/kPPmOBSDjYagOkGT8odz+RgdR2UVg34bJXoZVC/6F0hooM4CaNc9leFAGuPSZStz4a79gGfkOIOf5nm3FUyASx2AydaS3xd0jy03ijJFT1pLN7UJY5PI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188021; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TwMBwWhUCObCQODSt2PE3geZjaDC55CP59MmTESi1FE=; b=miPoxn9SrVFyHIf9qzY+z3NhHALNMLDd+UZYl0UJaZwJBm9i29/Kis5nhkj4mDPZa5w2LycE951wNKfnBhKIwTVU/Q+wFqy7g/LR6oNClyiadui49QfecCqKrTVo38snrKjmDPdHQ75oNdr++z+px5C1ijBOAPD28H2G2DDKaTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188021115247.32177031830452; Mon, 26 Sep 2022 03:27:01 -0700 (PDT) Received: from localhost ([::1]:51400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclKD-0008Jq-Tt for importer@patchew.org; Mon, 26 Sep 2022 06:26:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockps-0005ZH-Oa for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpr-0003o2-2d for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:36 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-kMv2CygHNneyVGTGJoIP8Q-1; Mon, 26 Sep 2022 05:55:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94FAD3810780; Mon, 26 Sep 2022 09:55:30 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4D2FFC15BA4; Mon, 26 Sep 2022 09:55:30 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 19D54180A401; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TwMBwWhUCObCQODSt2PE3geZjaDC55CP59MmTESi1FE=; b=JujMGLRo8FK0kNoAkPTPz11Ji5QsfoukmQGuXlpFZZS7x58qZvWcXdDZm0EGafrf39/VEv MvqRKBo3r19MCi5G2xy2GJ21F4PcUb1JwIkM5vhl9PPdmMmAf6VFsl3gINlySShefp8CnN RXOIK641OHOa6wE/VQezjELWwCD41y8= X-MC-Unique: kMv2CygHNneyVGTGJoIP8Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Michael Brown Subject: [PULL 20/25] usbnet: Report link-up via interrupt endpoint in CDC-ECM mode Date: Mon, 26 Sep 2022 11:55:04 +0200 Message-Id: <20220926095509.3759409-21-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188023365100001 Content-Type: text/plain; charset="utf-8" From: Michael Brown Signed-off-by: Michael Brown Message-Id: <20220906183053.3625472-5-mcb30@ipxe.org> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-network.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 9d83974ec9f0..ac1adca54355 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -91,6 +91,8 @@ enum usbstring_idx { #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 #define USB_CDC_GET_ETHERNET_STATISTIC 0x44 =20 +#define USB_CDC_NETWORK_CONNECTION 0x00 + #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 =3D=3D 32 msec */ #define STATUS_BYTECOUNT 16 /* 8 byte header + data */ =20 @@ -640,6 +642,8 @@ struct USBNetState { uint16_t filter; uint32_t vendorid; =20 + uint16_t connection; + unsigned int out_ptr; uint8_t out_buf[2048]; =20 @@ -1140,18 +1144,28 @@ static void usb_net_handle_control(USBDevice *dev, = USBPacket *p, =20 static void usb_net_handle_statusin(USBNetState *s, USBPacket *p) { - le32 buf[2]; + le32 rbuf[2]; + uint16_t ebuf[4]; =20 if (p->iov.size < 8) { p->status =3D USB_RET_STALL; return; } =20 - buf[0] =3D cpu_to_le32(1); - buf[1] =3D cpu_to_le32(0); - usb_packet_copy(p, buf, 8); - if (!s->rndis_resp.tqh_first) { - p->status =3D USB_RET_NAK; + if (is_rndis(s)) { + rbuf[0] =3D cpu_to_le32(1); + rbuf[1] =3D cpu_to_le32(0); + usb_packet_copy(p, rbuf, 8); + if (!s->rndis_resp.tqh_first) { + p->status =3D USB_RET_NAK; + } + } else { + ebuf[0] =3D + cpu_to_be16(ClassInterfaceRequest | USB_CDC_NETWORK_CONNECTION= ); + ebuf[1] =3D cpu_to_le16(s->connection); + ebuf[2] =3D cpu_to_le16(1); + ebuf[3] =3D cpu_to_le16(0); + usb_packet_copy(p, ebuf, 8); } =20 #ifdef TRAFFIC_DEBUG @@ -1366,6 +1380,7 @@ static void usb_net_realize(USBDevice *dev, Error **e= rrp) s->media_state =3D 0; /* NDIS_MEDIA_STATE_CONNECTED */; s->filter =3D 0; s->vendorid =3D 0x1234; + s->connection =3D 1; /* Connected */ s->intr =3D usb_ep_get(dev, USB_TOKEN_IN, 1); s->bulk_in =3D usb_ep_get(dev, USB_TOKEN_IN, 2); =20 --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188531; cv=none; d=zohomail.com; s=zohoarc; b=XTUciWBeYlpZINgUDknMKvHxBWd2PKLeEGJRoTAto3FMfhCJyfY2dOpb8dSrGnbmEoVf3JtOsCSqGD2pE2xh98l3xaByWbl4LsiLG5NDLpjgL+FYyGCX3Gsm46PPyIR9HPKv6PKjwotGofOSv86ubSQrkJq3f2dYx0YsUhidbaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188531; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IaAIzLnv6j0oElP8sw877kHAdtnTXggNHIKJP/nbolc=; b=lOpHl5rSOvi2ke/C2E2z7Dt5Ky5YJ6+QxPxPr6JdKHRP70+EKI6+sTORO5GALnEMDFCE/hULpriuEtmOagIbNjVt/kHG3WbamxxoHSay6/skIDEiBhgj3dWiV+zWfF/77DrQFJj6V6oId7BhI+baysT1Seg2TEy6/p4wwZzb3gg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188531850660.5949510068879; Mon, 26 Sep 2022 03:35:31 -0700 (PDT) Received: from localhost ([::1]:48282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclSR-0005O3-Qd for importer@patchew.org; Mon, 26 Sep 2022 06:35:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpu-0005fR-Pi for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpr-0003oJ-Hr for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:38 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-GHJKgt-oPj-9BdvGQzSM_Q-1; Mon, 26 Sep 2022 05:55:31 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F12573810781; Mon, 26 Sep 2022 09:55:30 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AFD4492CA2; Mon, 26 Sep 2022 09:55:30 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3DE8D180A403; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IaAIzLnv6j0oElP8sw877kHAdtnTXggNHIKJP/nbolc=; b=ieATp5igfroibtWHigMt13yCB9LkpyqZndtuJsjyJ/naq2gFnwBijLHyEM1OjahF2OF19r cEkY+IDJ7MPlHraurebr+5S5fxalCZ3Eu/5dVvcZriGK4+NEEzhLNHMrrhdjlhp6alQwLv AoX7loLeNaY2fq6W6tcEC/qBE5nElRc= X-MC-Unique: GHJKgt-oPj-9BdvGQzSM_Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Brad Smith , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 21/25] audio: Add sndio backend Date: Mon, 26 Sep 2022 11:55:05 +0200 Message-Id: <20220926095509.3759409-22-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188533076100001 From: Alexandre Ratchov sndio is the native API used by OpenBSD, although it has been ported to other *BSD's and Linux (packages for Ubuntu, Debian, Void, Arch, etc.). Signed-off-by: Brad Smith Signed-off-by: Alexandre Ratchov Reviewed-by: Volker R=C3=BCmelin Tested-by: Volker R=C3=BCmelin Message-Id: Signed-off-by: Gerd Hoffmann --- meson_options.txt | 4 +- audio/audio_template.h | 2 + audio/audio.c | 1 + audio/sndioaudio.c | 565 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 7 + audio/meson.build | 1 + meson.build | 9 +- qapi/audio.json | 25 +- qemu-options.hx | 16 + scripts/meson-buildoptions.sh | 7 +- 10 files changed, 632 insertions(+), 5 deletions(-) create mode 100644 audio/sndioaudio.c diff --git a/meson_options.txt b/meson_options.txt index 63f072517427..9df9e86d7d35 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -21,7 +21,7 @@ option('tls_priority', type : 'string', value : 'NORMAL', option('default_devices', type : 'boolean', value : true, description: 'Include a default selection of devices in emulators') option('audio_drv_list', type: 'array', value: ['default'], - choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', = 'pa', 'sdl'], + choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', = 'pa', 'sdl', 'sndio'], description: 'Set audio driver list') option('block_drv_rw_whitelist', type : 'string', value : '', description: 'set block driver read-write whitelist (by default aff= ects only QEMU, not tools like qemu-img)') @@ -240,6 +240,8 @@ option('oss', type: 'feature', value: 'auto', description: 'OSS sound support') option('pa', type: 'feature', value: 'auto', description: 'PulseAudio sound support') +option('sndio', type: 'feature', value: 'auto', + description: 'sndio sound support') =20 option('vhost_kernel', type: 'feature', value: 'auto', description: 'vhost kernel backend support') diff --git a/audio/audio_template.h b/audio/audio_template.h index 7192b19e7390..81860cea6202 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -336,6 +336,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)= (Audiodev *dev) return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE); case AUDIODEV_DRIVER_SDL: return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.TYPE); + case AUDIODEV_DRIVER_SNDIO: + return dev->u.sndio.TYPE; case AUDIODEV_DRIVER_SPICE: return dev->u.spice.TYPE; case AUDIODEV_DRIVER_WAV: diff --git a/audio/audio.c b/audio/audio.c index cfa4119c0598..5600593da043 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2030,6 +2030,7 @@ void audio_create_pdos(Audiodev *dev) CASE(OSS, oss, Oss); CASE(PA, pa, Pa); CASE(SDL, sdl, Sdl); + CASE(SNDIO, sndio, ); CASE(SPICE, spice, ); CASE(WAV, wav, ); =20 diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c new file mode 100644 index 000000000000..7c45276d36ce --- /dev/null +++ b/audio/sndioaudio.c @@ -0,0 +1,565 @@ +/* + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2019 Alexandre Ratchov + */ + +/* + * TODO : + * + * Use a single device and open it in full-duplex rather than + * opening it twice (once for playback once for recording). + * + * This is the only way to ensure that playback doesn't drift with respect + * to recording, which is what guest systems expect. + */ + +#include +#include +#include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "audio.h" +#include "trace.h" + +#define AUDIO_CAP "sndio" +#include "audio_int.h" + +/* default latency in microseconds if no option is set */ +#define SNDIO_LATENCY_US 50000 + +typedef struct SndioVoice { + union { + HWVoiceOut out; + HWVoiceIn in; + } hw; + struct sio_par par; + struct sio_hdl *hdl; + struct pollfd *pfds; + struct pollindex { + struct SndioVoice *self; + int index; + } *pindexes; + unsigned char *buf; + size_t buf_size; + size_t sndio_pos; + size_t qemu_pos; + unsigned int mode; + unsigned int nfds; + bool enabled; +} SndioVoice; + +typedef struct SndioConf { + const char *devname; + unsigned int latency; +} SndioConf; + +/* needed for forward reference */ +static void sndio_poll_in(void *arg); +static void sndio_poll_out(void *arg); + +/* + * stop polling descriptors + */ +static void sndio_poll_clear(SndioVoice *self) +{ + struct pollfd *pfd; + int i; + + for (i =3D 0; i < self->nfds; i++) { + pfd =3D &self->pfds[i]; + qemu_set_fd_handler(pfd->fd, NULL, NULL, NULL); + } + + self->nfds =3D 0; +} + +/* + * write data to the device until it blocks or + * all of our buffered data is written + */ +static void sndio_write(SndioVoice *self) +{ + size_t todo, n; + + todo =3D self->qemu_pos - self->sndio_pos; + + /* + * transfer data to device, until it blocks + */ + while (todo > 0) { + n =3D sio_write(self->hdl, self->buf + self->sndio_pos, todo); + if (n =3D=3D 0) { + break; + } + self->sndio_pos +=3D n; + todo -=3D n; + } + + if (self->sndio_pos =3D=3D self->buf_size) { + /* + * we complete the block + */ + self->sndio_pos =3D 0; + self->qemu_pos =3D 0; + } +} + +/* + * read data from the device until it blocks or + * there no room any longer + */ +static void sndio_read(SndioVoice *self) +{ + size_t todo, n; + + todo =3D self->buf_size - self->sndio_pos; + + /* + * transfer data from the device, until it blocks + */ + while (todo > 0) { + n =3D sio_read(self->hdl, self->buf + self->sndio_pos, todo); + if (n =3D=3D 0) { + break; + } + self->sndio_pos +=3D n; + todo -=3D n; + } +} + +/* + * Set handlers for all descriptors libsndio needs to + * poll + */ +static void sndio_poll_wait(SndioVoice *self) +{ + struct pollfd *pfd; + int events, i; + + events =3D 0; + if (self->mode =3D=3D SIO_PLAY) { + if (self->sndio_pos < self->qemu_pos) { + events |=3D POLLOUT; + } + } else { + if (self->sndio_pos < self->buf_size) { + events |=3D POLLIN; + } + } + + /* + * fill the given array of descriptors with the events sndio + * wants, they are different from our 'event' variable because + * sndio may use descriptors internally. + */ + self->nfds =3D sio_pollfd(self->hdl, self->pfds, events); + + for (i =3D 0; i < self->nfds; i++) { + pfd =3D &self->pfds[i]; + if (pfd->fd < 0) { + continue; + } + qemu_set_fd_handler(pfd->fd, + (pfd->events & POLLIN) ? sndio_poll_in : NULL, + (pfd->events & POLLOUT) ? sndio_poll_out : NULL, + &self->pindexes[i]); + pfd->revents =3D 0; + } +} + +/* + * call-back called when one of the descriptors + * became readable or writable + */ +static void sndio_poll_event(SndioVoice *self, int index, int event) +{ + int revents; + + /* + * ensure we're not called twice this cycle + */ + sndio_poll_clear(self); + + /* + * make self->pfds[] look as we're returning from poll syscal, + * this is how sio_revents expects events to be. + */ + self->pfds[index].revents =3D event; + + /* + * tell sndio to handle events and return whether we can read or + * write without blocking. + */ + revents =3D sio_revents(self->hdl, self->pfds); + if (self->mode =3D=3D SIO_PLAY) { + if (revents & POLLOUT) { + sndio_write(self); + } + + if (self->qemu_pos < self->buf_size) { + audio_run(self->hw.out.s, "sndio_out"); + } + } else { + if (revents & POLLIN) { + sndio_read(self); + } + + if (self->qemu_pos < self->sndio_pos) { + audio_run(self->hw.in.s, "sndio_in"); + } + } + + /* + * audio_run() may have changed state + */ + if (self->enabled) { + sndio_poll_wait(self); + } +} + +/* + * return the upper limit of the amount of free play buffer space + */ +static size_t sndio_buffer_get_free(HWVoiceOut *hw) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + return self->buf_size - self->qemu_pos; +} + +/* + * return a buffer where data to play can be stored, + * its size is stored in the location pointed by the size argument. + */ +static void *sndio_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + *size =3D self->buf_size - self->qemu_pos; + return self->buf + self->qemu_pos; +} + +/* + * put back to sndio back-end a buffer returned by sndio_get_buffer_out() + */ +static size_t sndio_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + self->qemu_pos +=3D size; + sndio_poll_wait(self); + return size; +} + +/* + * return a buffer from where recorded data is available, + * its size is stored in the location pointed by the size argument. + * it may not exceed the initial value of "*size". + */ +static void *sndio_get_buffer_in(HWVoiceIn *hw, size_t *size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + size_t todo, max_todo; + + /* + * unlike the get_buffer_out() method, get_buffer_in() + * must return a buffer of at most the given size, see audio.c + */ + max_todo =3D *size; + + todo =3D self->sndio_pos - self->qemu_pos; + if (todo > max_todo) { + todo =3D max_todo; + } + + *size =3D todo; + return self->buf + self->qemu_pos; +} + +/* + * discard the given amount of recorded data + */ +static void sndio_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + self->qemu_pos +=3D size; + if (self->qemu_pos =3D=3D self->buf_size) { + self->qemu_pos =3D 0; + self->sndio_pos =3D 0; + } + sndio_poll_wait(self); +} + +/* + * call-back called when one of our descriptors becomes writable + */ +static void sndio_poll_out(void *arg) +{ + struct pollindex *pindex =3D (struct pollindex *) arg; + + sndio_poll_event(pindex->self, pindex->index, POLLOUT); +} + +/* + * call-back called when one of our descriptors becomes readable + */ +static void sndio_poll_in(void *arg) +{ + struct pollindex *pindex =3D (struct pollindex *) arg; + + sndio_poll_event(pindex->self, pindex->index, POLLIN); +} + +static void sndio_fini(SndioVoice *self) +{ + if (self->hdl) { + sio_close(self->hdl); + self->hdl =3D NULL; + } + + g_free(self->pfds); + g_free(self->pindexes); + g_free(self->buf); +} + +static int sndio_init(SndioVoice *self, + struct audsettings *as, int mode, Audiodev *dev) +{ + AudiodevSndioOptions *opts =3D &dev->u.sndio; + unsigned long long latency; + const char *dev_name; + struct sio_par req; + unsigned int nch; + int i, nfds; + + dev_name =3D opts->has_dev ? opts->dev : SIO_DEVANY; + latency =3D opts->has_latency ? opts->latency : SNDIO_LATENCY_US; + + /* open the device in non-blocking mode */ + self->hdl =3D sio_open(dev_name, mode, 1); + if (self->hdl =3D=3D NULL) { + dolog("failed to open device\n"); + return -1; + } + + self->mode =3D mode; + + sio_initpar(&req); + + switch (as->fmt) { + case AUDIO_FORMAT_S8: + req.bits =3D 8; + req.sig =3D 1; + break; + case AUDIO_FORMAT_U8: + req.bits =3D 8; + req.sig =3D 0; + break; + case AUDIO_FORMAT_S16: + req.bits =3D 16; + req.sig =3D 1; + break; + case AUDIO_FORMAT_U16: + req.bits =3D 16; + req.sig =3D 0; + break; + case AUDIO_FORMAT_S32: + req.bits =3D 32; + req.sig =3D 1; + break; + case AUDIO_FORMAT_U32: + req.bits =3D 32; + req.sig =3D 0; + break; + default: + dolog("unknown audio sample format\n"); + return -1; + } + + if (req.bits > 8) { + req.le =3D as->endianness ? 0 : 1; + } + + req.rate =3D as->freq; + if (mode =3D=3D SIO_PLAY) { + req.pchan =3D as->nchannels; + } else { + req.rchan =3D as->nchannels; + } + + /* set on-device buffer size */ + req.appbufsz =3D req.rate * latency / 1000000; + + if (!sio_setpar(self->hdl, &req)) { + dolog("failed set audio params\n"); + goto fail; + } + + if (!sio_getpar(self->hdl, &self->par)) { + dolog("failed get audio params\n"); + goto fail; + } + + nch =3D (mode =3D=3D SIO_PLAY) ? self->par.pchan : self->par.rchan; + + /* + * With the default setup, sndio supports any combination of parameters + * so these checks are mostly to catch configuration errors. + */ + if (self->par.bits !=3D req.bits || self->par.bps !=3D req.bits / 8 || + self->par.sig !=3D req.sig || (req.bits > 8 && self->par.le !=3D r= eq.le) || + self->par.rate !=3D as->freq || nch !=3D as->nchannels) { + dolog("unsupported audio params\n"); + goto fail; + } + + /* + * we use one block as buffer size; this is how + * transfers get well aligned + */ + self->buf_size =3D self->par.round * self->par.bps * nch; + + self->buf =3D g_malloc(self->buf_size); + if (self->buf =3D=3D NULL) { + dolog("failed to allocate audio buffer\n"); + goto fail; + } + + nfds =3D sio_nfds(self->hdl); + + self->pfds =3D g_malloc_n(nfds, sizeof(struct pollfd)); + if (self->pfds =3D=3D NULL) { + dolog("failed to allocate pollfd structures\n"); + goto fail; + } + + self->pindexes =3D g_malloc_n(nfds, sizeof(struct pollindex)); + if (self->pindexes =3D=3D NULL) { + dolog("failed to allocate pollindex structures\n"); + goto fail; + } + + for (i =3D 0; i < nfds; i++) { + self->pindexes[i].self =3D self; + self->pindexes[i].index =3D i; + } + + return 0; +fail: + sndio_fini(self); + return -1; +} + +static void sndio_enable(SndioVoice *self, bool enable) +{ + if (enable) { + sio_start(self->hdl); + self->enabled =3D true; + sndio_poll_wait(self); + } else { + self->enabled =3D false; + sndio_poll_clear(self); + sio_stop(self->hdl); + } +} + +static void sndio_enable_out(HWVoiceOut *hw, bool enable) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_enable(self, enable); +} + +static void sndio_enable_in(HWVoiceIn *hw, bool enable) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_enable(self, enable); +} + +static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as, void *op= aque) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + if (sndio_init(self, as, SIO_PLAY, opaque) =3D=3D -1) { + return -1; + } + + audio_pcm_init_info(&hw->info, as); + hw->samples =3D self->par.round; + return 0; +} + +static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as, void *opaq= ue) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + if (sndio_init(self, as, SIO_REC, opaque) =3D=3D -1) { + return -1; + } + + audio_pcm_init_info(&hw->info, as); + hw->samples =3D self->par.round; + return 0; +} + +static void sndio_fini_out(HWVoiceOut *hw) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_fini(self); +} + +static void sndio_fini_in(HWVoiceIn *hw) +{ + SndioVoice *self =3D (SndioVoice *) hw; + + sndio_fini(self); +} + +static void *sndio_audio_init(Audiodev *dev) +{ + assert(dev->driver =3D=3D AUDIODEV_DRIVER_SNDIO); + return dev; +} + +static void sndio_audio_fini(void *opaque) +{ +} + +static struct audio_pcm_ops sndio_pcm_ops =3D { + .init_out =3D sndio_init_out, + .fini_out =3D sndio_fini_out, + .enable_out =3D sndio_enable_out, + .write =3D audio_generic_write, + .buffer_get_free =3D sndio_buffer_get_free, + .get_buffer_out =3D sndio_get_buffer_out, + .put_buffer_out =3D sndio_put_buffer_out, + .init_in =3D sndio_init_in, + .fini_in =3D sndio_fini_in, + .read =3D audio_generic_read, + .enable_in =3D sndio_enable_in, + .get_buffer_in =3D sndio_get_buffer_in, + .put_buffer_in =3D sndio_put_buffer_in, +}; + +static struct audio_driver sndio_audio_driver =3D { + .name =3D "sndio", + .descr =3D "sndio https://sndio.org", + .init =3D sndio_audio_init, + .fini =3D sndio_audio_fini, + .pcm_ops =3D &sndio_pcm_ops, + .can_be_default =3D 1, + .max_voices_out =3D INT_MAX, + .max_voices_in =3D INT_MAX, + .voice_size_out =3D sizeof(SndioVoice), + .voice_size_in =3D sizeof(SndioVoice) +}; + +static void register_audio_sndio(void) +{ + audio_driver_register(&sndio_audio_driver); +} + +type_init(register_audio_sndio); diff --git a/MAINTAINERS b/MAINTAINERS index 738c4eb647c8..269e07cf4777 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2438,6 +2438,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndioaudio.c X: audio/spiceaudio.c F: qapi/audio.json =20 @@ -2482,6 +2483,12 @@ R: Thomas Huth S: Odd Fixes F: audio/sdlaudio.c =20 +Sndio Audio backend +M: Gerd Hoffmann +R: Alexandre Ratchov +S: Odd Fixes +F: audio/sndioaudio.c + Block layer core M: Kevin Wolf M: Hanna Reitz diff --git a/audio/meson.build b/audio/meson.build index 3abee908602a..34aed7834223 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -17,6 +17,7 @@ foreach m : [ ['pa', pulse, files('paaudio.c')], ['sdl', sdl, files('sdlaudio.c')], ['jack', jack, files('jackaudio.c')], + ['sndio', sndio, files('sndioaudio.c')], ['spice', spice, files('spiceaudio.c')] ] if m[1].found() diff --git a/meson.build b/meson.build index d9ac91ff3659..13db89c65af1 100644 --- a/meson.build +++ b/meson.build @@ -675,6 +675,11 @@ if not get_option('jack').auto() or have_system jack =3D dependency('jack', required: get_option('jack'), method: 'pkg-config', kwargs: static_kwargs) endif +sndio =3D not_found +if not get_option('sndio').auto() or have_system + sndio =3D dependency('sndio', required: get_option('sndio'), + method: 'pkg-config', kwargs: static_kwargs) +endif =20 spice_protocol =3D not_found if not get_option('spice_protocol').auto() or have_system @@ -1591,6 +1596,7 @@ if have_system 'oss': oss.found(), 'pa': pulse.found(), 'sdl': sdl.found(), + 'sndio': sndio.found(), } foreach k, v: audio_drivers_available config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v) @@ -1598,7 +1604,7 @@ if have_system =20 # Default to native drivers first, OSS second, SDL third audio_drivers_priority =3D \ - [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \ + [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \ (targetos =3D=3D 'linux' ? [] : [ 'sdl' ]) audio_drivers_default =3D [] foreach k: audio_drivers_priority @@ -3922,6 +3928,7 @@ if vnc.found() endif if targetos not in ['darwin', 'haiku', 'windows'] summary_info +=3D {'OSS support': oss} + summary_info +=3D {'sndio support': sndio} elif targetos =3D=3D 'darwin' summary_info +=3D {'CoreAudio support': coreaudio} elif targetos =3D=3D 'windows' diff --git a/qapi/audio.json b/qapi/audio.json index 8099e3d7f13b..1e0a24bdfc40 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -106,6 +106,28 @@ '*out': 'AudiodevAlsaPerDirectionOptions', '*threshold': 'uint32' } } =20 +## +# @AudiodevSndioOptions: +# +# Options of the sndio audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @dev: the name of the sndio device to use (default 'default') +# +# @latency: play buffer size (in microseconds) +# +# Since: 7.2 +## +{ 'struct': 'AudiodevSndioOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*dev': 'str', + '*latency': 'uint32'} } + ## # @AudiodevCoreaudioPerDirectionOptions: # @@ -387,7 +409,7 @@ ## { 'enum': 'AudiodevDriver', 'data': [ 'none', 'alsa', 'coreaudio', 'dbus', 'dsound', 'jack', 'oss', = 'pa', - 'sdl', 'spice', 'wav' ] } + 'sdl', 'sndio', 'spice', 'wav' ] } =20 ## # @Audiodev: @@ -418,5 +440,6 @@ 'oss': 'AudiodevOssOptions', 'pa': 'AudiodevPaOptions', 'sdl': 'AudiodevSdlOptions', + 'sndio': 'AudiodevSndioOptions', 'spice': 'AudiodevGenericOptions', 'wav': 'AudiodevWavOptions' } } diff --git a/qemu-options.hx b/qemu-options.hx index d8b5ce5b4354..2ff06884f42d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -769,6 +769,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, "-audiodev sdl,id=3Did[,prop[=3Dvalue][,...]]\n" " in|out.buffer-count=3D number of buffers\n" #endif +#ifdef CONFIG_AUDIO_SNDIO + "-audiodev sndio,id=3Did[,prop[=3Dvalue][,...]]\n" +#endif #ifdef CONFIG_SPICE "-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]\n" #endif @@ -935,6 +938,19 @@ SRST ``in|out.buffer-count=3Dcount`` Sets the count of the buffers. =20 +``-audiodev sndio,id=3Did[,prop[=3Dvalue][,...]]`` + Creates a backend using SNDIO. This backend is available on + OpenBSD and most other Unix-like systems. + + Sndio specific options are: + + ``in|out.dev=3Ddevice`` + Specify the sndio device to use for input and/or output. Default + is ``default``. + + ``in|out.latency=3Dusecs`` + Sets the desired period length in microseconds. + ``-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]`` Creates a backend that sends audio through SPICE. This backend requires ``-spice`` and automatically selected in that case, so diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 359b04e0e6d3..f08e3a8a7e02 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -1,7 +1,7 @@ # This file is generated by meson-buildoptions.py, do not edit! meson_options_help() { - printf "%s\n" ' --audio-drv-list=3DCHOICES Set audio driver list [defau= lt] (choices:' - printf "%s\n" ' alsa/coreaudio/default/dsound/= jack/oss/pa/sdl)' + printf "%s\n" ' --audio-drv-list=3DCHOICES Set audio driver list [defau= lt] (choices: alsa/co' + printf "%s\n" ' reaudio/default/dsound/jack/os= s/pa/sdl/sndio)' printf "%s\n" ' --block-drv-ro-whitelist=3DVALUE' printf "%s\n" ' set block driver read-only whi= telist (by default' printf "%s\n" ' affects only QEMU, not tools l= ike qemu-img)' @@ -144,6 +144,7 @@ meson_options_help() { printf "%s\n" ' slirp-smbd use smbd (at path --smbd=3D*) in slirp = networking' printf "%s\n" ' smartcard CA smartcard emulation support' printf "%s\n" ' snappy snappy compression support' + printf "%s\n" ' sndio sndio sound support' printf "%s\n" ' sparse sparse checker' printf "%s\n" ' spice Spice server support' printf "%s\n" ' spice-protocol Spice protocol support' @@ -393,6 +394,8 @@ _meson_option_parse() { --disable-smartcard) printf "%s" -Dsmartcard=3Ddisabled ;; --enable-snappy) printf "%s" -Dsnappy=3Denabled ;; --disable-snappy) printf "%s" -Dsnappy=3Ddisabled ;; + --enable-sndio) printf "%s" -Dsndio=3Denabled ;; + --disable-sndio) printf "%s" -Dsndio=3Ddisabled ;; --enable-sparse) printf "%s" -Dsparse=3Denabled ;; --disable-sparse) printf "%s" -Dsparse=3Ddisabled ;; --sphinx-build=3D*) quote_sh "-Dsphinx_build=3D$2" ;; --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664187753; cv=none; d=zohomail.com; s=zohoarc; b=TUE0wCZuFZZ3OHaqh6t4TLk0hmqz2/igGr37OM/9pMnOZcE3q9/unD9vQNqr6iBNOYN0QYeAK2uQwa06mFVwoPt3RTPL6/O9D9a4wGcdJV3/iLRrUVlfjmB6wFcnhwZEmq9kM4Z/P3lYwxd5hWdahCZliJ+POCJ0G6qXZ9VOysM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664187753; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TJpHQZVHvsstAM7uMbP+gvvt8yEVZkMarUyInSA1C80=; b=fEnXY9jY5nn9uCCH+CA+kbgLehN43pvAc8XO7OMvMLmwWtpZ+cHQXktGMBk/MStOGdSNmYvwyifUbHWVzeu0WDl6W+hJrPt2pcTGilqiv+PSg7e4QXWOZkrbo6lPMAv9hjPyVLAUDY/rpp+2Sl8WmDFQ+B+4PlAaPrDHFEDYIHY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664187753128774.5338063642861; Mon, 26 Sep 2022 03:22:33 -0700 (PDT) Received: from localhost ([::1]:53480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclFv-00042k-PY for importer@patchew.org; Mon, 26 Sep 2022 06:22:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpv-0005hl-Hb for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpt-0003ox-Jd for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:39 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-xF9RULUxMt2T2KJK5VpJ7w-1; Mon, 26 Sep 2022 05:55:32 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6ABCD29AB44C; Mon, 26 Sep 2022 09:55:32 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3516C15BA4; Mon, 26 Sep 2022 09:55:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4E646180A404; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TJpHQZVHvsstAM7uMbP+gvvt8yEVZkMarUyInSA1C80=; b=DCloWoyI1zgl9xiU6Obu5plDiQdZMItafKnXc/xDtvQUzrZenMFLguV0f18YmEhDat2Cwx kt/x6i6gddJQD9emXNON3iHSi3+Hp2zmuYXd6LmzQzPGjO/63HRpkaqg610ZQyJFkGdfbc lKxv2ozHrc34WzSFWlq75CFH4Bakd0g= X-MC-Unique: xF9RULUxMt2T2KJK5VpJ7w-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 22/25] Revert "audio: Log context for audio bug" Date: Mon, 26 Sep 2022 11:55:06 +0200 Message-Id: <20220926095509.3759409-23-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664187754679100003 From: Volker R=C3=BCmelin This reverts commit 8e30d39bade3010387177ca23dbc2244352ed4a3. Revert commit 8e30d39bad "audio: Log context for audio bug" to make error propagation work again. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220917131626.7521-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio_template.h | 27 +++++++++++++++------------ audio/audio.c | 25 +++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 81860cea6202..98ab557684d8 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -59,13 +59,12 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioStat= e *s, if (audio_bug(__func__, !voice_size && max_voices)) { dolog ("drv=3D`%s' voice_size=3D0 max_voices=3D%d\n", drv->name, max_voices); - abort(); + glue (s->nb_hw_voices_, TYPE) =3D 0; } =20 if (audio_bug(__func__, voice_size && !max_voices)) { dolog ("drv=3D`%s' voice_size=3D%d max_voices=3D0\n", drv->name, voice_size); - abort(); } } =20 @@ -82,7 +81,6 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW = *hw) size_t samples =3D hw->samples; if (audio_bug(__func__, samples =3D=3D 0)) { dolog("Attempted to allocate empty buffer\n"); - abort(); } =20 HWBUF =3D g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * s= amples); @@ -254,12 +252,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioSta= te *s, =20 if (audio_bug(__func__, !drv)) { dolog ("No host audio driver\n"); - abort(); + return NULL; } =20 if (audio_bug(__func__, !drv->pcm_ops)) { dolog ("Host audio driver without pcm_ops\n"); - abort(); + return NULL; } =20 hw =3D audio_calloc(__func__, 1, glue(drv->voice_size_, TYPE)); @@ -277,13 +275,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioSta= te *s, QLIST_INIT (&hw->cap_head); #endif if (glue (hw->pcm_ops->init_, TYPE) (hw, as, s->drv_opaque)) { - g_free(hw); - return NULL; + goto err0; } =20 if (audio_bug(__func__, hw->samples <=3D 0)) { dolog("hw->samples=3D%zd\n", hw->samples); - abort(); + goto err1; } =20 if (hw->info.is_float) { @@ -312,6 +309,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioStat= e *s, audio_attach_capture (hw); #endif return hw; + + err1: + glue (hw->pcm_ops->fini_, TYPE) (hw); + err0: + g_free (hw); + return NULL; } =20 AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev) @@ -434,7 +437,7 @@ void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *= sw) if (sw) { if (audio_bug(__func__, !card)) { dolog ("card=3D%p\n", card); - abort(); + return; } =20 glue (audio_close_, TYPE) (sw); @@ -456,7 +459,7 @@ SW *glue (AUD_open_, TYPE) ( if (audio_bug(__func__, !card || !name || !callback_fn || !as)) { dolog ("card=3D%p name=3D%p callback_fn=3D%p as=3D%p\n", card, name, callback_fn, as); - abort(); + goto fail; } =20 s =3D card->state; @@ -467,12 +470,12 @@ SW *glue (AUD_open_, TYPE) ( =20 if (audio_bug(__func__, audio_validate_settings(as))) { audio_print_settings (as); - abort(); + goto fail; } =20 if (audio_bug(__func__, !s->drv)) { dolog ("Can not open `%s' (no host audio driver)\n", name); - abort(); + goto fail; } =20 if (sw && audio_pcm_info_eq (&sw->info, as)) { diff --git a/audio/audio.c b/audio/audio.c index 5600593da043..d96a13055940 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -118,6 +118,7 @@ int audio_bug (const char *funcname, int cond) AUD_log (NULL, "I am sorry\n"); } AUD_log (NULL, "Context:\n"); + abort(); } =20 return cond; @@ -138,7 +139,7 @@ static inline int audio_bits_to_index (int bits) default: audio_bug ("bits_to_index", 1); AUD_log (NULL, "invalid bits %d\n", bits); - abort(); + return 0; } } =20 @@ -156,7 +157,7 @@ void *audio_calloc (const char *funcname, int nmemb, si= ze_t size) AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n", funcname); AUD_log (NULL, "nmemb=3D%d size=3D%zu (len=3D%zu)\n", nmemb, size,= len); - abort(); + return NULL; } =20 return g_malloc0 (len); @@ -543,7 +544,7 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) size_t live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in = (hw); if (audio_bug(__func__, live > hw->conv_buf->size)) { dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); - abort(); + return 0; } return live; } @@ -581,7 +582,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t size) } if (audio_bug(__func__, live > hw->conv_buf->size)) { dolog("live_in=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_b= uf->size); - abort(); + return 0; } =20 rpos =3D audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); @@ -656,7 +657,7 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw= , int *nb_live) =20 if (audio_bug(__func__, live > hw->mix_buf->size)) { dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hw->mix_bu= f->size); - abort(); + return 0; } return live; } @@ -706,7 +707,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) live =3D sw->total_hw_samples_mixed; if (audio_bug(__func__, live > hwsamples)) { dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hwsamples); - abort(); + return 0; } =20 if (live =3D=3D hwsamples) { @@ -998,7 +999,7 @@ static size_t audio_get_avail (SWVoiceIn *sw) if (audio_bug(__func__, live > sw->hw->conv_buf->size)) { dolog("live=3D%zu sw->hw->conv_buf->size=3D%zu\n", live, sw->hw->conv_buf->size); - abort(); + return 0; } =20 ldebug ( @@ -1028,7 +1029,7 @@ static size_t audio_get_free(SWVoiceOut *sw) if (audio_bug(__func__, live > sw->hw->mix_buf->size)) { dolog("live=3D%zu sw->hw->mix_buf->size=3D%zu\n", live, sw->hw->mix_buf->size); - abort(); + return 0; } =20 dead =3D sw->hw->mix_buf->size - live; @@ -1170,7 +1171,7 @@ static void audio_run_out (AudioState *s) =20 if (audio_bug(__func__, live > hw->mix_buf->size)) { dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hw->mix_bu= f->size); - abort(); + continue; } =20 if (hw->pending_disable && !nb_live) { @@ -1203,7 +1204,7 @@ static void audio_run_out (AudioState *s) if (audio_bug(__func__, hw->mix_buf->pos >=3D hw->mix_buf->size)) { dolog("hw->mix_buf->pos=3D%zu hw->mix_buf->size=3D%zu played= =3D%zu\n", hw->mix_buf->pos, hw->mix_buf->size, played); - abort(); + hw->mix_buf->pos =3D 0; } =20 #ifdef DEBUG_OUT @@ -1223,7 +1224,7 @@ static void audio_run_out (AudioState *s) if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) { dolog("played=3D%zu sw->total_hw_samples_mixed=3D%zu\n", played, sw->total_hw_samples_mixed); - abort(); + played =3D sw->total_hw_samples_mixed; } =20 sw->total_hw_samples_mixed -=3D played; @@ -1346,7 +1347,7 @@ static void audio_run_capture (AudioState *s) if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)= ) { dolog("captured=3D%zu sw->total_hw_samples_mixed=3D%zu\n", captured, sw->total_hw_samples_mixed); - abort(); + captured =3D sw->total_hw_samples_mixed; } =20 sw->total_hw_samples_mixed -=3D captured; --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664189123; cv=none; d=zohomail.com; s=zohoarc; b=XW6GpD+PebeX4obrK3voDUD+uWQA3pBZpMRj9MxzYHDQoaJRLiAuapNiNMayZW89dIQsgsapdnHmK7a3fJO01gQrRBLTRUKBnt9SSZ7RB5EWZnLiJUIK0cPuGr9aYZrDZJrfIRWO7mj/YRyguM3jTc3ND38ApNsDkCb6en8LvZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664189123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VdNGq6hWlpuhjkU34UysDLKoPOaBocYG/ganxIELqNM=; b=iBxGYRGEzpTA4BHYBZyEpG2AUDszOlXK9nP/5KO3R/ZkZC0TJ0mJuMpBlzeFBmIkVNjq29FCf5lVs7cQmiUumtIML/jzyfUfOSZJ74B2m9RVoHNZdjHjpRX7YY0mG8T/iTddT4xUtyM/T5C4Z+eLBFQLNojeO4P4dUy1lDToycs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664189123023349.0166654038692; Mon, 26 Sep 2022 03:45:23 -0700 (PDT) Received: from localhost ([::1]:48088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclc1-0000dI-Mw for importer@patchew.org; Mon, 26 Sep 2022 06:45:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpu-0005ey-KK for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockps-0003om-OV for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:38 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-220-lq0ZusRZMRSkNkvC7HyfMQ-1; Mon, 26 Sep 2022 05:55:32 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7017F80029D; Mon, 26 Sep 2022 09:55:32 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26686492B04; Mon, 26 Sep 2022 09:55:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5B3F9180A405; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VdNGq6hWlpuhjkU34UysDLKoPOaBocYG/ganxIELqNM=; b=Sf/EmJV3D1ZczFdkENQ34gjXsTsOf5jN4QetzoSXEMyaty/hCzvQpGEvf3cZFpA+8yYbuK vkpVdSvCYOVDCu2/79DX+AUU1JAHJVF50HerTQOau/CC+sY5SBT8Eg6RR0Y8fzQmQZRFaS 0lyzghCdfoKTq1PldcEIM8UG0N/wobo= X-MC-Unique: lq0ZusRZMRSkNkvC7HyfMQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 23/25] audio: remove abort() in audio_bug() Date: Mon, 26 Sep 2022 11:55:07 +0200 Message-Id: <20220926095509.3759409-24-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664189125156100001 From: Volker R=C3=BCmelin Commit ab32b78cd1 "audio: Simplify audio_bug() removing old code" introduced abort() in audio_bug() for regular builds. audio_bug() was never meant to abort QEMU for the following reasons. - There's code in audio_bug() that expects audio_bug() gets called more than once with error condition true. The variable 'shown' is only 0 on first error. - All call sites test the return code of audio_bug(), print an error context message and handle the errror. - The abort() in audio_bug() enables a class of guest-triggered aborts similar to the Launchpad Bug #1910603 at https://bugs.launchpad.net/bugs/1910603. Fixes: ab32b78cd1 "audio: Simplify audio_bug() removing old code" Buglink: https://bugs.launchpad.net/bugs/1910603 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220917131626.7521-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index d96a13055940..df6818ed5598 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -118,7 +118,6 @@ int audio_bug (const char *funcname, int cond) AUD_log (NULL, "I am sorry\n"); } AUD_log (NULL, "Context:\n"); - abort(); } =20 return cond; --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664189000; cv=none; d=zohomail.com; s=zohoarc; b=DP+Rt+yIjyUzXfYIczMEWbxFz5NtqR5GoxAvWGuQxedAPzdhYBemw8oTKIn8CiPPVppNfOlhc5DVMCZHykpriW9xUK5UhGsld73VFtOjFLCums219pbnM6EWeL7cBvbA8YMwaUQTm12dxdj+rh1UpzM9h00o+B/rGWAMH+IFiNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664189000; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tbw9W7pPdJJ3uWnYTKdZaKFVJP/G2X2I0succO0vGcQ=; b=l7FVj2Epp6bmov/8bqiQs5be18v+aYuTK/IhQQ60Ks8sI+ccEylKWkxD48quXD5j1iEzY3AkBDbV1NFNkZFdI87UO50efgRl9cJflvmA0B/5RgOjzFnFsMA8YTSOhth1Sp1I1PINnXaggbBGoV6JEEWuhU9bdFhmNk4eLmCPhAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664189000245107.08693271172444; Mon, 26 Sep 2022 03:43:20 -0700 (PDT) Received: from localhost ([::1]:54156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocla3-0006F1-5t for importer@patchew.org; Mon, 26 Sep 2022 06:43:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpu-0005dL-2a for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockps-0003od-CL for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:37 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-HJ8D5Z77PBS1Zt_m3DR9BA-1; Mon, 26 Sep 2022 05:55:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD1D73810782; Mon, 26 Sep 2022 09:55:33 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A3AC40C2065; Mon, 26 Sep 2022 09:55:33 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 68653180A407; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tbw9W7pPdJJ3uWnYTKdZaKFVJP/G2X2I0succO0vGcQ=; b=eXyZ18bp18efPos/6vX5FwYV1u8i4Ew6vzQ2ZkcicKkpZk/zKzxV2RISi/cs+OabKNfFYk 6MIgwUgqCdAId+G9jy8tXjOL18rr/URgtPBGqMzhUjduQlfpKw4ou7MyWcHxPcau//EZXv TaY16hx9rrB6UnSxhgWEGtODQyYj/1w= X-MC-Unique: HJ8D5Z77PBS1Zt_m3DR9BA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Qiang Liu , Mauro Matteo Cascella Subject: [PULL 24/25] hw/display/ati_2d: Fix buffer overflow in ati_2d_blt (CVE-2021-3638) Date: Mon, 26 Sep 2022 11:55:08 +0200 Message-Id: <20220926095509.3759409-25-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664189001143100001 From: Philippe Mathieu-Daud=C3=A9 When building QEMU with DEBUG_ATI defined then running with '-device ati-vga,romfile=3D"" -d unimp,guest_errors -trace ati\*' we get: ati_mm_write 4 0x16c0 DP_CNTL <- 0x1 ati_mm_write 4 0x146c DP_GUI_MASTER_CNTL <- 0x2 ati_mm_write 4 0x16c8 DP_MIX <- 0xff0000 ati_mm_write 4 0x16c4 DP_DATATYPE <- 0x2 ati_mm_write 4 0x224 CRTC_OFFSET <- 0x0 ati_mm_write 4 0x142c DST_PITCH_OFFSET <- 0xfe00000 ati_mm_write 4 0x1420 DST_Y <- 0x3fff ati_mm_write 4 0x1410 DST_HEIGHT <- 0x3fff ati_mm_write 4 0x1588 DST_WIDTH_X <- 0x3fff3fff ati_2d_blt: vram:0x7fff5fa00000 addr:0 ds:0x7fff61273800 stride:2560 bpp:= 32 rop:0xff ati_2d_blt: 0 0 0, 0 127 0, (0,0) -> (16383,16383) 16383x16383 > ^ ati_2d_blt: pixman_fill(dst:0x7fff5fa00000, stride:254, bpp:8, x:16383, y= :16383, w:16383, h:16383, xor:0xff000000) Thread 3 "qemu-system-i38" received signal SIGSEGV, Segmentation fault. (gdb) bt #0 0x00007ffff7f62ce0 in sse2_fill.lto_priv () at /lib64/libpixman-1.so.0 #1 0x00007ffff7f09278 in pixman_fill () at /lib64/libpixman-1.so.0 #2 0x0000555557b5a9af in ati_2d_blt (s=3D0x631000028800) at hw/display/a= ti_2d.c:196 #3 0x0000555557b4b5a2 in ati_mm_write (opaque=3D0x631000028800, addr=3D5= 512, data=3D1073692671, size=3D4) at hw/display/ati.c:843 #4 0x0000555558b90ec4 in memory_region_write_accessor (mr=3D0x631000039c= c0, addr=3D5512, ..., size=3D4, ...) at softmmu/memory.c:492 Commit 584acf34cb0 ("ati-vga: Fix reverse bit blts") introduced the local dst_x and dst_y which adjust the (x, y) coordinates depending on the direction in the SRCCOPY ROP3 operation, but forgot to address the same issue for the PATCOPY, BLACKNESS and WHITENESS operations, which also call pixman_fill(). Fix that now by using the adjusted coordinates in the pixman_fill call, and update the related debug printf(). Reported-by: Qiang Liu Fixes: 584acf34cb0 ("ati-vga: Fix reverse bit blts") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Mauro Matteo Cascella Message-Id: <20210906153103.1661195-1-philmd@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/display/ati_2d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 4dc10ea79529..692bec91de45 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -84,7 +84,7 @@ void ati_2d_blt(ATIVGAState *s) DPRINTF("%d %d %d, %d %d %d, (%d,%d) -> (%d,%d) %dx%d %c %c\n", s->regs.src_offset, s->regs.dst_offset, s->regs.default_offset, s->regs.src_pitch, s->regs.dst_pitch, s->regs.default_pitch, - s->regs.src_x, s->regs.src_y, s->regs.dst_x, s->regs.dst_y, + s->regs.src_x, s->regs.src_y, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height, (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? '>' : '<'), (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? 'v' : '^')); @@ -180,11 +180,11 @@ void ati_2d_blt(ATIVGAState *s) dst_stride /=3D sizeof(uint32_t); DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n", dst_bits, dst_stride, bpp, - s->regs.dst_x, s->regs.dst_y, + dst_x, dst_y, s->regs.dst_width, s->regs.dst_height, filler); pixman_fill((uint32_t *)dst_bits, dst_stride, bpp, - s->regs.dst_x, s->regs.dst_y, + dst_x, dst_y, s->regs.dst_width, s->regs.dst_height, filler); if (dst_bits >=3D s->vga.vram_ptr + s->vga.vbe_start_addr && --=20 2.37.3 From nobody Sun Feb 8 22:42:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664188719; cv=none; d=zohomail.com; s=zohoarc; b=ODAgB09vCLJWxvs5Bxu0rEVplAFKLNdpa0AVQtYIQJC55UhjcrAsTOBzXEk/nXbIIoEqf83nwcMQD3+fjZRx8l4AhdfOw9LdArLQWs0mG2DtgC/3mYoS2oDfGs4Q9Yr2I7fU2wEbItUs+UmvfCytVZ5MMpY10quIkVHtgVvd9AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664188719; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wap4bE3M153XlNUESFRpL6QFaSZ1Y/NXM6sOa6Kq+is=; b=ap1APT0cUB4szFZc2k0J7eRRYL0wCdtpo3BHo3Yn4UaBoXZMndWBrBGDEk8QhPczBhah+M5Cv1n/+E3d6VMj4cS8MXAVTviAKlQQIC8fiPkgceBUBihvk+84X8HIhCvJTighEzyc4cTUF+yAYCbrpu5tpSjVloLa2AbJHMXmDpg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664188719289380.715002030174; Mon, 26 Sep 2022 03:38:39 -0700 (PDT) Received: from localhost ([::1]:37852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oclVV-0001Qh-1P for importer@patchew.org; Mon, 26 Sep 2022 06:38:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockq0-0005oR-2A for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ockpv-0003pO-BX for qemu-devel@nongnu.org; Mon, 26 Sep 2022 05:55:43 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-e1sCCUMRMBae7bM_-G8l9g-1; Mon, 26 Sep 2022 05:55:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE2F3101CC62; Mon, 26 Sep 2022 09:55:33 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F63A2084836; Mon, 26 Sep 2022 09:55:33 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 760C8180A408; Mon, 26 Sep 2022 11:55:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664186138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wap4bE3M153XlNUESFRpL6QFaSZ1Y/NXM6sOa6Kq+is=; b=CSj1H82LVn5KSUDQLbH23QpvR5FHkMHOYI4nW1uu6/DWO8Mimi95Oh2EScRCORPWdmTwdd aKCBO937Gzp6mSqRS65k3At+Hw5cVIaBUMWQCeU/5IpEW0bfezrGSrmE4/P7Uk16nik1bl wbJDQPO/PEGMa311phRKPiy2Q4Qa5O8= X-MC-Unique: e1sCCUMRMBae7bM_-G8l9g-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Eric Blake , Markus Armbruster , Gerd Hoffmann , Bandan Das , Alexander Bulekov , Laurent Vivier , Darren Kenny , Qiuhao Li , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Alexandre Ratchov , Peter Maydell , Stefan Hajnoczi , Thomas Huth , Dongwon Kim , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 25/25] virtio-gpu: update scanout if there is any area covered by the rect Date: Mon, 26 Sep 2022 11:55:09 +0200 Message-Id: <20220926095509.3759409-26-kraxel@redhat.com> In-Reply-To: <20220926095509.3759409-1-kraxel@redhat.com> References: <20220926095509.3759409-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664188721134100001 From: Dongwon Kim The scanout is currently updated only if the whole rect is inside the scanout space. This is not a correct condition because the scanout should be updated even a small area in the scanout space is covered by the rect. Cc: Gerd Hoffmann Signed-off-by: Dongwon Kim Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220909014052.7297-1-dongwon.kim@intel.com> Signed-off-by: Gerd Hoffmann --- hw/display/virtio-gpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 20cc703dcc6e..5e15c79b94a5 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -515,9 +515,10 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { scanout =3D &g->parent_obj.scanout[i]; if (scanout->resource_id =3D=3D res->resource_id && - rf.r.x >=3D scanout->x && rf.r.y >=3D scanout->y && - rf.r.x + rf.r.width <=3D scanout->x + scanout->width && - rf.r.y + rf.r.height <=3D scanout->y + scanout->height && + rf.r.x < scanout->x + scanout->width && + rf.r.x + rf.r.width >=3D scanout->x && + rf.r.y < scanout->y + scanout->height && + rf.r.y + rf.r.height >=3D scanout->y && console_has_gl(scanout->con)) { dpy_gl_update(scanout->con, 0, 0, scanout->width, scanout->height); --=20 2.37.3