Changeset 103165 in vbox for trunk/src/VBox/Additions/common/VBoxGuest
- Timestamp:
- Feb 1, 2024 4:17:38 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r102881 r103165 66 66 *********************************************************************************************************************************/ 67 67 /** Set if GUEST_MSG_PEEK_WAIT and friends are supported. */ 68 static int g_fVbglR3GuestCtrlHavePeekGetCancel = -1; 68 static int g_fVbglR3GuestCtrlHavePeekGetCancel = -1; 69 /** Represents the currently cached host features 0. 70 * Set to 0 if not available / not cached yet. */ 71 static uint64_t g_fVbglR3GuestCtrlHostFeatures0 = 0; 72 73 74 /********************************************************************************************************************************* 75 * Prototypes * 76 *********************************************************************************************************************************/ 77 static int vbglR3GuestCtrlQueryFeatures(uint32_t idClient, uint64_t *pfHostFeatures0, uint64_t *pfHostFeatures1); 78 79 80 /** 81 * Invalidates the internal state of the Guest Control API. 82 * 83 * @returns VBox status code. 84 * @param idClient The client ID returned by VbglR3GuestCtrlConnect(). 85 */ 86 static int vbglR3GuestCtrlInvalidate(uint32_t idClient) 87 { 88 uint64_t fVbglR3GuestCtrlHostFeatures0 = 0; 89 int const rc2 = vbglR3GuestCtrlQueryFeatures(idClient, 90 &fVbglR3GuestCtrlHostFeatures0, NULL /* pfHostFeatures1, unused */); 91 if (RT_SUCCESS(rc2)) 92 { 93 /* Check if the host's feature set has changed. This might happen on a VM restore. */ 94 if ( g_fVbglR3GuestCtrlHostFeatures0 95 && g_fVbglR3GuestCtrlHostFeatures0 != fVbglR3GuestCtrlHostFeatures0) 96 LogRelFunc(("Host feature set has changed (%#x -> %#x)\n", 97 g_fVbglR3GuestCtrlHostFeatures0, fVbglR3GuestCtrlHostFeatures0)); 98 99 g_fVbglR3GuestCtrlHostFeatures0 = fVbglR3GuestCtrlHostFeatures0; 100 } 101 else 102 LogRelFunc(("Querying host features not supported, rc=%Rrc\n", rc2)); 103 /* Note: Very old hosts don't know about querying host features, so this isn't fatal for the caller. */ 104 105 return VINF_SUCCESS; 106 } 69 107 70 108 … … 78 116 VBGLR3DECL(int) VbglR3GuestCtrlConnect(uint32_t *pidClient) 79 117 { 80 return VbglR3HGCMConnect("VBoxGuestControlSvc", pidClient); 118 AssertPtrReturn(pidClient, VERR_INVALID_POINTER); 119 120 int rc = VbglR3HGCMConnect("VBoxGuestControlSvc", pidClient); 121 if (RT_SUCCESS(rc)) 122 rc = vbglR3GuestCtrlInvalidate(*pidClient); 123 124 return rc; 81 125 } 82 126 … … 324 368 325 369 /** 326 * Reports features to the host and retrieve host feature set.370 * Reports features to the host and retrieve host features set. 327 371 * 328 372 * @returns VBox status code. … … 364 408 365 409 /** 366 * Query the host features. 367 * 368 * @returns VBox status code. 369 * @param idClient The client ID returned by VbglR3GuestCtrlConnect(). 370 * @param pfHostFeatures Where to store the host feature, VBOX_GUESTCTRL_HF_XXX. 371 */ 372 VBGLR3DECL(int) VbglR3GuestCtrlQueryFeatures(uint32_t idClient, uint64_t *pfHostFeatures) 410 * Queries the host features, internal version. 411 * 412 * @returns VBox status code. 413 * @param idClient The client ID returned by VbglR3GuestCtrlConnect(). 414 * @param pfHostFeatures0 Where to store the host features, VBOX_GUESTCTRL_HF_0_XXX. 415 * Optional and can be NULL. 416 * @param pfHostFeatures1 Where to store the host features, VBOX_GUESTCTRL_HF_1_XXX. 417 * Currently unused. Optional and can be NULL. 418 */ 419 static int vbglR3GuestCtrlQueryFeatures(uint32_t idClient, uint64_t *pfHostFeatures0, uint64_t *pfHostFeatures1) 373 420 { 374 421 int rc; … … 392 439 if (Msg.f64Features1.u.value64 & RT_BIT_64(63)) 393 440 rc = VERR_NOT_SUPPORTED; 394 else if (pfHostFeatures) 395 *pfHostFeatures = Msg.f64Features0.u.value64; 441 else 442 { 443 if (pfHostFeatures0) 444 *pfHostFeatures0 = Msg.f64Features0.u.value64; 445 if (pfHostFeatures1) 446 *pfHostFeatures1 = Msg.f64Features1.u.value64; 447 } 396 448 break; 397 449 } 398 450 } while (rc == VERR_INTERRUPTED); 399 451 return rc; 400 452 } 453 454 455 /** 456 * Queries the host features. 457 * 458 * @returns VBox status code. 459 * @param idClient The client ID returned by VbglR3GuestCtrlConnect(). 460 * @param pfHostFeatures Where to store the host features, VBOX_GUESTCTRL_HF_0_XXX. Optional and can be NULL. 461 */ 462 VBGLR3DECL(int) VbglR3GuestCtrlQueryFeatures(uint32_t idClient, uint64_t *pfHostFeatures) 463 { 464 return vbglR3GuestCtrlQueryFeatures(idClient, pfHostFeatures, NULL /* pfHostFeatures1, unused */); 401 465 } 402 466 … … 1674 1738 VbglHGCMParmUInt32Set(&Msg.cb_env, 0); 1675 1739 VbglHGCMParmPtrSet(&Msg.env, pStartupInfo->pszEnv, pStartupInfo->cbEnv); 1676 if (pCtx->uProtocol < 2) 1740 if (pCtx->uProtocol < 2) /* Protocol v1, deprecated. */ 1677 1741 { 1678 1742 VbglHGCMParmPtrSet(&Msg.u.v1.username, pStartupInfo->pszUser, pStartupInfo->cbUser); … … 1680 1744 VbglHGCMParmUInt32Set(&Msg.u.v1.timeout, 0); 1681 1745 } 1682 else 1746 else /* Protocol v2. */ 1683 1747 { 1684 1748 VbglHGCMParmUInt32Set(&Msg.u.v2.timeout, 0); … … 1686 1750 VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0); 1687 1751 VbglHGCMParmPtrSet(&Msg.u.v2.affinity, pStartupInfo->uAffinity, sizeof(pStartupInfo->uAffinity)); 1688 /* v2.cwd was added in 7.1. If the host is older, the Msg struct it sends is 1689 * shorter and these fields are zero-filled, which equals 'no cwd requested'. */ 1690 VbglHGCMParmPtrSet(&Msg.u.v2.cwd, pStartupInfo->pszCwd, pStartupInfo->cbCwd); 1691 } 1692 1693 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1752 } 1753 1754 /* CWD support was added in VBox 7.1. Otherwise just skip setting it. */ 1755 if (g_fVbglR3GuestCtrlHostFeatures0 & VBOX_GUESTCTRL_HF_0_PROCESS_CWD) 1756 VbglHGCMParmPtrSet(&Msg.cwd, pStartupInfo->pszCwd, pStartupInfo->cbCwd); 1757 1758 /* 1759 * We need to calculate the data size ourselves here and not rely on sizeof(), 1760 * as sizeof(Msg) might be different to what the host expects. 1761 * 1762 * This first was needed when excluding the CWD support for hosts running VBox < 7.1. 1763 */ 1764 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(VBGLIOCHGCMCALL) + pCtx->uNumParms * sizeof(HGCMFunctionParameter)); 1694 1765 if (RT_FAILURE(rc)) 1695 1766 {
Note:
See TracChangeset
for help on using the changeset viewer.