VirtualBox

Changeset 95505 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Jul 4, 2022 7:06:19 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152123
Message:

Guest Control/VBoxService: Handle new VM sessions (i.e. when restoring from VM snapshot) more gracefully. bugref:10157

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

Legend:

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

    r93115 r95505  
    342342        else if (rc == VERR_VM_RESTORED)
    343343        {
    344             VGSvcVerbose(1, "The VM session ID changed (i.e. restored)\n");
    345             int rc2 = VGSvcGstCtrlSessionClose(&g_Session);
     344            VGSvcVerbose(1, "The VM session ID changed (i.e. restored), closing stale root session\n");
     345
     346            /* Make sure that all other session threads are gone.
     347             * This is necessary, as the new VM session (NOT to be confused with guest session!) will re-use
     348             * the guest session IDs. */
     349            int rc2 = VGSvcGstCtrlSessionThreadDestroyAll(&g_lstControlSessionThreads, 0 /* Flags */);
     350            if (RT_FAILURE(rc2))
     351                VGSvcError("Closing session threads failed with rc=%Rrc\n", rc2);
     352
     353            /* Make sure to also close the root session (session 0). */
     354            rc2 = VGSvcGstCtrlSessionClose(&g_Session);
    346355            AssertRC(rc2);
    347356
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r93115 r95505  
    18601860                    else if (rc == VERR_VM_RESTORED)
    18611861                    {
    1862                         VGSvcVerbose(1, "The VM session ID changed (i.e. restored)\n");
    1863                         int rc2 = VGSvcGstCtrlSessionClose(&g_Session);
    1864                         AssertRC(rc2);
    1865 
    1866                         rc2 = VbglR3GuestCtrlSessionHasChanged(g_idControlSvcClient, g_idControlSvcClient);
    1867                         AssertRC(rc2);
    1868 
    1869                         /* Invalidate the internal state to match the current host we got restored from. */
    1870                         vgsvcGstCtrlSessionInvalidate(pSession, g_idControlSvcClient);
     1862                        VGSvcVerbose(1, "The VM session ID changed (i.e. restored), closing stale session %RU32\n",
     1863                                     pSession->StartupInfo.uSessionID);
     1864
     1865                        /* We currently don't serialize guest sessions, guest processes and other guest control objects
     1866                         * within saved states. So just close this session and report success to the parent process.
     1867                         *
     1868                         * Note: Not notifying the host here is intentional, as it wouldn't have any information
     1869                         *       about what to do with it.
     1870                         */
     1871                        rc = VINF_SUCCESS; /* Report success as exit code. */
     1872                        break;
    18711873                    }
    18721874                    else
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