From patchwork Tue May 30 13:58:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9754657 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 B5C5F602B9 for ; Tue, 30 May 2017 14:11:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A81FC2847A for ; Tue, 30 May 2017 14:11:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CB3A28485; Tue, 30 May 2017 14:11:18 +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 DB2F82848B for ; Tue, 30 May 2017 14:11:17 +0000 (UTC) Received: from localhost ([::1]:54052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFhrh-0006nS-4J for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 May 2017 10:11:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFhfc-0005G9-V4 for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFhfY-0007IN-FH for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:49 -0400 Received: from mail-he1eur01on0136.outbound.protection.outlook.com ([104.47.0.136]:15171 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 1dFhfY-0007GL-6u for qemu-devel@nongnu.org; Tue, 30 May 2017 09:58:44 -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=Sl4C1hZQAn/zQ9rVhK9K6y4XaDW7T2AAfzjR5s1CP08=; b=iGQ23cYlbHpxfd7p10OUix5EOx/rTh8o6WMQE3JMPQSv/K6jUSmZ/UmN4qNW4CLHPOgx7vvxh5jC9607X0Sb1mVJOLuzF+4xKlzPYiJ/L4K+HEB0nnpU6ANYdj17Jp4rsMgBf3iLaR42cZV1q2C9+++8lZ4shm4XJcIxvIT0HHE= 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:35 +0000 From: Anton Nefedov To: Date: Tue, 30 May 2017 16:58:01 +0300 Message-ID: <1496152683-102751-12-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: 39c3cc2b-0c05-4d71-6f30-08d4a763f7c9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:HE1PR0801MB1993; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 3:wX6u/AgjDLJp9Sq4EHkxuaE/OboXavHJzxnaYo7u/7KMzZZ5ZF0uCrbkKTiwzlS0w2EJCPAxfahHBKKDjXQ7NznHm3bVOyMlaa10C/kj9NukYFvgNgMGdZt1gnf5Fgt11cGMdbKkBT5HiCpDSAgoz/O0Vl4OqoATlqCOlBg1/QsRUYr7qabjAY6p6tFsXs1T4rEh/H1wA45IuhA3Ey5n5JeuM6ZCEPjXc4WQwY2zmhu7ZZcU/vQJvNmQNQNikbUToASlhFp414trPpGTWWUUdYj2h9egGB8jIIJIcPL6o+dwYeOzm71VvR1k/ty4Ka3AQ0BXmwMMmpRkTWQLZgseOw==; 25:lzuNtbvo8sLSm4CBaLbHPUQ26vPJR58kJIxP++QXmRPQ0d02o7KEQc0DWojHcYA78/kWqd94SUI3dxUEY8dhF2HIEjmngxVRibvN3hCTU1kKRRE7f4fZxIV47D9NDZQxIvCf8zQedKCqQPyUcP6PYWVa5qdENiffjziFtbxlfkjH9zOMTK134Mcz0ds2yOZmfjgHORckVHHcwrMB6e1DVbpkJe86oest2452OZ7ejfLonXduSI5GiXeG0CLrCsIYjQne2JX80HcNOzPR9lvTqUCUnWyWZpPZeNle5JTBp5sovDs5VvUagoKpNCPtgDejPk3ot+04mxKfwyacS/peyyGwM8UBvrKuMNcq5Yc5g/x/nu1xAYYqhvhJcHswaahy7/+bNVgbas9hvCvS7k3blAeaVKQEsp9EzFD2ottW4j5wAqgTXXBeAkaHzWml8C3Q+L0Mdn/gMWCof7gW12+Fsmnsm/fKQQIPwXBE8E3Q8FA= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 31:Yu5f+9MBoT25Lv9Ohm/r3fyOlyVPWmtygEGyfvk5rdnmoLu2tJXxNXRIZ1jzNkUbvXUP5rhnnDd10XfhXL632Dc21fESM4vAZlNSq2PTe42+ZVdVLEmgJSUhl75YAbq//mTT66xgL2gV+dIYnipouNautNmN+65G8mjTNtAYtnjOM7OVmLhRL27qzovxjgzGixDZBzquq00a7wtlT4jS2lU7A3U3EuOa2RTe86R/O1g3sq/bUJLAhj0RL0gnnOugdghE1OJRz8k5Lhtln4VngA==; 20:3x3cUgR77pSLGCCoZHEQXAtI7JDb+vkuwSIX7kiwMXWCMKvpvnoNQ3DGN37sjcfmoq+Jda1UYSpaRqrF37SR//RgtmgpKkK2cojsjayTGzCguoIQAE27ZkDtn7BlUFUn6pFqNLwFpj3M7wqfIs74IbL5xbqttZgdjBymabeB6M1AwgfDAxR8KFrDWczkRvNTmu+y9Yj9+CubBpgyVFxCoW1XVtXqwGd9IwcxZ5qIsl2Uad/dmgX0jvjgqSUxGtP8FVS5rggnVnUiJSAUXuN3KUlGgVZITjlJvDDLDa0/6d+IcRJjmAOflGftshycLU15dgFWfUizHxI5gmhbBBqIe9JIx+raLbirLdqWxJQ3vUH6eqIoZWTBgqj87Td1vG8YdXMd+nKUs+LjoQ0PVhfsMQlB3REKUic+R2/Tpl2tcNM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; 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:3/zRQRvz2CgLLIEt2PsYX7PhPqcrQgnhv3x8gHLZ?= =?us-ascii?Q?VsgQfj1MOhNTTaaBd1HDycjqDfESBYoaXgus+ZCud7Va5M0TF0u4WsG9u4KR?= =?us-ascii?Q?vraOsDkH3n8rlMyIuR4ZsshlmZsjT55VlemjomQ/dpdmBZvjPH35haLkPAg3?= =?us-ascii?Q?UQRPpF6moQFJ9q+sE6+FQvq/rHjTyxHzoLLkBZ2YDuwrHyjzN6SXCcTATFz4?= =?us-ascii?Q?xw3vn9xro/GeGTMyxqz+BN15bf8TVezsCCPkLFVjCJlnfy9xdaDwXXL0geg9?= =?us-ascii?Q?LO57N0GmqOHlXCAlG3fLg16353Y7mEZ8cJKzKo4JNFABGOhi7iG2J2ozeY9l?= =?us-ascii?Q?ltMxZ+SRspVGqX72njL5aIKzSnIyIi76eQaVtaNeXG/fotf8OoeBPU1Oq93a?= =?us-ascii?Q?KbUSl7FsX+PLQbWFF806UloDrU0g4AxLBoT5uSzFZvME3TIbg/PALxosqWVl?= =?us-ascii?Q?DNTB+Tu3sa3wJMPdzcjpQomLfFy46r03K9NUo4GCCWbLJrPUIZ5TBqyttEyI?= =?us-ascii?Q?rJaKVBiqPUiw7NazZ+d/RrVOsqwV1TtOQlPa399zRKvopLnMVWu2Ap1kIkgS?= =?us-ascii?Q?w3wmEUfHytV72bIfhz9BmPLQPPurrGJ8/0vz/7l4DzX+aPQ3rY1B6yUB3ZFO?= =?us-ascii?Q?ek67fm8K26OpuP7Qg60dgQCEBf2FB9ea0/QEsqFusfOAJ26Nc9wRnzvFgrxl?= =?us-ascii?Q?8aOO4RS01H2sc0VOpjOQck+Ew/4t+znBIgDEqoJvW/KZwEGC3gVOSKg0DQIF?= =?us-ascii?Q?FEGOE8Oti6hEdm0Ls/NUcxpiabkm4fupMIX9vwvwB4+fuTuYUP1s1BHpX/WJ?= =?us-ascii?Q?mukVxdKxkJKAB34vzbzWqD+R79vjLY83hY6lNR6mpyrxTFqjcXvIloFXu6os?= =?us-ascii?Q?LOdTa3qR+jC04kJZFd1goSpUHH310YqqLxWex5O6FjZY0pwxulERDJaY4yxM?= =?us-ascii?Q?40l3XP38zj6IHwEEnpvzJzEjSM0xb6+PwnddFJs3oy7B+s5cpJVIRR3zHuAt?= =?us-ascii?Q?i5xhdDqd3YLgZHF2ILH1kMbchuijZaEEnFLA8NQe5HTaKmNly+1mK8TW7FMd?= =?us-ascii?Q?mb8LaAtPZLS1+oV1AWunzstsPGdMfZOEBxBR9pGZJ5YvXp9DW8TBAli55y4H?= =?us-ascii?Q?dTPNzPr+/iEAWck/k9wkYc9qOvOKJUWm?= X-Forefront-PRVS: 032334F434 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(979002)(6009001)(39830400002)(39450400003)(39410400002)(39400400002)(6506006)(6486002)(86362001)(6916009)(2950100002)(6666003)(54906002)(38730400002)(53936002)(6512007)(25786009)(478600001)(5660300001)(47776003)(305945005)(7736002)(66066001)(5003940100001)(110136004)(189998001)(2906002)(4326008)(50226002)(3846002)(8676002)(81166006)(6116002)(53416004)(50466002)(2351001)(48376002)(76176999)(42186005)(50986999)(33646002)(36756003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0801MB1993; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1993; 23:gqoeGCHyz6KkwGwpENNMDJknKIKS+U+hC6hivDu?= =?us-ascii?Q?+Rzo9j0MfP5VurRY5xgfoAXx1Nn595aLXPtnahYF8xCrBBgN1G8YCYnQQ2oY?= =?us-ascii?Q?JKN/2sZ3BgFF5xMDs8CF/sM2UYQmHL1dSCf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mC2PuCIWfAwFaVcE/1zCys0gRq3x0OafLASGsmZHp18PLAYO4MhKV/kSkzuKmsSRnUfixXE2k0xkl43QUgqyoBc6V0WpijhjAf5R+//lTu9pjkLq9mmceX73GiH1+q9F+2p2AvwVvwirGFWU7N9KnSyrEew82pcSs5mN1OSymSaUl0Yi4cbcuJI0WWcDMYOMrZJ22nKgYTgY3clyO0HIUNHSmwADVzqtXOeVeaN8ooflRATbbpMY2iBu63Ea0JTR7jNzKxHokZchafpI; 24:rNxLd7BTIYu6yENem4C7pjLD+NuVKQCH9WYUDsLXAbgVO/xshUE8YnusSlFFvJgHHNSwFvf9uWbYJUYyg5O3JvTLYr3E3yZrNE+gnE93T/4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1993; 7:RllfcuSJYOO2oIFIY4UMASTGira5VBTwprzT/DcrMX/YXmVm1LvYvNijrVkGG4Ss/XRyyOAQSLzB5dfD8riNQmetPTUZ47eMaSL73JMvB88zy9JfCOceYiQQLIpzKOOIrbemsWQxcfZRqbn8jX9M5AtVBcFliOS671Vzv21DNlh2ZpjuEeSUzb04rz1FI+qmSWTWfk1ZtVGxxj2dCtRehRHZGHOFnsemVeWYhf6Tw/wdKz1n7TxTscODk/V5EwUp+AFxFiKlh2/4rgRXazNH24pODe7zKTK9suCwC6kAo5uprLA5ltoq+ukiC+6z9gSEUj6fnS6MVUCleS4rqm6LBw==; 20:8koaS6wuwOIiA5UC21zkjH+bAVPmw3/hUUSChIcVUSPVcuHkCtQ2IodjvZ2MTFkf34i2XcY6gRhBgnxFygIznB1BeWYL0nW717qYk7Do1ddDlTF639qc3A63aY6zI/ac72OFA5Z8wNcducepcvTva4nam5H98zbea9tiroShe3g= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2017 13:58:35.8019 (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.136 Subject: [Qemu-devel] [PATCH v3 11/13] virtio-console: 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 , den@virtuozzo.com, Amit Shah , 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 Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy CC: Amit Shah --- hw/char/virtio-console.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index cf7331d..bd74669 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -49,7 +49,7 @@ static ssize_t flush_buf(VirtIOSerialPort *port, VirtConsole *vcon = VIRTIO_CONSOLE(port); ssize_t ret; - if (!qemu_chr_fe_get_driver(&vcon->chr)) { + if (!qemu_chr_fe_backend_connected(&vcon->chr)) { /* If there's no backend, we can just say we consumed all data. */ return len; } @@ -163,12 +163,35 @@ static void chr_event(void *opaque, int event) } } +static int chr_be_change(void *opaque) +{ + VirtConsole *vcon = opaque; + VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(vcon); + VirtIOSerialPortClass *k = VIRTIO_SERIAL_PORT_GET_CLASS(port); + + if (k->is_console) { + qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, + NULL, chr_be_change, vcon, NULL, true); + } else { + qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, + chr_event, chr_be_change, vcon, NULL, false); + } + + if (vcon->watch) { + g_source_remove(vcon->watch); + vcon->watch = qemu_chr_fe_add_watch(&vcon->chr, + G_IO_OUT | G_IO_HUP, + chr_write_unblocked, vcon); + } + + return 0; +} + static void virtconsole_realize(DeviceState *dev, Error **errp) { VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev); VirtConsole *vcon = VIRTIO_CONSOLE(dev); VirtIOSerialPortClass *k = VIRTIO_SERIAL_PORT_GET_CLASS(dev); - Chardev *chr = qemu_chr_fe_get_driver(&vcon->chr); if (port->id == 0 && !k->is_console) { error_setg(errp, "Port number 0 on virtio-serial devices reserved " @@ -176,7 +199,7 @@ static void virtconsole_realize(DeviceState *dev, Error **errp) return; } - if (chr) { + if (qemu_chr_fe_backend_connected(&vcon->chr)) { /* * For consoles we don't block guest data transfer just * because nothing is connected - we'll just let it go @@ -188,11 +211,13 @@ static void virtconsole_realize(DeviceState *dev, Error **errp) */ if (k->is_console) { qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, - NULL, NULL, vcon, NULL, true); + NULL, chr_be_change, + vcon, NULL, true); virtio_serial_open(port); } else { qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, - chr_event, NULL, vcon, NULL, false); + chr_event, chr_be_change, + vcon, NULL, false); } } }