- Timestamp:
- Aug 23, 2012 10:18:41 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r42926 r42937 104 104 BOOL fCompleted; 105 105 if ( SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted))) 106 && !fCompleted) 106 && fCompleted) 107 { 108 AssertMsgFailed(("Setting value of an already completed progress\n")); 107 109 return VINF_SUCCESS; 110 } 108 111 HRESULT hr = mProgress->SetCurrentOperationProgress(uPercent); 109 112 if (FAILED(hr)) … … 748 751 if (RT_SUCCESS(rc)) 749 752 { 750 Log Rel(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n",751 strFileSource.c_str(), strFileDest.c_str()));753 LogFlowThisFunc(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n", 754 strFileSource.c_str(), strFileDest.c_str())); 752 755 753 756 if (RT_SUCCESS(rc)) … … 786 789 if (RT_SUCCESS(rc)) 787 790 { 788 LogRel(("Verifying Guest Additions installer file \"%s\" ...\n", strFileDest.c_str())); 791 LogFlowThisFunc(("Verifying Guest Additions installer file \"%s\" ...\n", 792 strFileDest.c_str())); 789 793 790 794 GuestFsObjData objData; … … 794 798 && cbSize == (uint64_t)cbSizeOnGuest) 795 799 { 796 Log Rel(("Guest Additions installer file \"%s\" successfully verified\n",797 strFileDest.c_str()));800 LogFlowThisFunc(("Guest Additions installer file \"%s\" successfully verified\n", 801 strFileDest.c_str())); 798 802 } 799 803 else … … 801 805 if (RT_SUCCESS(rc)) /* Size does not match. */ 802 806 { 803 Log Rel(("Size of Guest Additions installer file \"%s\" does not match: %RI64bytes copied, %RU64bytes expected\n",804 strFileDest.c_str(), cbSizeOnGuest, cbSize));807 LogFlowThisFunc(("Size of Guest Additions installer file \"%s\" does not match: %RI64bytes copied, %RU64bytes expected\n", 808 strFileDest.c_str(), cbSizeOnGuest, cbSize)); 805 809 rc = VERR_BROKEN_PIPE; /** @todo Find a better error. */ 806 810 } 807 811 else 808 Log Rel(("Error copying Guest Additions installer file \"%s\": %Rrc\n",809 strFileDest.c_str(), rc));812 LogFlowThisFunc(("Error copying Guest Additions installer file \"%s\": %Rrc\n", 813 strFileDest.c_str(), rc)); 810 814 } 811 815 … … 831 835 if (RT_SUCCESS(rc)) 832 836 { 833 Log Rel(("Running %s ...\n", procInfo.mName.c_str()));837 LogFlowThisFunc(("Running %s ...\n", procInfo.mName.c_str())); 834 838 835 839 GuestProcessWaitResult waitRes; … … 853 857 else /* Yay, success! */ 854 858 { 855 Log Rel(("%s successfully completed\n", procInfo.mName.c_str()));859 LogFlowThisFunc(("%s successfully completed\n", procInfo.mName.c_str())); 856 860 } 857 861 } … … 950 954 { 951 955 rc = getGuestProperty(pGuest, "/VirtualBox/GuestAdd/InstallDir", strInstallerDir); 952 if (RT_SUCCESS(rc))953 {954 LogRel(("Guest Additions were installed to: %ls\n",955 strInstallerDir.c_str()));956 rc = setProgress(8);957 }958 959 956 if (RT_SUCCESS(rc)) 960 957 { … … 969 966 } 970 967 971 LogRel(("Guest Additions update will be installed to: %s\n",968 LogRel(("Guest Additions update directory is: %s\n", 972 969 strInstallerDir.c_str())); 973 970 974 /* Prepare the file(s) we want to copy over to the guest and 975 * (maybe) want to run. */ 976 switch (eOSType) 977 { 978 case eOSType_Windows: 979 { 980 /* Our certificate. */ 981 mFiles.push_back(InstallerFile("CERT/ORACLE_VBOX.CER", "Oracle_VBox.cer", 982 UPDATEFILE_FLAG_OPTIONAL)); 983 /* Our certificate installation utility. */ 984 GuestProcessStartupInfo siCertUtil; 985 siCertUtil.mArguments.push_back(Utf8Str("add-trusted-publisher")); 986 siCertUtil.mArguments.push_back(Utf8Str(strInstallerDir + "oracle-vbox.cer")); 987 mFiles.push_back(InstallerFile("CERT/VBOXCERTUTIL.EXE", "VBoxCertUtil.exe", 988 UPDATEFILE_FLAG_OPTIONAL | UPDATEFILE_FLAG_EXECUTE, siCertUtil)); 989 /* The installers in different flavors. */ 990 mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS_X86.EXE", 991 strInstallerDir + "VBoxWindowsAdditions_x86.exe", 992 UPDATEFILE_FLAG_NONE)); 993 mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS_AMD64.EXE", 994 strInstallerDir + "VBoxWindowsAdditions_amd64.exe", 995 UPDATEFILE_FLAG_NONE)); 996 GuestProcessStartupInfo siInstaller; 997 siInstaller.mArguments.push_back(Utf8Str("/S")); /* We want to install in silent mode. */ 998 siInstaller.mArguments.push_back(Utf8Str("/l")); /* ... and logging enabled. */ 999 /* Don't quit VBoxService during upgrade because it still is used for this 1000 * piece of code we're in right now (that is, here!) ... */ 1001 siInstaller.mArguments.push_back(Utf8Str("/no_vboxservice_exit")); 1002 /* Tell the installer to report its current installation status 1003 * using a running VBoxTray instance via balloon messages in the 1004 * Windows taskbar. */ 1005 siInstaller.mArguments.push_back(Utf8Str("/post_installstatus")); 1006 /* If the caller does not want to wait for out guest update process to end, 1007 * complete the progress object now so that the caller can do other work. */ 1008 if (mFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly) 1009 siInstaller.mFlags |= ProcessCreateFlag_WaitForProcessStartOnly; 1010 mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS.EXE", 1011 strInstallerDir + "VBoxWindowsAdditions.exe", 1012 UPDATEFILE_FLAG_EXECUTE, siInstaller)); 1013 break; 1014 } 1015 case eOSType_Linux: 1016 /** @todo Add Linux support. */ 1017 break; 1018 case eOSType_Solaris: 1019 /** @todo Add Solaris support. */ 1020 break; 1021 default: 1022 rc = VERR_INVALID_PARAMETER; 1023 } 1024 971 /* Create the installation directory. */ 972 rc = pSession->directoryCreateInternal(strInstallerDir, 973 755 /* Mode */, DirectoryCreateFlag_Parents); 974 if (RT_FAILURE(rc)) 975 hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR, 976 Utf8StrFmt(GuestSession::tr("Error creating installation directory \"%s\" on the guest: %Rrc"), 977 strInstallerDir.c_str(), rc)); 1025 978 if (RT_SUCCESS(rc)) 1026 { 979 rc = setProgress(10); 980 981 if (RT_SUCCESS(rc)) 982 { 983 /* Prepare the file(s) we want to copy over to the guest and 984 * (maybe) want to run. */ 985 switch (eOSType) 986 { 987 case eOSType_Windows: 988 { 989 #if 0 /* VBoxCertUtil.exe does not work yet, disabled. */ 990 /* Our certificate. */ 991 mFiles.push_back(InstallerFile("CERT/ORACLE_VBOX.CER", 992 strInstallerDir + "Oracle_VBox.cer", 993 UPDATEFILE_FLAG_OPTIONAL)); 994 /* Our certificate installation utility. */ 995 GuestProcessStartupInfo siCertUtil; 996 siCertUtil.mArguments.push_back(Utf8Str("add-trusted-publisher")); 997 siCertUtil.mArguments.push_back(Utf8Str(strInstallerDir + "oracle-vbox.cer")); 998 mFiles.push_back(InstallerFile("CERT/VBOXCERTUTIL.EXE", 999 strInstallerDir + "VBoxCertUtil.exe", 1000 UPDATEFILE_FLAG_OPTIONAL | UPDATEFILE_FLAG_EXECUTE, siCertUtil)); 1001 #endif 1002 /* The installers in different flavors. */ 1003 mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS_X86.EXE", 1004 strInstallerDir + "VBoxWindowsAdditions-x86.exe", 1005 UPDATEFILE_FLAG_NONE)); 1006 mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS_AMD64.EXE", 1007 strInstallerDir + "VBoxWindowsAdditions-amd64.exe", 1008 UPDATEFILE_FLAG_NONE)); 1009 GuestProcessStartupInfo siInstaller; 1010 siInstaller.mArguments.push_back(Utf8Str("/S")); /* We want to install in silent mode. */ 1011 siInstaller.mArguments.push_back(Utf8Str("/l")); /* ... and logging enabled. */ 1012 /* Don't quit VBoxService during upgrade because it still is used for this 1013 * piece of code we're in right now (that is, here!) ... */ 1014 siInstaller.mArguments.push_back(Utf8Str("/no_vboxservice_exit")); 1015 /* Tell the installer to report its current installation status 1016 * using a running VBoxTray instance via balloon messages in the 1017 * Windows taskbar. */ 1018 siInstaller.mArguments.push_back(Utf8Str("/post_installstatus")); 1019 /* If the caller does not want to wait for out guest update process to end, 1020 * complete the progress object now so that the caller can do other work. */ 1021 if (mFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly) 1022 siInstaller.mFlags |= ProcessCreateFlag_WaitForProcessStartOnly; 1023 mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS.EXE", 1024 strInstallerDir + "VBoxWindowsAdditions.exe", 1025 UPDATEFILE_FLAG_EXECUTE, siInstaller)); 1026 break; 1027 } 1028 case eOSType_Linux: 1029 /** @todo Add Linux support. */ 1030 break; 1031 case eOSType_Solaris: 1032 /** @todo Add Solaris support. */ 1033 break; 1034 default: 1035 AssertReleaseMsgFailed(("Unsupported guest type: %d\n", eOSType)); 1036 break; 1037 } 1038 } 1039 1040 if (RT_SUCCESS(rc)) 1041 { 1042 /* We want to spend 40% total for all copying operations. So roughly 1043 * calculate the specific percentage step of each copied file. */ 1044 uint8_t uOffset = 20; /* Start at 20%. */ 1045 uint8_t uStep = 40 / mFiles.size(); 1046 1047 LogRel(("Copying over Guest Additions update files to the guest ...\n")); 1048 1027 1049 std::vector<InstallerFile>::const_iterator itFiles = mFiles.begin(); 1028 1050 while (itFiles != mFiles.end()) … … 1037 1059 break; 1038 1060 } 1061 1062 rc = setProgress(uOffset); 1063 if (RT_FAILURE(rc)) 1064 break; 1065 uOffset += uStep; 1066 1039 1067 itFiles++; 1040 1068 } … … 1043 1071 if (RT_SUCCESS(rc)) 1044 1072 { 1073 /* We want to spend 35% total for all copying operations. So roughly 1074 * calculate the specific percentage step of each copied file. */ 1075 uint8_t uOffset = 60; /* Start at 60%. */ 1076 uint8_t uStep = 35 / mFiles.size(); 1077 1078 LogRel(("Executing Guest Additions update files ...\n")); 1079 1045 1080 std::vector<InstallerFile>::iterator itFiles = mFiles.begin(); 1046 1081 while (itFiles != mFiles.end()) 1047 1082 { 1048 rc = runFile(pSession, itFiles->mProcInfo); 1083 if (itFiles->fFlags & UPDATEFILE_FLAG_EXECUTE) 1084 { 1085 rc = runFile(pSession, itFiles->mProcInfo); 1086 if (RT_FAILURE(rc)) 1087 { 1088 hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR, 1089 Utf8StrFmt(GuestSession::tr("Error while running installer file \"%s\" on the guest: %Rrc"), 1090 itFiles->strDest.c_str(), rc)); 1091 break; 1092 } 1093 } 1094 1095 rc = setProgress(uOffset); 1049 1096 if (RT_FAILURE(rc)) 1097 break; 1098 uOffset += uStep; 1099 1100 itFiles++; 1101 } 1102 } 1103 1104 if (RT_SUCCESS(rc)) 1105 { 1106 LogRel(("Automatic update of Guest Additions succeeded\n")); 1107 rc = setProgressSuccess(); 1108 } 1109 else if (rc == VERR_CANCELLED) 1110 { 1111 LogRel(("Automatic update of Guest Additions canceled\n")); 1112 } 1113 else 1114 { 1115 Utf8Str strError = Utf8StrFmt("No further error information available (%Rrc)", rc); 1116 if (!mProgress.isNull()) /* Progress object is optional. */ 1117 { 1118 ComPtr<IVirtualBoxErrorInfo> pError; 1119 hr = mProgress->COMGETTER(ErrorInfo)(pError.asOutParam()); 1120 Assert(!pError.isNull()); 1121 if (SUCCEEDED(hr)) 1050 1122 { 1051 hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR, 1052 Utf8StrFmt(GuestSession::tr("Error while running installer file \"%s\" on the guest: %Rrc"), 1053 itFiles->strDest.c_str(), rc)); 1054 break; 1123 Bstr strVal; 1124 hr = pError->COMGETTER(Text)(strVal.asOutParam()); 1125 if ( SUCCEEDED(hr) 1126 && strVal.isNotEmpty()) 1127 strError = strVal; 1055 1128 } 1056 itFiles++; 1057 } 1058 } 1059 1060 if (RT_SUCCESS(rc)) 1061 hr = setProgressSuccess(); 1129 } 1130 1131 LogRel(("Automatic update of Guest Additions failed: %s\n", strError.c_str())); 1132 } 1062 1133 1063 1134 RTIsoFsClose(&iso);
Note:
See TracChangeset
for help on using the changeset viewer.