VirtualBox

Ignore:
Timestamp:
Feb 22, 2023 3:00:11 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155990
Message:

Main: Linux Guest Additions upgrade: Check if kernel modules and user services were reloaded after installation has completed, bugref:10359.

File:
1 edited

Legend:

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

    r98526 r98690  
    26742674
    26752675/**
     2676 * Helper function which checks Guest Additions installation status.
     2677 *
     2678 * @returns IPRT status code.
     2679 * @param   pSession    Guest session to use.
     2680 * @param   osType      Guest type.
     2681 */
     2682int GuestSessionTaskUpdateAdditions::checkGuestAdditionsStatus(GuestSession *pSession, eOSType osType)
     2683{
     2684    int vrc = VINF_SUCCESS;
     2685#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
     2686    int hrc;
     2687
     2688    if (osType == eOSType_Linux)
     2689    {
     2690        const Utf8Str ksStatusScript = Utf8Str("/usr/sbin/rcvboxadd");
     2691
     2692        /* Check if Guest Additions kernel modules were loaded. */
     2693        GuestProcessStartupInfo procInfo;
     2694        procInfo.mFlags = ProcessCreateFlag_None;
     2695        procInfo.mExecutable = Utf8Str("/bin/sh");;
     2696        procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */
     2697        procInfo.mArguments.push_back(ksStatusScript);
     2698        procInfo.mArguments.push_back("status-kernel");
     2699
     2700        vrc = runFileOnGuest(pSession, procInfo);
     2701        if (RT_SUCCESS(vrc))
     2702        {
     2703            /* Replace the last argument with corresponding value and check
     2704             * if Guest Additions user services were started. */
     2705            procInfo.mArguments.pop_back();
     2706            procInfo.mArguments.push_back("status-user");
     2707
     2708            vrc = runFileOnGuest(pSession, procInfo);
     2709            if (RT_FAILURE(vrc))
     2710                hrc = setProgressErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR,
     2711                                          Utf8StrFmt(tr("Automatic update of Guest Additions has failed: "
     2712                                                        "files were installed, but user services were not reloaded automatically. "
     2713                                                        "Please consider rebooting the guest")));
     2714        }
     2715        else
     2716            hrc = setProgressErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR,
     2717                                      Utf8StrFmt(tr("Automatic update of Guest Additions has failed: "
     2718                                                    "files were installed, but kernel modules were not reloaded automatically. "
     2719                                                    "Please consider rebooting the guest")));
     2720    }
     2721#endif
     2722    return vrc;
     2723}
     2724
     2725/**
    26762726 * Helper function which waits until Guest Additions services started.
    26772727 *
     
    26792729 *          started on time.
    26802730 * @param   pGuest      Guest interface to use.
     2731 * @param   osType      Guest type.
    26812732 */
    2682 int GuestSessionTaskUpdateAdditions::waitForGuestSession(ComObjPtr<Guest> pGuest)
     2733int GuestSessionTaskUpdateAdditions::waitForGuestSession(ComObjPtr<Guest> pGuest, eOSType osType)
    26832734{
    26842735    int vrc                         = VERR_GSTCTL_GUEST_ERROR;
     
    27142765                if (RT_SUCCESS(vrc))
    27152766                {
     2767                    /* Make sure Guest Additions were reloaded on the guest side. */
     2768                    vrc = checkGuestAdditionsStatus(pSession, osType);
     2769                    if (RT_SUCCESS(vrc))
     2770                        LogRel(("Guest Additions were successfully reloaded after installation\n"));
     2771                    else
     2772                        LogRel(("Guest Additions were failed to reload after installation, please consider rebooting the guest\n"));
     2773
    27162774                    vrc = pSession->Close();
    27172775                    vrcRet = VINF_SUCCESS;
     
    32283286
    32293287                            /* Wait for VBoxService to restart. */
    3230                             vrc = waitForGuestSession(pSession->i_getParent());
     3288                            vrc = waitForGuestSession(pSession->i_getParent(), osType);
    32313289                            if (RT_FAILURE(vrc))
    32323290                                hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
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