Changeset 30668 in vbox
- Timestamp:
- Jul 6, 2010 2:26:53 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuestLib.h
r30061 r30668 414 414 VBGLR3DECL(int) VbglR3GetAdditionsVersion(char **ppszVer, char **ppszRev); 415 415 VBGLR3DECL(int) VbglR3GetAdditionsInstallationPath(char **ppszPath); 416 VBGLR3DECL(int) VbglR3GetSessionId(uint64_t *pu64IdSession); 417 416 418 /** @} */ 417 419 -
trunk/include/VBox/VMMDev.h
r30061 r30668 176 176 VMMDevReq_GetPageSharingStatus = 215, 177 177 VMMDevReq_DebugIsPageShared = 216, 178 VMMDevReq_GetSessionId = 217, /* since version 3.2.6 */ 178 179 VMMDevReq_SizeHack = 0x7fffffff 179 180 } VMMDevRequestType; … … 1204 1205 bool fAlignment[3]; 1205 1206 } VMMDevPageIsSharedRequest; 1207 1208 /** 1209 * Session id request structure. 1210 * 1211 * Used by VMMDevReq_GetSessionId. 1212 */ 1213 typedef struct 1214 { 1215 /** Header */ 1216 VMMDevRequestHeader header; 1217 /** OUT: unique session id; the id will be different after each start, reset or restore of the VM */ 1218 uint64_t idSession; 1219 } VMMDevReqSessionId; 1220 AssertCompileSize(VMMDevReqSessionId, 24+8); 1206 1221 1207 1222 #pragma pack() … … 1717 1732 case VMMDevReq_DebugIsPageShared: 1718 1733 return sizeof(VMMDevPageIsSharedRequest); 1734 case VMMDevReq_GetSessionId: 1735 return sizeof(VMMDevReqSessionId); 1719 1736 default: 1720 1737 return 0; -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp
r28800 r30668 75 75 } 76 76 77 /** 78 * Query the session id of this VM; this is a unique id that gets changed for each VM start, reset or restore. 79 * Useful for detection a VM restore. 80 * 81 * @returns IPRT status code. 82 * pu64IdSession Session id (out) 83 * 84 */ 85 VBGLR3DECL(int) VbglR3GetSessionId(uint64_t *pu64IdSession) 86 { 87 VMMDevReqSessionId Req; 88 89 vmmdevInitRequest(&Req.header, VMMDevReq_GetSessionId); 90 int rc = vbglR3GRPerform(&Req.header); 91 if (rc == VINF_SUCCESS) 92 *pu64IdSession = Req.idSession; 93 94 return rc; 95 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePageSharing.cpp
r30666 r30668 87 87 static DECLCALLBACK(int) VBoxServicePageSharingEmptyTreeCallback(PAVLPVNODECORE pNode, void *pvUser); 88 88 89 static PAVLPVNODECORE pKnownModuleTree = NULL; 89 static PAVLPVNODECORE g_pKnownModuleTree = NULL; 90 static uint64_t g_idSession = 0; 90 91 91 92 /** … … 302 303 if (!pRec) 303 304 { 304 pRec = RTAvlPVRemove(& pKnownModuleTree, ModuleInfo.modBaseAddr);305 pRec = RTAvlPVRemove(&g_pKnownModuleTree, ModuleInfo.modBaseAddr); 305 306 if (!pRec) 306 307 { … … 411 412 if (!pRec) 412 413 { 413 pRec = RTAvlPVRemove(& pKnownModuleTree, pSystemModules->Modules[i].ImageBase);414 pRec = RTAvlPVRemove(&g_pKnownModuleTree, pSystemModules->Modules[i].ImageBase); 414 415 if (!pRec) 415 416 { … … 484 485 485 486 /* Delete leftover modules in the old tree. */ 486 RTAvlPVDestroy(& pKnownModuleTree, VBoxServicePageSharingEmptyTreeCallback, NULL);487 RTAvlPVDestroy(&g_pKnownModuleTree, VBoxServicePageSharingEmptyTreeCallback, NULL); 487 488 488 489 /* Check all registered modules. */ 489 490 VbglR3CheckSharedModules(); 491 490 492 /* Activate new module tree. */ 491 pKnownModuleTree = pNewTree;493 g_pKnownModuleTree = pNewTree; 492 494 } 493 495 … … 566 568 #endif 567 569 570 rc = VbglR3GetSessionId(&g_idSession); 571 AssertRCReturn(rc, rc); 572 568 573 /* Never fail here. */ 569 574 return VINF_SUCCESS; … … 584 589 for (;;) 585 590 { 591 uint64_t idNewSession; 592 586 593 VBoxServiceVerbose(3, "VBoxServicePageSharingWorker: enabled=%d\n", VbglR3PageSharingIsEnabled()); 587 594 … … 605 612 break; 606 613 } 614 idNewSession = g_idSession; 615 rc = VbglR3GetSessionId(&idNewSession); 616 AssertRC(rc); 617 618 if (idNewSession != g_idSession) 619 { 620 bool fUnregister = false; 621 622 VBoxServiceVerbose(3, "VBoxServicePageSharingWorker: VM was restored!!\n")); 623 /* The VM was restored, so reregister all modules the next time. */ 624 RTAvlPVDestroy(&g_pKnownModuleTree, VBoxServicePageSharingEmptyTreeCallback, &fUnregister); 625 g_pKnownModuleTree = NULL; 626 } 627 607 628 } 608 629 -
trunk/src/VBox/Devices/VMMDev/VMMDev.cpp
r30594 r30668 33 33 34 34 #include <iprt/asm.h> 35 #include <iprt/asm-amd64-x86.h> 35 36 #include <iprt/assert.h> 36 37 #include <iprt/buildconfig.h> … … 1880 1881 } 1881 1882 #endif 1883 1884 /* 1885 * Get a unique session id for this VM; the id will be different after each start, reset or restore of the VM 1886 * This can be used for restore detection inside the guest. 1887 */ 1888 case VMMDevReq_GetSessionId: 1889 { 1890 if (pRequestHeader->size != sizeof(VMMDevReqSessionId)) 1891 { 1892 AssertMsgFailed(("VMMDevReq_GetSessionId request size too small.\n")); 1893 pRequestHeader->rc = VERR_INVALID_PARAMETER; 1894 } 1895 else 1896 { 1897 VMMDevReqSessionId *pReq = (VMMDevReqSessionId *)pRequestHeader; 1898 pReq->idSession = pThis->idSession; 1899 pRequestHeader->rc = VINF_SUCCESS; 1900 } 1901 break; 1902 } 1903 1882 1904 default: 1883 1905 { 1884 1906 pRequestHeader->rc = VERR_NOT_IMPLEMENTED; 1885 1886 1907 Log(("VMMDev unknown request type %d\n", pRequestHeader->requestType)); 1887 1888 1908 break; 1889 1909 } … … 2707 2727 if (fCapsChanged) 2708 2728 pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps); 2729 2730 /* Generate a unique session id for this VM; it will be changed for each start, reset or restore. 2731 * This can be used for restore detection inside the guest. 2732 */ 2733 pThis->idSession = ASMReadTSC(); 2709 2734 } 2710 2735 … … 2930 2955 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Memory balloon size", "/Devices/VMMDev/BalloonChunks"); 2931 2956 2957 /* Generate a unique session id for this VM; it will be changed for each start, reset or restore. 2958 * This can be used for restore detection inside the guest. 2959 */ 2960 pThis->idSession = ASMReadTSC(); 2932 2961 return rc; 2933 2962 } -
trunk/src/VBox/Devices/VMMDev/VMMDevState.h
r29590 r30668 164 164 /* guest ram size */ 165 165 uint64_t cbGuestRAM; 166 167 /* unique session id; the id will be different after each start, reset or restore of the VM. */ 168 uint64_t idSession; 166 169 167 170 /* statistics interval change request */
Note:
See TracChangeset
for help on using the changeset viewer.