Changeset 14784 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 28, 2008 2:57:31 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 40103
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r14696 r14784 1206 1206 ComPtr <IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 1207 1207 { 1208 #if 11209 RTPrintf("Error: Create iSCSI hard disk operation is temporarily unavailable!\n");1210 return 1;1211 #else1212 1208 HRESULT rc; 1213 1209 Bstr server; 1214 1210 Bstr target; 1215 uint16_t port = UINT16_MAX;1216 uint64_t lun = UINT64_MAX;1211 Bstr port; 1212 Bstr lun; 1217 1213 Bstr username; 1218 1214 Bstr password; … … 1245 1241 return errorArgument("Missing argument to '%s'", argv[i]); 1246 1242 i++; 1247 port = RTStrToUInt16(argv[i]);1243 port = argv[i]; 1248 1244 } 1249 1245 else if (strcmp(argv[i], "-lun") == 0) 1250 1246 { 1247 /// @todo is the below todo still relevant? Note that we do a 1248 /// strange string->int->string conversion here. 1249 1251 1250 /** @todo move the LUN encoding algorithm into IISCSIHardDisk, add decoding */ 1251 1252 1252 if (argc <= i + 1) 1253 1253 return errorArgument("Missing argument to '%s'", argv[i]); 1254 1254 i++; 1255 1255 char *pszNext; 1256 int rc = RTStrToUInt64Ex(argv[i], &pszNext, 0, &lun); 1257 if (RT_FAILURE(rc) || *pszNext != '\0' || lun >= 16384) 1256 uint64_t lunNum; 1257 int rc = RTStrToUInt64Ex(argv[i], &pszNext, 0, &lunNum); 1258 if (RT_FAILURE(rc) || *pszNext != '\0' || lunNum >= 16384) 1258 1259 return errorArgument("Invalid LUN number '%s'", argv[i]); 1259 if (lun <= 255)1260 if (lunNum <= 255) 1260 1261 { 1261 1262 /* Assume bus identifier = 0. */ 1262 lun = (lun<< 48); /* uses peripheral device addressing method */1263 lunNum = (lunNum << 48); /* uses peripheral device addressing method */ 1263 1264 } 1264 1265 else 1265 1266 { 1266 1267 /* Check above already limited the LUN to 14 bits. */ 1267 lun = (lun << 48) | RT_BIT_64(62); /* uses flat space addressing method */ 1268 } 1268 lunNum = (lunNum << 48) | RT_BIT_64(62); /* uses flat space addressing method */ 1269 } 1270 1271 lun = BstrFmt ("%llu", lunNum); 1269 1272 } 1270 1273 else if (strcmp(argv[i], "-encodedlun") == 0) … … 1273 1276 return errorArgument("Missing argument to '%s'", argv[i]); 1274 1277 i++; 1275 char *pszNext; 1276 int rc = RTStrToUInt64Ex(argv[i], &pszNext, 0, &lun); 1277 if (RT_FAILURE(rc) || *pszNext != '\0') 1278 return errorArgument("Invalid encoded LUN number '%s'", argv[i]); 1278 lun = argv[i]; 1279 1279 } 1280 1280 else if (strcmp(argv[i], "-username") == 0) … … 1307 1307 return errorSyntax(USAGE_ADDISCSIDISK, "Parameters -server and -target are required"); 1308 1308 1309 ComPtr<IHardDisk> hardDisk; 1310 CHECK_ERROR(aVirtualBox, CreateHardDisk(HardDiskStorageType_ISCSIHardDisk, hardDisk.asOutParam())); 1311 if (SUCCEEDED(rc) && hardDisk) 1312 { 1313 CHECK_ERROR(hardDisk, COMSETTER(Description)(comment)); 1314 ComPtr<IISCSIHardDisk> iSCSIDisk = hardDisk; 1315 CHECK_ERROR(iSCSIDisk, COMSETTER(Server)(server)); 1316 if (port != UINT16_MAX) 1317 CHECK_ERROR(iSCSIDisk, COMSETTER(Port)(port)); 1318 CHECK_ERROR(iSCSIDisk, COMSETTER(Target)(target)); 1319 if (lun != UINT64_MAX) 1320 CHECK_ERROR(iSCSIDisk, COMSETTER(Lun)(lun)); 1321 CHECK_ERROR(iSCSIDisk, COMSETTER(UserName)(username)); 1322 CHECK_ERROR(iSCSIDisk, COMSETTER(Password)(password)); 1323 1324 if (SUCCEEDED(rc)) 1325 { 1326 CHECK_ERROR(aVirtualBox, RegisterHardDisk(hardDisk)); 1327 } 1328 1329 if (SUCCEEDED(rc)) 1330 { 1331 Guid guid; 1332 CHECK_ERROR(hardDisk, COMGETTER(Id)(guid.asOutParam())); 1333 RTPrintf("iSCSI disk created. UUID: %s\n", guid.toString().raw()); 1334 } 1335 } 1309 do 1310 { 1311 ComPtr<IHardDisk2> hardDisk; 1312 CHECK_ERROR_BREAK (aVirtualBox, 1313 CreateHardDisk2(Bstr ("iSCSI"), 1314 BstrFmt ("%ls/%ls", server.raw(), target.raw()), 1315 hardDisk.asOutParam())); 1316 CheckComRCBreakRC (rc); 1317 1318 if (!comment.isNull()) 1319 CHECK_ERROR_BREAK(hardDisk, COMSETTER(Description)(comment)); 1320 1321 if (!port.isNull()) 1322 server = BstrFmt ("%ls:%ls", server.raw(), port.raw()); 1323 CHECK_ERROR_BREAK(hardDisk, SetProperty(Bstr("TargetAddress"), server)); 1324 CHECK_ERROR_BREAK(hardDisk, SetProperty(Bstr("TargetName"), target)); 1325 1326 if (!lun.isNull()) 1327 CHECK_ERROR_BREAK(hardDisk, SetProperty(Bstr("LUN"), lun)); 1328 if (!username.isNull()) 1329 CHECK_ERROR_BREAK(hardDisk, SetProperty(Bstr("InitiatorUsername"), username)); 1330 if (!password.isNull()) 1331 CHECK_ERROR_BREAK(hardDisk, SetProperty(Bstr("InitiatorSecret"), password)); 1332 1333 /// @todo add -initiator option 1334 CHECK_ERROR_BREAK(hardDisk, 1335 SetProperty(Bstr("InitiatorName"), 1336 Bstr("iqn.2008-04.com.sun.virtualbox.initiator"))); 1337 1338 /// @todo add -targetName and -targetPassword options 1339 1340 Guid guid; 1341 CHECK_ERROR(hardDisk, COMGETTER(Id)(guid.asOutParam())); 1342 RTPrintf("iSCSI disk created. UUID: %s\n", guid.toString().raw()); 1343 } 1344 while (0); 1336 1345 1337 1346 return SUCCEEDED(rc) ? 0 : 1; 1338 #endif1339 1347 } 1340 1348
Note:
See TracChangeset
for help on using the changeset viewer.