virtio-serial: Clean up virtconsole detection
virtio-serial-bus needs to treat "virtconsole" devices specially. It uses VirtIOSerialPort member is_console to recognize them. It gets its value via property initialization. Cute hack, except it lets users mess with it: "-device virtconsole,is_console=0" isn't plugged into port 0 as it should. Move the flag to VirtIOSerialPortInfo. Keep the property for backward compatibility; its value has no effect. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
parent
5e52e5f903
commit
2a3d57ce42
@ -91,7 +91,7 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
|
|||||||
{
|
{
|
||||||
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
|
||||||
|
|
||||||
port->is_console = true;
|
port->is_console_dummy = true;
|
||||||
return generic_port_init(vcon, port);
|
return generic_port_init(vcon, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,10 +113,11 @@ static int virtconsole_exitfn(VirtIOSerialPort *port)
|
|||||||
static VirtIOSerialPortInfo virtconsole_info = {
|
static VirtIOSerialPortInfo virtconsole_info = {
|
||||||
.qdev.name = "virtconsole",
|
.qdev.name = "virtconsole",
|
||||||
.qdev.size = sizeof(VirtConsole),
|
.qdev.size = sizeof(VirtConsole),
|
||||||
|
.is_console = true,
|
||||||
.init = virtconsole_initfn,
|
.init = virtconsole_initfn,
|
||||||
.exit = virtconsole_exitfn,
|
.exit = virtconsole_exitfn,
|
||||||
.qdev.props = (Property[]) {
|
.qdev.props = (Property[]) {
|
||||||
DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1),
|
DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console_dummy, 1),
|
||||||
DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID),
|
DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID),
|
||||||
DEFINE_PROP_CHR("chardev", VirtConsole, chr),
|
DEFINE_PROP_CHR("chardev", VirtConsole, chr),
|
||||||
DEFINE_PROP_STRING("name", VirtConsole, port.name),
|
DEFINE_PROP_STRING("name", VirtConsole, port.name),
|
||||||
|
@ -356,7 +356,7 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
|
|||||||
* this port is a console port so that the guest can hook it
|
* this port is a console port so that the guest can hook it
|
||||||
* up to hvc.
|
* up to hvc.
|
||||||
*/
|
*/
|
||||||
if (port->is_console) {
|
if (port->info->is_console) {
|
||||||
send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
|
send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,7 +729,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
|
|||||||
* location 0. This is done for backward compatibility (old
|
* location 0. This is done for backward compatibility (old
|
||||||
* kernel, new qemu).
|
* kernel, new qemu).
|
||||||
*/
|
*/
|
||||||
plugging_port0 = port->is_console && !find_port_by_id(port->vser, 0);
|
plugging_port0 = info->is_console && !find_port_by_id(port->vser, 0);
|
||||||
|
|
||||||
if (find_port_by_id(port->vser, port->id)) {
|
if (find_port_by_id(port->vser, port->id)) {
|
||||||
error_report("virtio-serial-bus: A port already exists at id %u\n",
|
error_report("virtio-serial-bus: A port already exists at id %u\n",
|
||||||
|
@ -124,8 +124,8 @@ struct VirtIOSerialPort {
|
|||||||
*/
|
*/
|
||||||
QEMUBH *bh;
|
QEMUBH *bh;
|
||||||
|
|
||||||
/* Identify if this is a port that binds with hvc in the guest */
|
/* For property backward compatibility, not used otherwise */
|
||||||
uint8_t is_console;
|
uint8_t is_console_dummy;
|
||||||
|
|
||||||
/* Is the corresponding guest device open? */
|
/* Is the corresponding guest device open? */
|
||||||
bool guest_connected;
|
bool guest_connected;
|
||||||
@ -137,6 +137,10 @@ struct VirtIOSerialPort {
|
|||||||
|
|
||||||
struct VirtIOSerialPortInfo {
|
struct VirtIOSerialPortInfo {
|
||||||
DeviceInfo qdev;
|
DeviceInfo qdev;
|
||||||
|
|
||||||
|
/* Is this a device that binds with hvc in the guest? */
|
||||||
|
bool is_console;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The per-port (or per-app) init function that's called when a
|
* The per-port (or per-app) init function that's called when a
|
||||||
* new device is found on the bus.
|
* new device is found on the bus.
|
||||||
|
Loading…
Reference in New Issue
Block a user