Revision 675d9367 src/lcm/LifeCycleActions.cc

View differences:

src/lcm/LifeCycleActions.cc
337 337
/* -------------------------------------------------------------------------- */
338 338
/* -------------------------------------------------------------------------- */
339 339

  
340
void  LifeCycleManager::shutdown_save_action(int vid, bool hard)
341
{
342
    VirtualMachine *    vm;
343

  
344
    vm = vmpool->get(vid,true);
345

  
346
    if ( vm == 0 )
347
    {
348
        return;
349
    }
350

  
351
    if (vm->get_state()     == VirtualMachine::ACTIVE &&
352
        vm->get_lcm_state() == VirtualMachine::RUNNING)
353
    {
354
        Nebula&                 nd = Nebula::instance();
355
        VirtualMachineManager * vmm = nd.get_vmm();
356

  
357
        //----------------------------------------------------
358
        //             SHUTDOWN_SAVE STATE
359
        //----------------------------------------------------
360

  
361
        vm->set_state(VirtualMachine::SHUTDOWN_SAVE);
362

  
363
        vm->set_resched(false);
364

  
365
        vmpool->update(vm);
366

  
367
        vm->log("LCM",Log::INFO,"New VM state is SHUTDOWN_SAVE");
368

  
369
        //----------------------------------------------------
370

  
371
        if (hard)
372
        {
373
            vmm->trigger(VirtualMachineManager::CANCEL,vid);
374
        }
375
        else
376
        {
377
            vmm->trigger(VirtualMachineManager::SHUTDOWN,vid);
378
        }
379
    }
380
    else
381
    {
382
        vm->log("LCM", Log::ERROR, "shutdown_save_action, VM in a wrong state.");
383
    }
384

  
385
    vm->unlock();
386

  
387
    return;
388
}
389

  
390

  
391
/* -------------------------------------------------------------------------- */
392
/* -------------------------------------------------------------------------- */
393

  
340 394
void  LifeCycleManager::poweroff_action(int vid)
341 395
{
342 396
    VirtualMachine *    vm;

Also available in: Unified diff