Commit ab73ff29ceb785aad3fc182e09d702ccee2e5559
Committed by
Anthony Liguori
1 parent
ccb63de3
qdev/compat: virtio-blk-pci 0.10 compatibility.
Add class property to virtio-blk-pci allowing to specify the PCI class. Add compat property to pc-0.10 to set the old PCI class. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
2 changed files
with
21 additions
and
1 deletions
hw/pc.c
... | ... | @@ -1525,6 +1525,11 @@ static QEMUMachine pc_machine_v0_10 = { |
1525 | 1525 | .init = pc_init_pci, |
1526 | 1526 | .max_cpus = 255, |
1527 | 1527 | .compat_props = (CompatProperty[]) { |
1528 | + { | |
1529 | + .driver = "virtio-blk-pci", | |
1530 | + .property = "class", | |
1531 | + .value = stringify(PCI_CLASS_STORAGE_OTHER), | |
1532 | + }, | |
1528 | 1533 | { /* end of list */ } |
1529 | 1534 | }, |
1530 | 1535 | }; | ... | ... |
hw/virtio-pci.c
... | ... | @@ -86,6 +86,7 @@ typedef struct { |
86 | 86 | PCIDevice pci_dev; |
87 | 87 | VirtIODevice *vdev; |
88 | 88 | uint32_t addr; |
89 | + uint32_t class_code; | |
89 | 90 | } VirtIOPCIProxy; |
90 | 91 | |
91 | 92 | /* virtio device */ |
... | ... | @@ -435,7 +436,13 @@ static void virtio_blk_init_pci_with_class(PCIDevice *pci_dev, |
435 | 436 | |
436 | 437 | static void virtio_blk_init_pci(PCIDevice *pci_dev) |
437 | 438 | { |
438 | - virtio_blk_init_pci_with_class(pci_dev, PCI_CLASS_STORAGE_SCSI); | |
439 | + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); | |
440 | + | |
441 | + if (proxy->class_code != PCI_CLASS_STORAGE_SCSI && | |
442 | + proxy->class_code != PCI_CLASS_STORAGE_OTHER) | |
443 | + proxy->class_code = PCI_CLASS_STORAGE_SCSI; | |
444 | + | |
445 | + virtio_blk_init_pci_with_class(pci_dev, proxy->class_code); | |
439 | 446 | } |
440 | 447 | |
441 | 448 | static void virtio_blk_init_pci_0_10(PCIDevice *pci_dev) |
... | ... | @@ -497,6 +504,14 @@ static PCIDeviceInfo virtio_info[] = { |
497 | 504 | .qdev.name = "virtio-blk-pci", |
498 | 505 | .qdev.size = sizeof(VirtIOPCIProxy), |
499 | 506 | .init = virtio_blk_init_pci, |
507 | + .qdev.props = (Property[]) { | |
508 | + { | |
509 | + .name = "class", | |
510 | + .info = &qdev_prop_hex32, | |
511 | + .offset = offsetof(VirtIOPCIProxy, class_code), | |
512 | + }, | |
513 | + {/* end of list */} | |
514 | + }, | |
500 | 515 | },{ |
501 | 516 | .qdev.name = "virtio-net-pci", |
502 | 517 | .qdev.size = sizeof(VirtIOPCIProxy), | ... | ... |