Revision e348918e src/host/HostShare.cc

View differences:

src/host/HostShare.cc
67 67
/* ------------------------------------------------------------------------*/
68 68
/* ------------------------------------------------------------------------*/
69 69

  
70
bool HostSharePCI::test(unsigned int vendor_id, unsigned int device_id,
71
        unsigned int class_id, const VectorAttribute * devreq,
72
        std::set<string>& assigned) const
73
{
74
    map<string, PCIDevice *>::const_iterator it;
75

  
76
    for (it=pci_devices.begin(); it!=pci_devices.end(); it++)
77
    {
78
        PCIDevice * dev = it->second;
79

  
80
        if ((class_id  == 0 || dev->class_id  == class_id)  &&
81
            (vendor_id == 0 || dev->vendor_id == vendor_id) &&
82
            (device_id == 0 || dev->device_id == device_id) &&
83
            dev->vmid  == -1 &&
84
            assigned.find(dev->address) == assigned.end())
85
        {
86
            assigned.insert(dev->address);
87

  
88
            return true;
89
        }
90
    }
91

  
92
    return false;
93
}
94

  
95
/* ------------------------------------------------------------------------*/
96

  
97
bool HostSharePCI::test(vector<Attribute *> &devs) const
98
{
99
    vector<Attribute *>::iterator it;
100
    std::set<string> assigned;
101

  
102
    unsigned int vendor_id, device_id, class_id;
103

  
104
    for ( it=devs.begin(); it!= devs.end(); it++)
105
    {
106
        VectorAttribute * pci = dynamic_cast<VectorAttribute *>(*it);
107

  
108
        if ( pci == 0 )
109
        {
110
            return false;
111
        }
112

  
113
        vendor_id = get_pci_value("VENDOR", pci);
114
        device_id = get_pci_value("DEVICE", pci);
115
        class_id  = get_pci_value("CLASS", pci);
116

  
117
        if (!test(vendor_id, device_id, class_id, pci, assigned))
118
        {
119
            return false;
120
        }
121
    }
122

  
123
    return true;
124
}
125

  
126

  
127
/* ------------------------------------------------------------------------*/
128
/* ------------------------------------------------------------------------*/
129

  
70 130
bool HostSharePCI::test_set(unsigned int vendor_id, unsigned int device_id,
71 131
        unsigned int class_id, VectorAttribute * devreq, int vmid,
72
        std::set<string>& assigned)
132
        std::set<string>& assigned) const
73 133
{
74
    map<string, PCIDevice *>::iterator it;
134
    map<string, PCIDevice *>::const_iterator it;
75 135

  
76 136
    for (it=pci_devices.begin(); it!=pci_devices.end(); it++)
77 137
    {
......
107 167

  
108 168
/* ------------------------------------------------------------------------*/
109 169

  
110
bool HostSharePCI::test_set(vector<Attribute *> &devs, int vmid)
170
bool HostSharePCI::test_set(vector<Attribute *> &devs, int vmid) const
111 171
{
112 172
    vector<Attribute *>::iterator it;
113 173
    std::set<string> assigned;

Also available in: Unified diff