4 * Copyright IBM, Corp. 2007
5 * Copyright (c) 2009 CodeSourcery
8 * Anthony Liguori <aliguori@us.ibm.com>
9 * Paul Brook <paul@codesourcery.com>
11 * This work is licensed under the terms of the GNU GPL, version 2. See
12 * the COPYING file in the top-level directory.
19 #include "virtio-blk.h"
20 #include "virtio-net.h"
22 #include "qemu-error.h"
25 #include "block_int.h"
29 /* from Linux's linux/virtio_pci.h */
31 /* A 32-bit r/o bitmask of the features supported by the host */
32 #define VIRTIO_PCI_HOST_FEATURES 0
34 /* A 32-bit r/w bitmask of features activated by the guest */
35 #define VIRTIO_PCI_GUEST_FEATURES 4
37 /* A 32-bit r/w PFN for the currently selected queue */
38 #define VIRTIO_PCI_QUEUE_PFN 8
40 /* A 16-bit r/o queue size for the currently selected queue */
41 #define VIRTIO_PCI_QUEUE_NUM 12
43 /* A 16-bit r/w queue selector */
44 #define VIRTIO_PCI_QUEUE_SEL 14
46 /* A 16-bit r/w queue notifier */
47 #define VIRTIO_PCI_QUEUE_NOTIFY 16
49 /* An 8-bit device status register. */
50 #define VIRTIO_PCI_STATUS 18
52 /* An 8-bit r/o interrupt status register. Reading the value will return the
53 * current contents of the ISR and will also clear it. This is effectively
54 * a read-and-acknowledge. */
55 #define VIRTIO_PCI_ISR 19
57 /* MSI-X registers: only enabled if MSI-X is enabled. */
58 /* A 16-bit vector for configuration changes. */
59 #define VIRTIO_MSI_CONFIG_VECTOR 20
60 /* A 16-bit vector for selected queue notifications. */
61 #define VIRTIO_MSI_QUEUE_VECTOR 22
63 /* Config space size */
64 #define VIRTIO_PCI_CONFIG_NOMSI 20
65 #define VIRTIO_PCI_CONFIG_MSI 24
66 #define VIRTIO_PCI_REGION_SIZE(dev) (msix_present(dev) ? \
67 VIRTIO_PCI_CONFIG_MSI : \
68 VIRTIO_PCI_CONFIG_NOMSI)
70 /* The remaining space is defined by each driver as the per-driver
71 * configuration space */
72 #define VIRTIO_PCI_CONFIG(dev) (msix_enabled(dev) ? \
73 VIRTIO_PCI_CONFIG_MSI : \
74 VIRTIO_PCI_CONFIG_NOMSI)
76 /* Virtio ABI version, if we increment this, we break the guest driver. */
77 #define VIRTIO_PCI_ABI_VERSION 0
79 /* How many bits to shift physical queue address written to QUEUE_PFN.
80 * 12 is historical, and due to x86 page size. */
81 #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12
83 /* We can catch some guest bugs inside here so we continue supporting older
85 #define VIRTIO_PCI_BUG_BUS_MASTER (1 << 0)
87 /* QEMU doesn't strictly need write barriers since everything runs in
88 * lock-step. We'll leave the calls to wmb() in though to make it obvious for
89 * KVM or if kqemu gets SMP support.
91 #define wmb() do { } while (0)
104 uint32_t host_features
;
108 /* Max. number of ports we can have for a the virtio-serial device */
109 uint32_t max_virtserial_ports
;
114 static void virtio_pci_notify(void *opaque
, uint16_t vector
)
116 VirtIOPCIProxy
*proxy
= opaque
;
117 if (msix_enabled(&proxy
->pci_dev
))
118 msix_notify(&proxy
->pci_dev
, vector
);
120 qemu_set_irq(proxy
->pci_dev
.irq
[0], proxy
->vdev
->isr
& 1);
123 static void virtio_pci_save_config(void * opaque
, QEMUFile
*f
)
125 VirtIOPCIProxy
*proxy
= opaque
;
126 pci_device_save(&proxy
->pci_dev
, f
);
127 msix_save(&proxy
->pci_dev
, f
);
128 if (msix_present(&proxy
->pci_dev
))
129 qemu_put_be16(f
, proxy
->vdev
->config_vector
);
132 static void virtio_pci_save_queue(void * opaque
, int n
, QEMUFile
*f
)
134 VirtIOPCIProxy
*proxy
= opaque
;
135 if (msix_present(&proxy
->pci_dev
))
136 qemu_put_be16(f
, virtio_queue_vector(proxy
->vdev
, n
));
139 static int virtio_pci_load_config(void * opaque
, QEMUFile
*f
)
141 VirtIOPCIProxy
*proxy
= opaque
;
143 ret
= pci_device_load(&proxy
->pci_dev
, f
);
147 msix_load(&proxy
->pci_dev
, f
);
148 if (msix_present(&proxy
->pci_dev
)) {
149 qemu_get_be16s(f
, &proxy
->vdev
->config_vector
);
151 proxy
->vdev
->config_vector
= VIRTIO_NO_VECTOR
;
153 if (proxy
->vdev
->config_vector
!= VIRTIO_NO_VECTOR
) {
154 return msix_vector_use(&proxy
->pci_dev
, proxy
->vdev
->config_vector
);
157 /* Try to find out if the guest has bus master disabled, but is
158 in ready state. Then we have a buggy guest OS. */
159 if (!(proxy
->vdev
->status
& VIRTIO_CONFIG_S_DRIVER_OK
) &&
160 !(proxy
->pci_dev
.config
[PCI_COMMAND
] & PCI_COMMAND_MASTER
)) {
161 proxy
->bugs
|= VIRTIO_PCI_BUG_BUS_MASTER
;
166 static int virtio_pci_load_queue(void * opaque
, int n
, QEMUFile
*f
)
168 VirtIOPCIProxy
*proxy
= opaque
;
170 if (msix_present(&proxy
->pci_dev
)) {
171 qemu_get_be16s(f
, &vector
);
173 vector
= VIRTIO_NO_VECTOR
;
175 virtio_queue_set_vector(proxy
->vdev
, n
, vector
);
176 if (vector
!= VIRTIO_NO_VECTOR
) {
177 return msix_vector_use(&proxy
->pci_dev
, vector
);
182 static void virtio_pci_reset(DeviceState
*d
)
184 VirtIOPCIProxy
*proxy
= container_of(d
, VirtIOPCIProxy
, pci_dev
.qdev
);
185 virtio_reset(proxy
->vdev
);
186 msix_reset(&proxy
->pci_dev
);
190 static void virtio_ioport_write(void *opaque
, uint32_t addr
, uint32_t val
)
192 VirtIOPCIProxy
*proxy
= opaque
;
193 VirtIODevice
*vdev
= proxy
->vdev
;
194 target_phys_addr_t pa
;
197 case VIRTIO_PCI_GUEST_FEATURES
:
198 /* Guest does not negotiate properly? We have to assume nothing. */
199 if (val
& (1 << VIRTIO_F_BAD_FEATURE
)) {
200 if (vdev
->bad_features
)
201 val
= proxy
->host_features
& vdev
->bad_features(vdev
);
205 if (vdev
->set_features
)
206 vdev
->set_features(vdev
, val
);
207 vdev
->guest_features
= val
;
209 case VIRTIO_PCI_QUEUE_PFN
:
210 pa
= (target_phys_addr_t
)val
<< VIRTIO_PCI_QUEUE_ADDR_SHIFT
;
212 virtio_reset(proxy
->vdev
);
213 msix_unuse_all_vectors(&proxy
->pci_dev
);
216 virtio_queue_set_addr(vdev
, vdev
->queue_sel
, pa
);
218 case VIRTIO_PCI_QUEUE_SEL
:
219 if (val
< VIRTIO_PCI_QUEUE_MAX
)
220 vdev
->queue_sel
= val
;
222 case VIRTIO_PCI_QUEUE_NOTIFY
:
223 virtio_queue_notify(vdev
, val
);
225 case VIRTIO_PCI_STATUS
:
226 virtio_set_status(vdev
, val
& 0xFF);
227 if (vdev
->status
== 0) {
228 virtio_reset(proxy
->vdev
);
229 msix_unuse_all_vectors(&proxy
->pci_dev
);
232 /* Linux before 2.6.34 sets the device as OK without enabling
233 the PCI device bus master bit. In this case we need to disable
234 some safety checks. */
235 if ((val
& VIRTIO_CONFIG_S_DRIVER_OK
) &&
236 !(proxy
->pci_dev
.config
[PCI_COMMAND
] & PCI_COMMAND_MASTER
)) {
237 proxy
->bugs
|= VIRTIO_PCI_BUG_BUS_MASTER
;
240 case VIRTIO_MSI_CONFIG_VECTOR
:
241 msix_vector_unuse(&proxy
->pci_dev
, vdev
->config_vector
);
242 /* Make it possible for guest to discover an error took place. */
243 if (msix_vector_use(&proxy
->pci_dev
, val
) < 0)
244 val
= VIRTIO_NO_VECTOR
;
245 vdev
->config_vector
= val
;
247 case VIRTIO_MSI_QUEUE_VECTOR
:
248 msix_vector_unuse(&proxy
->pci_dev
,
249 virtio_queue_vector(vdev
, vdev
->queue_sel
));
250 /* Make it possible for guest to discover an error took place. */
251 if (msix_vector_use(&proxy
->pci_dev
, val
) < 0)
252 val
= VIRTIO_NO_VECTOR
;
253 virtio_queue_set_vector(vdev
, vdev
->queue_sel
, val
);
256 fprintf(stderr
, "%s: unexpected address 0x%x value 0x%x\n",
257 __func__
, addr
, val
);
262 static uint32_t virtio_ioport_read(VirtIOPCIProxy
*proxy
, uint32_t addr
)
264 VirtIODevice
*vdev
= proxy
->vdev
;
265 uint32_t ret
= 0xFFFFFFFF;
268 case VIRTIO_PCI_HOST_FEATURES
:
269 ret
= proxy
->host_features
;
271 case VIRTIO_PCI_GUEST_FEATURES
:
272 ret
= vdev
->guest_features
;
274 case VIRTIO_PCI_QUEUE_PFN
:
275 ret
= virtio_queue_get_addr(vdev
, vdev
->queue_sel
)
276 >> VIRTIO_PCI_QUEUE_ADDR_SHIFT
;
278 case VIRTIO_PCI_QUEUE_NUM
:
279 ret
= virtio_queue_get_num(vdev
, vdev
->queue_sel
);
281 case VIRTIO_PCI_QUEUE_SEL
:
282 ret
= vdev
->queue_sel
;
284 case VIRTIO_PCI_STATUS
:
288 /* reading from the ISR also clears it. */
291 qemu_set_irq(proxy
->pci_dev
.irq
[0], 0);
293 case VIRTIO_MSI_CONFIG_VECTOR
:
294 ret
= vdev
->config_vector
;
296 case VIRTIO_MSI_QUEUE_VECTOR
:
297 ret
= virtio_queue_vector(vdev
, vdev
->queue_sel
);
306 static uint32_t virtio_pci_config_readb(void *opaque
, uint32_t addr
)
308 VirtIOPCIProxy
*proxy
= opaque
;
309 uint32_t config
= VIRTIO_PCI_CONFIG(&proxy
->pci_dev
);
312 return virtio_ioport_read(proxy
, addr
);
314 return virtio_config_readb(proxy
->vdev
, addr
);
317 static uint32_t virtio_pci_config_readw(void *opaque
, uint32_t addr
)
319 VirtIOPCIProxy
*proxy
= opaque
;
320 uint32_t config
= VIRTIO_PCI_CONFIG(&proxy
->pci_dev
);
323 return virtio_ioport_read(proxy
, addr
);
325 return virtio_config_readw(proxy
->vdev
, addr
);
328 static uint32_t virtio_pci_config_readl(void *opaque
, uint32_t addr
)
330 VirtIOPCIProxy
*proxy
= opaque
;
331 uint32_t config
= VIRTIO_PCI_CONFIG(&proxy
->pci_dev
);
334 return virtio_ioport_read(proxy
, addr
);
336 return virtio_config_readl(proxy
->vdev
, addr
);
339 static void virtio_pci_config_writeb(void *opaque
, uint32_t addr
, uint32_t val
)
341 VirtIOPCIProxy
*proxy
= opaque
;
342 uint32_t config
= VIRTIO_PCI_CONFIG(&proxy
->pci_dev
);
345 virtio_ioport_write(proxy
, addr
, val
);
349 virtio_config_writeb(proxy
->vdev
, addr
, val
);
352 static void virtio_pci_config_writew(void *opaque
, uint32_t addr
, uint32_t val
)
354 VirtIOPCIProxy
*proxy
= opaque
;
355 uint32_t config
= VIRTIO_PCI_CONFIG(&proxy
->pci_dev
);
358 virtio_ioport_write(proxy
, addr
, val
);
362 virtio_config_writew(proxy
->vdev
, addr
, val
);
365 static void virtio_pci_config_writel(void *opaque
, uint32_t addr
, uint32_t val
)
367 VirtIOPCIProxy
*proxy
= opaque
;
368 uint32_t config
= VIRTIO_PCI_CONFIG(&proxy
->pci_dev
);
371 virtio_ioport_write(proxy
, addr
, val
);
375 virtio_config_writel(proxy
->vdev
, addr
, val
);
378 static void virtio_map(PCIDevice
*pci_dev
, int region_num
,
379 pcibus_t addr
, pcibus_t size
, int type
)
381 VirtIOPCIProxy
*proxy
= container_of(pci_dev
, VirtIOPCIProxy
, pci_dev
);
382 VirtIODevice
*vdev
= proxy
->vdev
;
383 unsigned config_len
= VIRTIO_PCI_REGION_SIZE(pci_dev
) + vdev
->config_len
;
387 register_ioport_write(addr
, config_len
, 1, virtio_pci_config_writeb
, proxy
);
388 register_ioport_write(addr
, config_len
, 2, virtio_pci_config_writew
, proxy
);
389 register_ioport_write(addr
, config_len
, 4, virtio_pci_config_writel
, proxy
);
390 register_ioport_read(addr
, config_len
, 1, virtio_pci_config_readb
, proxy
);
391 register_ioport_read(addr
, config_len
, 2, virtio_pci_config_readw
, proxy
);
392 register_ioport_read(addr
, config_len
, 4, virtio_pci_config_readl
, proxy
);
394 if (vdev
->config_len
)
395 vdev
->get_config(vdev
, vdev
->config
);
398 static void virtio_write_config(PCIDevice
*pci_dev
, uint32_t address
,
399 uint32_t val
, int len
)
401 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
403 if (PCI_COMMAND
== address
) {
404 if (!(val
& PCI_COMMAND_MASTER
)) {
405 if (!(proxy
->bugs
& VIRTIO_PCI_BUG_BUS_MASTER
)) {
406 virtio_set_status(proxy
->vdev
,
407 proxy
->vdev
->status
& ~VIRTIO_CONFIG_S_DRIVER_OK
);
412 pci_default_write_config(pci_dev
, address
, val
, len
);
413 msix_write_config(pci_dev
, address
, val
, len
);
416 static unsigned virtio_pci_get_features(void *opaque
)
418 VirtIOPCIProxy
*proxy
= opaque
;
419 return proxy
->host_features
;
422 static void virtio_pci_guest_notifier_read(void *opaque
)
424 VirtQueue
*vq
= opaque
;
425 EventNotifier
*n
= virtio_queue_get_guest_notifier(vq
);
426 if (event_notifier_test_and_clear(n
)) {
431 static int virtio_pci_set_guest_notifier(void *opaque
, int n
, bool assign
)
433 VirtIOPCIProxy
*proxy
= opaque
;
434 VirtQueue
*vq
= virtio_get_queue(proxy
->vdev
, n
);
435 EventNotifier
*notifier
= virtio_queue_get_guest_notifier(vq
);
438 int r
= event_notifier_init(notifier
, 0);
442 qemu_set_fd_handler(event_notifier_get_fd(notifier
),
443 virtio_pci_guest_notifier_read
, NULL
, vq
);
445 qemu_set_fd_handler(event_notifier_get_fd(notifier
),
447 event_notifier_cleanup(notifier
);
453 static int virtio_pci_set_host_notifier(void *opaque
, int n
, bool assign
)
455 VirtIOPCIProxy
*proxy
= opaque
;
456 VirtQueue
*vq
= virtio_get_queue(proxy
->vdev
, n
);
457 EventNotifier
*notifier
= virtio_queue_get_host_notifier(vq
);
460 r
= event_notifier_init(notifier
, 1);
464 r
= kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier
),
465 proxy
->addr
+ VIRTIO_PCI_QUEUE_NOTIFY
,
468 event_notifier_cleanup(notifier
);
471 r
= kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier
),
472 proxy
->addr
+ VIRTIO_PCI_QUEUE_NOTIFY
,
477 event_notifier_cleanup(notifier
);
482 static const VirtIOBindings virtio_pci_bindings
= {
483 .notify
= virtio_pci_notify
,
484 .save_config
= virtio_pci_save_config
,
485 .load_config
= virtio_pci_load_config
,
486 .save_queue
= virtio_pci_save_queue
,
487 .load_queue
= virtio_pci_load_queue
,
488 .get_features
= virtio_pci_get_features
,
489 .set_host_notifier
= virtio_pci_set_host_notifier
,
490 .set_guest_notifier
= virtio_pci_set_guest_notifier
,
493 static void virtio_init_pci(VirtIOPCIProxy
*proxy
, VirtIODevice
*vdev
,
494 uint16_t vendor
, uint16_t device
,
495 uint16_t class_code
, uint8_t pif
)
502 config
= proxy
->pci_dev
.config
;
503 pci_config_set_vendor_id(config
, vendor
);
504 pci_config_set_device_id(config
, device
);
506 config
[0x08] = VIRTIO_PCI_ABI_VERSION
;
509 pci_config_set_class(config
, class_code
);
510 config
[PCI_HEADER_TYPE
] = PCI_HEADER_TYPE_NORMAL
;
512 config
[0x2c] = vendor
& 0xFF;
513 config
[0x2d] = (vendor
>> 8) & 0xFF;
514 config
[0x2e] = vdev
->device_id
& 0xFF;
515 config
[0x2f] = (vdev
->device_id
>> 8) & 0xFF;
519 if (vdev
->nvectors
&& !msix_init(&proxy
->pci_dev
, vdev
->nvectors
, 1, 0)) {
520 pci_register_bar(&proxy
->pci_dev
, 1,
521 msix_bar_size(&proxy
->pci_dev
),
522 PCI_BASE_ADDRESS_SPACE_MEMORY
,
527 proxy
->pci_dev
.config_write
= virtio_write_config
;
529 size
= VIRTIO_PCI_REGION_SIZE(&proxy
->pci_dev
) + vdev
->config_len
;
531 size
= 1 << qemu_fls(size
);
533 pci_register_bar(&proxy
->pci_dev
, 0, size
, PCI_BASE_ADDRESS_SPACE_IO
,
536 virtio_bind_device(vdev
, &virtio_pci_bindings
, proxy
);
537 proxy
->host_features
|= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY
;
538 proxy
->host_features
|= 0x1 << VIRTIO_F_BAD_FEATURE
;
539 proxy
->host_features
= vdev
->get_features(vdev
, proxy
->host_features
);
542 static int virtio_blk_init_pci(PCIDevice
*pci_dev
)
544 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
547 if (proxy
->class_code
!= PCI_CLASS_STORAGE_SCSI
&&
548 proxy
->class_code
!= PCI_CLASS_STORAGE_OTHER
)
549 proxy
->class_code
= PCI_CLASS_STORAGE_SCSI
;
551 if (!proxy
->block
.dinfo
) {
552 error_report("virtio-blk-pci: drive property not set");
555 vdev
= virtio_blk_init(&pci_dev
->qdev
, &proxy
->block
);
556 vdev
->nvectors
= proxy
->nvectors
;
557 virtio_init_pci(proxy
, vdev
,
558 PCI_VENDOR_ID_REDHAT_QUMRANET
,
559 PCI_DEVICE_ID_VIRTIO_BLOCK
,
560 proxy
->class_code
, 0x00);
561 /* make the actual value visible */
562 proxy
->nvectors
= vdev
->nvectors
;
566 static int virtio_exit_pci(PCIDevice
*pci_dev
)
568 return msix_uninit(pci_dev
);
571 static int virtio_blk_exit_pci(PCIDevice
*pci_dev
)
573 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
575 drive_uninit(proxy
->block
.dinfo
);
576 return virtio_exit_pci(pci_dev
);
579 static int virtio_serial_init_pci(PCIDevice
*pci_dev
)
581 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
584 if (proxy
->class_code
!= PCI_CLASS_COMMUNICATION_OTHER
&&
585 proxy
->class_code
!= PCI_CLASS_DISPLAY_OTHER
&& /* qemu 0.10 */
586 proxy
->class_code
!= PCI_CLASS_OTHERS
) /* qemu-kvm */
587 proxy
->class_code
= PCI_CLASS_COMMUNICATION_OTHER
;
589 vdev
= virtio_serial_init(&pci_dev
->qdev
, proxy
->max_virtserial_ports
);
593 vdev
->nvectors
= proxy
->nvectors
== DEV_NVECTORS_UNSPECIFIED
594 ? proxy
->max_virtserial_ports
+ 1
596 virtio_init_pci(proxy
, vdev
,
597 PCI_VENDOR_ID_REDHAT_QUMRANET
,
598 PCI_DEVICE_ID_VIRTIO_CONSOLE
,
599 proxy
->class_code
, 0x00);
600 proxy
->nvectors
= vdev
->nvectors
;
604 static int virtio_net_init_pci(PCIDevice
*pci_dev
)
606 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
609 vdev
= virtio_net_init(&pci_dev
->qdev
, &proxy
->nic
);
611 vdev
->nvectors
= proxy
->nvectors
;
612 virtio_init_pci(proxy
, vdev
,
613 PCI_VENDOR_ID_REDHAT_QUMRANET
,
614 PCI_DEVICE_ID_VIRTIO_NET
,
615 PCI_CLASS_NETWORK_ETHERNET
,
618 /* make the actual value visible */
619 proxy
->nvectors
= vdev
->nvectors
;
623 static int virtio_net_exit_pci(PCIDevice
*pci_dev
)
625 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
627 virtio_net_exit(proxy
->vdev
);
628 return virtio_exit_pci(pci_dev
);
631 static int virtio_balloon_init_pci(PCIDevice
*pci_dev
)
633 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
636 vdev
= virtio_balloon_init(&pci_dev
->qdev
);
637 virtio_init_pci(proxy
, vdev
,
638 PCI_VENDOR_ID_REDHAT_QUMRANET
,
639 PCI_DEVICE_ID_VIRTIO_BALLOON
,
640 PCI_CLASS_MEMORY_RAM
,
646 static int virtio_9p_init_pci(PCIDevice
*pci_dev
)
648 VirtIOPCIProxy
*proxy
= DO_UPCAST(VirtIOPCIProxy
, pci_dev
, pci_dev
);
651 vdev
= virtio_9p_init(&pci_dev
->qdev
, &proxy
->fsconf
);
652 virtio_init_pci(proxy
, vdev
,
653 PCI_VENDOR_ID_REDHAT_QUMRANET
,
662 static PCIDeviceInfo virtio_info
[] = {
664 .qdev
.name
= "virtio-blk-pci",
665 .qdev
.size
= sizeof(VirtIOPCIProxy
),
666 .init
= virtio_blk_init_pci
,
667 .exit
= virtio_blk_exit_pci
,
668 .qdev
.props
= (Property
[]) {
669 DEFINE_PROP_HEX32("class", VirtIOPCIProxy
, class_code
, 0),
670 DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy
, block
),
671 DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy
, nvectors
, 2),
672 DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy
, host_features
),
673 DEFINE_PROP_END_OF_LIST(),
675 .qdev
.reset
= virtio_pci_reset
,
677 .qdev
.name
= "virtio-net-pci",
678 .qdev
.size
= sizeof(VirtIOPCIProxy
),
679 .init
= virtio_net_init_pci
,
680 .exit
= virtio_net_exit_pci
,
681 .romfile
= "pxe-virtio.bin",
682 .qdev
.props
= (Property
[]) {
683 DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy
, nvectors
, 3),
684 DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy
, host_features
),
685 DEFINE_NIC_PROPERTIES(VirtIOPCIProxy
, nic
),
686 DEFINE_PROP_END_OF_LIST(),
688 .qdev
.reset
= virtio_pci_reset
,
690 .qdev
.name
= "virtio-serial-pci",
691 .qdev
.alias
= "virtio-serial",
692 .qdev
.size
= sizeof(VirtIOPCIProxy
),
693 .init
= virtio_serial_init_pci
,
694 .exit
= virtio_exit_pci
,
695 .qdev
.props
= (Property
[]) {
696 DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy
, nvectors
,
697 DEV_NVECTORS_UNSPECIFIED
),
698 DEFINE_PROP_HEX32("class", VirtIOPCIProxy
, class_code
, 0),
699 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy
, host_features
),
700 DEFINE_PROP_UINT32("max_ports", VirtIOPCIProxy
, max_virtserial_ports
,
702 DEFINE_PROP_END_OF_LIST(),
704 .qdev
.reset
= virtio_pci_reset
,
706 .qdev
.name
= "virtio-balloon-pci",
707 .qdev
.size
= sizeof(VirtIOPCIProxy
),
708 .init
= virtio_balloon_init_pci
,
709 .exit
= virtio_exit_pci
,
710 .qdev
.props
= (Property
[]) {
711 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy
, host_features
),
712 DEFINE_PROP_END_OF_LIST(),
714 .qdev
.reset
= virtio_pci_reset
,
717 .qdev
.name
= "virtio-9p-pci",
718 .qdev
.size
= sizeof(VirtIOPCIProxy
),
719 .init
= virtio_9p_init_pci
,
720 .qdev
.props
= (Property
[]) {
721 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy
, host_features
),
722 DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy
, fsconf
.tag
),
723 DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy
, fsconf
.fsdev_id
),
724 DEFINE_PROP_END_OF_LIST(),
732 static void virtio_pci_register_devices(void)
734 pci_qdev_register_many(virtio_info
);
737 device_init(virtio_pci_register_devices
)