VirtualBox

Changeset 32852 in vbox


Ignore:
Timestamp:
Sep 30, 2010 3:49:35 PM (14 years ago)
Author:
vboxsync
Message:

Guest Execution:

  • Implemented "ignore orphaned childs" flag (--flags ignoreorphanedchilds); this flag will tell the host to not bitch about an executed process which still is alive when VBoxService (or the entire guest OS) shuts down.
  • Fixed shutdown/notification hang when waiting for std output which never arrives.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/GuestControlSvc.h

    r30013 r32852  
    6262    /** Process timed out and was not killed successfully. */
    6363    PROC_STS_TOA = 6,
    64     /** Service is stopping, process was killed. */
     64    /** Service/OS is stopping, process was killed. */
    6565    PROC_STS_DWN = 7,
    6666    /** Something went wrong (error code in flags). */
     
    8888    /* The process status. */
    8989    uint32_t u32Status;
    90     /** Optional flags (not used atm). */
     90    /** Optional flags, varies, based on u32Status. */
    9191    uint32_t u32Flags;
    9292    /** Optional data buffer (not used atm). */
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp

    r32777 r32852  
    258258
    259259    AssertPtr(pThread);
    260 
    261     AssertPtr(pThread);
     260    Assert(pThread->enmType == VBoxServiceCtrlThreadDataExec);
    262261    PVBOXSERVICECTRLTHREADDATAEXEC pData = (PVBOXSERVICECTRLTHREADDATAEXEC)pThread->pvData;
    263262    AssertPtr(pData);
     
    457456            VBoxServiceVerbose(3, "ControlExec: Process got terminated because system/service is about to shutdown\n");
    458457            uStatus = PROC_STS_DWN; /* Service is stopping, process was killed. */
     458            uFlags = pData->uFlags; /* Return handed-in execution flags back to the host. */
    459459        }
    460460        else if (fProcessAlive)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r32733 r32852  
    195195        else if (!strcmp(a->argv[i], "--flags"))
    196196        {
    197             if (   i + 1 >= a->argc
    198                 || RTStrToUInt32Full(a->argv[i + 1], 10, &uFlags) != VINF_SUCCESS)
    199                 usageOK = false;
    200             else
    201                 ++i;
     197            if (i + 1 >= a->argc)
     198                usageOK = false;
     199            else
     200            {
     201                /** @todo Needs a bit better processing as soon as we have more flags. */
     202                if (!strcmp(a->argv[i + 1], "ignoreorphanedchilds"))
     203                    uFlags |= ExecuteProcessFlag_IgnoreOrphanedProcesses;
     204                else
     205                    usageOK = false;
     206                ++i;
     207            }
    202208        }
    203209        else if (   !strcmp(a->argv[i], "--username")
     
    409415                            }
    410416                            cbOutputData = 0;
     417                            fCompleted = true; /* rc contains a failure, so we'll go into aborted state down below. */
    411418                        }
    412419                        else
     
    489496                    if (FAILED(iRc))
    490497                    {
    491                         ComPtr<IVirtualBoxErrorInfo> execError;
    492                         rc = progress->COMGETTER(ErrorInfo)(execError.asOutParam());
    493                         com::ErrorInfo info(execError, COM_IIDOF(IVirtualBoxErrorInfo));
    494                         if (SUCCEEDED(rc) && info.isFullAvailable())
     498                        com::ProgressErrorInfo info(progress);
     499                        if (   info.isFullAvailable()
     500                            || info.isBasicAvailable())
    495501                        {
    496502                            /* If we got a VBOX_E_IPRT error we handle the error in a more gentle way
     
    505511                        }
    506512                        else
    507                             AssertMsgFailed(("Full error description is missing!\n"));
     513                        {
     514                            if (RT_FAILURE(rc))
     515                                RTMsgError("Error while looking up error code, rc=%Rrc", rc);
     516                            else
     517                                com::GluePrintRCMessage(iRc);
     518                        }
    508519                    }
    509520                    else if (fVerbose)
  • trunk/src/VBox/Main/GuestImpl.cpp

    r32851 r32852  
    687687
    688688                case PROC_STS_DWN:
    689                     LogRel(("Guest process (PID %u) exited because system is shutting down\n", pCBData->u32PID)); /** @todo Add process name */
    690                     errMsg = Utf8StrFmt(Guest::tr("Process exited because system is shutting down"));
     689                    LogRel(("Guest process (PID %u) killed because system is shutting down\n", pCBData->u32PID)); /** @todo Add process name */
     690                    /*
     691                     * If u32Flags has ExecuteProcessFlag_IgnoreOrphanedProcesses set, we don't report an error to
     692                     * our progress object. This is helpful for waiters which rely on the success of our progress object
     693                     * even if the executed process was killed because the system/VBoxService is shutting down.
     694                     *
     695                     * In this case u32Flags contains the actual execution flags reached in via Guest::ExecuteProcess().
     696                     */
     697                    if (pData->u32Flags & ExecuteProcessFlag_IgnoreOrphanedProcesses)
     698                    {
     699                        hr = it->second.pProgress->notifyComplete(S_OK);
     700                        AssertComRC(hr);
     701                    }
     702                    else
     703                    {
     704                        errMsg = Utf8StrFmt(Guest::tr("Process killed because system is shutting down"));
     705                    }
    691706                    break;
    692707
     
    734749                || fCanceled) /* If canceled we have to report E_FAIL! */
    735750            {
     751                /* Destroy all callbacks which are still waiting on something
     752                 * which is related to the current PID. */
     753                CallbackMapIter it2;
     754                for (it2 = mCallbackMap.begin(); it2 != mCallbackMap.end(); it2++)
     755                {
     756                    switch(it2->second.mType)
     757                    {
     758                        case VBOXGUESTCTRLCALLBACKTYPE_EXEC_START:
     759                            break;
     760
     761                        /* When waiting for process output while the process is destroyed,
     762                         * make sure we also destroy the actual waiting operation (internal progress object)
     763                         * in order to not block the caller. */
     764                        case VBOXGUESTCTRLCALLBACKTYPE_EXEC_OUTPUT:
     765                        {
     766                            PCALLBACKDATAEXECOUT pItData = (CALLBACKDATAEXECOUT*)it2->second.pvData;
     767                            AssertPtr(pItData);
     768                            if (pItData->u32PID == pCBData->u32PID)
     769                                destroyCtrlCallbackContext(it2);
     770                            break;
     771                        }
     772                    }
     773                }
     774
    736775                HRESULT hr2 = it->second.pProgress->notifyComplete(VBOX_E_IPRT_ERROR,
    737776                                                                   COM_IIDOF(IGuest),
     
    9671006    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    9681007
    969     if (aFlags != 0) /* Flags are not supported at the moment. */
    970         return E_INVALIDARG;
     1008    /* Validate flags. */
     1009    if (aFlags)
     1010    {
     1011        if (!(aFlags & ExecuteProcessFlag_IgnoreOrphanedProcesses))
     1012            return E_INVALIDARG;
     1013    }
    9711014
    9721015    HRESULT rc = S_OK;
     
    12771320        /*
    12781321         * Create progress object.
    1279          * This progress object, compared to the one in executeProgress() above,
     1322         * This progress object, compared to the one in executeProgress() above
    12801323         * is only local and is used to determine whether the operation finished
    12811324         * or got canceled.
     
    12991342        AssertReturn(pData, VBOX_E_IPRT_ERROR);
    13001343        RT_ZERO(*pData);
     1344        /* Save PID + output flags for later use. */
     1345        pData->u32PID = aPID;
     1346        pData->u32Flags = aFlags;
     1347        /* Add job to callback contexts. */
    13011348        uint32_t uContextID = addCtrlCallbackContext(VBOXGUESTCTRLCALLBACKTYPE_EXEC_OUTPUT,
    13021349                                                     pData, sizeof(CALLBACKDATAEXECOUT), progress);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r32536 r32852  
    77027702  </enum>
    77037703
     7704  <enum
     7705    name="ExecuteProcessFlag"
     7706    uuid="9a24c17d-bd46-4207-b247-517fdd6d6b8f"
     7707  >
     7708    <desc>
     7709      Guest process execution flags.
     7710    </desc>
     7711
     7712    <const name="None"                    value="0">
     7713      <desc>No flag set.</desc>
     7714    </const>
     7715
     7716    <const name="IgnoreOrphanedProcesses" value="2">
     7717      <desc>Do not report an error when executed processes are still alive when VBoxService or the guest OS is shutting down.</desc>
     7718    </const>
     7719  </enum>
     7720
    77047721  <interface
    77057722     name="IGuest" extends="$unknown"
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