VirtualBox

Changeset 106142 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 24, 2024 3:51:42 PM (5 months ago)
Author:
vboxsync
Message:

Additions: Automatic Upgrade: Cleanup guest session files after upgrade, bugref:10776.

Also improve logging.

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

Legend:

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

    r106061 r106142  
    459459
    460460    int checkGuestAdditionsStatus(GuestSession *pSession, eOSType osType);
    461     int waitForGuestSession(ComObjPtr<Guest> pGuest, eOSType osType);
     461    int waitForGuestSession(ComObjPtr<Guest> pGuest, eOSType osType, ComObjPtr<GuestSession> &pNewSession);
    462462
    463463    /** Files to handle. */
  • trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp

    r106141 r106142  
    27522752        && !fSilent)
    27532753    {
     2754        Utf8Str cmdLine;
     2755        for (size_t iArg = 0; iArg < procInfo.mArguments.size(); iArg++)
     2756        {
     2757            cmdLine.append(procInfo.mArguments.at(iArg));
     2758            if (iArg < procInfo.mArguments.size() - 1)
     2759                cmdLine.append(" ");
     2760        }
     2761
    27542762        switch (vrc)
    27552763        {
     
    27612769                setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR,
    27622770                                  Utf8StrFmt(tr("Running update file \"%s\" on guest failed with exit code %d"),
    2763                                              procInfo.mExecutable.c_str(), iExitCode));
     2771                                             cmdLine.c_str(), iExitCode));
    27642772                break;
    27652773
     
    27672775            case VERR_GSTCTL_GUEST_ERROR:
    27682776                setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, tr("Running update file on guest failed"),
    2769                                   GuestErrorInfo(GuestErrorInfo::Type_Process, vrcGuest, procInfo.mExecutable.c_str()));
     2777                                  GuestErrorInfo(GuestErrorInfo::Type_Process, vrcGuest, cmdLine.c_str()));
    27702778                break;
    27712779
     
    27782786            default:
    27792787                setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR,
    2780                                   Utf8StrFmt(tr("Error while running update file \"%s\" on guest: %Rrc"),
    2781                                              procInfo.mExecutable.c_str(), vrc));
     2788                                  Utf8StrFmt(tr("Error while running update command \"%s\" on guest: %Rrc"),
     2789                                             cmdLine.c_str(), vrc));
    27822790                break;
    27832791        }
     
    28062814        /* Check if Guest Additions kernel modules were loaded. */
    28072815        GuestProcessStartupInfo procInfo;
     2816        procInfo.mName = "Kernel modules status check";
    28082817        procInfo.mFlags = ProcessCreateFlag_None;
    28092818        procInfo.mExecutable = Utf8Str("/bin/sh");;
     
    28172826            /* Replace the last argument with corresponding value and check
    28182827             * if Guest Additions user services were started. */
     2828            procInfo.mName = "User services status check";
    28192829            procInfo.mArguments.pop_back();
    28202830            procInfo.mArguments.push_back("status-user");
     
    28382848 * Helper function which waits until Guest Additions services started.
    28392849 *
     2850 * Newly created guest session needs to be closed by caller.
     2851 *
    28402852 * @returns 0 on success or VERR_TIMEOUT if guest services were not
    28412853 *          started on time.
    2842  * @param   pGuest      Guest interface to use.
    2843  * @param   osType      Guest type.
     2854 * @param   pGuest          Guest interface to use.
     2855 * @param   osType          Guest type.
     2856 * @param   pNewSession     Output parameter for newly established guest type.
    28442857 */
    2845 int GuestSessionTaskUpdateAdditions::waitForGuestSession(ComObjPtr<Guest> pGuest, eOSType osType)
     2858int GuestSessionTaskUpdateAdditions::waitForGuestSession(ComObjPtr<Guest> pGuest, eOSType osType,
     2859                                                         ComObjPtr<GuestSession> &pNewSession)
    28462860{
    28472861    int vrc                         = VERR_GSTCTL_GUEST_ERROR;
     
    28552869    do
    28562870    {
    2857         ComObjPtr<GuestSession> pSession;
    28582871        GuestCredentials        guestCreds;
    28592872        GuestSessionStartupInfo startupInfo;
    28602873
    2861         startupInfo.mName           = "Guest Additions connection checker";
     2874        startupInfo.mName           = "Guest Additions connection check";
    28622875        startupInfo.mOpenTimeoutMS  = 100;
    28632876
    2864         vrc = pGuest->i_sessionCreate(startupInfo, guestCreds, pSession);
     2877        vrc = pGuest->i_sessionCreate(startupInfo, guestCreds, pNewSession);
    28652878        if (RT_SUCCESS(vrc))
    28662879        {
    2867             Assert(!pSession.isNull());
     2880            Assert(!pNewSession.isNull());
    28682881
    28692882            int vrcGuest = VERR_GSTCTL_GUEST_ERROR; /* unused. */
    2870             vrc = pSession->i_startSession(&vrcGuest);
     2883            vrc = pNewSession->i_startSession(&vrcGuest);
    28712884            if (RT_SUCCESS(vrc))
    28722885            {
     
    28742887                GuestSessionWaitResult_T enmWaitResult = GuestSessionWaitResult_None;
    28752888                int vrcGuest2 = VINF_SUCCESS; /* unused. */
    2876                 vrc = pSession->i_waitFor(GuestSessionWaitForFlag_Start, 100 /* timeout, ms */, enmWaitResult, &vrcGuest2);
     2889                vrc = pNewSession->i_waitFor(GuestSessionWaitForFlag_Start, 100 /* timeout, ms */, enmWaitResult, &vrcGuest2);
    28772890                if (RT_SUCCESS(vrc))
    28782891                {
    28792892                    /* Make sure Guest Additions were reloaded on the guest side. */
    2880                     vrc = checkGuestAdditionsStatus(pSession, osType);
     2893                    vrc = checkGuestAdditionsStatus(pNewSession, osType);
    28812894                    if (RT_SUCCESS(vrc))
    28822895                        LogRel(("Guest Additions Update: Guest Additions were successfully reloaded after installation\n"));
     
    28842897                        LogRel(("Guest Additions Update: Guest Additions were failed to reload after installation, please consider rebooting the guest\n"));
    28852898
    2886                     vrc = pSession->Close();
    28872899                    vrcRet = VINF_SUCCESS;
    28882900                    break;
     
    28902902            }
    28912903
    2892             vrc = pSession->Close();
     2904            vrc = pNewSession->Close();
    28932905        }
    28942906
     
    33643376                        if (pSession->i_isTerminated())
    33653377                        {
     3378                            ComObjPtr<GuestSession> pNewSession;
     3379
    33663380                            LogRel(("Guest Additions Update: Old guest session has terminated, waiting updated guest services to start\n"));
    33673381
    33683382                            /* Wait for VBoxService to restart. */
    3369                             vrc = waitForGuestSession(pSession->i_getParent(), osType);
    3370                             if (RT_FAILURE(vrc))
     3383                            vrc = waitForGuestSession(pSession->i_getParent(), osType, pNewSession);
     3384                            if (RT_SUCCESS(vrc))
     3385                            {
     3386                                hrc = pNewSession->i_directoryRemove(strUpdateDir, DIRREMOVEREC_FLAG_RECURSIVE | DIRREMOVEREC_FLAG_CONTENT_AND_DIR, &vrc);
     3387                                LogRel(("Cleanup Guest Additions update directory '%s', hrc=%Rrc, vrc=%Rrc\n",
     3388                                        strUpdateDir.c_str(), hrc, vrc));
     3389                                pNewSession->Close();
     3390                            }
     3391                            else
    33713392                                hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR,
    33723393                                                        Utf8StrFmt(tr("Guest services were not restarted, please reinstall Guest Additions manually")));
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