Revision e348918e include/HostShare.h
include/HostShare.h | ||
---|---|---|
75 | 75 |
int from_xml_node(const xmlNodePtr node); |
76 | 76 |
|
77 | 77 |
/** |
78 |
* Test wether this PCI device set has the requested devices available. |
|
78 |
* Test whether this PCI device set has the requested devices available.
|
|
79 | 79 |
* @param devs list of requested devices by the VM. |
80 | 80 |
* @return true if all the devices are available. |
81 | 81 |
*/ |
82 |
bool test(vector<Attribute *> &devs) |
|
83 |
{ |
|
84 |
return test_set(devs, -1); |
|
85 |
} |
|
82 |
bool test(vector<Attribute *> &devs) const; |
|
86 | 83 |
|
87 | 84 |
/** |
88 |
* Assign the requested devices to the given VM. The assgined devices will
|
|
85 |
* Assign the requested devices to the given VM. The assigned devices will
|
|
89 | 86 |
* be labeled with the VM and the PCI attribute of the VM extended with |
90 | 87 |
* the address of the assigned devices. |
91 | 88 |
* @param devs list of requested PCI devices, will include address of |
92 |
* assgined devices.
|
|
89 |
* assigned devices.
|
|
93 | 90 |
* @param vmid of the VM |
94 | 91 |
*/ |
95 | 92 |
void add(vector<Attribute *> &devs, int vmid) |
... | ... | |
98 | 95 |
} |
99 | 96 |
|
100 | 97 |
/** |
101 |
* Remove the VM assigment from the PCI device list |
|
98 |
* Remove the VM assignment from the PCI device list
|
|
102 | 99 |
*/ |
103 | 100 |
void del(const vector<Attribute *> &devs); |
104 | 101 |
|
... | ... | |
122 | 119 |
|
123 | 120 |
/** |
124 | 121 |
* Test if a PCIDevice matches the vendor, device and class request spec |
125 |
* and can be assigned. It will assgin it if requested.
|
|
122 |
* and can be assigned. If free, it is stored in the assigned set
|
|
126 | 123 |
* @param vendor_id id in uint form 0 means * |
127 | 124 |
* @param device_id id in uint form 0 means * |
128 | 125 |
* @param class_id id in uint form 0 means * |
129 | 126 |
* @param pci requested pci device |
130 | 127 |
* @param vmid if not -1 it will also assign the PCI device to the VM, |
131 | 128 |
* and the pci attribute will be extended with device information. |
132 |
* @param assgined set of addresses already assgined devices, it will |
|
129 |
* @param assigned set of addresses already assigned devices, it will |
|
130 |
* include the selected device if found; useful to iterate. |
|
131 |
* |
|
132 |
* @return true if a device was found. |
|
133 |
*/ |
|
134 |
bool test(unsigned int vendor_id, unsigned int device_id, |
|
135 |
unsigned int class_id, const VectorAttribute *pci, |
|
136 |
std::set<string> &assigned) const; |
|
137 |
|
|
138 |
/** |
|
139 |
* Test if a PCIDevice matches the vendor, device and class request spec |
|
140 |
* and can be assigned. It will assign it if requested. |
|
141 |
* @param vendor_id id in uint form 0 means * |
|
142 |
* @param device_id id in uint form 0 means * |
|
143 |
* @param class_id id in uint form 0 means * |
|
144 |
* @param pci requested pci device |
|
145 |
* @param vmid if not -1 it will also assign the PCI device to the VM, |
|
146 |
* and the pci attribute will be extended with device information. |
|
147 |
* @param assigned set of addresses already assigned devices, it will |
|
133 | 148 |
* include the selected device if found; useful to iterate. |
134 | 149 |
* |
135 | 150 |
* @return true if a device was found. |
136 | 151 |
*/ |
137 | 152 |
bool test_set(unsigned int vendor_id, unsigned int device_id, |
138 | 153 |
unsigned int class_id, VectorAttribute *pci, int vmid, |
139 |
std::set<string> &assigned); |
|
154 |
std::set<string> &assigned) const;
|
|
140 | 155 |
|
141 | 156 |
/** |
142 | 157 |
* Test if the given list of PCIDevices can be assigned to the VM |
143 | 158 |
* @param devs, list of PCI devices |
144 | 159 |
* @param vmid if not -1 it will assign the devices to the VM |
145 | 160 |
* |
146 |
* @return true if the PCIDevice list can be assgined.
|
|
161 |
* @return true if the PCIDevice list can be assigned.
|
|
147 | 162 |
*/ |
148 |
bool test_set(vector<Attribute *> &devs, int vmid); |
|
163 |
bool test_set(vector<Attribute *> &devs, int vmid) const;
|
|
149 | 164 |
|
150 | 165 |
/** |
151 | 166 |
* Gets a 4 hex digits value from attribute |
... | ... | |
249 | 264 |
* @param cpu requested by the VM |
250 | 265 |
* @param mem requested by the VM |
251 | 266 |
* @param disk requested by the VM |
267 |
* @param pci_devs requested by the VM |
|
268 |
* @param error Returns the error reason, if any |
|
252 | 269 |
* |
253 | 270 |
* @return true if the share can host the VM or it is the only one |
254 | 271 |
* configured |
255 | 272 |
*/ |
256 |
bool test(long long cpu, long long mem, long long disk) const |
|
273 |
bool test(long long cpu, long long mem, long long disk, |
|
274 |
vector<Attribute *>& pci_devs, string& error) const |
|
257 | 275 |
{ |
258 |
return (((max_cpu - cpu_usage ) >= cpu) && |
|
259 |
((max_mem - mem_usage ) >= mem) && |
|
260 |
((max_disk - disk_usage) >= disk)); |
|
276 |
bool pci_fits = pci.test(pci_devs); |
|
277 |
|
|
278 |
bool fits = (((max_cpu - cpu_usage ) >= cpu) && |
|
279 |
((max_mem - mem_usage ) >= mem) && |
|
280 |
((max_disk - disk_usage) >= disk)&& |
|
281 |
pci_fits); |
|
282 |
|
|
283 |
if (!fits) |
|
284 |
{ |
|
285 |
if ( pci_fits ) |
|
286 |
{ |
|
287 |
error = "Not enough capacity."; |
|
288 |
} |
|
289 |
else |
|
290 |
{ |
|
291 |
error = "Unavailable PCI device."; |
|
292 |
} |
|
293 |
} |
|
294 |
|
|
295 |
return fits; |
|
261 | 296 |
} |
262 | 297 |
|
263 | 298 |
/** |
Also available in: Unified diff