Changeset 75853 in vbox for trunk/src/VBox/Additions/common/VBoxGuest/lib
- Timestamp:
- Nov 30, 2018 7:26:42 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r75824 r75853 307 307 308 308 309 310 309 /** 311 310 * Peeks at the next host message, waiting for one to turn up. … … 314 313 * @retval VERR_INTERRUPTED if interrupted. Does the necessary cleanup, so 315 314 * caller just have to repeat this call. 315 * @retval VERR_VM_RESTORED if the VM has been restored (idRestoreCheck). 316 316 * 317 317 * @param idClient The client ID returned by VbglR3GuestCtrlConnect(). … … 319 319 * @param pcParameters Where to store the number of parameters which will 320 320 * be received in a second call to the host. 321 */ 322 VBGLR3DECL(int) VbglR3GuestCtrlMsgPeekWait(uint32_t idClient, uint32_t *pidMsg, uint32_t *pcParameters) 321 * @param pidRestoreCheck Pointer to the VbglR3GetSessionId() variable to use 322 * for the VM restore check. Optional. 323 * 324 * @note Restore check is only performed optimally with a 6.0 host. 325 */ 326 VBGLR3DECL(int) VbglR3GuestCtrlMsgPeekWait(uint32_t idClient, uint32_t *pidMsg, uint32_t *pcParameters, uint64_t *pidRestoreCheck) 323 327 { 324 328 AssertPtrReturn(pidMsg, VERR_INVALID_POINTER); … … 328 332 if (vbglR3GuestCtrlSupportsPeekGetCancel(idClient)) 329 333 { 330 HGCMMsgCmdWaitFor Msg; 331 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, GUEST_MSG_PEEK_WAIT, 2); 332 VbglHGCMParmUInt32Set(&Msg.msg, 0); 333 VbglHGCMParmUInt32Set(&Msg.num_parms, 0); 334 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 334 struct 335 { 336 VBGLIOCHGCMCALL Hdr; 337 HGCMFunctionParameter idMsg; /* Doubles as restore check on input. */ 338 HGCMFunctionParameter cParameters; 339 } Msg; 340 VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, GUEST_MSG_PEEK_WAIT, 2); 341 VbglHGCMParmUInt64Set(&Msg.idMsg, pidRestoreCheck ? *pidRestoreCheck : 0); 342 VbglHGCMParmUInt32Set(&Msg.cParameters, 0); 343 rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg)); 335 344 LogRel(("VbglR3GuestCtrlMsgPeekWait -> %Rrc\n", rc)); 336 345 if (RT_SUCCESS(rc)) 337 346 { 338 AssertMsgReturn( Msg. msg.type == VMMDevHGCMParmType_32bit339 && Msg. num_parms.type == VMMDevHGCMParmType_32bit,340 ("msg.type=%d num_parms.type=%d\n", Msg. msg.type, Msg.num_parms.type),347 AssertMsgReturn( Msg.idMsg.type == VMMDevHGCMParmType_64bit 348 && Msg.cParameters.type == VMMDevHGCMParmType_32bit, 349 ("msg.type=%d num_parms.type=%d\n", Msg.idMsg.type, Msg.cParameters.type), 341 350 VERR_INTERNAL_ERROR_3); 342 351 343 *pidMsg = Msg.msg.u.value32;344 *pcParameters = Msg. num_parms.u.value32;352 *pidMsg = (uint32_t)Msg.idMsg.u.value64; 353 *pcParameters = Msg.cParameters.u.value32; 345 354 return rc; 346 355 } … … 351 360 if (rc == VERR_INTERRUPTED) 352 361 { 353 VBGL_HGCM_HDR_INIT(&Msg. hdr, idClient, GUEST_MSG_CANCEL, 0);354 int rc2 = VbglR3HGCMCall(&Msg. hdr, sizeof(Msg.hdr));362 VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, GUEST_MSG_CANCEL, 0); 363 int rc2 = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg.Hdr)); 355 364 AssertRC(rc2); 356 365 } 366 367 /* 368 * If restored, update pidRestoreCheck. 369 */ 370 if (rc == VERR_VM_RESTORED && pidRestoreCheck) 371 *pidRestoreCheck = Msg.idMsg.u.value64; 357 372 358 373 *pidMsg = UINT32_MAX - 1; … … 363 378 /* 364 379 * Fallback if host < v6.0. 380 * 381 * Note! The restore check isn't perfect. Would require checking afterwards 382 * and stash the result if we were restored during the call. Too much 383 * hazzle for a downgrade scenario. 365 384 */ 385 if (pidRestoreCheck) 386 { 387 uint64_t idRestoreCur = *pidRestoreCheck; 388 rc = VbglR3GetSessionId(&idRestoreCur); 389 if (RT_SUCCESS(rc) && idRestoreCur != *pidRestoreCheck) 390 { 391 *pidRestoreCheck = idRestoreCur; 392 return VERR_VM_RESTORED; 393 } 394 } 395 366 396 rc = vbglR3GuestCtrlMsgWaitFor(idClient, pidMsg, pcParameters); 367 397 if (rc == VERR_TOO_MUCH_DATA)
Note:
See TracChangeset
for help on using the changeset viewer.