Changeset 108442 in vbox
- Timestamp:
- Mar 4, 2025 6:26:48 PM (2 months ago)
- svn:sync-xref-src-repo-rev:
- 167816
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/VBoxWinDrvInst.h
r107989 r108442 120 120 /** Restart the service. */ 121 121 VBOXWINDRVSVCFN_RESTART, 122 /** Deletes a service. */ 123 VBOXWINDRVSVCFN_DELETE, 122 124 /** End marker, do not use. */ 123 125 VBOXWINDRVSVCFN_END -
trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp
r108441 r108442 2429 2429 } 2430 2430 2431 case VBOXWINDRVSVCFN_DELETE: 2432 { 2433 if (!DeleteService(hSvc)) 2434 rc = vboxWinDrvInstLogLastError(pCtx, "Deleting service '%s' failed", pszService); 2435 else 2436 { 2437 vboxWinDrvInstLogInfo(pCtx, "Successfully deleted service '%s'", pszService); 2438 fFlags &= ~VBOXWINDRVSVCFN_F_WAIT; /* Drop the wait flag, makes no sense here. */ 2439 } 2440 break; 2441 } 2442 2431 2443 default: 2432 2444 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); … … 2434 2446 } 2435 2447 2436 if ( RT_SUCCESS(rc) 2437 && (fFlags & VBOXWINDRVSVCFN_F_WAIT)) 2438 { 2439 uint64_t const msStartTS = RTTimeMilliTS(); 2440 2441 rc = VERR_NO_CHANGE; /* No change yet. */ 2442 2443 if (!g_pfnQueryServiceStatusEx) 2444 { 2445 vboxWinDrvInstLogWarn(pCtx, "Waiting for status change of service '%s' not supported on this OS, skipping", 2446 pszService); 2447 rc = VINF_SUCCESS; 2448 } 2449 else 2450 { 2451 vboxWinDrvInstLogInfo(pCtx, "Waiting for status change of service '%s' (%ums timeout) ...", pszService, msTimeout); 2452 for (;;) 2448 if (RT_SUCCESS(rc)) 2449 { 2450 if (fFlags & VBOXWINDRVSVCFN_F_WAIT) 2451 { 2452 uint64_t const msStartTS = RTTimeMilliTS(); 2453 2454 rc = VERR_NO_CHANGE; /* No change yet. */ 2455 2456 if (!g_pfnQueryServiceStatusEx) 2453 2457 { 2454 DWORD dwBytes; 2455 if (!g_pfnQueryServiceStatusEx(hSvc, 2456 SC_STATUS_PROCESS_INFO, 2457 (LPBYTE)&enmSvcSts, 2458 sizeof(SERVICE_STATUS_PROCESS), 2459 &dwBytes)) 2458 vboxWinDrvInstLogWarn(pCtx, "Waiting for status change of service '%s' not supported on this OS, skipping", 2459 pszService); 2460 rc = VINF_SUCCESS; 2461 } 2462 else 2463 { 2464 vboxWinDrvInstLogInfo(pCtx, "Waiting for status change of service '%s' (%ums timeout) ...", pszService, msTimeout); 2465 for (;;) 2460 2466 { 2461 rc = vboxWinDrvInstLogLastError(pCtx, "Failed to query service status"); 2462 break; 2463 } 2464 2465 if ((RTTimeMilliTS() - msStartTS) % RT_MS_1SEC == 0) /* Don't spam. */ 2466 vboxWinDrvInstLogVerbose(pCtx, 3, "Service '%s' status is %#x: %u", 2467 pszService, enmSvcSts.dwCurrentState, (RTTimeMilliTS() - msStartTS) % 100 == 0); 2468 2469 switch (enmSvcSts.dwCurrentState) 2470 { 2471 case SERVICE_STOP_PENDING: 2472 case SERVICE_START_PENDING: 2473 RTThreadSleep(100); /* Wait a bit before retrying. */ 2474 break; 2475 2476 case SERVICE_RUNNING: 2467 DWORD dwBytes; 2468 if (!g_pfnQueryServiceStatusEx(hSvc, 2469 SC_STATUS_PROCESS_INFO, 2470 (LPBYTE)&enmSvcSts, 2471 sizeof(SERVICE_STATUS_PROCESS), 2472 &dwBytes)) 2477 2473 { 2478 if (enmFn == VBOXWINDRVSVCFN_START) 2479 rc = VINF_SUCCESS; 2474 rc = vboxWinDrvInstLogLastError(pCtx, "Failed to query service status"); 2480 2475 break; 2481 2476 } 2482 2477 2483 case SERVICE_STOPPED: 2478 if ((RTTimeMilliTS() - msStartTS) % RT_MS_1SEC == 0) /* Don't spam. */ 2479 vboxWinDrvInstLogVerbose(pCtx, 3, "Service '%s' status is %#x: %u", 2480 pszService, enmSvcSts.dwCurrentState, (RTTimeMilliTS() - msStartTS) % 100 == 0); 2481 2482 switch (enmSvcSts.dwCurrentState) 2484 2483 { 2485 if (enmFn == VBOXWINDRVSVCFN_START) 2484 case SERVICE_STOP_PENDING: 2485 case SERVICE_START_PENDING: 2486 RTThreadSleep(100); /* Wait a bit before retrying. */ 2487 break; 2488 2489 case SERVICE_RUNNING: 2486 2490 { 2487 vboxWinDrvInstLogError(pCtx, "Service '%s' stopped unexpectedly", pszService); 2491 if (enmFn == VBOXWINDRVSVCFN_START) 2492 rc = VINF_SUCCESS; 2493 break; 2494 } 2495 2496 case SERVICE_STOPPED: 2497 { 2498 if (enmFn == VBOXWINDRVSVCFN_START) 2499 { 2500 vboxWinDrvInstLogError(pCtx, "Service '%s' stopped unexpectedly", pszService); 2501 rc = VERR_INVALID_STATE; 2502 } 2503 else 2504 rc = VINF_SUCCESS; 2505 break; 2506 } 2507 2508 default: 2509 { 2510 vboxWinDrvInstLogError(pCtx, "Service '%s' reported an unexpected state (%#x)", 2511 pszService, enmSvcSts.dwCurrentState); 2488 2512 rc = VERR_INVALID_STATE; 2489 2513 } 2490 else 2491 rc = VINF_SUCCESS; 2514 } 2515 2516 if ( RT_FAILURE(rc) 2517 && rc != VERR_NO_CHANGE) 2518 break; 2519 2520 if (RT_SUCCESS(rc)) 2521 break; 2522 2523 if (RTTimeMilliTS() - msStartTS >= msTimeout) 2524 { 2525 vboxWinDrvInstLogError(pCtx, "Waiting for service '%s' timed out (%ums)", pszService, msTimeout); 2526 rc = VERR_TIMEOUT; 2492 2527 break; 2493 2528 } 2494 2495 default:2496 {2497 vboxWinDrvInstLogError(pCtx, "Service '%s' reported an unexpected state (%#x)",2498 pszService, enmSvcSts.dwCurrentState);2499 rc = VERR_INVALID_STATE;2500 }2501 }2502 2503 if ( RT_FAILURE(rc)2504 && rc != VERR_NO_CHANGE)2505 break;2506 2507 if (RT_SUCCESS(rc))2508 break;2509 2510 if (RTTimeMilliTS() - msStartTS >= msTimeout)2511 {2512 vboxWinDrvInstLogError(pCtx, "Waiting for service '%s' timed out (%ums)", pszService, msTimeout);2513 rc = VERR_TIMEOUT;2514 break;2515 2529 } 2516 2530 } 2517 } 2518 2519 if (RT_SUCCESS(rc))2520 vboxWinDrvInstLogInfo(pCtx, "Service '%s' successfully %s",2521 pszService, enmFn == VBOXWINDRVSVCFN_START ? "started" : "stopped");2522 }2523 else2524 vboxWinDrvInstLogVerbose(pCtx, 1, "Service '%s' was %s asynchronously",2525 pszService, enmFn == VBOXWINDRVSVCFN_START ? "started" : "stopped");2531 2532 if (RT_SUCCESS(rc)) 2533 vboxWinDrvInstLogInfo(pCtx, "Service '%s' successfully %s", 2534 pszService, enmFn == VBOXWINDRVSVCFN_START ? "started" : "stopped"); 2535 } 2536 else 2537 vboxWinDrvInstLogVerbose(pCtx, 1, "Service '%s' was %s asynchronously", 2538 pszService, enmFn == VBOXWINDRVSVCFN_START ? "started" : "stopped"); 2539 } 2526 2540 2527 2541 RTUtf16Free(pwszService);
Note:
See TracChangeset
for help on using the changeset viewer.