Changeset 66244 in vbox
- Timestamp:
- Mar 24, 2017 12:14:06 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114165
- Location:
- trunk/src/VBox/ValidationKit/tests/storage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/storage/storagecfg.py
r65963 r66244 8 8 __copyright__ = \ 9 9 """ 10 Copyright (C) 2016 Oracle Corporation10 Copyright (C) 2016-2017 Oracle Corporation 11 11 12 12 This file is part of VirtualBox Open Source Edition (OSE), as … … 38 38 """ 39 39 40 def __init__(self, sPath): 41 self.sPath = sPath; 42 self.fUsed = False; 40 def __init__(self, sPath, fRamDisk = False): 41 self.sPath = sPath; 42 self.fUsed = False; 43 self.fRamDisk = fRamDisk; 43 44 44 45 def getPath(self): … … 53 54 """ 54 55 return self.fUsed; 56 57 def isRamDisk(self): 58 """ 59 Returns whether the disk objecthas a RAM backing. 60 """ 61 return self.fRamDisk; 55 62 56 63 def setUsed(self, fUsed): … … 94 101 def __init__(self): 95 102 StorageConfigOs.__init__(self); 103 self.idxRamDisk = 0; 96 104 97 105 def _getActivePoolsStartingWith(self, oExec, sPoolIdStart): … … 211 219 return fRc; 212 220 221 def createRamDisk(self, oExec, cbRamDisk): 222 """ 223 Creates a RAM backed disk with the given size. 224 """ 225 oDisk = None; 226 sRamDiskName = 'ramdisk%u' % (self.idxRamDisk,); 227 fRc, sOut, _ = oExec.execBinary('ramdiskadm', '-a', sRamDiskName, str(cbRamDisk)); 228 if fRc: 229 self.idxRamDisk += 1; 230 oDisk = StorageDisk(sOut.rstrip(), True); 231 232 return oDisk; 233 234 def destroyRamDisk(self, oExec, oDisk): 235 """ 236 Destroys the given ramdisk object. 237 """ 238 sRamDiskName = os.path.basename(oDisk.getPath()); 239 return oExec.execBinaryNoStdOut('ramdiskadm', ('-d', sRamDiskName)); 240 213 241 class StorageConfigOsLinux(StorageConfigOs): 214 242 """ … … 285 313 if self.dSimplePools.has_key(sPool): 286 314 sDiskPath = self.dSimplePools.get(sPool); 287 # Create a partition with the requested size 288 sFdiskScript = ';\n'; # Single partition filling everything 289 if cbVol is not None: 290 sFdiskScript = ',' + str(cbVol / 512) + '\n'; # Get number of sectors 291 fRc = oExec.execBinaryNoStdOut('sfdisk', ('--no-reread', '--wipe', 'always', '-q', '-f', sDiskPath), sFdiskScript); 292 if fRc: 293 if sDiskPath.find('nvme') != -1: 294 sBlkDev = sDiskPath + 'p1'; 295 else: 296 sBlkDev = sDiskPath + '1'; 315 if sDiskPath.find('zram') != -1: 316 sBlkDev = sDiskPath; 317 else: 318 # Create a partition with the requested size 319 sFdiskScript = ';\n'; # Single partition filling everything 320 if cbVol is not None: 321 sFdiskScript = ',' + str(cbVol / 512) + '\n'; # Get number of sectors 322 fRc = oExec.execBinaryNoStdOut('sfdisk', ('--no-reread', '--wipe', 'always', '-q', '-f', sDiskPath), \ 323 sFdiskScript); 324 if fRc: 325 if sDiskPath.find('nvme') != -1: 326 sBlkDev = sDiskPath + 'p1'; 327 else: 328 sBlkDev = sDiskPath + '1'; 297 329 else: 298 330 if cbVol is None: … … 324 356 # Wipe partition table 325 357 sDiskPath = self.dSimplePools.get(sPool); 326 fRc = oExec.execBinaryNoStdOut('sfdisk', ('--no-reread', '--wipe', 'always', '-q', '-f', '--delete', sDiskPath)); 358 if sDiskPath.find('zram') == -1: 359 fRc = oExec.execBinaryNoStdOut('sfdisk', ('--no-reread', '--wipe', 'always', '-q', '-f', '--delete', \ 360 sDiskPath)); 327 361 else: 328 362 fRc = oExec.execBinaryNoStdOut('lvremove', (sPool + '/' + sVol,)); … … 351 385 _ = sVolIdStart; 352 386 return True; 387 388 def createRamDisk(self, oExec, cbRamDisk): 389 """ 390 Creates a RAM backed disk with the given size. 391 """ 392 # Make sure the ZRAM module is loaded. 393 oDisk = None; 394 fRc = oExec.execBinaryNoStdOut('modprobe', ('zram',)); 395 if fRc: 396 fRc, sOut, _ = oExec.execBinary('zramctl', ('--raw', '-f', '-s', str(cbRamDisk))); 397 if fRc: 398 oDisk = StorageDisk(sOut.rstrip(), True); 399 400 return oDisk; 401 402 def destroyRamDisk(self, oExec, oDisk): 403 """ 404 Destroys the given ramdisk object. 405 """ 406 return oExec.execBinaryNoStdOut('zramctl', ('-r', oDisk.getPath())); 353 407 354 408 class StorageCfg(object): … … 427 481 return cDisksUnused; 428 482 429 def createStoragePool(self, cDisks = 0, sRaidLvl = None): 483 def createStoragePool(self, cDisks = 0, sRaidLvl = None, 484 cbPool = None, fRamDisk = False): 430 485 """ 431 486 Create a new storage pool … … 435 490 sPool = None; 436 491 437 if cDisks == 0: 438 cDisks = self.getUnusedDiskCount(); 439 440 for oDisk in self.lstDisks: 441 if not oDisk.isUsed(): 442 oDisk.setUsed(True); 492 if fRamDisk: 493 oDisk = self.oStorOs.createRamDisk(self.oExec, cbPool); 494 if oDisk is not None: 443 495 lstDisks.append(oDisk); 444 if len(lstDisks) == cDisks: 445 break; 496 cDisks = 1; 497 else: 498 if cDisks == 0: 499 cDisks = self.getUnusedDiskCount(); 500 501 for oDisk in self.lstDisks: 502 if not oDisk.isUsed(): 503 oDisk.setUsed(True); 504 lstDisks.append(oDisk); 505 if len(lstDisks) == cDisks: 506 break; 446 507 447 508 # Enough drives to satisfy the request? … … 468 529 for oDisk in lstDisks: 469 530 oDisk.setUsed(False); 531 if oDisk.isRamDisk(): 532 self.oStorOs.destroyRamDisk(self.oExec, oDisk); 470 533 471 534 return fRc, sPool; … … 484 547 for oDisk in lstDisks: 485 548 oDisk.setUsed(False); 549 if oDisk.isRamDisk(): 550 self.oStorOs.destroyRamDisk(self.oExec, oDisk); 486 551 else: 487 552 fRc = False; -
trunk/src/VBox/ValidationKit/tests/storage/tdStorageBenchmark1.py
r65963 r66244 9 9 __copyright__ = \ 10 10 """ 11 Copyright (C) 2012-201 6Oracle Corporation11 Copyright (C) 2012-2017 Oracle Corporation 12 12 13 13 This file is part of VirtualBox Open Source Edition (OSE), as … … 430 430 'TestsetSize': '20g', 431 431 'QueueDepth': '32', 432 'DiskSizeGb': 100432 'DiskSizeGb': 30 433 433 }, 434 434 # For stress testing which takes a lot of time. … … 500 500 self.sIoLogPath = self.sIoLogPathDef; 501 501 self.fIoLog = False; 502 self.fUseRamDiskDef = False; 503 self.fUseRamDisk = self.fUseRamDiskDef; 502 504 503 505 # … … 552 554 reporter.log(' --enable-io-log'); 553 555 reporter.log(' Whether to enable I/O logging for each test'); 556 reporter.log(' --use-ramdisk'); 557 reporter.log(' Default: %s' % (self.fUseRamDiskDef)); 554 558 return rc; 555 559 … … 641 645 elif asArgs[iArg] == '--enable-io-log': 642 646 self.fIoLog = True; 647 elif asArgs[iArg] == '--use-ramdisk': 648 self.fUseRamDisk = True; 643 649 else: 644 650 return vbox.TestDriver.parseOption(self, asArgs, iArg); … … 703 709 # 704 710 705 def prepareStorage(self, oStorCfg ):711 def prepareStorage(self, oStorCfg, fRamDisk = False, cbPool = None): 706 712 """ 707 713 Prepares the host storage for disk images or direct testing on the host. … … 709 715 # Create a basic pool with the default configuration. 710 716 sMountPoint = None; 711 fRc, sPoolId = oStorCfg.createStoragePool( );717 fRc, sPoolId = oStorCfg.createStoragePool(cbPool = cbPool, fRamDisk = fRamDisk); 712 718 if fRc: 713 719 fRc, sMountPoint = oStorCfg.createVolume(sPoolId); … … 984 990 # for benchmarks 985 991 if self.fRecreateStorCfg: 986 sMountPoint = self.prepareStorage(self.oStorCfg );992 sMountPoint = self.prepareStorage(self.oStorCfg, self.fUseRamDisk, cbDisk); 987 993 if sMountPoint is not None: 988 994 # Create a directory where every normal user can write to.
Note:
See TracChangeset
for help on using the changeset viewer.