VirtualBox

Changeset 38644 in vbox


Ignore:
Timestamp:
Sep 5, 2011 4:45:44 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73852
Message:

VDDbg+DrvDiskIntegrity+tstVDIo: Bugfixes and add a I/O log replay action for the scripted I/O testcase

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvDiskIntegrity.cpp

    r38631 r38644  
    11621162    {
    11631163        rc = VDDbgIoLogCreate(&pThis->hIoLogger, pszIoLogFilename, VDDBG_IOLOG_LOG_DATA);
    1164         RTStrFree(pszIoLogFilename);
     1164        MMR3HeapFree(pszIoLogFilename);
    11651165    }
    11661166
  • trunk/src/VBox/Storage/Debug/VDDbgIoLog.cpp

    r38631 r38644  
    9898{
    9999    /** Event type. */
    100     uint8_t     u32Type;
     100    uint32_t    u32Type;
    101101    /** Id of the matching start entry. */
    102102    uint64_t    u64Id;
     
    328328                pIoLogger->offReadNext  = sizeof(Hdr);
    329329                pIoLogger->idNext       = RT_LE2H_U64(Hdr.u64Id);
     330                *phIoLogger = pIoLogger;
    330331            }
    331332            else if (RT_SUCCESS(rc))
     
    468469        pIoLogEntry->idStart = pIoLogger->idNext++;
    469470
    470         Entry.u32Type          = VDIOLOG_EVENT_START;
     471        Entry.u32Type         = VDIOLOG_EVENT_START;
    471472        Entry.u8AsyncIo       = fAsync ? 1 : 0;
    472473        Entry.u32ReqType      = VDDBGIOLOGREQ_DISCARD;
     474        Entry.u64Id           = RT_H2LE_U64(pIoLogEntry->idStart);
    473475        Entry.Discard.cRanges = RT_H2LE_U32(cRanges);
    474476
     
    588590        if (RT_SUCCESS(rc))
    589591        {
    590             pIoLogger->u32EventTypeNext = (VDIOLOGEVENT)abBuf[0];
     592            pIoLogger->u32EventTypeNext = abBuf[0];
    591593            pIoLogger->enmReqTypeNext   = (VDDBGIOLOGREQ)abBuf[1];
    592594        }
     
    687689        rc = VERR_INVALID_STATE;
    688690
     691    if (RT_SUCCESS(rc))
     692        pIoLogger->u32EventTypeNext = 0;
     693
    689694    RTSemFastMutexRelease(pIoLogger->hMtx);
    690695    return rc;
     
    748753        rc = VERR_INVALID_STATE;
    749754
     755    if (RT_SUCCESS(rc))
     756        pIoLogger->u32EventTypeNext = 0;
     757
    750758    RTSemFastMutexRelease(pIoLogger->hMtx);
    751759    return rc;
     
    796804        rc = VERR_INVALID_STATE;
    797805
     806    if (RT_SUCCESS(rc))
     807        pIoLogger->u32EventTypeNext = 0;
     808
    798809    RTSemFastMutexRelease(pIoLogger->hMtx);
    799810    return rc;
  • trunk/src/VBox/Storage/testcase/Makefile.kmk

    r38563 r38644  
    5353        VDMemDisk.cpp \
    5454        VDIoRnd.cpp
    55  tstVDIo_LIBS = $(LIB_DDU)
     55 tstVDIo_LIBS = \
     56        $(LIB_DDU) \
     57        $(PATH_STAGE_LIB)/StorageDbgLib$(VBOX_SUFF_LIB)
    5658
    5759 tstVDSetUuid_TEMPLATE = VBOXR3TSTEXE
  • trunk/src/VBox/Storage/testcase/tstVDIo.cpp

    r38636 r38644  
    1818#define LOGGROUP LOGGROUP_DEFAULT
    1919#include <VBox/vd.h>
     20#include <VBox/vddbg.h>
    2021#include <VBox/err.h>
    2122#include <VBox/log.h>
     
    300301static DECLCALLBACK(int) vdScriptHandlerClose(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    301302static DECLCALLBACK(int) vdScriptHandlerPrintFileSize(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
     303static DECLCALLBACK(int) vdScriptHandlerIoLogReplay(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    302304static DECLCALLBACK(int) vdScriptHandlerIoRngCreate(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    303305static DECLCALLBACK(int) vdScriptHandlerIoRngDestroy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
     
    419421};
    420422
     423/* print file size action */
     424const 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
    421431/* I/O RNG create action */
    422432const VDSCRIPTARGDESC g_aArgIoRngCreate[] =
     
    513523    {"close",                      g_aArgClose,                       RT_ELEMENTS(g_aArgClose),                      vdScriptHandlerClose},
    514524    {"printfilesize",              g_aArgPrintFileSize,               RT_ELEMENTS(g_aArgPrintFileSize),              vdScriptHandlerPrintFileSize},
     525    {"ioreplay",                   g_aArgIoLogReplay,                 RT_ELEMENTS(g_aArgIoLogReplay),                vdScriptHandlerIoLogReplay},
    515526    {"merge",                      g_aArgMerge,                       RT_ELEMENTS(g_aArgMerge),                      vdScriptHandlerMerge},
    516527    {"compact",                    g_aArgCompact,                     RT_ELEMENTS(g_aArgCompact),                    vdScriptHandlerCompact},
     
    15121523    if (pDisk)
    15131524        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
     1532static 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    }
    15141692    else
    15151693        rc = VERR_NOT_FOUND;
     
    31853363{
    31863364    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");
    31893366}
    31903367
    31913368static const RTGETOPTDEF g_aOptions[] =
    31923369{
    3193     { "--script",   's', RTGETOPT_REQ_STRING },
    3194     { "--replay",   'r', RTGETOPT_REQ_STRING },
     3370    { "--script",   's', RTGETOPT_REQ_STRING }
    31953371};
    31963372
     
    32243400                tstVDIoScriptRun(ValueUnion.psz);
    32253401                break;
    3226             case 'r':
    3227                 RTPrintf("Replaying I/O logs is not implemented yet\n");
    3228                 break;
    32293402            default:
    32303403                printUsage();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette