From nobody Tue Feb 10 07:41:35 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 150603624559579.03251724529832; Thu, 21 Sep 2017 16:24:05 -0700 (PDT) Received: from localhost ([::1]:55887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAp5-000214-Mw for importer@patchew.org; Thu, 21 Sep 2017 19:23:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAiA-0004YL-Pj for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAi8-0003pE-GH for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:16:50 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35737) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvAi8-0003lh-9W for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:16:48 -0400 Received: by mail-wm0-x242.google.com with SMTP id e64so6456409wmi.2 for ; Thu, 21 Sep 2017 16:16:46 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-246-117.clienti.tiscali.it. [78.12.246.117]) by smtp.gmail.com with ESMTPSA id u186sm2596278wmd.19.2017.09.21.16.16.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 16:16:44 -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=HR4POX1gKMXEiTYcXikNmU9qITb+zNhWjTx7VpkLQWU=; b=hMT9APECGdOFLLVR2Wr9zp/r4ZjDpDkBrwaK65Yngem6r05+xLMuVZhSR4Tzi98DNk xZvsoSuQ9FMG5xhKL4KRjo9p9l6fYWQ6J/lCMPGnmJipipWIdmOHC3oBJ+GmzVh7PnrE vuZdHJHdASHl5f4lJba41T8t9Lf1wNgJe1jRuUMqcLEUJhozgP3CVfvk+21kVoJDNZkG 7aRBYXrPOUB5qRm2cukECatv5YBGplSaFlssnMneTvhcakPzFkW/RIB0DxNqKmpJTo8f MJTzZG88QVpuRHNMOFO+Lnu+DgjxzsEOLvBeMSU515aNUxglUvHw22W2V69tNyoqcwuu 9EkA== 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=HR4POX1gKMXEiTYcXikNmU9qITb+zNhWjTx7VpkLQWU=; b=dXoNIV3SjiPt0EXCFSLmq8XoD7FPZTigzo/jIF4tcU7qF2PuJRt4Nw2RInGvJOceC8 hRK8FFvHvzl05+7PQo8DlStT5wn9JN9nxHk/BsCTHNW8b1CU375souK/XRxRXWKSl2fk p0DACfjTUgvkXj4ZbCDFHsnNamzl1bScuRUppfmpAALxF0sMIYMhDKGTpqxG8+Yxkd1s mS/AcuGYuAeX6U/WZ4fj4psDl+vbFbc2RZ81UKkkLAvIX4V/f9zNqLZCjjNO3A9xGUdN 7saVwEGxGpXC1HWjxm+YnRIqJCTBdk22t+aYtcwawqzgLCLNzRCUfW4ofUcPId0gbAq6 nENg== X-Gm-Message-State: AHPjjUhSv4Fdg4WAYx41fUD5C9WVB1YY0Yc7eITopUILQFRB1YLDr5J8 eNCAQ6zIe7uJbJiPOV8/lbEBI9nw X-Google-Smtp-Source: AOwi7QB6UPYhmo+jvWmdVyO4Y5YN97UY6qv0BxrF7BJpykJzOmZkU8v919VcRevhu4IkpGL0LujzXw== X-Received: by 10.28.70.133 with SMTP id t127mr2464956wma.42.1506035805541; Thu, 21 Sep 2017 16:16:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:16:09 +0200 Message-Id: <1506035800-30509-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506035800-30509-1-git-send-email-pbonzini@redhat.com> References: <1506035800-30509-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 01/32] virtio-serial: add enable_backend callback 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: Pavel Butsykin 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: Pavel Butsykin We should guarantee that RAM will not be modified while VM has a stopped state, otherwise it can lead to negative consequences during post-copy migration. In RUN_STATE_FINISH_MIGRATE step, it's expected that RAM on source side will not be modified as this could lead to non-consistent vm st= ate on the destination side. Also RAM access during postcopy-ram migration with enabled release-ram capability can lead to sad consequences. Let's add enable_backend() callback to avoid undesirable virtioqueue changes in the guest memory. Signed-off-by: Pavel Butsykin Message-Id: <20170919120733.22020-1-pbutsykin@virtuozzo.com> Signed-off-by: Paolo Bonzini --- hw/char/virtio-console.c | 21 +++++++++++++++++++++ hw/char/virtio-serial-bus.c | 7 +++++++ include/hw/virtio/virtio-serial.h | 3 +++ 3 files changed, 31 insertions(+) diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 198b2a8..172c72d 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -187,6 +187,26 @@ static int chr_be_change(void *opaque) return 0; } =20 +static void virtconsole_enable_backend(VirtIOSerialPort *port, bool enable) +{ + VirtConsole *vcon =3D VIRTIO_CONSOLE(port); + + if (!qemu_chr_fe_backend_connected(&vcon->chr)) { + return; + } + + if (enable) { + VirtIOSerialPortClass *k =3D VIRTIO_SERIAL_PORT_GET_CLASS(port); + + qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, + k->is_console ? NULL : chr_event, + chr_be_change, vcon, NULL, false); + } else { + qemu_chr_fe_set_handlers(&vcon->chr, NULL, NULL, NULL, + NULL, NULL, NULL, false); + } +} + static void virtconsole_realize(DeviceState *dev, Error **errp) { VirtIOSerialPort *port =3D VIRTIO_SERIAL_PORT(dev); @@ -258,6 +278,7 @@ static void virtserialport_class_init(ObjectClass *klas= s, void *data) k->unrealize =3D virtconsole_unrealize; k->have_data =3D flush_buf; k->set_guest_connected =3D set_guest_connected; + k->enable_backend =3D virtconsole_enable_backend; k->guest_writable =3D guest_writable; dc->props =3D virtserialport_properties; } diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 17a1bb0..9470bd7 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -637,6 +637,13 @@ static void set_status(VirtIODevice *vdev, uint8_t sta= tus) if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) { guest_reset(vser); } + + QTAILQ_FOREACH(port, &vser->ports, next) { + VirtIOSerialPortClass *vsc =3D VIRTIO_SERIAL_PORT_GET_CLASS(port); + if (vsc->enable_backend) { + vsc->enable_backend(port, vdev->vm_running); + } + } } =20 static void vser_reset(VirtIODevice *vdev) diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-s= erial.h index b19c447..12657a9 100644 --- a/include/hw/virtio/virtio-serial.h +++ b/include/hw/virtio/virtio-serial.h @@ -58,6 +58,9 @@ typedef struct VirtIOSerialPortClass { /* Guest opened/closed device. */ void (*set_guest_connected)(VirtIOSerialPort *port, int guest_connecte= d); =20 + /* Enable/disable backend for virtio serial port */ + void (*enable_backend)(VirtIOSerialPort *port, bool enable); + /* Guest is now ready to accept data (virtqueues set up). */ void (*guest_ready)(VirtIOSerialPort *port); =20 --=20 1.8.3.1