Changeset 38644 in vbox
- Timestamp:
- Sep 5, 2011 4:45:44 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 73852
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvDiskIntegrity.cpp
r38631 r38644 1162 1162 { 1163 1163 rc = VDDbgIoLogCreate(&pThis->hIoLogger, pszIoLogFilename, VDDBG_IOLOG_LOG_DATA); 1164 RTStrFree(pszIoLogFilename);1164 MMR3HeapFree(pszIoLogFilename); 1165 1165 } 1166 1166 -
trunk/src/VBox/Storage/Debug/VDDbgIoLog.cpp
r38631 r38644 98 98 { 99 99 /** Event type. */ 100 uint 8_tu32Type;100 uint32_t u32Type; 101 101 /** Id of the matching start entry. */ 102 102 uint64_t u64Id; … … 328 328 pIoLogger->offReadNext = sizeof(Hdr); 329 329 pIoLogger->idNext = RT_LE2H_U64(Hdr.u64Id); 330 *phIoLogger = pIoLogger; 330 331 } 331 332 else if (RT_SUCCESS(rc)) … … 468 469 pIoLogEntry->idStart = pIoLogger->idNext++; 469 470 470 Entry.u32Type 471 Entry.u32Type = VDIOLOG_EVENT_START; 471 472 Entry.u8AsyncIo = fAsync ? 1 : 0; 472 473 Entry.u32ReqType = VDDBGIOLOGREQ_DISCARD; 474 Entry.u64Id = RT_H2LE_U64(pIoLogEntry->idStart); 473 475 Entry.Discard.cRanges = RT_H2LE_U32(cRanges); 474 476 … … 588 590 if (RT_SUCCESS(rc)) 589 591 { 590 pIoLogger->u32EventTypeNext = (VDIOLOGEVENT)abBuf[0];592 pIoLogger->u32EventTypeNext = abBuf[0]; 591 593 pIoLogger->enmReqTypeNext = (VDDBGIOLOGREQ)abBuf[1]; 592 594 } … … 687 689 rc = VERR_INVALID_STATE; 688 690 691 if (RT_SUCCESS(rc)) 692 pIoLogger->u32EventTypeNext = 0; 693 689 694 RTSemFastMutexRelease(pIoLogger->hMtx); 690 695 return rc; … … 748 753 rc = VERR_INVALID_STATE; 749 754 755 if (RT_SUCCESS(rc)) 756 pIoLogger->u32EventTypeNext = 0; 757 750 758 RTSemFastMutexRelease(pIoLogger->hMtx); 751 759 return rc; … … 796 804 rc = VERR_INVALID_STATE; 797 805 806 if (RT_SUCCESS(rc)) 807 pIoLogger->u32EventTypeNext = 0; 808 798 809 RTSemFastMutexRelease(pIoLogger->hMtx); 799 810 return rc; -
trunk/src/VBox/Storage/testcase/Makefile.kmk
r38563 r38644 53 53 VDMemDisk.cpp \ 54 54 VDIoRnd.cpp 55 tstVDIo_LIBS = $(LIB_DDU) 55 tstVDIo_LIBS = \ 56 $(LIB_DDU) \ 57 $(PATH_STAGE_LIB)/StorageDbgLib$(VBOX_SUFF_LIB) 56 58 57 59 tstVDSetUuid_TEMPLATE = VBOXR3TSTEXE -
trunk/src/VBox/Storage/testcase/tstVDIo.cpp
r38636 r38644 18 18 #define LOGGROUP LOGGROUP_DEFAULT 19 19 #include <VBox/vd.h> 20 #include <VBox/vddbg.h> 20 21 #include <VBox/err.h> 21 22 #include <VBox/log.h> … … 300 301 static DECLCALLBACK(int) vdScriptHandlerClose(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 301 302 static DECLCALLBACK(int) vdScriptHandlerPrintFileSize(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 303 static DECLCALLBACK(int) vdScriptHandlerIoLogReplay(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 302 304 static DECLCALLBACK(int) vdScriptHandlerIoRngCreate(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); 303 305 static DECLCALLBACK(int) vdScriptHandlerIoRngDestroy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs); … … 419 421 }; 420 422 423 /* print file size action */ 424 const VDSCRIPTARGDESC g_aArgIoLogReplay[] = 425 { 426 /* pcszName chId enmType fFlags */ 427 {"disk", 'd', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY}, 428 {"iolog", 'i', VDSCRIPTARGTYPE_STRING, VDSCRIPTARGDESC_FLAG_MANDATORY} 429 }; 430 421 431 /* I/O RNG create action */ 422 432 const VDSCRIPTARGDESC g_aArgIoRngCreate[] = … … 513 523 {"close", g_aArgClose, RT_ELEMENTS(g_aArgClose), vdScriptHandlerClose}, 514 524 {"printfilesize", g_aArgPrintFileSize, RT_ELEMENTS(g_aArgPrintFileSize), vdScriptHandlerPrintFileSize}, 525 {"ioreplay", g_aArgIoLogReplay, RT_ELEMENTS(g_aArgIoLogReplay), vdScriptHandlerIoLogReplay}, 515 526 {"merge", g_aArgMerge, RT_ELEMENTS(g_aArgMerge), vdScriptHandlerMerge}, 516 527 {"compact", g_aArgCompact, RT_ELEMENTS(g_aArgCompact), vdScriptHandlerCompact}, … … 1512 1523 if (pDisk) 1513 1524 RTPrintf("%s: size of image %u is %llu\n", pcszDisk, nImage, VDGetFileSize(pDisk->pVD, nImage)); 1525 else 1526 rc = VERR_NOT_FOUND; 1527 1528 return rc; 1529 } 1530 1531 1532 static DECLCALLBACK(int) vdScriptHandlerIoLogReplay(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs) 1533 { 1534 int rc = VINF_SUCCESS; 1535 const char *pcszDisk = NULL; 1536 PVDDISK pDisk = NULL; 1537 const char *pcszIoLog = NULL; 1538 1539 for (unsigned i = 0; i < cScriptArgs; i++) 1540 { 1541 switch (paScriptArgs[i].chId) 1542 { 1543 case 'd': 1544 { 1545 pcszDisk = paScriptArgs[i].u.pcszString; 1546 break; 1547 } 1548 case 'i': 1549 { 1550 pcszIoLog = paScriptArgs[i].u.pcszString; 1551 break; 1552 } 1553 default: 1554 AssertMsgFailed(("Invalid argument given!\n")); 1555 } 1556 } 1557 1558 pDisk = tstVDIoGetDiskByName(pGlob, pcszDisk); 1559 if (pDisk) 1560 { 1561 VDIOLOGGER hIoLogger; 1562 1563 rc = VDDbgIoLogOpen(&hIoLogger, pcszIoLog); 1564 if (RT_SUCCESS(rc)) 1565 { 1566 uint32_t fIoLogFlags; 1567 VDIOLOGEVENT enmEvent; 1568 void *pvBuf = NULL; 1569 size_t cbBuf = 0; 1570 1571 fIoLogFlags = VDDbgIoLogGetFlags(hIoLogger); 1572 1573 /* Loop through events. */ 1574 rc = VDDbgIoLogEventTypeGetNext(hIoLogger, &enmEvent); 1575 while ( RT_SUCCESS(rc) 1576 && enmEvent != VDIOLOGEVENT_END) 1577 { 1578 VDDBGIOLOGREQ enmReq = VDDBGIOLOGREQ_INVALID; 1579 uint64_t idEvent = 0; 1580 bool fAsync = false; 1581 uint64_t off = 0; 1582 size_t cbIo = 0; 1583 Assert(enmEvent == VDIOLOGEVENT_START); 1584 1585 rc = VDDbgIoLogReqTypeGetNext(hIoLogger, &enmReq); 1586 if (RT_FAILURE(rc)) 1587 break; 1588 1589 switch (enmReq) 1590 { 1591 case VDDBGIOLOGREQ_READ: 1592 { 1593 rc = VDDbgIoLogEventGetStart(hIoLogger, &idEvent, &fAsync, 1594 &off, &cbIo, 0, NULL); 1595 if ( RT_SUCCESS(rc) 1596 && cbIo > cbBuf) 1597 { 1598 pvBuf = RTMemRealloc(pvBuf, cbIo); 1599 if (pvBuf) 1600 cbBuf = cbIo; 1601 else 1602 rc = VERR_NO_MEMORY; 1603 } 1604 1605 if ( RT_SUCCESS(rc) 1606 && !fAsync) 1607 rc = VDRead(pDisk->pVD, off, pvBuf, cbIo); 1608 else if (RT_SUCCESS(rc)) 1609 rc = VERR_NOT_SUPPORTED; 1610 break; 1611 } 1612 case VDDBGIOLOGREQ_WRITE: 1613 { 1614 rc = VDDbgIoLogEventGetStart(hIoLogger, &idEvent, &fAsync, 1615 &off, &cbIo, cbBuf, pvBuf); 1616 if (rc == VERR_BUFFER_OVERFLOW) 1617 { 1618 pvBuf = RTMemRealloc(pvBuf, cbIo); 1619 if (pvBuf) 1620 { 1621 cbBuf = cbIo; 1622 rc = VDDbgIoLogEventGetStart(hIoLogger, &idEvent, &fAsync, 1623 &off, &cbIo, cbBuf, pvBuf); 1624 } 1625 else 1626 rc = VERR_NO_MEMORY; 1627 } 1628 1629 if ( RT_SUCCESS(rc) 1630 && !fAsync) 1631 rc = VDWrite(pDisk->pVD, off, pvBuf, cbIo); 1632 else if (RT_SUCCESS(rc)) 1633 rc = VERR_NOT_SUPPORTED; 1634 break; 1635 } 1636 case VDDBGIOLOGREQ_FLUSH: 1637 { 1638 rc = VDDbgIoLogEventGetStart(hIoLogger, &idEvent, &fAsync, 1639 &off, &cbIo, 0, NULL); 1640 if ( RT_SUCCESS(rc) 1641 && !fAsync) 1642 rc = VDFlush(pDisk->pVD); 1643 else if (RT_SUCCESS(rc)) 1644 rc = VERR_NOT_SUPPORTED; 1645 break; 1646 } 1647 case VDDBGIOLOGREQ_DISCARD: 1648 { 1649 PVDRANGE paRanges = NULL; 1650 unsigned cRanges = 0; 1651 1652 rc = VDDbgIoLogEventGetStartDiscard(hIoLogger, &idEvent, &fAsync, 1653 &paRanges, &cRanges); 1654 if ( RT_SUCCESS(rc) 1655 && !fAsync) 1656 { 1657 rc = VDDiscardRanges(pDisk->pVD, paRanges, cRanges); 1658 RTMemFree(paRanges); 1659 } 1660 else if (RT_SUCCESS(rc)) 1661 rc = VERR_NOT_SUPPORTED; 1662 break; 1663 } 1664 default: 1665 AssertMsgFailed(("Invalid request type %d\n", enmReq)); 1666 } 1667 1668 if (RT_SUCCESS(rc)) 1669 { 1670 /* Get matching complete event. */ 1671 rc = VDDbgIoLogEventTypeGetNext(hIoLogger, &enmEvent); 1672 if (RT_SUCCESS(rc)) 1673 { 1674 uint64_t idEvtComplete; 1675 int rcReq; 1676 uint64_t msDuration; 1677 1678 Assert(enmEvent == VDIOLOGEVENT_COMPLETE); 1679 rc = VDDbgIoLogEventGetComplete(hIoLogger, &idEvtComplete, &rcReq, 1680 &msDuration, &cbIo, cbBuf, pvBuf); 1681 Assert(RT_FAILURE(rc) || idEvtComplete == idEvent); 1682 } 1683 } 1684 1685 if (RT_SUCCESS(rc)) 1686 rc = VDDbgIoLogEventTypeGetNext(hIoLogger, &enmEvent); 1687 } 1688 1689 VDDbgIoLogDestroy(hIoLogger); 1690 } 1691 } 1514 1692 else 1515 1693 rc = VERR_NOT_FOUND; … … 3185 3363 { 3186 3364 RTPrintf("Usage:\n" 3187 "--script <filename> Script to execute\n" 3188 "--replay <filename> Log to replay (not implemented yet)\n"); 3365 "--script <filename> Script to execute\n"); 3189 3366 } 3190 3367 3191 3368 static const RTGETOPTDEF g_aOptions[] = 3192 3369 { 3193 { "--script", 's', RTGETOPT_REQ_STRING }, 3194 { "--replay", 'r', RTGETOPT_REQ_STRING }, 3370 { "--script", 's', RTGETOPT_REQ_STRING } 3195 3371 }; 3196 3372 … … 3224 3400 tstVDIoScriptRun(ValueUnion.psz); 3225 3401 break; 3226 case 'r':3227 RTPrintf("Replaying I/O logs is not implemented yet\n");3228 break;3229 3402 default: 3230 3403 printUsage();
Note:
See TracChangeset
for help on using the changeset viewer.