- Timestamp:
- May 26, 2020 5:43:31 PM (5 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r84238 r84548 1027 1027 1028 1028 /** 1029 * Retrieves a HOST_MSG_SHUTDOWN message. 1030 * 1031 * @returns VBox status code. 1032 * @param pCtx Guest control command context to use. 1033 * @param pfAction Where to store the action flags on success. 1034 */ 1035 VBGLR3DECL(int) VbglR3GuestCtrlGetShutdown(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *pfAction) 1036 { 1037 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1038 AssertReturn(pCtx->uNumParms == 1, VERR_INVALID_PARAMETER); 1039 1040 int rc; 1041 do 1042 { 1043 HGCMMsgShutdown Msg; 1044 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1045 VbglHGCMParmUInt32Set(&Msg.context, HOST_MSG_SHUTDOWN); 1046 1047 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1048 if (RT_SUCCESS(rc)) 1049 { 1050 Msg.context.GetUInt32(&pCtx->uContextID); 1051 Msg.action.GetUInt32(pfAction); 1052 } 1053 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1054 return rc; 1055 } 1056 1057 /** 1029 1058 * Initializes a process startup info, extended version. 1030 1059 * -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r84243 r84548 247 247 const uint64_t fGuestFeatures = VBOX_GUESTCTRL_GF_0_SET_SIZE 248 248 | VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0 249 | VBOX_GUESTCTRL_GF_0_PROCESS_DYNAMIC_SIZES; 249 | VBOX_GUESTCTRL_GF_0_PROCESS_DYNAMIC_SIZES 250 | VBOX_GUESTCTRL_GF_0_SHUTDOWN; 250 251 251 252 rc = VbglR3GuestCtrlReportFeatures(g_idControlSvcClient, fGuestFeatures, &g_fControlHostFeatures0); -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r84215 r84548 34 34 #include <iprt/process.h> 35 35 #include <iprt/rand.h> 36 #include <iprt/system.h> /* For RTShutdown. */ 36 37 37 38 #include "VBoxServiceInternal.h" … … 990 991 991 992 /** 993 * Handles shutting down / rebooting the guest OS. 994 * 995 * @returns VBox status code. 996 * @param pSession Guest session. 997 * @param pHostCtx Host context. 998 */ 999 static int vgsvcGstCtrlSessionHandleShutdown(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx) 1000 { 1001 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 1002 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 1003 1004 /* 1005 * Retrieve the request. 1006 */ 1007 uint32_t fAction; 1008 int rc = VbglR3GuestCtrlGetShutdown(pHostCtx, &fAction); 1009 if (RT_SUCCESS(rc)) 1010 { 1011 VGSvcVerbose(1, "Host requested to %s system ...\n", (fAction & RTSYSTEM_SHUTDOWN_REBOOT) ? "reboot" : "shutdown"); 1012 1013 /* Reply first to the host, in order to avoid host hangs when issuing the guest shutdown. */ 1014 rc = VbglR3GuestCtrlMsgReply(pHostCtx, VINF_SUCCESS); 1015 if (RT_FAILURE(rc)) 1016 { 1017 VGSvcError("Failed to reply to shutdown / reboot request, rc=%Rrc\n", rc); 1018 } 1019 else 1020 { 1021 rc = RTSystemShutdown(0 /*cMsDelay*/, 1022 fAction | RTSYSTEM_SHUTDOWN_PLANNED, 1023 "VBoxService"); 1024 if (RT_FAILURE(rc)) 1025 VGSvcError("%s system failed with %Rrc\n", (fAction & RTSYSTEM_SHUTDOWN_REBOOT) ? "Rebooting" : "Shuting down"); 1026 } 1027 } 1028 else 1029 { 1030 VGSvcError("Error fetching parameters for shutdown / reboot request: %Rrc\n", rc); 1031 VbglR3GuestCtrlMsgSkip(pHostCtx->uClientID, rc, UINT32_MAX); 1032 } 1033 1034 return rc; 1035 } 1036 1037 1038 /** 992 1039 * Handles getting the user's home directory. 993 1040 * … … 1412 1459 if (fImpersonated) 1413 1460 rc = vgsvcGstCtrlSessionHandlePathUserHome(pSession, pHostCtx); 1461 break; 1462 1463 case HOST_MSG_SHUTDOWN: 1464 rc = vgsvcGstCtrlSessionHandleShutdown(pSession, pHostCtx); 1414 1465 break; 1415 1466
Note:
See TracChangeset
for help on using the changeset viewer.