VirtualBox

Changeset 6375 in vbox


Ignore:
Timestamp:
Jan 18, 2008 1:54:23 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27317
Message:

Main: Fixed VM error callback used during powerup so that it doesn't complete the progress object but simply saves the received error message; Fixed Progress::notifyComplete() to not accept the second and subsequent calls (all for #2238).

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

Legend:

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

    r6367 r6375  
    168168
    169169    const ComObjPtr <Progress> mProgress;
     170
     171    Utf8Str mErrorMsg;
    170172};
    171173
     
    53295331 * VM error callback function. Called by the various VM components.
    53305332 *
    5331  * @param   pVM         The VM handle. Can be NULL if an error occurred before
    5332  *                          successfully creating a VM.
     5333 * @param   pVM         VM handle. Can be NULL if an error occurred before
     5334 *                      successfully creating a VM.
    53335335 * @param   pvUser      Pointer to the VMProgressTask structure.
    53345336 * @param   rc          VBox status code.
    5335  * @param   pszFormat   The error message.
    5336  * @thread EMT.
     5337 * @param   pszFormat   Printf-like error message.
     5338 * @param   args        Various number of argumens for the error message.
     5339 *
     5340 * @thread EMT, VMPowerUp...
     5341 * 
     5342 * @note The VMProgressTask structure modified by this callback is not thread
     5343 *       safe.
    53375344 */
    53385345/* static */ DECLCALLBACK (void)
     
    53465353    va_list va2;
    53475354    va_copy(va2, args); /* Have to make a copy here or GCC will break. */
    5348     HRESULT hrc = setError (E_FAIL, tr ("%N.\n"
    5349                                         "VBox status code: %d (%Vrc)"),
    5350                                     tr (pszFormat), &va2,
    5351                                     rc, rc);
    5352     task->mProgress->notifyComplete (hrc);
     5355    Utf8Str errorMsg = Utf8StrFmt (tr ("%N.\n"
     5356                                       "VBox status code: %d (%Vrc)"),
     5357                                   pszFormat, &va2, rc, rc);
    53535358    va_end(va2);
     5359
     5360    /* For now, this may be called only once. Ignore subsequent calls. */
     5361    AssertMsgReturnVoid (task->mErrorMsg.isNull(),
     5362                         ("Cannot set error to '%s': it is already set to '%s'",
     5363                         errorMsg.raw(), task->mErrorMsg.raw()));
     5364
     5365    task->mErrorMsg = errorMsg;
    53545366}
    53555367
     
    59195931                ErrorInfoKeeper eik;
    59205932
    5921                 /*
    5922                  *  powerDown() will call VMR3Destroy() and do all necessary
    5923                  *  cleanup (VRDP, USB devices)
    5924                  */
     5933                /* powerDown() will call VMR3Destroy() and do all necessary
     5934                 * cleanup (VRDP, USB devices) */
    59255935                HRESULT hrc2 = console->powerDown();
    59265936                AssertComRC (hrc2);
     
    59375947        if (SUCCEEDED (hrc) && VBOX_FAILURE (vrc))
    59385948        {
    5939             /*
    5940              *  If VMR3Create() or one of the other calls in this function fail,
    5941              *  an appropriate error message has been already set. However since
    5942              *  that happens via a callback, the status code in this function is
    5943              *  not updated.
     5949            /* If VMR3Create() or one of the other calls in this function fail,
     5950             * an appropriate error message has been set in task->mErrorMsg.
     5951             * However since that happens via a callback, the hrc status code in
     5952             * this function is not updated.
    59445953             */
    5945             if (!task->mProgress->completed())
     5954            if (task->mErrorMsg.isNull())
    59465955            {
    5947                 /*
    5948                  *  If the COM error info is not yet set but we've got a
    5949                  *  failure, convert the VBox status code into a meaningful
    5950                  *  error message. This becomes unused once all the sources of
    5951                  *  errors set the appropriate error message themselves.
    5952                  *  Note that we don't use VMSetError() below because pVM is
    5953                  *  either invalid or NULL here.
     5956                /* If the error message is not set but we've got a failure,
     5957                 * convert the VBox status code into a meaningfulerror message.
     5958                 * This becomes unused once all the sources of errors set the
     5959                 * appropriate error message themselves.
    59545960                 */
    59555961                AssertMsgFailed (("Missing error message during powerup for "
    59565962                                  "status code %Vrc\n", vrc));
    5957                 hrc = setError (E_FAIL,
     5963                task->mErrorMsg = Utf8StrFmt (
    59585964                    tr ("Failed to start VM execution (%Vrc)"), vrc);
    59595965            }
    5960             else
    5961                 hrc = task->mProgress->resultCode();
    5962 
    5963             Assert (FAILED (hrc));
     5966
     5967            /* Set the error message as the COM error.
     5968             * Progress::notifyComplete() will pick it up later. */
     5969            hrc = setError (E_FAIL, task->mErrorMsg);
    59645970            break;
    59655971        }
     
    59705976        console->mMachineState == MachineState_Restoring)
    59715977    {
    5972         /*
    5973          *  We are still in the Starting/Restoring state. This means one of:
    5974          *  1) we failed before VMR3Create() was called;
    5975          *  2) VMR3Create() failed.
    5976          *  In both cases, there is no need to call powerDown(), but we still
    5977          *  need to go back to the PoweredOff/Saved state. Reuse
    5978          *  vmstateChangeCallback() for that purpose.
     5978        /* We are still in the Starting/Restoring state. This means one of:
     5979         *
     5980         * 1) we failed before VMR3Create() was called;
     5981         * 2) VMR3Create() failed.
     5982         *
     5983         * In both cases, there is no need to call powerDown(), but we still
     5984         * need to go back to the PoweredOff/Saved state. Reuse
     5985         * vmstateChangeCallback() for that purpose.
    59795986         */
    59805987
     
    59885995
    59895996    /*
    5990      *  Evaluate the final result.
    5991      *  Note that the appropriate mMachineState value is already set by
    5992      *  vmstateChangeCallback() in all cases.
     5997     * Evaluate the final result. Note that the appropriate mMachineState value
     5998     * is already set by vmstateChangeCallback() in all cases.
    59935999     */
    59946000
     
    60036009    else
    60046010    {
    6005         if (!task->mProgress->completed())
    6006         {
    6007             /*  The progress object will fetch the current error info. This
    6008              *  gets the errors signalled by using setError(). The ones
    6009              *  signalled via VMSetError() immediately notify the progress
    6010              *  object that the operation is completed. */
    6011             task->mProgress->notifyComplete (hrc);
    6012         }
     6011        /* The progress object will fetch the current error info */
     6012        task->mProgress->notifyComplete (hrc);
    60136013
    60146014        LogRel (("Power up failed (vrc=%Vrc, hrc=0x%08X)\n", vrc, hrc));
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r5999 r6375  
    747747 *  If the result code indicates a success (|SUCCEEDED (@a aResultCode)|)
    748748 *  then the current operation is set to the last
     749 * 
     750 *  Note that this method may be called only once for the given Progress object.
     751 *  Subsequent calls will assert.
    749752 *
    750753 *  @param aResultCode  Operation result code
     
    754757    AutoLock lock (this);
    755758    AssertReturn (isReady(), E_FAIL);
     759
     760    AssertReturn (mCompleted == FALSE, E_FAIL);
    756761
    757762    mCompleted = TRUE;
  • trunk/src/VBox/Main/glue/ErrorInfo.cpp

    r5999 r6375  
    233233    }
    234234}
    235 
    236 /**
    237  *  Sets the given error info object for the current thread.  If @a aPreserve
    238  *  is @c true, then the current error info set on the thread before this
    239  *  method is called will be preserved in the IVirtualBoxErrorInfo::next
    240  *  attribute of the new error info object that will be then set as the
    241  *  current error info object.
    242  */
    243 
    244 //static
    245 HRESULT setError (IVirtualBoxErrorInfo *aInfo);
    246235
    247236// ProgressErrorInfo class
Note: See TracChangeset for help on using the changeset viewer.

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