From nobody Tue Feb 10 01:35:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149995734986834.82079070909765; Thu, 13 Jul 2017 07:49:09 -0700 (PDT) Received: from localhost ([::1]:60472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVfQQ-0006nu-L0 for importer@patchew.org; Thu, 13 Jul 2017 10:49:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVf4H-0001lx-UT for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:26:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVf4D-0004Ct-SV for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:26:13 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVf4D-0004BZ-Kj for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:26:09 -0400 Received: by mail-wr0-f195.google.com with SMTP id n18so1462190wrb.0 for ; Thu, 13 Jul 2017 07:26:09 -0700 (PDT) Received: from 640k.lan (94-39-191-51.adsl-ull.clienti.tiscali.it. [94.39.191.51]) by smtp.gmail.com with ESMTPSA id k75sm6042448wmh.10.2017.07.13.07.25.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 07:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=izWCwgSD55hnDu925DqQIx8w9GIvWflL/V3HGMK4CWs=; b=uy5bbmAjpuIzn+31qigvvbbgq/H8ctSf7nHttIFsfEHDpUGxxjRgDkGQtUD1tJJkFc fxGWY6qd8yZuFA6+QzbdZhWnyvMMmjnyIn/QI6YTkNWJdMT5NQxZ8qxeJDVnHX3+2HSX Dv+0931nHOOkCM27rkNTBgVxYj604Ye7uY6cm8woI0bQYoaJ/8XMdZQzZXMvqy/apkYi QLS5Tth6zyzkelUaJBj+C/3fDv/ANmxoxpstmpRA+GFTMOh+3KDnhzQ4aNe2fzRkQsep gMFum7bTsex/RG7Cas2dtSgG5LuIsaNV64EGEbD7w7uEJueOHDg0Y5+INKNi/uMpiu0E 0pMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=izWCwgSD55hnDu925DqQIx8w9GIvWflL/V3HGMK4CWs=; b=VImf22ecQfSUm0vdJdsqAVRNIz0D59LODd09XmlZvFvupOxED6r0GYm3Mrp/CuhfPX Yem0lTLXO4wkKNyDm4RFBrr1T4pLfIwV76FX+yHdXaBmwWUXOZ3eEdyxf4aX0O0/jgTZ rarTfQzZGNHr+T/6Rrc5K7dgJw1KEGlAuFT3/0JR0S84Xx5x/ln+5fSTJqBkLaIexYDo dLQ0M18SK/5VSo8TJFn85JORZb/pPSQ+RjNlzAiyv8XNcSAiP4Rb+JZBziGJ47hgtr5s m1zUkCigd6wEz3bhZvRD8YNqYXfPYxu99jlUxia1BB063Azr5XyxNoBsj9+ThYQJ4bjy g3yg== X-Gm-Message-State: AIVw110Ynqr4BXciVpNd7AzgqtfabALi2EuYj4XihVQ8QuU3qLYr3i5l uwzSEg/YZuGiKYIu/KA= X-Received: by 10.223.134.157 with SMTP id 29mr2153877wrx.157.1499955908363; Thu, 13 Jul 2017 07:25:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 13 Jul 2017 16:24:11 +0200 Message-Id: <1499955874-10954-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1499955874-10954-1-git-send-email-pbonzini@redhat.com> References: <1499955874-10954-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.195 Subject: [Qemu-devel] [PULL 18/41] 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: Anton Nefedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Anton Nefedov In case of a backend change, the handler functions and the watch have to be reset. Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <1499342940-56739-12-git-send-email-anton.nefedov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- hw/char/virtio-console.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 4d3967c..198b2a8 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -163,6 +163,30 @@ static void chr_event(void *opaque, int event) } } =20 +static int chr_be_change(void *opaque) +{ + VirtConsole *vcon =3D opaque; + VirtIOSerialPort *port =3D VIRTIO_SERIAL_PORT(vcon); + VirtIOSerialPortClass *k =3D 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, fal= se); + } + + if (vcon->watch) { + g_source_remove(vcon->watch); + vcon->watch =3D 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 =3D VIRTIO_SERIAL_PORT(dev); @@ -187,11 +211,13 @@ static void virtconsole_realize(DeviceState *dev, Err= or **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); } } } --=20 1.8.3.1