Revision a43f9c90

b/hw/virtio-console.c
57 57
    }
58 58
}
59 59

  
60
static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev)
60
static int generic_port_init(VirtConsole *vcon, VirtIOSerialPort *port)
61 61
{
62
    vcon->port.info = dev->info;
63

  
64 62
    if (vcon->chr) {
65 63
        qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
66 64
                              vcon);
......
70 68
}
71 69

  
72 70
/* Virtio Console Ports */
73
static int virtconsole_initfn(VirtIOSerialDevice *dev)
71
static int virtconsole_initfn(VirtIOSerialPort *port)
74 72
{
75
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
76 73
    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
77 74

  
78 75
    port->is_console = true;
79
    return generic_port_init(vcon, dev);
76
    return generic_port_init(vcon, port);
80 77
}
81 78

  
82
static int virtconsole_exitfn(VirtIOSerialDevice *dev)
79
static int virtconsole_exitfn(VirtIOSerialPort *port)
83 80
{
84
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
85 81
    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
86 82

  
87 83
    if (vcon->chr) {
......
113 109
device_init(virtconsole_register)
114 110

  
115 111
/* Generic Virtio Serial Ports */
116
static int virtserialport_initfn(VirtIOSerialDevice *dev)
112
static int virtserialport_initfn(VirtIOSerialPort *port)
117 113
{
118
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
119 114
    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
120 115

  
121
    return generic_port_init(vcon, dev);
116
    return generic_port_init(vcon, port);
122 117
}
123 118

  
124 119
static VirtIOSerialPortInfo virtserialport_info = {
b/hw/virtio-serial-bus.c
658 658

  
659 659
static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
660 660
{
661
    VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
662
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
661
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
663 662

  
664 663
    monitor_printf(mon, "%*s dev-prop-int: id: %u\n",
665 664
                   indent, "", port->id);
......
721 720

  
722 721
static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
723 722
{
724
    VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
723
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
725 724
    VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev, base);
726
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
727 725
    VirtIOSerialBus *bus = DO_UPCAST(VirtIOSerialBus, qbus, qdev->parent_bus);
728 726
    int ret;
729 727
    bool plugging_port0;
......
761 759
        return -1;
762 760
    }
763 761

  
764
    dev->info = info;
765
    ret = info->init(dev);
762
    port->info = info;
763
    ret = info->init(port);
766 764
    if (ret) {
767 765
        return ret;
768 766
    }
......
791 789

  
792 790
static int virtser_port_qdev_exit(DeviceState *qdev)
793 791
{
794
    VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
795
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
792
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
796 793
    VirtIOSerial *vser = port->vser;
797 794

  
798 795
    remove_port(port->vser, port->id);
......
800 797
    QTAILQ_REMOVE(&vser->ports, port, next);
801 798

  
802 799
    if (port->info->exit)
803
        port->info->exit(dev);
800
        port->info->exit(port);
804 801

  
805 802
    return 0;
806 803
}
b/hw/virtio-serial.h
62 62
typedef struct VirtIOSerialPort VirtIOSerialPort;
63 63
typedef struct VirtIOSerialPortInfo VirtIOSerialPortInfo;
64 64

  
65
typedef struct VirtIOSerialDevice {
66
    DeviceState qdev;
67
    VirtIOSerialPortInfo *info;
68
} VirtIOSerialDevice;
69

  
70 65
/*
71 66
 * This is the state that's shared between all the ports.  Some of the
72 67
 * state is configurable via command-line options. Some of it can be
......
136 131
     * The per-port (or per-app) init function that's called when a
137 132
     * new device is found on the bus.
138 133
     */
139
    int (*init)(VirtIOSerialDevice *dev);
134
    int (*init)(VirtIOSerialPort *port);
140 135
    /*
141 136
     * Per-port exit function that's called when a port gets
142 137
     * hot-unplugged or removed.
143 138
     */
144
    int (*exit)(VirtIOSerialDevice *dev);
139
    int (*exit)(VirtIOSerialPort *port);
145 140

  
146 141
    /* Callbacks for guest events */
147 142
        /* Guest opened device. */

Also available in: Unified diff