VirtualBox

Changeset 71301 in vbox for trunk


Ignore:
Timestamp:
Mar 12, 2018 4:24:27 PM (7 years ago)
Author:
vboxsync
Message:

Guest Control/Process: Check guest error information in the GuestProcessTool static helpers more diligent.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r71299 r71301  
    188188{
    189189    /** Return code from the guest side for executing the process tool. */
    190     int  rcGuest;
     190    int     rcGuest;
    191191    /** The process tool's returned exit code. */
    192192    int32_t iExitCode;
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r71299 r71301  
    20452045}
    20462046
     2047/**
     2048 * Static helper function to start and wait for a certain toolbox tool.
     2049 *
     2050 * This function most likely is the one you want to use in the first place if you
     2051 * want to just use a toolbox tool and wait for its result. See runEx() if you also
     2052 * needs its output.
     2053 *
     2054 * @return  VBox status code.
     2055 * @param   pGuestSession           Guest control session to use for starting the toolbox tool in.
     2056 * @param   startupInfo             Startup information about the toolbox tool.
     2057 * @param   prcGuest                Where to store the toolbox tool's specific error code in case
     2058 *                                  VERR_GSTCTL_GUEST_ERROR is returned.
     2059 */
    20472060/* static */
    20482061int GuestProcessTool::run(      GuestSession              *pGuestSession,
     
    20562069    if (RT_SUCCESS(vrc))
    20572070    {
    2058         if (errorInfo.rcGuest == VWRN_GSTCTL_PROCESS_EXIT_CODE)
    2059             rcGuest = GuestProcessTool::exitCodeToRc(startupInfo, errorInfo.iExitCode);
    2060         else
    2061             rcGuest = errorInfo.rcGuest;
    2062 
    2063         if (prcGuest)
    2064             *prcGuest = rcGuest;
    2065     }
    2066 
     2071        /* Make sure to check the error information we got from the guest tool. */
     2072        if (GuestProcess::i_isGuestError(errorInfo.rcGuest))
     2073        {
     2074            if (errorInfo.rcGuest == VWRN_GSTCTL_PROCESS_EXIT_CODE) /* Translate exit code to a meaningful error code. */
     2075                rcGuest = GuestProcessTool::exitCodeToRc(startupInfo, errorInfo.iExitCode);
     2076            else /* At least return something. */
     2077                rcGuest = errorInfo.rcGuest;
     2078
     2079            if (prcGuest)
     2080                *prcGuest = rcGuest;
     2081
     2082            vrc = VERR_GSTCTL_GUEST_ERROR;
     2083        }
     2084    }
     2085
     2086    LogFlowFunc(("Returned rc=%Rrc, rcGuest=%Rrc, iExitCode=%d\n", vrc, errorInfo.rcGuest, errorInfo.iExitCode));
    20672087    return vrc;
    20682088}
    20692089
    20702090/**
    2071  * Static helper function to start and wait for a certain toolbox tool.
     2091 * Static helper function to start and wait for a certain toolbox tool, returning
     2092 * extended error information from the guest.
    20722093 *
    2073  * @return  IPRT status code.
     2094 * @return  VBox status code.
    20742095 * @param   pGuestSession           Guest control session to use for starting the toolbox tool in.
    20752096 * @param   startupInfo             Startup information about the toolbox tool.
     
    20822103{
    20832104    return runExErrorInfo(pGuestSession, startupInfo,
    2084                             NULL /* paStrmOutObjects */, 0 /* cStrmOutObjects */,
    2085                             errorInfo);
     2105                          NULL /* paStrmOutObjects */, 0 /* cStrmOutObjects */, errorInfo);
    20862106}
    20872107
     
    21102130    if (RT_SUCCESS(vrc))
    21112131    {
    2112         if (errorInfo.rcGuest == VWRN_GSTCTL_PROCESS_EXIT_CODE)
    2113             rcGuest = GuestProcessTool::exitCodeToRc(startupInfo, errorInfo.iExitCode);
    2114         else
    2115             rcGuest = errorInfo.rcGuest;
    2116 
    2117         /* Return VERR_GSTCTL_GUEST_ERROR if we retrieved a guest return code. */
    2118         if (RT_FAILURE(rcGuest))
     2132        /* Make sure to check the error information we got from the guest tool. */
     2133        if (GuestProcess::i_isGuestError(errorInfo.rcGuest))
     2134        {
     2135            if (errorInfo.rcGuest == VWRN_GSTCTL_PROCESS_EXIT_CODE) /* Translate exit code to a meaningful error code. */
     2136                rcGuest = GuestProcessTool::exitCodeToRc(startupInfo, errorInfo.iExitCode);
     2137            else /* At least return something. */
     2138                rcGuest = errorInfo.rcGuest;
     2139
     2140            if (prcGuest)
     2141                *prcGuest = rcGuest;
     2142
    21192143            vrc = VERR_GSTCTL_GUEST_ERROR;
    2120 
    2121         if (prcGuest)
    2122             *prcGuest = rcGuest;
    2123     }
    2124 
     2144        }
     2145    }
     2146
     2147    LogFlowFunc(("Returned rc=%Rrc, rcGuest=%Rrc, iExitCode=%d\n", vrc, errorInfo.rcGuest, errorInfo.iExitCode));
    21252148    return vrc;
    21262149}
     
    21332156 * on stdout and can be used on the host side to retrieve more information about the actual command issued on the guest side.
    21342157 *
    2135  * @return  IPRT status code.
     2158 * @return  VBox status code.
    21362159 * @param   pGuestSession           Guest control session to use for starting the toolbox tool in.
    21372160 * @param   startupInfo             Startup information about the toolbox tool.
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