VirtualBox

Changeset 44152 in vbox


Ignore:
Timestamp:
Dec 18, 2012 3:47:08 PM (12 years ago)
Author:
vboxsync
Message:

Main/Snapshot+Console: Set up logging earlier to capture more error information, and with explicit config allow online snapshots without saving state

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r44124 r44152  
    63496349                tr("The virtual machine is already running or busy (machine state: %s)"),
    63506350                Global::stringifyMachineState(mMachineState));
     6351
     6352        /* Set up release logging as early as possible after the check if
     6353         * there is already a running VM which we shouldn't disturb. */
     6354        rc = consoleInitReleaseLog(mMachine);
     6355        if (FAILED(rc))
     6356            throw rc;
    63516357
    63526358        /* test and clear the TeleporterEnabled property  */
     
    66296635            LogFlowThisFunc(("Machine has a current snapshot which is online, skipping immutable images reset\n"));
    66306636
    6631         rc = consoleInitReleaseLog(mMachine);
    6632         if (FAILED(rc))
    6633             throw rc;
    66346637#ifdef VBOX_WITH_EXTPACK
    66356638        mptrExtPackManager->dumpAllToReleaseLog();
     
    93469349        fBeganTakingSnapshot = true;
    93479350
    9348         /*
    9349          * state file is non-null only when the VM is paused
    9350          * (i.e. creating a snapshot online)
    9351          */
    9352         bool f =     (!pTask->bstrSavedStateFile.isEmpty() &&  pTask->fTakingSnapshotOnline)
    9353                   || ( pTask->bstrSavedStateFile.isEmpty() && !pTask->fTakingSnapshotOnline);
    9354         if (!f)
     9351        /* Check sanity: for offline snapshots there must not be a saved state
     9352         * file name. All other combinations are valid (even though online
     9353         * snapshots without saved state file seems inconsistent - there are
     9354         * some exotic use cases, which need to be explicitly enabled, see the
     9355         * code of SessionMachine::BeginTakingSnapshot. */
     9356        if (   !pTask->fTakingSnapshotOnline
     9357            && !pTask->bstrSavedStateFile.isEmpty())
    93559358            throw setErrorStatic(E_FAIL, "Invalid state of saved state file");
    93569359
     
    93649367        if (pTask->fTakingSnapshotOnline)
    93659368        {
    9366             Utf8Str strSavedStateFile(pTask->bstrSavedStateFile);
    9367 
     9369            int vrc;
    93689370            SafeVMPtr ptrVM(that);
    93699371            if (!ptrVM.isOk())
     
    93729374            pTask->mProgress->SetNextOperation(Bstr(tr("Saving the machine state")).raw(),
    93739375                                               pTask->ulMemSize);       // operation weight, same as computed when setting up progress object
    9374             pTask->mProgress->setCancelCallback(takesnapshotProgressCancelCallback, ptrVM.rawUVM());
    9375 
    9376             alock.release();
    9377             LogFlowFunc(("VMR3Save...\n"));
    9378             int vrc = VMR3Save(ptrVM,
     9376            if (!pTask->bstrSavedStateFile.isEmpty())
     9377            {
     9378                Utf8Str strSavedStateFile(pTask->bstrSavedStateFile);
     9379
     9380                pTask->mProgress->setCancelCallback(takesnapshotProgressCancelCallback, ptrVM.rawUVM());
     9381
     9382                alock.release();
     9383                LogFlowFunc(("VMR3Save...\n"));
     9384                vrc = VMR3Save(ptrVM,
    93799385                               strSavedStateFile.c_str(),
    93809386                               true /*fContinueAfterwards*/,
     
    93829388                               static_cast<IProgress *>(pTask->mProgress),
    93839389                               &fSuspenededBySave);
    9384             alock.acquire();
    9385             if (RT_FAILURE(vrc))
    9386                 throw setErrorStatic(E_FAIL,
    9387                                      tr("Failed to save the machine state to '%s' (%Rrc)"),
    9388                                      strSavedStateFile.c_str(), vrc);
    9389 
    9390             pTask->mProgress->setCancelCallback(NULL, NULL);
     9390                alock.acquire();
     9391                if (RT_FAILURE(vrc))
     9392                    throw setErrorStatic(E_FAIL,
     9393                                         tr("Failed to save the machine state to '%s' (%Rrc)"),
     9394                                         strSavedStateFile.c_str(), vrc);
     9395
     9396                pTask->mProgress->setCancelCallback(NULL, NULL);
     9397            }
     9398            else
     9399                LogRel(("Console: skipped saving state as part of online snapshot\n"));
     9400
    93919401            if (!pTask->mProgress->notifyPointOfNoReturn())
    93929402                throw setErrorStatic(E_FAIL, tr("Canceled"));
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r44041 r44152  
    14401440    /* stateFilePath is null when the machine is not online nor saved */
    14411441    if (fTakingSnapshotOnline)
    1442         // creating a new online snapshot: then we need a fresh saved state file
    1443         composeSavedStateFilename(strStateFilePath);
     1442    {
     1443        Bstr value;
     1444        HRESULT rc = GetExtraData(Bstr("VBoxInternal2/ForceTakeSnapshotWithoutState").raw(),
     1445                                  value.asOutParam());
     1446        if (FAILED(rc) || value != "1")
     1447        {
     1448            // creating a new online snapshot: we need a fresh saved state file
     1449            composeSavedStateFilename(strStateFilePath);
     1450        }
     1451    }
    14441452    else if (mData->mMachineState == MachineState_Saved)
    14451453        // taking an online snapshot from machine in "saved" state: then use existing state file
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette