From 3ca2d5c75515bdf0b25ccd627bfe1bce0cf71cc1 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 18 Jun 2010 00:23:56 +0200 Subject: [PATCH] feature #261: VM_POLLING_INTERVAL set to 0 disables VM monitoring --- share/etc/oned.conf | 7 ++++--- src/vm/VirtualMachinePool.cc | 8 ++------ src/vmm/VirtualMachineManager.cc | 31 ++++++++++++++++--------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 43f81be607..41dcbb66c8 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -7,7 +7,8 @@ #------------------------------------------------------------------------------- # HOST_MONITORING_INTERVAL: Time in seconds between host monitorization # -# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization +# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization. +# (use 0 to disable VM monitoring). # # VM_DIR: Remote path to store the VM images, it should be shared between all # the cluster nodes to perform live migrations. This variable is the default @@ -25,9 +26,9 @@ # DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG #******************************************************************************* -HOST_MONITORING_INTERVAL = 60 +HOST_MONITORING_INTERVAL = 600 -VM_POLLING_INTERVAL = 60 +VM_POLLING_INTERVAL = 600 #VM_DIR=/srv/cloud/one/var diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index 30b2a99685..8d5f4b96f9 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -260,14 +260,10 @@ int VirtualMachinePool::get_running( ostringstream os; string where; - // Get all machines that have been monitored ( > 0 ), - // but not recently ( <= last_poll ) and... - os << "last_poll > 0 and last_poll <= " << last_poll << " and " - // ... are running - << "state = " << VirtualMachine::ACTIVE + os << "last_poll > 0 and last_poll <= " << last_poll << " and" + << " state = " << VirtualMachine::ACTIVE << " and ( lcm_state = " << VirtualMachine::RUNNING << " or lcm_state = " << VirtualMachine::UNKNOWN << " )" - // order the results by last_poll, and return only the first 'vm_limit' rows << " ORDER BY last_poll ASC LIMIT " << vm_limit; where = os.str(); diff --git a/src/vmm/VirtualMachineManager.cc b/src/vmm/VirtualMachineManager.cc index 9622ca5392..7301324d0d 100644 --- a/src/vmm/VirtualMachineManager.cc +++ b/src/vmm/VirtualMachineManager.cc @@ -60,7 +60,15 @@ extern "C" void * vmm_action_loop(void *arg) NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager started."); - vmm->am.loop(vmm->timer_period,0); + if ( vmm->poll_period == 0 ) + { + NebulaLog::log("VMM",Log::INFO,"VM monitoring is disabled."); + vmm->am.loop(0,0); + } + else + { + vmm->am.loop(vmm->timer_period,0); + } NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager stopped."); @@ -804,12 +812,16 @@ void VirtualMachineManager::timer_action() vector oids; vector::iterator it; int rc; - time_t thetime; - time_t last_poll; ostringstream os; + time_t thetime = time(0); + const VirtualMachineManagerDriver * vmd; + // -------------- Max. number of VMs to monitor. --------------------- + int vm_limit = 5; + + mark = mark + timer_period; if ( mark >= 600 ) @@ -818,24 +830,14 @@ void VirtualMachineManager::timer_action() mark = 0; } - // TODO: Move this to oned.conf - // Max. number of VMs to monitor. - int vm_limit = 10; - - thetime = time(0); - // Monitor only VMs that hasn't been monitored for 'poll_period' seconds. - last_poll = thetime - poll_period; - - rc = vmpool->get_running(oids, vm_limit, last_poll); + rc = vmpool->get_running(oids, vm_limit, thetime - poll_period); if ( rc != 0 || oids.empty() ) { return; } - - for ( it = oids.begin(); it != oids.end(); it++ ) { vm = vmpool->get(*it,true); @@ -874,7 +876,6 @@ void VirtualMachineManager::timer_action() vmpool->update(vm); - vm->unlock(); } }