]> Git Repo - qemu.git/blob - hw/virtio-serial-bus.c
virtio-serial: Handle scatter-gather buffers for control messages
[qemu.git] / hw / virtio-serial-bus.c
1 /*
2  * A bus for connecting virtio serial and console ports
3  *
4  * Copyright (C) 2009, 2010 Red Hat, Inc.
5  *
6  * Author(s):
7  *  Amit Shah <[email protected]>
8  *
9  * Some earlier parts are:
10  *  Copyright IBM, Corp. 2008
11  * authored by
12  *  Christian Ehrhardt <[email protected]>
13  *
14  * This work is licensed under the terms of the GNU GPL, version 2.  See
15  * the COPYING file in the top-level directory.
16  */
17
18 #include "iov.h"
19 #include "monitor.h"
20 #include "qemu-queue.h"
21 #include "sysbus.h"
22 #include "virtio-serial.h"
23
24 /* The virtio-serial bus on top of which the ports will ride as devices */
25 struct VirtIOSerialBus {
26     BusState qbus;
27
28     /* This is the parent device that provides the bus for ports. */
29     VirtIOSerial *vser;
30
31     /* The maximum number of ports that can ride on top of this bus */
32     uint32_t max_nr_ports;
33 };
34
35 struct VirtIOSerial {
36     VirtIODevice vdev;
37
38     VirtQueue *c_ivq, *c_ovq;
39     /* Arrays of ivqs and ovqs: one per port */
40     VirtQueue **ivqs, **ovqs;
41
42     VirtIOSerialBus *bus;
43
44     QTAILQ_HEAD(, VirtIOSerialPort) ports;
45
46     /* bitmap for identifying active ports */
47     uint32_t *ports_map;
48
49     struct virtio_console_config config;
50 };
51
52 static VirtIOSerialPort *find_port_by_id(VirtIOSerial *vser, uint32_t id)
53 {
54     VirtIOSerialPort *port;
55
56     if (id == VIRTIO_CONSOLE_BAD_ID) {
57         return NULL;
58     }
59
60     QTAILQ_FOREACH(port, &vser->ports, next) {
61         if (port->id == id)
62             return port;
63     }
64     return NULL;
65 }
66
67 static VirtIOSerialPort *find_port_by_vq(VirtIOSerial *vser, VirtQueue *vq)
68 {
69     VirtIOSerialPort *port;
70
71     QTAILQ_FOREACH(port, &vser->ports, next) {
72         if (port->ivq == vq || port->ovq == vq)
73             return port;
74     }
75     return NULL;
76 }
77
78 static bool use_multiport(VirtIOSerial *vser)
79 {
80     return vser->vdev.guest_features & (1 << VIRTIO_CONSOLE_F_MULTIPORT);
81 }
82
83 static size_t write_to_port(VirtIOSerialPort *port,
84                             const uint8_t *buf, size_t size)
85 {
86     VirtQueueElement elem;
87     VirtQueue *vq;
88     size_t offset;
89
90     vq = port->ivq;
91     if (!virtio_queue_ready(vq)) {
92         return 0;
93     }
94
95     offset = 0;
96     while (offset < size) {
97         size_t len;
98
99         if (!virtqueue_pop(vq, &elem)) {
100             break;
101         }
102
103         len = iov_from_buf(elem.in_sg, elem.in_num,
104                            buf + offset, size - offset);
105         offset += len;
106
107         virtqueue_push(vq, &elem, len);
108     }
109
110     virtio_notify(&port->vser->vdev, vq);
111     return offset;
112 }
113
114 static size_t send_control_msg(VirtIOSerialPort *port, void *buf, size_t len)
115 {
116     VirtQueueElement elem;
117     VirtQueue *vq;
118     struct virtio_console_control *cpkt;
119
120     vq = port->vser->c_ivq;
121     if (!virtio_queue_ready(vq)) {
122         return 0;
123     }
124     if (!virtqueue_pop(vq, &elem)) {
125         return 0;
126     }
127
128     cpkt = (struct virtio_console_control *)buf;
129     stl_p(&cpkt->id, port->id);
130     memcpy(elem.in_sg[0].iov_base, buf, len);
131
132     virtqueue_push(vq, &elem, len);
133     virtio_notify(&port->vser->vdev, vq);
134     return len;
135 }
136
137 static size_t send_control_event(VirtIOSerialPort *port, uint16_t event,
138                                  uint16_t value)
139 {
140     struct virtio_console_control cpkt;
141
142     stw_p(&cpkt.event, event);
143     stw_p(&cpkt.value, value);
144
145     return send_control_msg(port, &cpkt, sizeof(cpkt));
146 }
147
148 /* Functions for use inside qemu to open and read from/write to ports */
149 int virtio_serial_open(VirtIOSerialPort *port)
150 {
151     /* Don't allow opening an already-open port */
152     if (port->host_connected) {
153         return 0;
154     }
155     /* Send port open notification to the guest */
156     port->host_connected = true;
157     send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
158
159     return 0;
160 }
161
162 int virtio_serial_close(VirtIOSerialPort *port)
163 {
164     port->host_connected = false;
165     send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 0);
166
167     return 0;
168 }
169
170 /* Individual ports/apps call this function to write to the guest. */
171 ssize_t virtio_serial_write(VirtIOSerialPort *port, const uint8_t *buf,
172                             size_t size)
173 {
174     if (!port || !port->host_connected || !port->guest_connected) {
175         return 0;
176     }
177     return write_to_port(port, buf, size);
178 }
179
180 /*
181  * Readiness of the guest to accept data on a port.
182  * Returns max. data the guest can receive
183  */
184 size_t virtio_serial_guest_ready(VirtIOSerialPort *port)
185 {
186     VirtQueue *vq = port->ivq;
187
188     if (!virtio_queue_ready(vq) ||
189         !(port->vser->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) ||
190         virtio_queue_empty(vq)) {
191         return 0;
192     }
193     if (use_multiport(port->vser) && !port->guest_connected) {
194         return 0;
195     }
196
197     if (virtqueue_avail_bytes(vq, 4096, 0)) {
198         return 4096;
199     }
200     if (virtqueue_avail_bytes(vq, 1, 0)) {
201         return 1;
202     }
203     return 0;
204 }
205
206 /* Guest wants to notify us of some event */
207 static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
208 {
209     struct VirtIOSerialPort *port;
210     struct virtio_console_control cpkt, *gcpkt;
211     uint8_t *buffer;
212     size_t buffer_len;
213
214     gcpkt = buf;
215
216     if (len < sizeof(cpkt)) {
217         /* The guest sent an invalid control packet */
218         return;
219     }
220
221     cpkt.event = lduw_p(&gcpkt->event);
222     cpkt.value = lduw_p(&gcpkt->value);
223
224     port = find_port_by_id(vser, ldl_p(&gcpkt->id));
225     if (!port && cpkt.event != VIRTIO_CONSOLE_DEVICE_READY)
226         return;
227
228     switch(cpkt.event) {
229     case VIRTIO_CONSOLE_DEVICE_READY:
230         if (!cpkt.value) {
231             error_report("virtio-serial-bus: Guest failure in adding device %s\n",
232                          vser->bus->qbus.name);
233             break;
234         }
235         /*
236          * The device is up, we can now tell the device about all the
237          * ports we have here.
238          */
239         QTAILQ_FOREACH(port, &vser->ports, next) {
240             send_control_event(port, VIRTIO_CONSOLE_PORT_ADD, 1);
241         }
242         break;
243
244     case VIRTIO_CONSOLE_PORT_READY:
245         if (!cpkt.value) {
246             error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n",
247                          port->id, vser->bus->qbus.name);
248             break;
249         }
250         /*
251          * Now that we know the guest asked for the port name, we're
252          * sure the guest has initialised whatever state is necessary
253          * for this port. Now's a good time to let the guest know if
254          * this port is a console port so that the guest can hook it
255          * up to hvc.
256          */
257         if (port->is_console) {
258             send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
259         }
260
261         if (port->name) {
262             stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME);
263             stw_p(&cpkt.value, 1);
264
265             buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
266             buffer = qemu_malloc(buffer_len);
267
268             memcpy(buffer, &cpkt, sizeof(cpkt));
269             memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
270             buffer[buffer_len - 1] = 0;
271
272             send_control_msg(port, buffer, buffer_len);
273             qemu_free(buffer);
274         }
275
276         if (port->host_connected) {
277             send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
278         }
279
280         /*
281          * When the guest has asked us for this information it means
282          * the guest is all setup and has its virtqueues
283          * initialised. If some app is interested in knowing about
284          * this event, let it know.
285          */
286         if (port->info->guest_ready) {
287             port->info->guest_ready(port);
288         }
289         break;
290
291     case VIRTIO_CONSOLE_PORT_OPEN:
292         port->guest_connected = cpkt.value;
293         if (cpkt.value && port->info->guest_open) {
294             /* Send the guest opened notification if an app is interested */
295             port->info->guest_open(port);
296         }
297
298         if (!cpkt.value && port->info->guest_close) {
299             /* Send the guest closed notification if an app is interested */
300             port->info->guest_close(port);
301         }
302         break;
303     }
304 }
305
306 static void control_in(VirtIODevice *vdev, VirtQueue *vq)
307 {
308 }
309
310 static void control_out(VirtIODevice *vdev, VirtQueue *vq)
311 {
312     VirtQueueElement elem;
313     VirtIOSerial *vser;
314     uint8_t *buf;
315     size_t len;
316
317     vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
318
319     len = 0;
320     buf = NULL;
321     while (virtqueue_pop(vq, &elem)) {
322         size_t cur_len, copied;
323
324         cur_len = iov_size(elem.out_sg, elem.out_num);
325         /*
326          * Allocate a new buf only if we didn't have one previously or
327          * if the size of the buf differs
328          */
329         if (cur_len > len) {
330             qemu_free(buf);
331
332             buf = qemu_malloc(cur_len);
333             len = cur_len;
334         }
335         copied = iov_to_buf(elem.out_sg, elem.out_num, buf, 0, len);
336
337         handle_control_message(vser, buf, copied);
338         virtqueue_push(vq, &elem, copied);
339     }
340     qemu_free(buf);
341     virtio_notify(vdev, vq);
342 }
343
344 /* Guest wrote something to some port. */
345 static void handle_output(VirtIODevice *vdev, VirtQueue *vq)
346 {
347     VirtIOSerial *vser;
348     VirtQueueElement elem;
349
350     vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
351
352     while (virtqueue_pop(vq, &elem)) {
353         VirtIOSerialPort *port;
354         size_t ret;
355
356         port = find_port_by_vq(vser, vq);
357         if (!port) {
358             ret = 0;
359             goto next_buf;
360         }
361
362         if (!port->host_connected) {
363             ret = 0;
364             goto next_buf;
365         }
366
367         /*
368          * A port may not have any handler registered for consuming the
369          * data that the guest sends or it may not have a chardev associated
370          * with it. Just ignore the data in that case.
371          */
372         if (!port->info->have_data) {
373             ret = 0;
374             goto next_buf;
375         }
376
377         /* The guest always sends only one sg */
378         ret = port->info->have_data(port, elem.out_sg[0].iov_base,
379                                     elem.out_sg[0].iov_len);
380
381     next_buf:
382         virtqueue_push(vq, &elem, ret);
383     }
384     virtio_notify(vdev, vq);
385 }
386
387 static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
388 {
389 }
390
391 static uint32_t get_features(VirtIODevice *vdev, uint32_t features)
392 {
393     VirtIOSerial *vser;
394
395     vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
396
397     if (vser->bus->max_nr_ports > 1) {
398         features |= (1 << VIRTIO_CONSOLE_F_MULTIPORT);
399     }
400     return features;
401 }
402
403 /* Guest requested config info */
404 static void get_config(VirtIODevice *vdev, uint8_t *config_data)
405 {
406     VirtIOSerial *vser;
407
408     vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
409     memcpy(config_data, &vser->config, sizeof(struct virtio_console_config));
410 }
411
412 static void set_config(VirtIODevice *vdev, const uint8_t *config_data)
413 {
414     struct virtio_console_config config;
415
416     memcpy(&config, config_data, sizeof(config));
417 }
418
419 static void virtio_serial_save(QEMUFile *f, void *opaque)
420 {
421     VirtIOSerial *s = opaque;
422     VirtIOSerialPort *port;
423     uint32_t nr_active_ports;
424     unsigned int i;
425
426     /* The virtio device */
427     virtio_save(&s->vdev, f);
428
429     /* The config space */
430     qemu_put_be16s(f, &s->config.cols);
431     qemu_put_be16s(f, &s->config.rows);
432
433     qemu_put_be32s(f, &s->config.max_nr_ports);
434
435     /* The ports map */
436
437     for (i = 0; i < (s->config.max_nr_ports + 31) / 32; i++) {
438         qemu_put_be32s(f, &s->ports_map[i]);
439     }
440
441     /* Ports */
442
443     nr_active_ports = 0;
444     QTAILQ_FOREACH(port, &s->ports, next) {
445         nr_active_ports++;
446     }
447
448     qemu_put_be32s(f, &nr_active_ports);
449
450     /*
451      * Items in struct VirtIOSerialPort.
452      */
453     QTAILQ_FOREACH(port, &s->ports, next) {
454         qemu_put_be32s(f, &port->id);
455         qemu_put_byte(f, port->guest_connected);
456         qemu_put_byte(f, port->host_connected);
457     }
458 }
459
460 static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
461 {
462     VirtIOSerial *s = opaque;
463     VirtIOSerialPort *port;
464     size_t ports_map_size;
465     uint32_t max_nr_ports, nr_active_ports, *ports_map;
466     unsigned int i;
467
468     if (version_id > 2) {
469         return -EINVAL;
470     }
471
472     /* The virtio device */
473     virtio_load(&s->vdev, f);
474
475     if (version_id < 2) {
476         return 0;
477     }
478
479     /* The config space */
480     qemu_get_be16s(f, &s->config.cols);
481     qemu_get_be16s(f, &s->config.rows);
482
483     qemu_get_be32s(f, &max_nr_ports);
484     if (max_nr_ports > s->config.max_nr_ports) {
485         /* Source could have had more ports than us. Fail migration. */
486         return -EINVAL;
487     }
488
489     ports_map_size = sizeof(uint32_t) * (max_nr_ports + 31) / 32;
490     ports_map = qemu_malloc(ports_map_size);
491
492     for (i = 0; i < (max_nr_ports + 31) / 32; i++) {
493         qemu_get_be32s(f, &ports_map[i]);
494
495         if (ports_map[i] != s->ports_map[i]) {
496             /*
497              * Ports active on source and destination don't
498              * match. Fail migration.
499              */
500             qemu_free(ports_map);
501             return -EINVAL;
502         }
503     }
504     qemu_free(ports_map);
505
506     qemu_get_be32s(f, &nr_active_ports);
507
508     /* Items in struct VirtIOSerialPort */
509     for (i = 0; i < nr_active_ports; i++) {
510         uint32_t id;
511         bool host_connected;
512
513         id = qemu_get_be32(f);
514         port = find_port_by_id(s, id);
515
516         port->guest_connected = qemu_get_byte(f);
517         host_connected = qemu_get_byte(f);
518         if (host_connected != port->host_connected) {
519             /*
520              * We have to let the guest know of the host connection
521              * status change
522              */
523             send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN,
524                                port->host_connected);
525         }
526     }
527     return 0;
528 }
529
530 static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
531
532 static struct BusInfo virtser_bus_info = {
533     .name      = "virtio-serial-bus",
534     .size      = sizeof(VirtIOSerialBus),
535     .print_dev = virtser_bus_dev_print,
536 };
537
538 static VirtIOSerialBus *virtser_bus_new(DeviceState *dev)
539 {
540     VirtIOSerialBus *bus;
541
542     bus = FROM_QBUS(VirtIOSerialBus, qbus_create(&virtser_bus_info, dev, NULL));
543     bus->qbus.allow_hotplug = 1;
544
545     return bus;
546 }
547
548 static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
549 {
550     VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
551     VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
552
553     monitor_printf(mon, "%*s dev-prop-int: id: %u\n",
554                    indent, "", port->id);
555     monitor_printf(mon, "%*s dev-prop-int: guest_connected: %d\n",
556                    indent, "", port->guest_connected);
557     monitor_printf(mon, "%*s dev-prop-int: host_connected: %d\n",
558                    indent, "", port->host_connected);
559 }
560
561 /* This function is only used if a port id is not provided by the user */
562 static uint32_t find_free_port_id(VirtIOSerial *vser)
563 {
564     unsigned int i;
565
566     for (i = 0; i < (vser->config.max_nr_ports + 31) / 32; i++) {
567         uint32_t map, bit;
568
569         map = vser->ports_map[i];
570         bit = ffs(~map);
571         if (bit) {
572             return (bit - 1) + i * 32;
573         }
574     }
575     return VIRTIO_CONSOLE_BAD_ID;
576 }
577
578 static void mark_port_added(VirtIOSerial *vser, uint32_t port_id)
579 {
580     unsigned int i;
581
582     i = port_id / 32;
583     vser->ports_map[i] |= 1U << (port_id % 32);
584 }
585
586 static void add_port(VirtIOSerial *vser, uint32_t port_id)
587 {
588     mark_port_added(vser, port_id);
589
590     send_control_event(find_port_by_id(vser, port_id),
591                        VIRTIO_CONSOLE_PORT_ADD, 1);
592 }
593
594 static void remove_port(VirtIOSerial *vser, uint32_t port_id)
595 {
596     unsigned int i;
597
598     i = port_id / 32;
599     vser->ports_map[i] &= ~(1U << (port_id % 32));
600
601     send_control_event(find_port_by_id(vser, port_id),
602                        VIRTIO_CONSOLE_PORT_REMOVE, 1);
603 }
604
605 static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
606 {
607     VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
608     VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev, base);
609     VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
610     VirtIOSerialBus *bus = DO_UPCAST(VirtIOSerialBus, qbus, qdev->parent_bus);
611     int ret;
612     bool plugging_port0;
613
614     port->vser = bus->vser;
615
616     /*
617      * Is the first console port we're seeing? If so, put it up at
618      * location 0. This is done for backward compatibility (old
619      * kernel, new qemu).
620      */
621     plugging_port0 = port->is_console && !find_port_by_id(port->vser, 0);
622
623     if (find_port_by_id(port->vser, port->id)) {
624         error_report("virtio-serial-bus: A port already exists at id %u\n",
625                      port->id);
626         return -1;
627     }
628
629     if (port->id == VIRTIO_CONSOLE_BAD_ID) {
630         if (plugging_port0) {
631             port->id = 0;
632         } else {
633             port->id = find_free_port_id(port->vser);
634             if (port->id == VIRTIO_CONSOLE_BAD_ID) {
635                 error_report("virtio-serial-bus: Maximum port limit for this device reached\n");
636                 return -1;
637             }
638         }
639     }
640
641     if (port->id >= port->vser->config.max_nr_ports) {
642         error_report("virtio-serial-bus: Out-of-range port id specified, max. allowed: %u\n",
643                      port->vser->config.max_nr_ports - 1);
644         return -1;
645     }
646
647     dev->info = info;
648     ret = info->init(dev);
649     if (ret) {
650         return ret;
651     }
652
653     if (!use_multiport(port->vser)) {
654         /*
655          * Allow writes to guest in this case; we have no way of
656          * knowing if a guest port is connected.
657          */
658         port->guest_connected = true;
659     }
660
661     QTAILQ_INSERT_TAIL(&port->vser->ports, port, next);
662     port->ivq = port->vser->ivqs[port->id];
663     port->ovq = port->vser->ovqs[port->id];
664
665     add_port(port->vser, port->id);
666
667     /* Send an update to the guest about this new port added */
668     virtio_notify_config(&port->vser->vdev);
669
670     return ret;
671 }
672
673 static int virtser_port_qdev_exit(DeviceState *qdev)
674 {
675     VirtIOSerialDevice *dev = DO_UPCAST(VirtIOSerialDevice, qdev, qdev);
676     VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, &dev->qdev);
677     VirtIOSerial *vser = port->vser;
678
679     remove_port(port->vser, port->id);
680
681     QTAILQ_REMOVE(&vser->ports, port, next);
682
683     if (port->info->exit)
684         port->info->exit(dev);
685
686     return 0;
687 }
688
689 void virtio_serial_port_qdev_register(VirtIOSerialPortInfo *info)
690 {
691     info->qdev.init = virtser_port_qdev_init;
692     info->qdev.bus_info = &virtser_bus_info;
693     info->qdev.exit = virtser_port_qdev_exit;
694     info->qdev.unplug = qdev_simple_unplug_cb;
695     qdev_register(&info->qdev);
696 }
697
698 VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
699 {
700     VirtIOSerial *vser;
701     VirtIODevice *vdev;
702     uint32_t i;
703
704     if (!max_nr_ports)
705         return NULL;
706
707     vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
708                               sizeof(struct virtio_console_config),
709                               sizeof(VirtIOSerial));
710
711     vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
712
713     /* Spawn a new virtio-serial bus on which the ports will ride as devices */
714     vser->bus = virtser_bus_new(dev);
715     vser->bus->vser = vser;
716     QTAILQ_INIT(&vser->ports);
717
718     vser->bus->max_nr_ports = max_nr_ports;
719     vser->ivqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
720     vser->ovqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
721
722     /* Add a queue for host to guest transfers for port 0 (backward compat) */
723     vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
724     /* Add a queue for guest to host transfers for port 0 (backward compat) */
725     vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output);
726
727     /* control queue: host to guest */
728     vser->c_ivq = virtio_add_queue(vdev, 16, control_in);
729     /* control queue: guest to host */
730     vser->c_ovq = virtio_add_queue(vdev, 16, control_out);
731
732     for (i = 1; i < vser->bus->max_nr_ports; i++) {
733         /* Add a per-port queue for host to guest transfers */
734         vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input);
735         /* Add a per-per queue for guest to host transfers */
736         vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
737     }
738
739     vser->config.max_nr_ports = max_nr_ports;
740     vser->ports_map = qemu_mallocz((max_nr_ports + 31) / 32);
741     /*
742      * Reserve location 0 for a console port for backward compat
743      * (old kernel, new qemu)
744      */
745     mark_port_added(vser, 0);
746
747     vser->vdev.get_features = get_features;
748     vser->vdev.get_config = get_config;
749     vser->vdev.set_config = set_config;
750
751     /*
752      * Register for the savevm section with the virtio-console name
753      * to preserve backward compat
754      */
755     register_savevm("virtio-console", -1, 2, virtio_serial_save,
756                     virtio_serial_load, vser);
757
758     return vdev;
759 }
This page took 0.064338 seconds and 4 git commands to generate.