Received: from eggs.gnu.org ([2001:4830:134:3::10]:32950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bosfr-0000UD-TH for qemu-devel@nongnu.org; Tue, 27 Sep 2016 09:43:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bosfm-0005jX-V3 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 09:43:55 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bosfm-0005jT-Mr for qemu-devel@nongnu.org; Tue, 27 Sep 2016 09:43:50 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8RDhMfc037733 for ; Tue, 27 Sep 2016 09:43:50 -0400 Received: from e06smtp09.uk.ibm.com (e06smtp09.uk.ibm.com [195.75.94.105]) by mx0a-001b2d01.pphosted.com with ESMTP id 25qr135ugx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 27 Sep 2016 09:43:49 -0400 Received: from localhost by e06smtp09.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Sep 2016 14:43:47 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id D5C1A1B0804B for ; Tue, 27 Sep 2016 14:45:37 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8RDhh7O11338082 for ; Tue, 27 Sep 2016 13:43:43 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u8RChiZP027860 for ; Tue, 27 Sep 2016 06:43:44 -0600 From: Sascha Silbe Date: Tue, 27 Sep 2016 15:43:37 +0200 In-Reply-To: <1474983817-603-1-git-send-email-silbe@linux.vnet.ibm.com> References: <1474983817-603-1-git-send-email-silbe@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Message-Id: <1474983817-603-3-git-send-email-silbe@linux.vnet.ibm.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 2/2] virtio-serial: enable virtio console emergency write feature List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , Paolo Bonzini , Amit Shah Cc: Cornelia Huck , qemu-devel@nongnu.org Add support for enabling the virtio 1.0 "emergency write" (VIRTIO_CONSOLE_F_EMERG_WRITE) feature. The previous patch introduced the plumbing required for this; now we expose the virtio feature to the guest. The feature is disabled for compatibility machines to avoid exposing a new feature to existing guests. As required by the virtio 1.0 spec, the emergency write functionality is available to the guest even if the guest doesn't negotatiate the feature, as well as before feature negotation. Reviewed-by: Cornelia Huck Signed-off-by: Sascha Silbe --- v1=E2=86=92v2: - rebased on current master (virtio-pci page-per-vq compat property) - split into two patches; no code changes (requested by Amit) hw/char/virtio-serial-bus.c | 12 +++++++++--- include/hw/compat.h | 5 +++++ include/hw/virtio/virtio-serial.h | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 57419b2..db2a9f1 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -541,6 +541,7 @@ static uint64_t get_features(VirtIODevice *vdev, uint= 64_t features, =20 vser =3D VIRTIO_SERIAL(vdev); =20 + features |=3D vser->host_features; if (vser->bus.max_nr_ports > 1) { virtio_add_feature(&features, VIRTIO_CONSOLE_F_MULTIPORT); } @@ -1003,6 +1004,7 @@ static void virtio_serial_device_realize(DeviceStat= e *dev, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOSerial *vser =3D VIRTIO_SERIAL(dev); uint32_t i, max_supported_ports; + size_t config_size =3D sizeof(struct virtio_console_config); =20 if (!vser->serial.max_virtserial_ports) { error_setg(errp, "Maximum number of serial ports not specified")= ; @@ -1017,10 +1019,12 @@ static void virtio_serial_device_realize(DeviceSt= ate *dev, Error **errp) return; } =20 - /* We don't support emergency write, skip it for now. */ - /* TODO: cleaner fix, depending on host features. */ + if (!virtio_has_feature(vser->host_features, + VIRTIO_CONSOLE_F_EMERG_WRITE)) { + config_size =3D offsetof(struct virtio_console_config, emerg_wr)= ; + } virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE, - offsetof(struct virtio_console_config, emerg_wr)); + config_size); =20 /* Spawn a new virtio-serial bus on which the ports will ride as dev= ices */ qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIA= L_BUS, @@ -1116,6 +1120,8 @@ VMSTATE_VIRTIO_DEVICE(console, 3, virtio_serial_loa= d, virtio_vmstate_save); static Property virtio_serial_properties[] =3D { DEFINE_PROP_UINT32("max_ports", VirtIOSerial, serial.max_virtserial_= ports, 31), + DEFINE_PROP_BIT64("emergency-write", VirtIOSerial, host_features, + VIRTIO_CONSOLE_F_EMERG_WRITE, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/compat.h b/include/hw/compat.h index a1d6694..552030a 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -6,6 +6,11 @@ .driver =3D "virtio-pci",\ .property =3D "page-per-vq",\ .value =3D "on",\ + },\ + {\ + .driver =3D "virtio-serial-device",\ + .property =3D "emergency-write",\ + .value =3D "off",\ }, =20 #define HW_COMPAT_2_6 \ diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio= -serial.h index 730c88d..b19c447 100644 --- a/include/hw/virtio/virtio-serial.h +++ b/include/hw/virtio/virtio-serial.h @@ -184,6 +184,8 @@ struct VirtIOSerial { struct VirtIOSerialPostLoad *post_load; =20 virtio_serial_conf serial; + + uint64_t host_features; }; =20 /* Interface to the virtio-serial bus */ --=20 1.9.1