From patchwork Tue May 30 13:57:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9754635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81003602BF for ; Tue, 30 May 2017 13:59:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70AAA2621D for ; Tue, 30 May 2017 13:59:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 655932846B; Tue, 30 May 2017 13:59:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 50C942621D for ; Tue, 30 May 2017 13:59:56 +0000 (UTC) Received: from localhost ([::1]:53966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFhgh-00054r-7C for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 May 2017 09:59:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFhfP-0004xG-UI for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFhfL-0007EB-KX for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:36 -0400 Received: from mail-he1eur01on0114.outbound.protection.outlook.com ([104.47.0.114]:16853 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFhfL-0007DL-7C for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=O9npnIFTJUYJlqEgXGeMzgajsBVwE4aUad1rLKGC2+I=; b=fteJIkczqN10MzHyz8mqbJTeM5Az/eucJAYrYa/y+5ytRgx4oDvn4wVaOplFwNpVnUdUCW9gLrk4I+3P0UM2Qn+6rjWMCDf+F1sE7XX7csdr/NTz+cu0fSeJgCZOTThX9pxW1PO/vmF958xNZtmgh9BAgRwx5xZBJ0pmn0BdIBI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by HE1PR0801MB1993.eurprd08.prod.outlook.com (2603:10a6:3:4f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Tue, 30 May 2017 13:58:28 +0000 From: Anton Nefedov To: Date: Tue, 30 May 2017 16:57:55 +0300 Message-ID: <1496152683-102751-6-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496152683-102751-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1496152683-102751-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR02CA0033.eurprd02.prod.outlook.com (2603:10a6:6:15::46) To HE1PR0801MB1993.eurprd08.prod.outlook.com (2603:10a6:3:4f::23) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0801MB1993: X-MS-Office365-Filtering-Correlation-Id: 14ea64e5-b0f0-41df-8098-08d4a763f387 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:HE1PR0801MB1993; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 3:7WKRl91iMTfOg97QpMGybq0QpZiI1DZlZPjSc7p2YMi7lLBVU5WkkpfVCxWTFZtDp+AJ7Zd/aHz9NqnGQ/bkJwVFDkvS/uGwPVHi81NB0nBff+NYCWUQc54WHkEfKTQw/YiWdBenwm98J5CY8bcE3t5gSrEjfW8ba6mDuoaSSpcY6MrXSkZ3qdAumm+aGwph7AdYWYzAAnxpXKamtDUkcxechEkfmfkTJan7jOcxSviptU0/NmTKvzVi9CWxDWTchgMgvVk8n8SB057tiiMxv9GMlV4wRsWWsJ5UYlJQ9XJkXoiZvIBATQAq9XqvFXT7dV7ecGAneQ+gb+kq5bTfqw==; 25:qtWys98p4roFfsuLUIlm8zAvp7iLx3GcxhAvQeaI8dEAjf9nC8/mYo9dNCEkAw50uwKpDmSxeRVKMre26NCTGVuOmsUHaZ8au3jVd87StJ9OnZoojTb9ua0IKTMAl2Hw7RRxbATlitc8Prybn3hkr5GcqJ7JnUBrA1K08xoca17Y2+7qKuiH6LPMeOkHhFt5T/J3S9eMR0l9IjyJcVqzNta0WARk6+vv8aaUiNttzf9YRBkZiKrQsmUGRsMjIYV1sjfZw0GQe8c4dPU2ExUzyKnRgCQY5qzfUHoU9YSS2oCPhUIZTkhyKSF76aTnUNLB/OgxnYgIFCaPfwe5IFv6ekPieWD6GaY5vGZjZjsCEWMxpBDelFsuZwsx0s9k7hh37KgKjz66ibMgP3orwYTog4kVlK0ATAsuYJ5QlG1TxTrDCqzQ79rCk1ulVJYiNR4j3/nXywJMI4/cQXmEyb4r9ZFy0uYmtOri1A6X4WPrkMU= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 31:TzPs/cv1W1sv4KSHI4cgyx//U1uMDAcbNselavEPcWbKFTWJ+dsMcpGqNmiP6aIE7FjCmtoQAie95eRPaJ2Nv7WrSw7Tx1c0P/P3+EUBcWBjXB32xM2q9WdFEv9bCHEPZT4rG6OWJk8CmByTo3XWNYYTMjAD9Cu9Jm5Kt/1SA7NuI+tMAZ2iyr982KuQWvSmOkifXr0iLlXq8OjV+HhXMjI23/pBSbpoqpDXYqaRTHk=; 20:4KGJMkfsVqe7jkbZgtt0Y/d9sZY1FR4VaHYhDKqCiW/UPCj7+5sQ1wt7kuYM2V1jIV3Xa9T71OuSKVXRAe5afPilNbRPSeNiGoArliG5IijxWsEpf1QkvevfXXC+bCfI1OQwGy3xrXinqVGqTHTwu2GrEvj8+hysDGm5ETbCthK33iHtf7dtPj+2fQuXxFnXI9YW/dw3RX8j4vQvtkYaLCLtusSF6Mz3yDWVtOUxixrq50upIe1AuFVTw5Wh2ws57YZPNLpSXFaaHyC7ugezyQOtxslv0ltsav1T6srKeHMlDaks248WC+6HT9oCBglf7Vqju4xno3JPY1bUxat4c3mMyN1VQI5sOQCoGmYZlzfP/1DS8b6uVbI/h05RXFq5DeNdPv0EPQuV+FXwrgzO8uqCvsZou8/2MIF1HWD15FA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700073)(100105000095)(100000701073)(100105300095)(100000702073)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703073)(100105400095)(10201501046)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123558100)(20161123555025)(6072148)(100000704073)(100105200095)(100000705073)(100105500095); SRVR:HE1PR0801MB1993; BCL:0; PCL:0; RULEID:(100000800073)(100110000095)(100000801073)(100110300095)(100000802073)(100110100095)(100000803073)(100110400095)(100000804073)(100110200095)(100000805073)(100110500095); SRVR:HE1PR0801MB1993; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1993; 4:jWY91Za8QHLgrRyG2tY1claUen7jP5GaQvJKe5jA?= =?us-ascii?Q?2Q6cajYnjHR1zDgPvSAIMzpq782xdU5oV3DF+g5yLa3n27czdRrb1m7JDynS?= =?us-ascii?Q?GkCpvrxHr3myWF1VxXBLSUJBLgUfSW9WdTbS5ENFy4HDttgdO+RCPUIPMDL3?= =?us-ascii?Q?5hcgieTuSEoWzw4WYbGhDyePXuA/aIPV97ZyUulSFNjoPLch/SkqYrn7fZQZ?= =?us-ascii?Q?ivtXVOpg06g1xZtMgCVaYBiiEPfBFv5zCsN6SuIdroG9oBmzo0+xLqBHgMyl?= =?us-ascii?Q?jlE4+ekcl6kRLOjSgl1/BIKqjjj7De5O1Qb/n8oYYStBOzR5u+PO2L/r1uZ9?= =?us-ascii?Q?M1hKfJxcuM9RYMDVMO7ue8y5/sIZ8gmdNdAyFXfekS0Rlp5M7SPK62geCHC8?= =?us-ascii?Q?lcGzNEDgLwoLyGti7yTHpGzeIbCODIv5hsCPJroSFim/T2UVUb2r4ux3j+LS?= =?us-ascii?Q?oSSSesvzyCeWG6EWvfDpFDKJ/3MkEkkPTVcOC6BiG/y6ePKP0MvlYfRQk/+3?= =?us-ascii?Q?npXZQIxlOl9RQR05acwJ8j7rI5RZPwaMJEUmfaquZINPYsOAmXn+Bo6PQF6G?= =?us-ascii?Q?fBN9KR50Ujik5goMsJhni1L8CEximsoJ6zSdDKy4iMrBSXMrTHN8r+hvYrEG?= =?us-ascii?Q?AZGiTisEoWHOisv0dqRnRkpZ4jkiTDd6Rs1wHgWjOych51qHg/NxODW5j844?= =?us-ascii?Q?XV+zEWGAkKhgVm6yafm1FAjxxgMzmI773AxKAWkPKJ2gF0Pk9d6Wl6+UY8X8?= =?us-ascii?Q?gP2vIwU8XZtW3uRXZuUC7IoG7Ngd4GAhN2FfDkI8nATbTtCehjaaKXluNEx/?= =?us-ascii?Q?sdpk+YGe7xu6wQNqOSsYaqSPZTTaFbmfrl5i1MmaRlWLkMfxoZUGoztWUMj1?= =?us-ascii?Q?sc61oIqasW42xjgyw25Rx1y/A36mMkN7K/yUqHaPZU/wXVStS1FSLb5W7ssX?= =?us-ascii?Q?vO3HXpZY+qx9cLZx4lYnk4a5XqBpIOIggqzIHVqahuYTwdirH/wJ00IOYwwr?= =?us-ascii?Q?DqCwAvAVuVbrhg7LUxlNuUYO1BXqSFmhALUOTr/YPfMyZT7FwSwZNLstpQ5v?= =?us-ascii?Q?mlRAkRUk0+l0yXFrbyL24jDrSrjOJbElXWlBtLaYprBjO90gRwZtCyoXFbY1?= =?us-ascii?Q?2YvmlabIQ20FkbNqELEdPBRYDl7sYm6KwisRt9MLllB2k52fsyIDD0QP9cpJ?= =?us-ascii?Q?NSnRNGcX56RhzjU=3D?= X-Forefront-PRVS: 032334F434 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39830400002)(39450400003)(39410400002)(39400400002)(6506006)(6486002)(86362001)(575784001)(6916009)(2950100002)(6666003)(54906002)(38730400002)(53936002)(6512007)(25786009)(478600001)(5660300001)(47776003)(305945005)(7736002)(66066001)(107886003)(5003940100001)(110136004)(189998001)(2906002)(4326008)(50226002)(3846002)(8676002)(81166006)(6116002)(5890100001)(53416004)(50466002)(2351001)(48376002)(76176999)(42186005)(50986999)(33646002)(36756003)(21314002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0801MB1993; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1993; 23:cS087e60jxv5GrEV6JUA/u9qqlnWMwXjMjUziVj?= =?us-ascii?Q?RQU4Ck4s1JFgOZv3mSKUZeAn0Xzl+rddFPFGJ4g8T9pwW9CWD+cqi/pYW0oz?= =?us-ascii?Q?jqnwh7uigjnyDlekj3V8tUO6LZb0imOwrxG2fFM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pHG1xt93WeTkTUpF8OC1oyXBU9TeX4CEetfP9vQd+0LNj6VGSldLaY6F+0RU/V+0xqA42OZaA/wEE6LFJeUsFhBq+9Tc2VTinbJrVDKT7lGKQqszbodiqODJjjr8nvEHsh6WrgEuxcFfg+m2FO3FQP8zOE8CCpXouwlauoujB3KwAaw1oXuRB3p1In+X+MxxF6xfJ83lgZnMasIg+HtddOxJRkCPs2aLDSMYZQ5bBnlVscO6Q80gqp8fjQwN4224uO6nzlH7YT0tDE8GJ1kaT/kDlrgQ2w; 24:HizcLYrpkjUHNufwBN3054otnsJ1Vtp7SQupbgi3L7LUNV+yMh8kwh5mlxBNh8RoaRZ+43qWgFzFKwJIpFurWUPujE96hCrKoM5lK5vIN+s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 7:7x7BSlmy/ua+299NBeKIHQwR+9OH1WgcQ8mgj+5NZWN5WrqnhHeDWeABnjopKJz5q7SMDqVB0dTzbnb0XrYuupkk38LvgTOYvEKf43xWysUDUa6Gpgpi5bqDLI77CCfv6KwYRzVKsx2HRI4CL4tA+OEw9UdV/g5uVmYLT06pJkwrK1TB5Nl0mFkoqmLgvTfwnqfvJ1rWwdDMz59j77715YP2GK4JSt8tzeURyNwbQ4zV+MAOGli5iyy2ujnw2AKYY2j8fOz8ew1DanLmjN3hy0hYrvxdQNmD9iXeUw191kYpd9AjflDUnPNW8znpoulZhDDlwNSuVzt6oSbzR/Ym+Q==; 20:ihJJw3ZrbkG3SBV43I4YldAx4CGFYMKaVMe8e3a/kTrBHBKh6H5+2eDQDjdLqTILBfUpmkMT9qhJXbSf143QCcFM0JnQo7pLD7ZBeNNalxZPC/O75vyDTLO7S6MUU+WfakS1CSSSFNrdt8rYdq7ZdvrWRUT+12/bZXLDA5TVuDk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2017 13:58:28.7550 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1993 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.114 Subject: [Qemu-devel] [PATCH v3 05/13] char: avoid chardevice direct access X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Anton Nefedov , den@virtuozzo.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP frontends should avoid accessing CharDriver struct where possible Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Marc-André Lureau --- chardev/char.c | 5 +++++ gdbstub.c | 2 +- hw/arm/strongarm.c | 2 +- hw/char/cadence_uart.c | 2 +- hw/char/debugcon.c | 2 +- hw/char/escc.c | 6 +++--- hw/char/exynos4210_uart.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/char/ipoctal232.c | 2 +- hw/char/parallel.c | 2 +- hw/char/sclpconsole-lm.c | 2 +- hw/char/sclpconsole.c | 2 +- hw/char/sh_serial.c | 2 +- hw/char/spapr_vty.c | 2 +- hw/char/terminal3270.c | 2 +- hw/char/xen_console.c | 2 +- hw/ipmi/ipmi_bmc_extern.c | 2 +- hw/misc/ivshmem.c | 4 ++-- hw/usb/ccid-card-passthru.c | 4 ++-- hw/usb/dev-serial.c | 5 ++--- hw/usb/redirect.c | 5 ++--- include/sysemu/char.h | 7 +++++++ net/filter-mirror.c | 2 +- 23 files changed, 39 insertions(+), 29 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 1eed934..2d6e204 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -494,6 +494,11 @@ bool qemu_chr_fe_backend_connected(CharBackend *be) return !!be->chr; } +bool qemu_chr_fe_backend_open(CharBackend *be) +{ + return be->chr && be->chr->be_open; +} + static bool qemu_chr_fe_connect(CharBackend *b, Chardev *s, Error **errp) { int tag = 0; diff --git a/gdbstub.c b/gdbstub.c index 1ac0489..68cbe8a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2001,7 +2001,7 @@ int gdbserver_start(const char *device) NULL, &error_abort); monitor_init(mon_chr, 0); } else { - if (qemu_chr_fe_get_driver(&s->chr)) { + if (qemu_chr_fe_backend_connected(&s->chr)) { object_unparent(OBJECT(qemu_chr_fe_get_driver(&s->chr))); } mon_chr = s->mon_chr; diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c index bec093d..9d7cf21 100644 --- a/hw/arm/strongarm.c +++ b/hw/arm/strongarm.c @@ -1105,7 +1105,7 @@ static void strongarm_uart_tx(void *opaque) if (s->utcr3 & UTCR3_LBM) /* loopback */ { strongarm_uart_receive(s, &s->tx_fifo[s->tx_start], 1); - } else if (qemu_chr_fe_get_driver(&s->chr)) { + } else if (qemu_chr_fe_backend_connected(&s->chr)) { /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all(&s->chr, &s->tx_fifo[s->tx_start], 1); diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 71867b3..19636c0 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -278,7 +278,7 @@ static gboolean cadence_uart_xmit(GIOChannel *chan, GIOCondition cond, int ret; /* instant drain the fifo when there's no back-end */ - if (!qemu_chr_fe_get_driver(&s->chr)) { + if (!qemu_chr_fe_backend_connected(&s->chr)) { s->tx_count = 0; return FALSE; } diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c index 6d95297..bd0d4f0 100644 --- a/hw/char/debugcon.c +++ b/hw/char/debugcon.c @@ -87,7 +87,7 @@ static const MemoryRegionOps debugcon_ops = { static void debugcon_realize_core(DebugconState *s, Error **errp) { - if (!qemu_chr_fe_get_driver(&s->chr)) { + if (!qemu_chr_fe_backend_connected(&s->chr)) { error_setg(errp, "Can't create debugcon device, empty char device"); return; } diff --git a/hw/char/escc.c b/hw/char/escc.c index aa882b6..dbbeb4a 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -416,7 +416,7 @@ static void escc_update_parameters(ChannelState *s) int speed, parity, data_bits, stop_bits; QEMUSerialSetParams ssp; - if (!qemu_chr_fe_get_driver(&s->chr) || s->type != ser) + if (!qemu_chr_fe_backend_connected(&s->chr) || s->type != ser) return; if (s->wregs[W_TXCTRL1] & TXCTRL1_PAREN) { @@ -556,7 +556,7 @@ static void escc_mem_write(void *opaque, hwaddr addr, trace_escc_mem_writeb_data(CHN_C(s), val); s->tx = val; if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) { // tx enabled - if (qemu_chr_fe_get_driver(&s->chr)) { + if (qemu_chr_fe_backend_connected(&s->chr)) { /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ qemu_chr_fe_write_all(&s->chr, &s->tx, 1); @@ -1012,7 +1012,7 @@ static void escc_realize(DeviceState *dev, Error **errp) ESCC_SIZE << s->it_shift); for (i = 0; i < 2; i++) { - if (qemu_chr_fe_get_driver(&s->chn[i].chr)) { + if (qemu_chr_fe_backend_connected(&s->chn[i].chr)) { s->chn[i].clock = s->frequency / 2; qemu_chr_fe_set_handlers(&s->chn[i].chr, serial_can_receive, serial_receive1, serial_event, NULL, diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index 7ef4ea5..2b0576c 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -379,7 +379,7 @@ static void exynos4210_uart_write(void *opaque, hwaddr offset, break; case UTXH: - if (qemu_chr_fe_get_driver(&s->chr)) { + if (qemu_chr_fe_backend_connected(&s->chr)) { s->reg[I_(UTRSTAT)] &= ~(UTRSTAT_TRANSMITTER_EMPTY | UTRSTAT_Tx_BUFFER_EMPTY); ch = (uint8_t)val; diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c index 610a317..1cb9026 100644 --- a/hw/char/grlib_apbuart.c +++ b/hw/char/grlib_apbuart.c @@ -201,7 +201,7 @@ static void grlib_apbuart_write(void *opaque, hwaddr addr, case DATA_OFFSET: case DATA_OFFSET + 3: /* When only one byte write */ /* Transmit when character device available and transmitter enabled */ - if (qemu_chr_fe_get_driver(&uart->chr) && + if (qemu_chr_fe_backend_connected(&uart->chr) && (uart->control & UART_TRANSMIT_ENABLE)) { c = value & 0xFF; /* XXX this blocks entire thread. Rewrite to use diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c index 734e42c..b5ada43 100644 --- a/hw/char/ipoctal232.c +++ b/hw/char/ipoctal232.c @@ -542,7 +542,7 @@ static void ipoctal_realize(DeviceState *dev, Error **errp) ch->ipoctal = s; /* Redirect IP-Octal channels to host character devices */ - if (qemu_chr_fe_get_driver(&ch->dev)) { + if (qemu_chr_fe_backend_connected(&ch->dev)) { qemu_chr_fe_set_handlers(&ch->dev, hostdev_can_receive, hostdev_receive, hostdev_event, NULL, ch, NULL, true); diff --git a/hw/char/parallel.c b/hw/char/parallel.c index c71a4a0..b3ed117 100644 --- a/hw/char/parallel.c +++ b/hw/char/parallel.c @@ -512,7 +512,7 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp) int base; uint8_t dummy; - if (!qemu_chr_fe_get_driver(&s->chr)) { + if (!qemu_chr_fe_backend_connected(&s->chr)) { error_setg(errp, "Can't create parallel device, empty char device"); return; } diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index ed1e2c5..ff54d19 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -195,7 +195,7 @@ static int write_console_data(SCLPEvent *event, const uint8_t *buf, int len) { SCLPConsoleLM *scon = SCLPLM_CONSOLE(event); - if (!qemu_chr_fe_get_driver(&scon->chr)) { + if (!qemu_chr_fe_backend_connected(&scon->chr)) { /* If there's no backend, we can just say we consumed all data. */ return len; } diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c index 9a65010..7e23d09 100644 --- a/hw/char/sclpconsole.c +++ b/hw/char/sclpconsole.c @@ -163,7 +163,7 @@ static ssize_t write_console_data(SCLPEvent *event, const uint8_t *buf, { SCLPConsole *scon = SCLP_CONSOLE(event); - if (!qemu_chr_fe_get_driver(&scon->chr)) { + if (!qemu_chr_fe_backend_connected(&scon->chr)) { /* If there's no backend, we can just say we consumed all data. */ return len; } diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index c352337..868773f 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c @@ -110,7 +110,7 @@ static void sh_serial_write(void *opaque, hwaddr offs, } return; case 0x0c: /* FTDR / TDR */ - if (qemu_chr_fe_get_driver(&s->chr)) { + if (qemu_chr_fe_backend_connected(&s->chr)) { ch = val; /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c index 9cdc0e0..6d1ccff 100644 --- a/hw/char/spapr_vty.c +++ b/hw/char/spapr_vty.c @@ -78,7 +78,7 @@ static void spapr_vty_realize(VIOsPAPRDevice *sdev, Error **errp) { VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(sdev); - if (!qemu_chr_fe_get_driver(&dev->chardev)) { + if (!qemu_chr_fe_backend_connected(&dev->chardev)) { error_setg(errp, "chardev property not set"); return; } diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c index 943a0f3..62803e5 100644 --- a/hw/char/terminal3270.c +++ b/hw/char/terminal3270.c @@ -239,7 +239,7 @@ static int write_payload_3270(EmulatedCcw3270Device *dev, uint8_t cmd, return 0; } } - if (!qemu_chr_fe_get_driver(&t->chr)) { + if (!qemu_chr_fe_backend_connected(&t->chr)) { /* We just say we consumed all data if there's no backend. */ return count; } diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index cb7975f..b066176 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -150,7 +150,7 @@ static void xencons_send(struct XenConsole *con) ssize_t len, size; size = con->buffer.size - con->buffer.consumed; - if (qemu_chr_fe_get_driver(&con->chr)) { + if (qemu_chr_fe_backend_connected(&con->chr)) { len = qemu_chr_fe_write(&con->chr, con->buffer.data + con->buffer.consumed, size); diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c index 6f2339d..0ca9e92 100644 --- a/hw/ipmi/ipmi_bmc_extern.c +++ b/hw/ipmi/ipmi_bmc_extern.c @@ -447,7 +447,7 @@ static void ipmi_bmc_extern_realize(DeviceState *dev, Error **errp) { IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(dev); - if (!qemu_chr_fe_get_driver(&ibe->chr)) { + if (!qemu_chr_fe_backend_connected(&ibe->chr)) { error_setg(errp, "IPMI external bmc requires chardev attribute"); return; } diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index e2dece8..a1be4bb 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -1130,7 +1130,7 @@ static void ivshmem_doorbell_realize(PCIDevice *dev, Error **errp) { IVShmemState *s = IVSHMEM_COMMON(dev); - if (!qemu_chr_fe_get_driver(&s->server_chr)) { + if (!qemu_chr_fe_backend_connected(&s->server_chr)) { error_setg(errp, "You must specify a 'chardev'"); return; } @@ -1259,7 +1259,7 @@ static void ivshmem_realize(PCIDevice *dev, Error **errp) " or ivshmem-doorbell instead"); } - if (!!qemu_chr_fe_get_driver(&s->server_chr) + !!s->shmobj != 1) { + if (qemu_chr_fe_backend_connected(&s->server_chr) + !!s->shmobj != 1) { error_setg(errp, "You must specify either 'shm' or 'chardev'"); return; } diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index 9ace5ac..c0f8acd 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -325,7 +325,7 @@ static void passthru_apdu_from_guest( { PassthruState *card = PASSTHRU_CCID_CARD(base); - if (!qemu_chr_fe_get_driver(&card->cs)) { + if (!qemu_chr_fe_backend_connected(&card->cs)) { printf("ccid-passthru: no chardev, discarding apdu length %d\n", len); return; } @@ -346,7 +346,7 @@ static int passthru_initfn(CCIDCardState *base) card->vscard_in_pos = 0; card->vscard_in_hdr = 0; - if (qemu_chr_fe_get_driver(&card->cs)) { + if (qemu_chr_fe_backend_connected(&card->cs)) { DPRINTF(card, D_INFO, "initing chardev\n"); qemu_chr_fe_set_handlers(&card->cs, ccid_card_vscard_can_read, diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index e6b2c7c..7aa7290 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -483,13 +483,12 @@ static void usb_serial_realize(USBDevice *dev, Error **errp) { USBSerialState *s = USB_SERIAL_DEV(dev); Error *local_err = NULL; - Chardev *chr = qemu_chr_fe_get_driver(&s->cs); usb_desc_create_serial(dev); usb_desc_init(dev); dev->auto_attach = 0; - if (!chr) { + if (!qemu_chr_fe_backend_connected(&s->cs)) { error_setg(errp, "Property chardev is required"); return; } @@ -504,7 +503,7 @@ static void usb_serial_realize(USBDevice *dev, Error **errp) usb_serial_event, NULL, s, NULL, true); usb_serial_handle_reset(dev); - if (chr->be_open && !dev->attached) { + if (qemu_chr_fe_backend_open(&s->cs) && !dev->attached) { usb_device_attach(dev, &error_abort); } } diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 1e9bf69..6992d92 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -273,10 +273,9 @@ static gboolean usbredir_write_unblocked(GIOChannel *chan, GIOCondition cond, static int usbredir_write(void *priv, uint8_t *data, int count) { USBRedirDevice *dev = priv; - Chardev *chr = qemu_chr_fe_get_driver(&dev->cs); int r; - if (!chr->be_open) { + if (!qemu_chr_fe_backend_open(&dev->cs)) { return 0; } @@ -1366,7 +1365,7 @@ static void usbredir_realize(USBDevice *udev, Error **errp) USBRedirDevice *dev = USB_REDIRECT(udev); int i; - if (!qemu_chr_fe_get_driver(&dev->cs)) { + if (!qemu_chr_fe_backend_connected(&dev->cs)) { error_setg(errp, QERR_MISSING_PARAMETER, "chardev"); return; } diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 117d628..342f531 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -405,6 +405,13 @@ Chardev *qemu_chr_fe_get_driver(CharBackend *be); bool qemu_chr_fe_backend_connected(CharBackend *be); /** + * @qemu_chr_fe_backend_open: + * + * Returns true if chardevice associated with @be is open. + */ +bool qemu_chr_fe_backend_open(CharBackend *be); + +/** * @qemu_chr_fe_deinit: * * Dissociate the CharBackend from the Chardev. diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 82bb157..a1295cc 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -163,7 +163,7 @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf, MirrorState *s = FILTER_REDIRECTOR(nf); int ret; - if (qemu_chr_fe_get_driver(&s->chr_out)) { + if (qemu_chr_fe_backend_connected(&s->chr_out)) { ret = filter_send(&s->chr_out, iov, iovcnt); if (ret) { error_report("filter redirector send failed(%s)", strerror(-ret));