VirtualBox

Changeset 84209 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
May 8, 2020 12:28:20 PM (5 years ago)
Author:
vboxsync
Message:

Guest Control/VBoxService: Invalidate host feature flags on VM session changes. bugref:9320

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r84147 r84209  
    107107static int  vgsvcGstCtrlHandleSessionOpen(PVBGLR3GUESTCTRLCMDCTX pHostCtx);
    108108static int  vgsvcGstCtrlHandleSessionClose(PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     109static int  vgsvcGstCtrlInvalidate(void);
    109110static void vgsvcGstCtrlShutdown(void);
    110111
     
    205206    if (RT_SUCCESS(rc))
    206207    {
    207         g_fControlSupportsOptimizations = VbglR3GuestCtrlSupportsOptimizations(g_idControlSvcClient);
    208         if (g_fControlSupportsOptimizations)
    209             rc = VbglR3GuestCtrlMakeMeMaster(g_idControlSvcClient);
     208        rc = vgsvcGstCtrlInvalidate();
    210209        if (RT_SUCCESS(rc))
    211         {
    212             VGSvcVerbose(3, "Guest control service client ID=%RU32%s\n",
    213                          g_idControlSvcClient, g_fControlSupportsOptimizations ? " w/ optimizations" : "");
    214 
    215             /*
    216              * Report features to the host.
    217              */
    218             const uint64_t fGuestFeatures = VBOX_GUESTCTRL_GF_0_SET_SIZE
    219                                           | VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0;
    220 
    221             rc = VbglR3GuestCtrlReportFeatures(g_idControlSvcClient, fGuestFeatures, &g_fControlHostFeatures0);
    222             if (RT_SUCCESS(rc))
    223                 VGSvcVerbose(3, "Host features: %#RX64\n", g_fControlHostFeatures0);
    224             else
    225                 VGSvcVerbose(1, "Warning! Feature reporing failed: %Rrc\n", rc);
    226 
    227             return VINF_SUCCESS;
    228         }
    229         VGSvcError("Failed to become guest control master: %Rrc\n", rc);
    230         VbglR3GuestCtrlDisconnect(g_idControlSvcClient);
     210            return rc;
    231211    }
    232212    else
     
    248228}
    249229
     230static int vgsvcGstCtrlInvalidate(void)
     231{
     232    VGSvcVerbose(1, "Invalidating configuration ...\n");
     233
     234    int rc = VINF_SUCCESS;
     235
     236    g_fControlSupportsOptimizations = VbglR3GuestCtrlSupportsOptimizations(g_idControlSvcClient);
     237    if (g_fControlSupportsOptimizations)
     238        rc = VbglR3GuestCtrlMakeMeMaster(g_idControlSvcClient);
     239    if (RT_SUCCESS(rc))
     240    {
     241        VGSvcVerbose(3, "Guest control service client ID=%RU32%s\n",
     242                     g_idControlSvcClient, g_fControlSupportsOptimizations ? " w/ optimizations" : "");
     243
     244        /*
     245         * Report features to the host.
     246         */
     247        const uint64_t fGuestFeatures = VBOX_GUESTCTRL_GF_0_SET_SIZE
     248                                      | VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0;
     249
     250        rc = VbglR3GuestCtrlReportFeatures(g_idControlSvcClient, fGuestFeatures, &g_fControlHostFeatures0);
     251        if (RT_SUCCESS(rc))
     252            VGSvcVerbose(3, "Host features: %#RX64\n", g_fControlHostFeatures0);
     253        else
     254            VGSvcVerbose(1, "Warning! Feature reporing failed: %Rrc\n", rc);
     255
     256        return VINF_SUCCESS;
     257    }
     258    VGSvcError("Failed to become guest control master: %Rrc\n", rc);
     259    VbglR3GuestCtrlDisconnect(g_idControlSvcClient);
     260
     261    return rc;
     262}
    250263
    251264/**
     
    327340        else if (rc == VERR_VM_RESTORED)
    328341        {
    329             VGSvcVerbose(1, "The VM session ID changed (i.e. restored).\n");
     342            VGSvcVerbose(1, "The VM session ID changed (i.e. restored)\n");
    330343            int rc2 = VGSvcGstCtrlSessionClose(&g_Session);
     344            AssertRC(rc2);
     345
     346            rc2 = VbglR3GuestCtrlSessionHasChanged(g_idControlSvcClient, g_idControlSession);
     347            AssertRC(rc2);
     348
     349            /* Invalidate the internal state to match the current host we got restored from. */
     350            rc2 = vgsvcGstCtrlInvalidate();
    331351            AssertRC(rc2);
    332352        }
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r84160 r84209  
    18521852
    18531853/**
     1854 * Invalidates a guest session by updating all it's internal parameters like host features and stuff.
     1855 *
     1856 * @param   pSession            Session to invalidate.
     1857 * @param   idClient            Client ID to use.
     1858 */
     1859static void vgsvcGstCtrlSessionInvalidate(PVBOXSERVICECTRLSESSION pSession, uint32_t idClient)
     1860{
     1861    RT_NOREF(pSession);
     1862
     1863    VGSvcVerbose(1, "Invalidating session %RU32 (client ID=%RU32)\n", idClient, pSession->StartupInfo.uSessionID);
     1864
     1865    int rc2 = VbglR3GuestCtrlQueryFeatures(idClient, &g_fControlHostFeatures0);
     1866    if (RT_SUCCESS(rc2)) /* Querying host features is not fatal -- do not use rc here. */
     1867    {
     1868        VGSvcVerbose(1, "g_fControlHostFeatures0=%#x\n", g_fControlHostFeatures0);
     1869    }
     1870    else
     1871        VGSvcVerbose(1, "Querying host features failed with %Rrc\n", rc2);
     1872}
     1873
     1874/**
    18541875 * Main message handler for the guest control session process.
    18551876 *
     
    18731894    g_idControlSvcClient            = idClient;
    18741895
    1875     int rc2 = VbglR3GuestCtrlQueryFeatures(idClient, &g_fControlHostFeatures0);
    1876     if (RT_FAILURE(rc2)) /* Querying host features is not fatal -- do not use rc here. */
    1877         VGSvcVerbose(1, "Querying host features failed with %Rrc\n", rc2);
     1896    VGSvcVerbose(1, "Using client ID=%RU32\n", idClient);
     1897
     1898    vgsvcGstCtrlSessionInvalidate(pSession, idClient);
    18781899
    18791900    rc = vgsvcGstCtrlSessionReadKeyAndAccept(idClient, pSession->StartupInfo.uSessionID);
    18801901    if (RT_SUCCESS(rc))
    18811902    {
    1882         VGSvcVerbose(1, "Using client ID=%RU32, g_fControlHostFeatures0=%#x\n", idClient, g_fControlHostFeatures0);
    1883 
    18841903        /*
    18851904         * Report started status.
     
    19271946                        /* Let others run (guests are often single CPU) ... */
    19281947                        RTThreadYield();
     1948                    }
     1949                    /*
     1950                     * Handle restore notification from host.  All the context IDs (sessions,
     1951                     * files, proceses, etc) are invalidated by a VM restore and must be closed.
     1952                     */
     1953                    else if (rc == VERR_VM_RESTORED)
     1954                    {
     1955                        VGSvcVerbose(1, "The VM session ID changed (i.e. restored)\n");
     1956                        int rc2 = VGSvcGstCtrlSessionClose(&g_Session);
     1957                        AssertRC(rc2);
     1958
     1959                        rc2 = VbglR3GuestCtrlSessionHasChanged(g_idControlSvcClient, g_idControlSvcClient);
     1960                        AssertRC(rc2);
     1961
     1962                        /* Invalidate the internal state to match the current host we got restored from. */
     1963                        vgsvcGstCtrlSessionInvalidate(pSession, g_idControlSvcClient);
    19291964                    }
    19301965                    else
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