Changeset 75803 in vbox
- Timestamp:
- Nov 29, 2018 2:22:10 AM (6 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 2 edited
-
VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp (modified) (4 diffs)
-
VBoxService/VBoxServiceControl.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r75798 r75803 195 195 } while (rc == VERR_INTERRUPTED); 196 196 197 LogRel 2(("vbglR3GuestCtrlDetectPeekGetCancelSupport: rc=%Rrc %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x\n",197 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: rc=%Rrc %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x\n", 198 198 rc, PeekCall.idMsg.u.value32, PeekCall.cParams.u.value32, 199 199 PeekCall.acbParams[ 0].u.value32, PeekCall.acbParams[ 1].u.value32, … … 205 205 PeekCall.acbParams[12].u.value32, PeekCall.acbParams[13].u.value32)); 206 206 207 #if 0 /* enable after testing. */208 207 /* 209 208 * VERR_TRY_AGAIN is likely and easy. … … 241 240 return true; 242 241 } 243 #endif244 242 245 243 /* 246 * If we get an invalid handle status, we can't really tell.244 * Okay, pretty sure it's not supported then. 247 245 */ 248 if (rc != VERR_INVALID_HANDLE) 249 { 250 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Not supported (#3)\n")); 251 g_fVbglR3GuestCtrlHavePeekGetCancel = 0; 252 } 253 else 254 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Jury is still out (#4)\n")); 246 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Not supported (#3)\n")); 247 g_fVbglR3GuestCtrlHavePeekGetCancel = 0; 255 248 return false; 256 249 } … … 336 329 * Fallback if host < v6.0. 337 330 */ 338 return vbglR3GuestCtrlMsgWaitFor(idClient, pidMsg, pcParameters); 331 rc = vbglR3GuestCtrlMsgWaitFor(idClient, pidMsg, pcParameters); 332 if (rc == VERR_TOO_MUCH_DATA) 333 rc = VINF_SUCCESS; 334 return rc; 339 335 } 340 336 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r75798 r75803 77 77 static uint64_t g_idControlSession; 78 78 /** The guest control service client ID. */ 79 static uint32_t g_ uControlSvcClientID= 0;79 static uint32_t g_idControlSvcClient = 0; 80 80 #if 0 /** @todo process limit */ 81 81 /** How many started guest processes are kept into memory for supplying … … 194 194 195 195 if (RT_SUCCESS(rc)) 196 rc = VbglR3GuestCtrlConnect(&g_ uControlSvcClientID);196 rc = VbglR3GuestCtrlConnect(&g_idControlSvcClient); 197 197 if (RT_SUCCESS(rc)) 198 198 { 199 VGSvcVerbose(3, "Guest control service client ID=%RU32\n", g_ uControlSvcClientID);199 VGSvcVerbose(3, "Guest control service client ID=%RU32\n", g_idControlSvcClient); 200 200 201 201 /* Init session thread list. */ … … 230 230 */ 231 231 RTThreadUserSignal(RTThreadSelf()); 232 Assert(g_uControlSvcClientID > 0); 233 234 int rc = VINF_SUCCESS; 232 Assert(g_idControlSvcClient > 0); 235 233 236 234 /* Allocate a scratch buffer for commands which also send … … 241 239 AssertReturn(pvScratchBuf, VERR_NO_MEMORY); 242 240 243 VBGLR3GUESTCTRLCMDCTX ctxHost = { g_ uControlSvcClientID};241 VBGLR3GUESTCTRLCMDCTX ctxHost = { g_idControlSvcClient }; 244 242 /* Set default protocol version to 1. */ 245 243 ctxHost.uProtocol = 1; 246 244 247 int cRetrievalFailed = 0; /* Number of failed message retrievals in a row. */ 248 for (;;) 245 int rc = VINF_SUCCESS; /* (shut up compiler warnings) */ 246 int cRetrievalFailed = 0; /* Number of failed message retrievals in a row. */ 247 while (!*pfShutdown) 249 248 { 250 249 VGSvcVerbose(3, "GstCtrl: Waiting for host msg ...\n"); 251 uint32_t uMsg= 0;250 uint32_t idMsg = 0; 252 251 uint32_t cParms = 0; 253 rc = VbglR3GuestCtrlMsgPeekWait(g_ uControlSvcClientID, &uMsg, &cParms);254 if ( rc == VERR_TOO_MUCH_DATA)252 rc = VbglR3GuestCtrlMsgPeekWait(g_idControlSvcClient, &idMsg, &cParms); 253 if (RT_SUCCESS(rc)) 255 254 { 256 #ifdef DEBUG 257 VGSvcVerbose(4, "Message requires %u parameters, but only 2 supplied -- retrying request (no error!)...\n", 258 cParms); 259 #endif 260 rc = VINF_SUCCESS; /* Try to get "real" message in next block below. */ 261 } 262 else if (RT_FAILURE(rc)) 263 { 264 /* Note: VERR_GEN_IO_FAILURE seems to be normal if ran into timeout. */ 265 VGSvcError("GstCtrl: Getting host message failed with %Rrc\n", rc); 266 267 /* Check for VM session change. */ 255 cRetrievalFailed = 0; /* Reset failed retrieval count. */ 256 VGSvcVerbose(4, "idMsg=%RU32 (%s) (%RU32 parms) retrieved\n", idMsg, GstCtrlHostFnName((eHostFn)idMsg), cParms); 257 258 /* 259 * Close all open guest sessions if the VM was restored (all context IDs, 260 * sessions, etc. are now invalid). 261 * 262 * Note! This will suck performance wise if we get a lot of messages thru here. 263 * What about the service returning a HOST_MSG_RESTORED message? 264 */ 268 265 uint64_t idNewSession = g_idControlSession; 269 266 int rc2 = VbglR3GetSessionId(&idNewSession); 270 267 if ( RT_SUCCESS(rc2) 271 && (idNewSession != g_idControlSession))268 && idNewSession != g_idControlSession) 272 269 { 273 VGSvcVerbose(1, " GstCtrl: The VM session ID changed\n");270 VGSvcVerbose(1, "The VM session ID changed (i.e. restored).\n"); 274 271 g_idControlSession = idNewSession; 275 276 /* Close all opened guest sessions -- all context IDs, sessions etc.277 * are now invalid. */278 rc2 = VGSvcGstCtrlSessionClose(&g_Session);279 AssertRC(rc2);280 281 /* Do a reconnect. */282 VGSvcVerbose(1, "Reconnecting to HGCM service ...\n");283 rc2 = VbglR3GuestCtrlConnect(&g_uControlSvcClientID);284 if (RT_SUCCESS(rc2))285 {286 VGSvcVerbose(3, "Guest control service client ID=%RU32\n", g_uControlSvcClientID);287 cRetrievalFailed = 0;288 continue; /* Skip waiting. */289 }290 VGSvcError("Unable to re-connect to HGCM service, rc=%Rrc, bailing out\n", rc);291 break;292 }293 294 if (rc == VERR_INTERRUPTED)295 RTThreadYield(); /* To be on the safe side... */296 else if (++cRetrievalFailed <= 16) /** @todo Make this configurable? */297 RTThreadSleep(1000); /* Wait a bit before retrying. */298 else299 {300 VGSvcError("Too many failed attempts in a row to get next message, bailing out\n");301 break;302 }303 }304 305 if (RT_SUCCESS(rc))306 {307 VGSvcVerbose(4, "Msg=%RU32 (%RU32 parms) retrieved\n", uMsg, cParms);308 cRetrievalFailed = 0; /* Reset failed retrieval count. */309 310 /* Set number of parameters for current host context. */311 ctxHost.uNumParms = cParms;312 313 /* Check for VM session change. */314 uint64_t idNewSession = g_idControlSession;315 int rc2 = VbglR3GetSessionId(&idNewSession);316 if ( RT_SUCCESS(rc2)317 && (idNewSession != g_idControlSession))318 {319 VGSvcVerbose(1, "The VM session ID changed\n");320 g_idControlSession = idNewSession;321 322 /* Close all opened guest sessions -- all context IDs, sessions etc.323 * are now invalid. */324 272 rc2 = VGSvcGstCtrlSessionClose(&g_Session); 325 273 AssertRC(rc2); 326 274 } 327 275 328 switch (uMsg) 276 /* 277 * Handle the host message. 278 */ 279 ctxHost.uNumParms = cParms; 280 switch (idMsg) 329 281 { 330 282 case HOST_CANCEL_PENDING_WAITS: … … 353 305 */ 354 306 if (ctxHost.uProtocol == 1) 355 rc = VGSvcGstCtrlSessionHandler(&g_Session, uMsg, &ctxHost, pvScratchBuf, cbScratchBuf, pfShutdown);307 rc = VGSvcGstCtrlSessionHandler(&g_Session, idMsg, &ctxHost, pvScratchBuf, cbScratchBuf, pfShutdown); 356 308 else 357 309 { … … 361 313 * skip all not wanted messages here. 362 314 */ 363 rc = VbglR3GuestCtrlMsgSkipOld(g_ uControlSvcClientID);364 VGSvcVerbose(3, "Skipping uMsg=%RU32, cParms=%RU32, rc=%Rrc\n", uMsg, cParms, rc);315 rc = VbglR3GuestCtrlMsgSkipOld(g_idControlSvcClient); 316 VGSvcVerbose(3, "Skipping idMsg=%RU32, cParms=%RU32, rc=%Rrc\n", idMsg, cParms, rc); 365 317 } 366 318 break; 367 319 } 368 320 } 321 322 /* Do we need to shutdown? */ 323 if (idMsg == HOST_CANCEL_PENDING_WAITS) 324 break; 325 326 /* Let's sleep for a bit and let others run ... */ 327 RTThreadYield(); 369 328 } 370 371 /* Do we need to shutdown? */ 372 if ( *pfShutdown 373 || (RT_SUCCESS(rc) && uMsg == HOST_CANCEL_PENDING_WAITS)) 329 else 374 330 { 375 break; 331 /* Note: VERR_GEN_IO_FAILURE seems to be normal if ran into timeout. */ 332 /** @todo r=bird: Above comment makes no sense. How can you get a timeout in a blocking HGCM call? */ 333 VGSvcError("GstCtrl: Getting host message failed with %Rrc\n", rc); 334 335 /* Check for VM session change. */ 336 uint64_t idNewSession = g_idControlSession; 337 int rc2 = VbglR3GetSessionId(&idNewSession); 338 if ( RT_SUCCESS(rc2) 339 && (idNewSession != g_idControlSession)) 340 { 341 VGSvcVerbose(1, "GstCtrl: The VM session ID changed\n"); 342 g_idControlSession = idNewSession; 343 344 /* Close all opened guest sessions -- all context IDs, sessions etc. 345 * are now invalid. */ 346 rc2 = VGSvcGstCtrlSessionClose(&g_Session); 347 AssertRC(rc2); 348 349 /* Do a reconnect. */ 350 VGSvcVerbose(1, "Reconnecting to HGCM service ...\n"); 351 rc2 = VbglR3GuestCtrlConnect(&g_idControlSvcClient); 352 if (RT_SUCCESS(rc2)) 353 { 354 VGSvcVerbose(3, "Guest control service client ID=%RU32\n", g_idControlSvcClient); 355 cRetrievalFailed = 0; 356 continue; /* Skip waiting. */ 357 } 358 VGSvcError("Unable to re-connect to HGCM service, rc=%Rrc, bailing out\n", rc); 359 break; 360 } 361 362 if (rc == VERR_INTERRUPTED) 363 RTThreadYield(); /* To be on the safe side... */ 364 else if (++cRetrievalFailed <= 16) /** @todo Make this configurable? */ 365 RTThreadSleep(1000); /* Wait a bit before retrying. */ 366 else 367 { 368 VGSvcError("Too many failed attempts in a row to get next message, bailing out\n"); 369 break; 370 } 376 371 } 377 378 /* Let's sleep for a bit and let others run ... */379 RTThreadYield();380 372 } 381 373 … … 486 478 * control thread so that we can shutdown properly here. 487 479 */ 488 if (g_ uControlSvcClientID)480 if (g_idControlSvcClient) 489 481 { 490 482 VGSvcVerbose(3, "Cancelling pending waits (client ID=%u) ...\n", 491 g_ uControlSvcClientID);492 493 int rc = VbglR3GuestCtrlCancelPendingWaits(g_ uControlSvcClientID);483 g_idControlSvcClient); 484 485 int rc = VbglR3GuestCtrlCancelPendingWaits(g_idControlSvcClient); 494 486 if (RT_FAILURE(rc)) 495 487 VGSvcError("Cancelling pending waits failed; rc=%Rrc\n", rc); … … 526 518 vgsvcGstCtrlShutdown(); 527 519 528 VGSvcVerbose(3, "Disconnecting client ID=%u ...\n", g_ uControlSvcClientID);529 VbglR3GuestCtrlDisconnect(g_ uControlSvcClientID);530 g_ uControlSvcClientID= 0;520 VGSvcVerbose(3, "Disconnecting client ID=%u ...\n", g_idControlSvcClient); 521 VbglR3GuestCtrlDisconnect(g_idControlSvcClient); 522 g_idControlSvcClient = 0; 531 523 532 524 if (g_hControlEvent != NIL_RTSEMEVENTMULTI)
Note:
See TracChangeset
for help on using the changeset viewer.

