Revision 675d9367 src/dm/DispatchManagerActions.cc

View differences:

src/dm/DispatchManagerActions.cc
209 209
/* -------------------------------------------------------------------------- */
210 210
/* -------------------------------------------------------------------------- */
211 211

  
212
int DispatchManager::shutdown_save(
213
    int vid,
214
    bool hard)
215
{
216
    VirtualMachine *    vm;
217
    ostringstream       oss;
218

  
219
    vm = vmpool->get(vid,true);
220

  
221
    if ( vm == 0 )
222
    {
223
        return -1;
224
    }
225

  
226
    oss << "Shutting down VM " << vid;
227
    NebulaLog::log("DiM",Log::DEBUG,oss);
228

  
229
    if (vm->get_state()     == VirtualMachine::ACTIVE &&
230
        vm->get_lcm_state() == VirtualMachine::RUNNING )
231
    {
232
        Nebula&             nd  = Nebula::instance();
233
        LifeCycleManager *  lcm = nd.get_lcm();
234

  
235
        if (hard)
236
        {
237
            lcm->trigger(LifeCycleManager::SHUTDOWN_SAVE_HARD,vid);
238
        }
239
        else
240
        {
241
            lcm->trigger(LifeCycleManager::SHUTDOWN_SAVE,vid);
242
        }
243
    }
244
    else
245
    {
246
        goto error;
247
    }
248

  
249
    vm->unlock();
250

  
251
    return 0;
252

  
253
error:
254
    oss.str("");
255
    oss << "Could not shutdown VM " << vid << ", wrong state.";
256
    NebulaLog::log("DiM",Log::ERROR,oss);
257

  
258
    vm->unlock();
259
    return -2;
260
}
261

  
262
/* -------------------------------------------------------------------------- */
263
/* -------------------------------------------------------------------------- */
264

  
212 265
int DispatchManager::poweroff (
213 266
    int vid)
214 267
{
......
804 857
        break;
805 858

  
806 859
        case VirtualMachine::STOPPED:
860
        case VirtualMachine::SHUTDOWN_SAVED:
807 861
            tm->trigger(TransferManager::EPILOG_DELETE_STOP,vid);
808 862
            finalize_cleanup(vm);
809 863
        break;
......
878 932

  
879 933
        case VirtualMachine::HOLD: // Move the VM to PENDING in any of these
880 934
        case VirtualMachine::STOPPED:
935
        case VirtualMachine::SHUTDOWN_SAVED:
881 936
            vm->set_state(VirtualMachine::LCM_INIT);
882 937
            vm->set_state(VirtualMachine::PENDING);
883 938

  

Also available in: Unified diff