Changeset 43603 in vbox
- Timestamp:
- Oct 10, 2012 3:58:48 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/vbox-img.cpp
r41550 r43603 65 65 " [--format VDI|VMDK|VHD] (default: VDI)\n" 66 66 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n" 67 " [--dataalignment <alignment in bytes>]\n" 67 68 "\n" 68 69 " repair --filename <filename>\n" … … 1297 1298 } 1298 1299 1300 static DECLCALLBACK(bool) vdIfCfgCreateBaseAreKeysValid(void *pvUser, const char *pszzValid) 1301 { 1302 return VINF_SUCCESS; /** @todo: Implement. */ 1303 } 1304 1305 static DECLCALLBACK(int) vdIfCfgCreateBaseQuerySize(void *pvUser, const char *pszName, size_t *pcbValue) 1306 { 1307 AssertReturn(VALID_PTR(pcbValue), VERR_INVALID_POINTER); 1308 1309 AssertPtrReturn(pvUser, VERR_GENERAL_FAILURE); 1310 1311 if (RTStrCmp(pszName, "DataAlignment")) 1312 return VERR_CFGM_VALUE_NOT_FOUND; 1313 1314 *pcbValue = strlen((const char *)pvUser) + 1 /* include terminator */; 1315 1316 return VINF_SUCCESS; 1317 } 1318 1319 static DECLCALLBACK(int) vdIfCfgCreateBaseQuery(void *pvUser, const char *pszName, char *pszValue, size_t cchValue) 1320 { 1321 AssertReturn(VALID_PTR(pszValue), VERR_INVALID_POINTER); 1322 1323 AssertPtrReturn(pvUser, VERR_GENERAL_FAILURE); 1324 1325 if (RTStrCmp(pszName, "DataAlignment")) 1326 return VERR_CFGM_VALUE_NOT_FOUND; 1327 1328 if (strlen((const char *)pvUser) >= cchValue) 1329 return VERR_CFGM_NOT_ENOUGH_SPACE; 1330 1331 memcpy(pszValue, pvUser, strlen((const char *)pvUser) + 1); 1332 1333 return VINF_SUCCESS; 1334 1335 } 1299 1336 1300 1337 int handleCreateBase(HandlerArg *a) … … 1307 1344 unsigned uImageFlags = VD_IMAGE_FLAGS_NONE; 1308 1345 uint64_t cbSize = 0; 1346 const char *pszDataAlignment = NULL; 1309 1347 VDGEOMETRY LCHSGeometry, PCHSGeometry; 1348 PVDINTERFACE pVDIfsOperation = NULL; 1349 VDINTERFACECONFIG vdIfCfg; 1310 1350 1311 1351 memset(&LCHSGeometry, 0, sizeof(VDGEOMETRY)); … … 1315 1355 static const RTGETOPTDEF s_aOptions[] = 1316 1356 { 1317 { "--filename", 'f', RTGETOPT_REQ_STRING }, 1318 { "--size", 's', RTGETOPT_REQ_UINT64 }, 1319 { "--format", 'b', RTGETOPT_REQ_STRING }, 1320 { "--variant", 'v', RTGETOPT_REQ_STRING } 1357 { "--filename", 'f', RTGETOPT_REQ_STRING }, 1358 { "--size", 's', RTGETOPT_REQ_UINT64 }, 1359 { "--format", 'b', RTGETOPT_REQ_STRING }, 1360 { "--variant", 'v', RTGETOPT_REQ_STRING }, 1361 { "--dataalignment", 'a', RTGETOPT_REQ_STRING } 1321 1362 }; 1322 1363 int ch; … … 1344 1385 break; 1345 1386 1387 case 'a': // --dataalignment 1388 pszDataAlignment = ValueUnion.psz; 1389 break; 1390 1346 1391 default: 1347 1392 ch = RTGetOptPrintError(ch, &ValueUnion); … … 1365 1410 } 1366 1411 1412 /* Setup the config interface if required. */ 1413 if (pszDataAlignment) 1414 { 1415 vdIfCfg.pfnAreKeysValid = vdIfCfgCreateBaseAreKeysValid; 1416 vdIfCfg.pfnQuerySize = vdIfCfgCreateBaseQuerySize; 1417 vdIfCfg.pfnQuery = vdIfCfgCreateBaseQuery; 1418 VDInterfaceAdd(&vdIfCfg.Core, "Config", VDINTERFACETYPE_CONFIG, (void *)pszDataAlignment, 1419 sizeof(vdIfCfg), &pVDIfsOperation); 1420 } 1421 1367 1422 /* just try it */ 1368 1423 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); … … 1372 1427 rc = VDCreateBase(pDisk, pszBackend, pszFilename, cbSize, uImageFlags, 1373 1428 NULL, &PCHSGeometry, &LCHSGeometry, NULL, VD_OPEN_FLAGS_NORMAL, 1374 NULL, NULL);1429 NULL, pVDIfsOperation); 1375 1430 if (RT_FAILURE(rc)) 1376 1431 return errorRuntime("Error while creating the virtual disk: %Rrc\n", rc);
Note:
See TracChangeset
for help on using the changeset viewer.