diff --git a/include/VirtualMachineManagerDriver.h b/include/VirtualMachineManagerDriver.h index c32b57ca16..c18e9adc68 100644 --- a/include/VirtualMachineManagerDriver.h +++ b/include/VirtualMachineManagerDriver.h @@ -74,16 +74,19 @@ public: * * @param id VM id * @param monitor_str String returned by the poll driver call + * @param update_db write data to DB (or keep it in memory) */ - static void process_poll(int id, const string &monitor_str); + static void process_poll(int id, const string &monitor_str, bool update_db); /** * Updates the VM with the information gathered by the drivers * * @param vm VM to update, must be locked * @param monitor_str String returned by the poll driver call + * @param update_db write data to DB (or keep it in memory) */ - static void process_poll(VirtualMachine* vm, const string &monitor_str); + static void process_poll(VirtualMachine* vm, const string &monitor_str, + bool update_db); /** * Check if action is supported for imported VMs diff --git a/src/im/MonitorThread.cc b/src/im/MonitorThread.cc index e79a89676c..9f2e2be2dd 100644 --- a/src/im/MonitorThread.cc +++ b/src/im/MonitorThread.cc @@ -282,7 +282,7 @@ void MonitorThread::do_message() continue; } - VirtualMachineManagerDriver::process_poll(vm, itm->second); + VirtualMachineManagerDriver::process_poll(vm, itm->second, true); vm->unlock(); } diff --git a/src/image/ImageManagerDriver.cc b/src/image/ImageManagerDriver.cc index 64cc412788..4770268023 100644 --- a/src/image/ImageManagerDriver.cc +++ b/src/image/ImageManagerDriver.cc @@ -706,7 +706,7 @@ static void monitor_action(istringstream& is, continue; } - VirtualMachineManagerDriver::process_poll(vm_id, poll_info); + VirtualMachineManagerDriver::process_poll(vm_id, poll_info, false); } oss << "Datastore " << ds_name << " (" << id << ") successfully monitored."; diff --git a/src/vmm/VirtualMachineManagerDriver.cc b/src/vmm/VirtualMachineManagerDriver.cc index de51da7228..1ffcaa7d48 100644 --- a/src/vmm/VirtualMachineManagerDriver.cc +++ b/src/vmm/VirtualMachineManagerDriver.cc @@ -645,7 +645,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const string monitor_str; getline(is, monitor_str); - process_poll(vm, monitor_str); + process_poll(vm, monitor_str, true); } else { @@ -670,7 +670,8 @@ void VirtualMachineManagerDriver::protocol(const string& message) const void VirtualMachineManagerDriver::process_poll( int id, - const string &monitor_str) + const string &monitor_str, + bool update_db) { // Get the VM from the pool VirtualMachine* vm = Nebula::instance().get_vmpool()->get(id,true); @@ -680,7 +681,7 @@ void VirtualMachineManagerDriver::process_poll( return; } - process_poll(vm, monitor_str); + process_poll(vm, monitor_str, update_db); vm->unlock(); } @@ -690,7 +691,8 @@ void VirtualMachineManagerDriver::process_poll( void VirtualMachineManagerDriver::process_poll( VirtualMachine* vm, - const string& monitor_str) + const string& monitor_str, + bool update_db) { char state; @@ -705,15 +707,20 @@ void VirtualMachineManagerDriver::process_poll( if (vm->get_state() == VirtualMachine::ACTIVE) { - if (vm->update_info(monitor_str) == 0) + int rc = vm->update_info(monitor_str); + + if ( update_db ) { - vmpool->update_history(vm); + if ( rc == 0) + { + vmpool->update_history(vm); - vmpool->update_monitoring(vm); + vmpool->update_monitoring(vm); + } + + vmpool->update(vm); } - vmpool->update(vm); - VirtualMachineMonitorInfo &minfo = vm->get_info(); state = minfo.remove_state();