Revision e75ccf2c

b/hw/virtio-pci.c
669 669
    .vmstate_change = virtio_pci_vmstate_change,
670 670
};
671 671

  
672
static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
673
                            uint16_t vendor, uint16_t device,
674
                            uint16_t class_code, uint8_t pif)
672
static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev)
675 673
{
676 674
    uint8_t *config;
677 675
    uint32_t size;
......
679 677
    proxy->vdev = vdev;
680 678

  
681 679
    config = proxy->pci_dev.config;
682
    pci_config_set_vendor_id(config, vendor);
683
    pci_config_set_device_id(config, device);
684

  
685
    config[0x08] = VIRTIO_PCI_ABI_VERSION;
686

  
687
    config[0x09] = pif;
688
    pci_config_set_class(config, class_code);
689

  
690
    config[0x2c] = vendor & 0xFF;
691
    config[0x2d] = (vendor >> 8) & 0xFF;
692
    config[0x2e] = vdev->device_id & 0xFF;
693
    config[0x2f] = (vdev->device_id >> 8) & 0xFF;
694 680

  
681
    if (proxy->class_code) {
682
        pci_config_set_class(config, proxy->class_code);
683
    }
684
    pci_set_word(config + 0x2c, pci_get_word(config + PCI_VENDOR_ID));
685
    pci_set_word(config + 0x2e, vdev->device_id);
695 686
    config[0x3d] = 1;
696 687

  
697 688
    if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0)) {
......
735 726
        return -1;
736 727
    }
737 728
    vdev->nvectors = proxy->nvectors;
738
    virtio_init_pci(proxy, vdev,
739
                    PCI_VENDOR_ID_REDHAT_QUMRANET,
740
                    PCI_DEVICE_ID_VIRTIO_BLOCK,
741
                    proxy->class_code, 0x00);
729
    virtio_init_pci(proxy, vdev);
742 730
    /* make the actual value visible */
743 731
    proxy->nvectors = vdev->nvectors;
744 732
    return 0;
......
776 764
    vdev->nvectors = proxy->nvectors == DEV_NVECTORS_UNSPECIFIED
777 765
                                        ? proxy->serial.max_virtserial_ports + 1
778 766
                                        : proxy->nvectors;
779
    virtio_init_pci(proxy, vdev,
780
                    PCI_VENDOR_ID_REDHAT_QUMRANET,
781
                    PCI_DEVICE_ID_VIRTIO_CONSOLE,
782
                    proxy->class_code, 0x00);
767
    virtio_init_pci(proxy, vdev);
783 768
    proxy->nvectors = vdev->nvectors;
784 769
    return 0;
785 770
}
......
801 786
    vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic, &proxy->net);
802 787

  
803 788
    vdev->nvectors = proxy->nvectors;
804
    virtio_init_pci(proxy, vdev,
805
                    PCI_VENDOR_ID_REDHAT_QUMRANET,
806
                    PCI_DEVICE_ID_VIRTIO_NET,
807
                    PCI_CLASS_NETWORK_ETHERNET,
808
                    0x00);
789
    virtio_init_pci(proxy, vdev);
809 790

  
810 791
    /* make the actual value visible */
811 792
    proxy->nvectors = vdev->nvectors;
......
827 808
    VirtIODevice *vdev;
828 809

  
829 810
    vdev = virtio_balloon_init(&pci_dev->qdev);
830
    virtio_init_pci(proxy, vdev,
831
                    PCI_VENDOR_ID_REDHAT_QUMRANET,
832
                    PCI_DEVICE_ID_VIRTIO_BALLOON,
833
                    PCI_CLASS_MEMORY_RAM,
834
                    0x00);
811
    virtio_init_pci(proxy, vdev);
835 812
    return 0;
836 813
}
837 814

  
......
843 820

  
844 821
    vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
845 822
    vdev->nvectors = proxy->nvectors;
846
    virtio_init_pci(proxy, vdev,
847
                    PCI_VENDOR_ID_REDHAT_QUMRANET,
848
                    0x1009,
849
                    0x2,
850
                    0x00);
823
    virtio_init_pci(proxy, vdev);
851 824
    /* make the actual value visible */
852 825
    proxy->nvectors = vdev->nvectors;
853 826
    return 0;
......
861 834
        .qdev.size = sizeof(VirtIOPCIProxy),
862 835
        .init      = virtio_blk_init_pci,
863 836
        .exit      = virtio_blk_exit_pci,
837
        .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
838
        .device_id = PCI_DEVICE_ID_VIRTIO_BLOCK,
839
        .revision  = VIRTIO_PCI_ABI_VERSION,
840
        .class_id  = PCI_CLASS_STORAGE_SCSI,
864 841
        .qdev.props = (Property[]) {
865 842
            DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
866 843
            DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
......
878 855
        .init       = virtio_net_init_pci,
879 856
        .exit       = virtio_net_exit_pci,
880 857
        .romfile    = "pxe-virtio.rom",
858
        .vendor_id  = PCI_VENDOR_ID_REDHAT_QUMRANET,
859
        .device_id  = PCI_DEVICE_ID_VIRTIO_NET,
860
        .revision   = VIRTIO_PCI_ABI_VERSION,
861
        .class_id   = PCI_CLASS_NETWORK_ETHERNET,
881 862
        .qdev.props = (Property[]) {
882 863
            DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
883 864
                            VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
......
898 879
        .qdev.size = sizeof(VirtIOPCIProxy),
899 880
        .init      = virtio_serial_init_pci,
900 881
        .exit      = virtio_serial_exit_pci,
882
        .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
883
        .device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE,
884
        .revision  = VIRTIO_PCI_ABI_VERSION,
885
        .class_id  = PCI_CLASS_COMMUNICATION_OTHER,
901 886
        .qdev.props = (Property[]) {
902 887
            DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
903 888
                            VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
......
916 901
        .qdev.size = sizeof(VirtIOPCIProxy),
917 902
        .init      = virtio_balloon_init_pci,
918 903
        .exit      = virtio_exit_pci,
904
        .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
905
        .device_id = PCI_DEVICE_ID_VIRTIO_BALLOON,
906
        .revision  = VIRTIO_PCI_ABI_VERSION,
907
        .class_id  = PCI_CLASS_MEMORY_RAM,
919 908
        .qdev.props = (Property[]) {
920 909
            DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
921 910
            DEFINE_PROP_END_OF_LIST(),
......
927 916
        .qdev.alias = "virtio-9p",
928 917
        .qdev.size = sizeof(VirtIOPCIProxy),
929 918
        .init      = virtio_9p_init_pci,
919
        .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
920
        .device_id = 0x1009,
921
        .revision  = VIRTIO_PCI_ABI_VERSION,
922
        .class_id  = 0x2,
930 923
        .qdev.props = (Property[]) {
931 924
            DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
932 925
            DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),

Also available in: Unified diff