Revision ea876146

View differences:

include/Host.h
165 165
                    bool            &with_vm_info,
166 166
                    set<int>        &lost,
167 167
                    map<int,string> &found,
168
                    set<int>        &found_twice,
168 169
                    const set<int>  &non_shared_ds,
169 170
                    long long       reserved_cpu,
170 171
                    long long       reserved_mem);
......
527 528
     */
528 529
    set<int>        tmp_zombie_vms;
529 530

  
531
    /**
532
     * Tmp set of found VM IDs. Used to give recovered poweroff VMs one
533
     * grace cycle, in case they reappear in outdated poll info.
534
     */
535
    set<int>        tmp_found_vms;
536

  
530 537
    // -------------------------------------------------------------------------
531 538
    //  VM Collection
532 539
    // -------------------------------------------------------------------------
src/host/Host.cc
248 248
                      bool            &with_vm_info,
249 249
                      set<int>        &lost,
250 250
                      map<int,string> &found,
251
                      set<int>        &found_twice,
251 252
                      const set<int>  &non_shared_ds,
252 253
                      long long       reserved_cpu,
253 254
                      long long       reserved_mem)
......
271 272

  
272 273
    set<int> prev_tmp_lost   = tmp_lost_vms;
273 274
    set<int> prev_tmp_zombie = tmp_zombie_vms;
275
    set<int> prev_tmp_found  = tmp_found_vms;
274 276

  
275 277
    int num_zombies = 0;
276 278
    int num_wilds   = 0;
......
337 339

  
338 340
    tmp_zombie_vms.clear();
339 341

  
342
    tmp_found_vms.clear();
343

  
340 344
    for (it = vm_att.begin(); it != vm_att.end(); it++)
341 345
    {
342 346
        vatt = dynamic_cast<VectorAttribute*>(*it);
......
362 366
            if (tmp_lost_vms.erase(vmid) == 1) //Good, known
363 367
            {
364 368
                found.insert(make_pair(vmid, vatt->vector_value("POLL")));
369

  
370
                tmp_found_vms.insert(vmid);
371

  
372
                if (prev_tmp_found.count(vmid) == 1)
373
                {
374
                    found_twice.insert(vmid);
375
                }
365 376
            }
366 377
            else //Bad, known but should not be here
367 378
            {
src/im/MonitorThread.cc
184 184

  
185 185
    set<int>        lost;
186 186
    map<int,string> found;
187
    set<int>        found_twice;
187 188

  
188 189
    ostringstream   oss;
189 190

  
......
194 195
        return;
195 196
    }
196 197

  
197
    rc = host->update_info(tmpl, vm_poll, lost, found, non_shared_ds,
198
                reserved_cpu, reserved_mem);
198
    rc = host->update_info(tmpl, vm_poll, lost, found, found_twice,
199
                non_shared_ds, reserved_cpu, reserved_mem);
199 200

  
200 201
    hpool->update(host);
201 202

  
......
252 253

  
253 254
        for (itm = found.begin(); itm != found.end(); itm++)
254 255
        {
255
            VirtualMachineManagerDriver::process_poll(itm->first, itm->second);
256
            VirtualMachine * vm = vmpool->get(itm->first, true);
257

  
258
            if (vm == 0)
259
            {
260
                continue;
261
            }
262

  
263
            // When a VM in poweroff is found again, it may be because of
264
            // outdated poll information. To make sure, we check if VM was
265
            // reported twice
266
            if (vm->get_state() == VirtualMachine::POWEROFF &&
267
                found_twice.count(itm->first) == 0)
268
            {
269
                vm->unlock();
270
                continue;
271
            }
272

  
273
            VirtualMachineManagerDriver::process_poll(vm, itm->second);
274

  
275
            vm->unlock();
256 276
        }
257 277
    }
258 278
};

Also available in: Unified diff