From patchwork Fri May 19 12:47:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9737105 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 63FDB6034C for ; Fri, 19 May 2017 12:49:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 581C728929 for ; Fri, 19 May 2017 12:49:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CB4A28932; Fri, 19 May 2017 12:49:38 +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 DA13228929 for ; Fri, 19 May 2017 12:49:37 +0000 (UTC) Received: from localhost ([::1]:58627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBhLd-0000oJ-4d for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 May 2017 08:49:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBhK2-0000e9-4I for qemu-devel@nongnu.org; Fri, 19 May 2017 08:48:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBhK1-0004MK-8V for qemu-devel@nongnu.org; Fri, 19 May 2017 08:47:58 -0400 Received: from mail-eopbgr00136.outbound.protection.outlook.com ([40.107.0.136]:31167 helo=EUR02-AM5-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 1dBhK0-0004AG-Tk for qemu-devel@nongnu.org; Fri, 19 May 2017 08:47:57 -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=qk4+N56zFOaQl8tTAT9xQowW3cvZ2Vo57CBCXApoVo8=; b=hjlwozk12bDqv2DiPlHwP8L2s6nBHDz6RiYw3L96T+9/jlXIzbQyvAyPePlGR8lpBCzTOAA6nzUbR9uQIhB8++KRwHsOtySUOyEwBNQ3VTnOIGAZEL+EqrSSz7YWhyymynoqTzykZkXyQC9Q7bjH6oA91kru9/lOr1OwUDQrCV8= 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 DB6PR0801MB1989.eurprd08.prod.outlook.com (10.168.85.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Fri, 19 May 2017 12:47:54 +0000 From: Anton Nefedov To: Date: Fri, 19 May 2017 15:47:21 +0300 Message-ID: <1495198042-124203-9-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495198042-124203-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1495198042-124203-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0002.EURPRD10.PROD.OUTLOOK.COM (10.171.79.12) To DB6PR0801MB1989.eurprd08.prod.outlook.com (10.168.85.150) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB6PR0801MB1989: X-MS-Office365-Filtering-Correlation-Id: 8075a02f-d8d5-4160-f7bc-08d49eb54537 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:DB6PR0801MB1989; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 3:4cpJRIS3VUz+TP9n1ek65sGYTwhZF07JOisIE3Me7ijVKPF+0cZluAQ8yk6KKq3FW3XvP0lPC/rxFEXZnqMWWJKfYzZE7wETHy6e1ei3gg5vpFX7pHkVQIim0ST+QDc1/8P+ZptHXuFbZr92Kr6hcCLV+JBuo/dA9PExGMQLv8d1Ig7ZsOqJ+W5xn4/ZwVv+fWhrIeoQ9XulyBZNVFo7k79DkVECPmIH2BfuORz4bWjs2J47CJn4RCEvmCLiomhiG16zZr9pXPKKycRKKTVNEdKVxw2NLeVq54XT76/rsCIfyAcOtVUuAl5Nigdsql3/3QU6UPzKZg5NH3uJMyLOZg==; 25:S6Er06bVdFC1S+maUqAnRVcPDcqzxECHja0wP2va5z4Sa9TSdH+GIvFF1JbzwwTIfdvpDpSX/+X/O92IikfD8yiPVTYjQUihNvwTT5oNa/DE/XGTUU6OIOkDtBClaX0Vyo7MtvMrX+rXiQKAv9VXe6sQYuoOx1R1MXJ4mxSCqy+aTLpTiJ2sbdDwetLgqmVCM41Bv+gY7GawhmEGV5055AsP6in6E9I/aJBPGuN32eD5osyr5/UBbd4ATlGHtAhsXBL3Xu07GXZ90+EV31ran83ECo35+ZwgZURmdUVBZetCprpn8onl1RUquRdfgaRCqcMOWq8JEwMFtdvccO51vR8XA+SldlJhpgtN4TJgu/TBhUmAGidyZ2A13jAg1tDXddw8Cck+1H9exj+JffwlxVhgg1XjGd0iwBrlzhmdsgH5V3bZbsTtbMHXTIhCxWbB+5MyaDj2MghlRuG9SlXTugn1vGI01j8XavsTTBhcOZg= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 31:KuAe63vd5wSUSJ21qgu1ZzdBMKeCfW568q+KhHLHfGM5nfaX0rxZZmecFmacDzwqrmCw3NF8D3tYSUz7vM8maFRtKbnQCGZ7ajzgJRndxBgHqWy3/DdKOexGGE6ToOaKWRs3au79acj6f4+ySFXI88YE1meETb7vHzin63VNNwgYHMm6bwIkwhbIQmQSPHtReyE5TZOObB7lNRXGW6VB59SxPEXjtojEY7S5d35zJhs=; 20:r1B10601LpP7IyF2qgVjGKNcwn80LqKmsReTYPW4X/nW+6f0/q8PDCXc2ue7n4WHicPHVeX9OXDqF/FHcfaqDTy9Tdl+W5LRkMhEx7RkYRHqBmcdVFxrmIpp0IGQrhMtSDOW1+WVYHlZ66JIx6gQ5vbYOEObzhWrw0kyaSrETSxr/RTGeJBkqQqF5wL4OU+WqXbL/FpQgkRFT9Dds0SgD+ihRHktwimwr2jn0x5gMw8AqfVQcB4u4Ukfk4jE+FmJIvmUXFiWyXs6pfpFj9cPqEQdnxW8INuSugF10/NooDhUFUoi8YgHk5lHYEpDW74jsIQQzEAn9cOAkUDEGUpz1yXCmXQzwn0jRH8E3jySrhE1jZy2oKovvPJ/uGEyr11GmQr7cJc6WPBZ3784lKei2XxZr4QyX0qtg1n8V+iRUh8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6041248)(20161123560025)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201703061421075)(6072148); SRVR:DB6PR0801MB1989; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1989; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 4:BX2bih+s2tQnyxsYJ6bbHq8Up8pQ4TeudGKuBQLIFiSV8JI3iOfgpynLfiaLXyzr7r2LaNe4MWtwA5+mkJ/CD/9o/gTLZtq3ETJo3FGTojg+BrPiF7YNl2VlTW+RYkRuCuK46aho6LjDrDUW16HLFW0Py7ibbff1ZezvL3WA5FMX2N0DNaysj3I2JzsgkjIaWKWF311zj8rzG7LgQQLD5E0lvIy5ry2tbgEvJ3kkphpwYy7b+CiWonIrxlou1sFWXLIjBLR7/HN/MZ+K9Wo66Bkx8c6f34hLVuv+LY3yzOTdVWaFTL73yTDkNRDudhH+Illvrp7a+Ee3ZRthnuOTikO+LWSi279cKdudauxzfksd8p0cxWJsx39Ms9KqtiBOY479onevZCBUatQKxSiR8P3C8gL0WHnRqPm6PQ9+O20AH/+ZplMq2CtLngfM/eVnDEzgEnUpyYKftILdzLYmenn77sK5cfRFS+wemAbfIXTBmQOFaMTPAxwMBN551mGHFAxcsme6Zu3SaL+FOOyZ3CZ6BOnpr1Mb0zXzUsOYF383K56V4LIhzEV5yDgAucK5dTRZ7pntVdE8QrNu0ehcn5k4lcuTI6CRP226jdIyqwGHuH77HcTAu4XBhPcatURtWILLYw2pBs5pBc7gZazezz/i5geko6GhW5bYegPBmHZEGVKvDJQQXO1K6M9TtoPFIXZYMukoAsJ70+6r4pFU0Q== X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39400400002)(39450400003)(33646002)(48376002)(5003940100001)(53936002)(38730400002)(25786009)(2351001)(6506006)(6486002)(4326008)(110136004)(5660300001)(36756003)(7736002)(6916009)(2950100002)(305945005)(6666003)(66066001)(2906002)(189998001)(50226002)(50466002)(54906002)(508600001)(86362001)(6512007)(81166006)(8676002)(50986999)(53416004)(3846002)(76176999)(42186005); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0801MB1989; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0801MB1989; 23:mMMwen1s+gtbOg1m61LK70ToDD/QN9qYTZUMogP?= =?us-ascii?Q?WZhwuneeOsNbu4dX6l+qdnzmtbVP2Mrpj3uFSNFtB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xw+t68wFGH7iByI2kzSEsAQ1b0K/7iDCCRFiQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 6:xGdT0S4K6HcCnFhYuiKEsc+osNgtfey90dTkHs4F0ffFAM/kczayFHu6mxUqncJPAamsoofaLwxmIxi/j1S/v0gPZXdw4RayGmCBqlj1NfBEN4cnzAJnZxd9EeOklMUHxIiHQlpiQsqh0JKZO6SbKqyINJ+zg7TblPhVYyomvfrGB4V6g7NVfOBa1buxoo51dnwa3WY5bIdEfkHdXBNcMBZcECRa40ZfzFhrUkB6128b7ML8ykQBNDtyev+3f8VE8XYbSc661VTmPiJ9gpZmL8a/6bnkxSP945BXfgROEKo1qK/gy3rhlsG61K+djs3Htsei/wVELE6pm+GOmzHgxl2i4MYWXO3ctYgtfeT0TehnyO9g32PFsO+t+C4mPXHqTElITo5JUfcaSUSE6LXVyb5TVJUNavliGJVibExRp83gLF+dTYw9Q1VsptyX1A+fWdYTu/c+96s9mSaFhSrR9yvVQwB8vha4+QYqXk/xoZLVTOJF+62DwW0eacoiyoJ9/EnJSOPj7yeXVOiWKPGfcw==; 5:qz0ut8sAJGYW/YZ9MEAGRXkBMqBNgCH9St66OGrnbonsspTCx4TStX0dmvj4pqY4tQ9uwqvIKoX3dXUMz42yO57stEITsRW3budWz00zqBZiNijpKXniVNvEOac3Y3MgZna6E/oyB2+IYyyRIvf5lg==; 24:8EN/+WNH3TgEYZmoiJJO/EwfEaYRZviGF2C2HzKcf8VlfipJyWboOmXzxbSTMqILduZY8xlVbOKeL8EepCER7aGMkiugIo9gAvYgoU11ah0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 7:AWQQFTVA/LrEXf1i9eGCx3hvdsWjQi71+PPr2WLv2Mmz0euLGCUZrEepNLYyv455HhQeqHMN8oJKGdDInSo/LeOTtkFePEoKgMielTOCII0xizHO+xmuWM6pKYB+5H1UVoAPKagjAC5TmqBbIjvCeqOsX19gXf4zlAfQMlR8zfimQEz45AF95yhtCOcPDrUeB+EUI/2PgOriBYo7iUxwgoGlbxsTc+cwcPkkockJYO4x4x5PetvTlTez5w7Ox5Me2dWvccndDkvZKc7laiEa5W4b1ZFpFGNJesxg/cA8K2X8bjR9jLcDlTZ9Ma1+H8nDwoVFScuZCJlCxGYdYFommg==; 20:XauWpLEG9lLRmk6PS2V3avmtZVNIbxlEmQ5NFWQLmiZNNic8DtU8hzGIbJmtOcCLrhYg2tDjQ40F6SnT0DJJUHAnJpooviQGvfqMR8RHx9j5fXhDTgXioXu5DDl+4yLNA/cT/paBW41lid18Jq1VJ8kNJy/oix7Z4YOFhJBd9Ic= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2017 12:47:54.8483 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1989 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.136 Subject: [Qemu-devel] [PATCH v2 8/9] serial: chardev hotswap support 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 , "Michael S . Tsirkin" , 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 for a backend change, a number of ioctls has to be replayed to sync the current setup of a frontend to a backend tty. This is hopefully enough so we don't have to track, store and replay the whole original control byte sequence. Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy CC: Michael S. Tsirkin CC: Paolo Bonzini --- hw/char/serial.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 1e6bdeb..ed01637 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -891,9 +891,37 @@ static void serial_reset(void *opaque) s->msr &= ~UART_MSR_ANY_DELTA; } +static int serial_be_change(void *opaque) +{ + SerialState *s = opaque; + + qemu_chr_fe_set_handlers(&s->chr, serial_can_receive1, serial_receive1, + serial_event, serial_be_change, s, NULL, true); + + serial_update_parameters(s); + + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_BREAK, + &s->last_break_enable); + + s->poll_msl = (s->ier & UART_IER_MSI) ? 1 : 0; + serial_update_msl(s); + + if (s->poll_msl >= 0 && !(s->mcr & UART_MCR_LOOP)) { + serial_update_tiocm(s); + } + + if (s->watch_tag > 0) { + g_source_remove(s->watch_tag); + s->watch_tag = qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, + serial_watch_cb, s); + } + + return 0; +} + void serial_realize_core(SerialState *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 serial device, empty char device"); return; } @@ -904,7 +932,7 @@ void serial_realize_core(SerialState *s, Error **errp) qemu_register_reset(serial_reset, s); qemu_chr_fe_set_handlers(&s->chr, serial_can_receive1, serial_receive1, - serial_event, NULL, s, NULL, true); + serial_event, serial_be_change, s, NULL, true); fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH); fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH); serial_reset(s);