Changeset 33564 in vbox
- Timestamp:
- Oct 28, 2010 3:16:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r33558 r33564 95 95 " --username <name> --password <password>\n" 96 96 " [--dryrun] [--recursive] [--verbose] [--flags <flags>]\n" 97 "\n" 98 " updateadditions <vmname>|<uuid>\n" 99 " [--source <guest additions .ISO file to use>] [--verbose]\n" 97 100 "\n"); 98 101 } … … 1060 1063 "No user name specified!"); 1061 1064 1062 /* lookup VM. */1065 /* Lookup VM. */ 1063 1066 ComPtr<IMachine> machine; 1064 /* assume it's an UUID*/1067 /* Assume it's an UUID. */ 1065 1068 HRESULT rc; 1066 1069 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(), … … 1070 1073 do 1071 1074 { 1072 /* open an existing session for VM*/1075 /* Open an existing session for VM. */ 1073 1076 CHECK_ERROR_BREAK(machine, LockMachine(a->session, LockType_Shared)); 1074 1077 // @todo r=dj assert that it's an existing session 1075 1078 1076 /* get the mutable session machine*/1079 /* Get the mutable session machine. */ 1077 1080 a->session->COMGETTER(Machine)(machine.asOutParam()); 1078 1081 … … 1165 1168 } 1166 1169 ctrlCopyDestroy(&listToCopy); 1170 } 1171 a->session->UnlockMachine(); 1172 } while (0); 1173 } 1174 return SUCCEEDED(rc) ? 0 : 1; 1175 } 1176 1177 static int handleCtrlUpdateAdditions(HandlerArg *a) 1178 { 1179 /* 1180 * Check the syntax. We can deduce the correct syntax from the number of 1181 * arguments. 1182 */ 1183 if (a->argc < 1) /* At least the VM name should be present :-). */ 1184 return errorSyntax(USAGE_GUESTCONTROL, "Incorrect parameters"); 1185 1186 Utf8Str Utf8Source; 1187 bool fVerbose = false; 1188 1189 /* Iterate through all possible commands (if available). */ 1190 bool usageOK = true; 1191 for (int i = 1; usageOK && i < a->argc; i++) 1192 { 1193 if (!strcmp(a->argv[i], "--source")) 1194 { 1195 if (i + 1 >= a->argc) 1196 usageOK = false; 1197 else 1198 { 1199 Utf8Source = a->argv[i + 1]; 1200 ++i; 1201 } 1202 } 1203 else if (!strcmp(a->argv[i], "--verbose")) 1204 fVerbose = true; 1205 else 1206 return errorSyntax(USAGE_GUESTCONTROL, 1207 "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str()); 1208 } 1209 1210 if (!usageOK) 1211 return errorSyntax(USAGE_GUESTCONTROL, "Incorrect parameters"); 1212 1213 /* Lookup VM. */ 1214 ComPtr<IMachine> machine; 1215 /* Assume it's an UUID. */ 1216 HRESULT rc; 1217 CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(), 1218 machine.asOutParam())); 1219 if (machine) 1220 { 1221 do 1222 { 1223 /* Open an existing session for VM. */ 1224 CHECK_ERROR_BREAK(machine, LockMachine(a->session, LockType_Shared)); 1225 // @todo r=dj assert that it's an existing session 1226 1227 /* Get the mutable session machine. */ 1228 a->session->COMGETTER(Machine)(machine.asOutParam()); 1229 1230 /* Get the associated console. */ 1231 ComPtr<IConsole> console; 1232 CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam())); 1233 1234 ComPtr<IGuest> guest; 1235 CHECK_ERROR_BREAK(console, COMGETTER(Guest)(guest.asOutParam())); 1236 1237 if (fVerbose) 1238 RTPrintf("Updating Guest Additions on \"%s\" ...\n", a->argv[0]); 1239 1240 #ifdef DEBUG_andy 1241 if (Utf8Source.isEmpty()) 1242 Utf8Source = "c:\\Downloads\\VBoxGuestAdditions-r67158.iso"; 1243 #endif 1244 /* Determine source if not set yet. */ 1245 if (Utf8Source.isEmpty()) 1246 { 1247 char strTemp[RTPATH_MAX]; 1248 int rc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp)); 1249 AssertRC(rc); 1250 Utf8Str Utf8Src1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso"); 1251 1252 rc = RTPathExecDir(strTemp, sizeof(strTemp)); 1253 AssertRC(rc); 1254 Utf8Str Utf8Src2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso"); 1255 1256 /* Check the standard image locations */ 1257 if (RTFileExists(Utf8Src1.c_str())) 1258 Utf8Source = Utf8Src1; 1259 else if (RTFileExists(Utf8Src2.c_str())) 1260 Utf8Source = Utf8Src2; 1261 else 1262 { 1263 RTMsgError("Source could not be determined! Please use --source to specify a valid source.\n"); 1264 break; 1265 } 1266 } 1267 else if (!RTFileExists(Utf8Source.c_str())) 1268 { 1269 RTMsgError("Source \"%s\" does not exist!\n", Utf8Source.c_str()); 1270 break; 1271 } 1272 if (fVerbose) 1273 RTPrintf("Using source: %s\n", Utf8Source.c_str()); 1274 1275 ComPtr<IProgress> progress; 1276 rc = guest->UpdateGuestAdditions(Bstr(Utf8Source).raw(), progress.asOutParam()); 1277 if (SUCCEEDED(rc) && progress) 1278 { 1279 rc = showProgress(progress); 1280 if (FAILED(rc)) 1281 { 1282 com::ProgressErrorInfo info(progress); 1283 if (info.isBasicAvailable()) 1284 RTMsgError("Failed to start Guest Additions update. Error message: %lS", info.getText().raw()); 1285 else 1286 RTMsgError("Failed to start Guest Additions update. No error message available!"); 1287 } 1288 else 1289 { 1290 if (fVerbose) 1291 RTPrintf("Guest Additions installer successfully copied and started.\n"); 1292 } 1167 1293 } 1168 1294 a->session->UnlockMachine(); … … 1188 1314 1189 1315 /* switch (cmd) */ 1190 if ( strcmp(a->argv[0], "exec") == 01191 || strcmp(a->argv[0], "execute") == 0)1316 if ( !strcmp(a->argv[0], "exec") 1317 || !strcmp(a->argv[0], "execute")) 1192 1318 { 1193 1319 return handleCtrlExecProgram(&arg); 1194 1320 } 1195 else if ( strcmp(a->argv[0], "copyto") == 0 1196 || strcmp(a->argv[0], "copy_to") == 0) 1321 else if (!strcmp(a->argv[0], "copyto")) 1197 1322 { 1198 1323 return handleCtrlCopyTo(&arg); 1324 } 1325 else if ( !strcmp(a->argv[0], "updateadditions") 1326 || !strcmp(a->argv[0], "updateadds")) 1327 { 1328 return handleCtrlUpdateAdditions(&arg); 1199 1329 } 1200 1330
Note:
See TracChangeset
for help on using the changeset viewer.