Revision ca2a1a42
include/Host.h | ||
---|---|---|
402 | 402 |
*/ |
403 | 403 |
const set<int>& get_prev_rediscovered_vms() const |
404 | 404 |
{ |
405 |
return prev_rediscovered_vms; |
|
405 |
return *prev_rediscovered_vms;
|
|
406 | 406 |
} |
407 | 407 |
|
408 | 408 |
/** |
... | ... | |
412 | 412 |
*/ |
413 | 413 |
void set_prev_rediscovered_vms(const set<int>& rediscovered_vms) |
414 | 414 |
{ |
415 |
prev_rediscovered_vms = rediscovered_vms; |
|
415 |
*prev_rediscovered_vms = rediscovered_vms;
|
|
416 | 416 |
} |
417 | 417 |
|
418 | 418 |
private: |
... | ... | |
453 | 453 |
/** |
454 | 454 |
* The Share represents the logical capacity associated with the host |
455 | 455 |
*/ |
456 |
HostShare host_share;
|
|
456 |
HostShare host_share; |
|
457 | 457 |
|
458 | 458 |
/** |
459 | 459 |
* Tmp set of lost VM IDs. Used to give lost VMs one grace cycle, in case |
460 | 460 |
* they reappear. |
461 | 461 |
*/ |
462 |
set<int> tmp_lost_vms;
|
|
462 |
set<int> * tmp_lost_vms;
|
|
463 | 463 |
|
464 | 464 |
/** |
465 | 465 |
* Tmp set of zombie VM IDs. Used to give zombie VMs one grace cycle, in |
466 | 466 |
* case they are cleaned. |
467 | 467 |
*/ |
468 |
set<int> tmp_zombie_vms;
|
|
468 |
set<int> * tmp_zombie_vms;
|
|
469 | 469 |
|
470 | 470 |
/** |
471 | 471 |
* Set that stores the VMs reported as found from the poweroff state. This |
472 | 472 |
* is managed from outside the host to avoid deadlocks, as the current |
473 | 473 |
* VM state is needed |
474 | 474 |
*/ |
475 |
set<int> prev_rediscovered_vms;
|
|
475 |
set<int> * prev_rediscovered_vms;
|
|
476 | 476 |
|
477 | 477 |
// ------------------------------------------------------------------------- |
478 | 478 |
// VM Collection |
include/HostPool.h | ||
---|---|---|
39 | 39 |
const string& hook_location, const string& remotes_location, |
40 | 40 |
time_t expire_time); |
41 | 41 |
|
42 |
~HostPool(){};
|
|
42 |
~HostPool(); |
|
43 | 43 |
|
44 | 44 |
/** |
45 | 45 |
* Function to allocate a new Host object |
... | ... | |
66 | 66 |
int oid, |
67 | 67 |
bool lock) |
68 | 68 |
{ |
69 |
return static_cast<Host *>(PoolSQL::get(oid,lock)); |
|
69 |
Host * h = static_cast<Host *>(PoolSQL::get(oid,lock)); |
|
70 |
|
|
71 |
if ( h != 0 ) |
|
72 |
{ |
|
73 |
HostVM * hv = get_host_vm(oid); |
|
74 |
|
|
75 |
h->tmp_lost_vms = &(hv->tmp_lost_vms); |
|
76 |
h->tmp_zombie_vms = &(hv->tmp_zombie_vms); |
|
77 |
|
|
78 |
h->prev_rediscovered_vms = &(hv->prev_rediscovered_vms); |
|
79 |
} |
|
80 |
|
|
81 |
return h; |
|
70 | 82 |
}; |
71 | 83 |
|
72 | 84 |
/** |
... | ... | |
79 | 91 |
Host * get(string name, bool lock) |
80 | 92 |
{ |
81 | 93 |
// The owner is set to -1, because it is not used in the key() method |
82 |
return static_cast<Host *>(PoolSQL::get(name,-1,lock)); |
|
94 |
Host * h = static_cast<Host *>(PoolSQL::get(name,-1,lock)); |
|
95 |
|
|
96 |
if ( h != 0 ) |
|
97 |
{ |
|
98 |
HostVM * hv = get_host_vm(h->oid); |
|
99 |
|
|
100 |
h->tmp_lost_vms = &(hv->tmp_lost_vms); |
|
101 |
h->tmp_zombie_vms = &(hv->tmp_zombie_vms); |
|
102 |
|
|
103 |
h->prev_rediscovered_vms = &(hv->prev_rediscovered_vms); |
|
104 |
} |
|
105 |
|
|
106 |
return h; |
|
83 | 107 |
}; |
84 | 108 |
|
85 | 109 |
/** |
... | ... | |
180 | 204 |
return -1; |
181 | 205 |
} |
182 | 206 |
|
183 |
return PoolSQL::drop(objsql, error_msg); |
|
207 |
int rc = PoolSQL::drop(objsql, error_msg); |
|
208 |
|
|
209 |
if ( rc == 0 ) |
|
210 |
{ |
|
211 |
delete_host_vm(host->oid); |
|
212 |
} |
|
213 |
|
|
214 |
return rc; |
|
184 | 215 |
}; |
185 | 216 |
|
186 | 217 |
/** |
... | ... | |
265 | 296 |
int clean_expired_monitoring(); |
266 | 297 |
|
267 | 298 |
private: |
299 |
/** |
|
300 |
* Stores several Host counters to give VMs one monitor grace cycle before |
|
301 |
* moving them to another state |
|
302 |
*/ |
|
303 |
struct HostVM |
|
304 |
{ |
|
305 |
/** |
|
306 |
* Tmp set of lost VM IDs. |
|
307 |
*/ |
|
308 |
set<int> tmp_lost_vms; |
|
309 |
|
|
310 |
/** |
|
311 |
* Tmp set of zombie VM IDs. |
|
312 |
*/ |
|
313 |
set<int> tmp_zombie_vms; |
|
314 |
|
|
315 |
/** |
|
316 |
* VMs reported as found from the poweroff state. |
|
317 |
*/ |
|
318 |
set<int> prev_rediscovered_vms; |
|
319 |
}; |
|
320 |
|
|
321 |
map<int, HostVM *> host_vms; |
|
322 |
|
|
323 |
HostVM * get_host_vm(int oid); |
|
324 |
|
|
325 |
void delete_host_vm(int oid); |
|
268 | 326 |
|
269 | 327 |
/** |
270 | 328 |
* Factory method to produce Host objects |
src/host/Host.cc | ||
---|---|---|
253 | 253 |
set<int>::iterator set_it; |
254 | 254 |
map<int,string>::iterator map_it; |
255 | 255 |
|
256 |
set<int> prev_tmp_lost = tmp_lost_vms; |
|
257 |
set<int> prev_tmp_zombie = tmp_zombie_vms; |
|
256 |
set<int> prev_tmp_lost = *tmp_lost_vms;
|
|
257 |
set<int> prev_tmp_zombie = *tmp_zombie_vms;
|
|
258 | 258 |
|
259 | 259 |
int num_zombies = 0; |
260 | 260 |
int num_wilds = 0; |
... | ... | |
298 | 298 |
|
299 | 299 |
obj_template->remove("VM", vm_att); |
300 | 300 |
|
301 |
tmp_lost_vms = vm_collection.clone(); |
|
301 |
*tmp_lost_vms = vm_collection.clone();
|
|
302 | 302 |
|
303 |
tmp_zombie_vms.clear();
|
|
303 |
tmp_zombie_vms->clear();
|
|
304 | 304 |
|
305 | 305 |
for (it = vm_att.begin(); it != vm_att.end(); it++) |
306 | 306 |
{ |
... | ... | |
328 | 328 |
|
329 | 329 |
it_vm = found.find(vmid); |
330 | 330 |
|
331 |
if ( tmp_lost_vms.erase(vmid) == 1 ) //Good, known
|
|
331 |
if ( tmp_lost_vms->erase(vmid) == 1 ) //Good, known
|
|
332 | 332 |
{ |
333 | 333 |
found.insert(make_pair(vmid, vatt->vector_value("POLL"))); |
334 | 334 |
} |
... | ... | |
338 | 338 |
} |
339 | 339 |
else //Bad, known but should not be here |
340 | 340 |
{ |
341 |
tmp_zombie_vms.insert(vmid);
|
|
341 |
tmp_zombie_vms->insert(vmid);
|
|
342 | 342 |
|
343 | 343 |
// Reported as zombie at least 2 times? |
344 | 344 |
if (prev_tmp_zombie.count(vmid) == 1) |
... | ... | |
389 | 389 |
{ |
390 | 390 |
if ( one_util::regex_match("STATE=. ",map_it->second.c_str()) != 0 ) |
391 | 391 |
{ |
392 |
tmp_lost_vms.insert(map_it->first);
|
|
392 |
tmp_lost_vms->insert(map_it->first);
|
|
393 | 393 |
found.erase(map_it++); |
394 | 394 |
} |
395 | 395 |
else |
... | ... | |
398 | 398 |
} |
399 | 399 |
} |
400 | 400 |
|
401 |
for(set_it = tmp_lost_vms.begin(); set_it != tmp_lost_vms.end(); set_it++)
|
|
401 |
for(set_it = tmp_lost_vms->begin(); set_it != tmp_lost_vms->end(); set_it++)
|
|
402 | 402 |
{ |
403 | 403 |
// Reported as lost at least 2 times? |
404 | 404 |
if (prev_tmp_lost.count(*set_it) == 1) |
src/host/HostPool.cc | ||
---|---|---|
145 | 145 |
/* -------------------------------------------------------------------------- */ |
146 | 146 |
/* -------------------------------------------------------------------------- */ |
147 | 147 |
|
148 |
HostPool::~HostPool() |
|
149 |
{ |
|
150 |
map<int, HostVM *>::iterator it; |
|
151 |
|
|
152 |
for (it=host_vms.begin(); it != host_vms.end() ; ++it) |
|
153 |
{ |
|
154 |
delete it->second; |
|
155 |
} |
|
156 |
}; |
|
157 |
|
|
158 |
/* -------------------------------------------------------------------------- */ |
|
159 |
/* -------------------------------------------------------------------------- */ |
|
160 |
|
|
148 | 161 |
int HostPool::allocate ( |
149 | 162 |
int * oid, |
150 | 163 |
const string& hostname, |
... | ... | |
322 | 335 |
|
323 | 336 |
return rc; |
324 | 337 |
} |
338 |
|
|
339 |
/* -------------------------------------------------------------------------- */ |
|
340 |
/* -------------------------------------------------------------------------- */ |
|
341 |
|
|
342 |
HostPool::HostVM * HostPool::get_host_vm(int oid) |
|
343 |
{ |
|
344 |
HostVM * hvm; |
|
345 |
|
|
346 |
map<int, HostVM *>::iterator it = host_vms.find(oid); |
|
347 |
|
|
348 |
if ( it == host_vms.end() ) |
|
349 |
{ |
|
350 |
hvm = new HostVM; |
|
351 |
|
|
352 |
host_vms.insert(make_pair(oid, new HostVM)); |
|
353 |
} |
|
354 |
else |
|
355 |
{ |
|
356 |
hvm = it->second; |
|
357 |
} |
|
358 |
|
|
359 |
return hvm; |
|
360 |
} |
|
361 |
|
|
362 |
void HostPool::delete_host_vm(int oid) |
|
363 |
{ |
|
364 |
HostVM * hvm; |
|
365 |
|
|
366 |
map<int, HostVM *>::iterator it = host_vms.find(oid); |
|
367 |
|
|
368 |
if ( it != host_vms.end() ) |
|
369 |
{ |
|
370 |
delete it->second; |
|
371 |
|
|
372 |
host_vms.erase(it); |
|
373 |
} |
|
374 |
} |
|
375 |
|
src/vmm/LibVirtDriverKVM.cc | ||
---|---|---|
870 | 870 |
script = nic[i]->vector_value("SCRIPT"); |
871 | 871 |
model = nic[i]->vector_value("MODEL"); |
872 | 872 |
ip = nic[i]->vector_value("IP"); |
873 |
vrouter_ip = nic[i]->vector_value("VROUTER_IP"); |
|
874 | 873 |
filter = nic[i]->vector_value("FILTER"); |
875 | 874 |
|
875 |
vrouter_ip = nic[i]->vector_value("VROUTER_IP"); |
|
876 |
|
|
876 | 877 |
i_avg_bw = nic[i]->vector_value("INBOUND_AVG_BW"); |
877 | 878 |
i_peak_bw = nic[i]->vector_value("INBOUND_PEAK_BW"); |
878 | 879 |
i_peak_kb = nic[i]->vector_value("INBOUND_PEAK_KB"); |
... | ... | |
959 | 960 |
<< one_util::escape_xml_attr(*the_filter) << ">\n" |
960 | 961 |
<< "\t\t\t\t<parameter name='IP' value=" |
961 | 962 |
<< one_util::escape_xml_attr(ip) << "/>\n"; |
963 |
|
|
962 | 964 |
if ( !vrouter_ip.empty() ) |
963 | 965 |
{ |
964 | 966 |
file << "\t\t\t\t<parameter name='IP' value=" |
965 | 967 |
<< one_util::escape_xml_attr(vrouter_ip) << "/>\n"; |
966 | 968 |
} |
969 |
|
|
967 | 970 |
file << "\t\t\t</filterref>\n"; |
968 | 971 |
} |
969 | 972 |
} |
Also available in: Unified diff