Revision 160600fd hw/virtio-serial-bus.c

b/hw/virtio-serial-bus.c
204 204
{
205 205
    struct VirtIOSerialPort *port;
206 206
    struct virtio_console_control cpkt, *gcpkt;
207
    uint8_t *buffer;
208
    size_t buffer_len;
207 209

  
208 210
    gcpkt = buf;
209 211
    port = find_port_by_id(vser, ldl_p(&gcpkt->id));
......
226 228
            send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
227 229
        }
228 230

  
231
        if (port->name) {
232
            stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME);
233
            stw_p(&cpkt.value, 1);
234

  
235
            buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
236
            buffer = qemu_malloc(buffer_len);
237

  
238
            memcpy(buffer, &cpkt, sizeof(cpkt));
239
            memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
240
            buffer[buffer_len - 1] = 0;
241

  
242
            send_control_msg(port, buffer, buffer_len);
243
            qemu_free(buffer);
244
        }
245

  
229 246
        if (port->host_connected) {
230 247
            send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
231 248
        }

Also available in: Unified diff