From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Sascha Silbe <silbe@linux.vnet.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Amit Shah <amit.shah@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 03/33] virtio-serial: enable virtio console emergency write feature
Date: Mon, 10 Oct 2016 05:57:37 +0300 [thread overview]
Message-ID: <1476057841-21108-4-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1476057841-21108-1-git-send-email-mst@redhat.com>
From: Sascha Silbe <silbe@linux.vnet.ibm.com>
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 <cornelia.huck@de.ibm.com>
Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/compat.h | 4 ++++
include/hw/virtio/virtio-serial.h | 2 ++
hw/char/virtio-serial-bus.c | 12 +++++++++---
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/hw/compat.h b/include/hw/compat.h
index 46412b2..ef3fae3 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -7,6 +7,10 @@
.property = "page-per-vq",\
.value = "on",\
},{\
+ .driver = "virtio-serial-device",\
+ .property = "emergency-write",\
+ .value = "off",\
+ },{\
.driver = "ioapic",\
.property = "version",\
.value = "0x11",\
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;
virtio_serial_conf serial;
+
+ uint64_t host_features;
};
/* Interface to the virtio-serial bus */
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, uint64_t features,
vser = VIRTIO_SERIAL(vdev);
+ features |= 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(DeviceState *dev, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSerial *vser = VIRTIO_SERIAL(dev);
uint32_t i, max_supported_ports;
+ size_t config_size = sizeof(struct virtio_console_config);
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(DeviceState *dev, Error **errp)
return;
}
- /* 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 = offsetof(struct virtio_console_config, emerg_wr);
+ }
virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
- offsetof(struct virtio_console_config, emerg_wr));
+ config_size);
/* Spawn a new virtio-serial bus on which the ports will ride as devices */
qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
@@ -1116,6 +1120,8 @@ VMSTATE_VIRTIO_DEVICE(console, 3, virtio_serial_load, virtio_vmstate_save);
static Property virtio_serial_properties[] = {
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(),
};
--
MST
next prev parent reply other threads:[~2016-10-10 2:57 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-10 2:57 [Qemu-devel] [PULL 00/33] virtio, pc: fixes and features Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 01/33] virtio-balloon: Remove needless precompiled directive Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 02/33] virtio-serial: add plumbing for virtio console emergency write support Michael S. Tsirkin
2016-10-10 2:57 ` Michael S. Tsirkin [this message]
2016-10-10 2:57 ` [Qemu-devel] [PULL 04/33] numa: reduce code duplication by adding helper numa_get_node_for_cpu() Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 05/33] acpi: provide _PXM method for CPU devices if QEMU is started numa enabled Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 06/33] tests: acpi: extend cphp testcase with numa check Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 07/33] tests: acpi tables expected blobs update Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 08/33] virtio: add virtio_detach_element() Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 09/33] virtio-blk: add missing virtio_detach_element() call Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 10/33] virtio-serial: " Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 11/33] virtio-9p: add parentheses to sizeof operator Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 12/33] virtio-blk: make some functions static Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 13/33] virtio-9p: handle handle_9p_output() error Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 14/33] virtio-blk: handle virtio_blk_handle_request() errors Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 15/33] virtio-net: handle virtio_net_handle_ctrl() error Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 16/33] virtio-net: handle virtio_net_receive() errors Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 17/33] virtio-net: handle virtio_net_flush_tx() errors Michael S. Tsirkin
2016-10-10 2:57 ` [Qemu-devel] [PULL 18/33] virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error() Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 19/33] virtio-scsi: handle virtio_scsi_set_config() error Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 20/33] net: don't poke at chardev internal QemuOpts Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 21/33] virtio: prepare change VMSTATE_VIRTIO_DEVICE macro Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 22/33] virtio-blk: convert VMSTATE_VIRTIO_DEVICE Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 23/33] virtio-net: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 24/33] virtio-9p: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 25/33] virtio-serial: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 26/33] virtio-gpu: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 27/33] virtio-input: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 28/33] virtio-scsi: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 29/33] virtio-balloon: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 30/33] virtio-rng: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 31/33] vhost-vsock: " Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 32/33] virtio: cleanup VMSTATE_VIRTIO_DEVICE Michael S. Tsirkin
2016-10-10 2:58 ` [Qemu-devel] [PULL 33/33] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE Michael S. Tsirkin
2016-10-10 14:13 ` [Qemu-devel] [PULL 00/33] virtio, pc: fixes and features Peter Maydell
2016-10-10 18:32 ` Peter Maydell
2016-10-10 19:27 ` Michael S. Tsirkin
2016-10-11 8:27 ` Sascha Silbe
2016-10-11 9:17 ` Peter Maydell
2016-10-11 11:17 ` Thomas Huth
2016-10-11 11:54 ` Sascha Silbe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476057841-21108-4-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=amit.shah@redhat.com \
--cc=cornelia.huck@de.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=silbe@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).