VirtualBox

Changeset 36131 in vbox for trunk/src


Ignore:
Timestamp:
Mar 2, 2011 9:56:42 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70308
Message:

tstVDIo: Updates

Location:
trunk/src/VBox/Storage/testcase
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/testcase/VDIoBackendMem.cpp

    r35663 r36131  
    5454} VDIOBACKENDREQ, *PVDIOBACKENDREQ;
    5555
     56typedef PVDIOBACKENDREQ *PPVDIOBACKENDREQ;
     57
    5658/**
    5759 * I/O memory backend
     
    6971    /** Flag whether the the server should be still running. */
    7072    volatile bool fRunning;
     73    /** Number of requests waiting in the request buffer. */
     74    volatile uint32_t cReqsWaiting;
    7175} VDIOBACKENDMEM;
    7276
     
    9397    if (pIoBackend)
    9498    {
    95         rc = RTCircBufCreate(&pIoBackend->pRequestRing, VDMEMIOBACKEND_REQS * sizeof(VDIOBACKENDREQ));
     99        rc = RTCircBufCreate(&pIoBackend->pRequestRing, VDMEMIOBACKEND_REQS * sizeof(PVDIOBACKENDREQ));
    96100        if (RT_SUCCESS(rc))
    97101        {
     
    143147{
    144148    PVDIOBACKENDREQ pReq = NULL;
     149    PPVDIOBACKENDREQ ppReq = NULL;
    145150    size_t cbData;
    146151
    147     RTCircBufAcquireWriteBlock(pIoBackend->pRequestRing, RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs]), (void **)&pReq, &cbData);
     152    LogFlowFunc(("Queuing request\n"));
     153
     154    pReq = (PVDIOBACKENDREQ)RTMemAlloc(RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs]));
    148155    if (!pReq)
    149156        return VERR_NO_MEMORY;
    150157
    151     Assert(cbData == (size_t)RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs]));
     158    RTCircBufAcquireWriteBlock(pIoBackend->pRequestRing, sizeof(PVDIOBACKENDREQ), (void **)&ppReq, &cbData);
     159    if (!pReq)
     160    {
     161        RTMemFree(pReq);
     162        return VERR_NO_MEMORY;
     163    }
     164
     165    Assert(cbData == sizeof(PVDIOBACKENDREQ));
    152166    pReq->enmTxDir    = enmTxDir;
    153167    pReq->cbTransfer  = cbTransfer;
     
    162176        pReq->aSegs[i].cbSeg = paSegs[i].cbSeg;
    163177    }
    164     RTCircBufReleaseWriteBlock(pIoBackend->pRequestRing, RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs]));
    165     vdIoBackendMemThreadPoke(pIoBackend);
     178
     179    *ppReq = pReq;
     180    RTCircBufReleaseWriteBlock(pIoBackend->pRequestRing, sizeof(PVDIOBACKENDREQ));
     181    uint32_t cReqsWaiting = ASMAtomicIncU32(&pIoBackend->cReqsWaiting);
     182    if (cReqsWaiting == 1)
     183        vdIoBackendMemThreadPoke(pIoBackend);
    166184
    167185    return VINF_SUCCESS;
     
    187205
    188206        PVDIOBACKENDREQ pReq;
     207        PPVDIOBACKENDREQ ppReq;
    189208        size_t cbData;
    190 
    191         RTCircBufAcquireReadBlock(pIoBackend->pRequestRing, sizeof(VDIOBACKENDREQ), (void **)&pReq, &cbData);
    192         Assert(!pReq || cbData == sizeof(VDIOBACKENDREQ));
    193 
    194         while (pReq)
     209        uint32_t cReqsWaiting = ASMAtomicXchgU32(&pIoBackend->cReqsWaiting, 0);
     210
     211        while (cReqsWaiting)
    195212        {
    196213            int rcReq = VINF_SUCCESS;
    197214
     215            /* Do we have another request? */
     216            RTCircBufAcquireReadBlock(pIoBackend->pRequestRing, sizeof(PVDIOBACKENDREQ), (void **)&ppReq, &cbData);
     217            Assert(!ppReq || cbData == sizeof(PVDIOBACKENDREQ));
     218            RTCircBufReleaseReadBlock(pIoBackend->pRequestRing, cbData);
     219
     220            pReq = *ppReq;
     221            cReqsWaiting--;
     222
     223            LogFlowFunc(("Processing request\n"));
    198224            switch (pReq->enmTxDir)
    199225            {
     
    220246            /* Notify completion. */
    221247            pReq->pfnComplete(pReq->pvUser, rcReq);
    222 
    223             RTCircBufReleaseReadBlock(pIoBackend->pRequestRing, cbData);
    224 
    225             /* Do we have another request? */
    226             RTCircBufAcquireReadBlock(pIoBackend->pRequestRing, sizeof(VDIOBACKENDREQ), (void **)&pReq, &cbData);
    227             Assert(!pReq || cbData == sizeof(VDIOBACKENDREQ));
     248            RTMemFree(pReq);
    228249        }
    229250    }
  • trunk/src/VBox/Storage/testcase/tstVDIo.cpp

    r35789 r36131  
    1717 */
    1818#define LOGGROUP LOGGROUP_DEFAULT
    19 #define RTMEM_WRAP_TO_EF_APIS
    2019#include <VBox/vd.h>
    2120#include <VBox/err.h>
     
    3130#include <iprt/semaphore.h>
    3231#include <iprt/thread.h>
     32#include <iprt/rand.h>
    3333
    3434#include "VDMemDisk.h"
     
    281281static DECLCALLBACK(int) vdScriptHandlerDestroyDisk(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    282282static DECLCALLBACK(int) vdScriptHandlerCompareDisks(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
     283static DECLCALLBACK(int) vdScriptHandlerDumpDiskInfo(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    283284
    284285/* create action */
     
    349350    /* pcszName    chId enmType                          fFlags */
    350351    {"size",       'd', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY | VDSCRIPTARGDESC_FLAG_SIZE_SUFFIX},
    351     {"seed",       's', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY}
     352    {"mode",       'm', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY},
     353    {"seed",       's', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, 0}
    352354};
    353355
     
    387389    {"disk1",      '1', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY},
    388390    {"disk2",      '2', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY}
     391};
     392
     393/* Dump disk info */
     394const VDSCRIPTARGDESC g_aArgDumpDiskInfo[] =
     395{
     396    /* pcszName    chId enmType                          fFlags */
     397    {"disk",       'd', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY},
    389398};
    390399
     
    404413    {"createdisk",   g_aArgCreateDisk,    RT_ELEMENTS(g_aArgCreateDisk),   vdScriptHandlerCreateDisk},
    405414    {"destroydisk",  g_aArgDestroyDisk,   RT_ELEMENTS(g_aArgDestroyDisk),  vdScriptHandlerDestroyDisk},
    406     {"comparedisks", g_aArgCompareDisks,  RT_ELEMENTS(g_aArgCompareDisks), vdScriptHandlerCompareDisks}
     415    {"comparedisks", g_aArgCompareDisks,  RT_ELEMENTS(g_aArgCompareDisks), vdScriptHandlerCompareDisks},
     416    {"dumpdiskinfo", g_aArgDumpDiskInfo,  RT_ELEMENTS(g_aArgDumpDiskInfo), vdScriptHandlerDumpDiskInfo},
    407417};
    408418
     
    982992    size_t cbPattern = 0;
    983993    uint64_t uSeed = 0;
     994    const char *pcszSeeder = NULL;
    984995
    985996    for (unsigned i = 0; i < cScriptArgs; i++)
     
    9951006            {
    9961007                uSeed = paScriptArgs[i].u.u64;
     1008                break;
     1009            }
     1010            case 'm':
     1011            {
     1012                pcszSeeder = paScriptArgs[i].u.pcszString;
    9971013                break;
    9981014            }
     
    10081024    }
    10091025    else
    1010         rc = VDIoRndCreate(&pGlob->pIoRnd, cbPattern, uSeed);
     1026    {
     1027        uint64_t uSeedToUse = 0;
     1028
     1029        if (!RTStrICmp(pcszSeeder, "manual"))
     1030            uSeedToUse = uSeed;
     1031        else if (!RTStrICmp(pcszSeeder, "time"))
     1032            uSeedToUse = RTTimeSystemMilliTS();
     1033        else if (!RTStrICmp(pcszSeeder, "system"))
     1034        {
     1035            RTRAND hRand;
     1036            rc = RTRandAdvCreateSystemTruer(&hRand);
     1037            if (RT_SUCCESS(rc))
     1038            {
     1039                RTRandAdvBytes(hRand, &uSeedToUse, sizeof(uSeedToUse));
     1040                RTRandAdvDestroy(hRand);
     1041            }
     1042        }
     1043
     1044        if (RT_SUCCESS(rc))
     1045            rc = VDIoRndCreate(&pGlob->pIoRnd, cbPattern, uSeed);
     1046    }
    10111047
    10121048    return rc;
     
    12661302        }
    12671303    }
     1304    else
     1305        rc = VERR_NOT_FOUND;
     1306
     1307    return rc;
     1308}
     1309
     1310static DECLCALLBACK(int) vdScriptHandlerDumpDiskInfo(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs)
     1311{
     1312    int rc = VINF_SUCCESS;
     1313    const char *pcszDisk = NULL;
     1314    PVDDISK pDisk = NULL;
     1315
     1316    for (unsigned i = 0; i < cScriptArgs; i++)
     1317    {
     1318        switch (paScriptArgs[i].chId)
     1319        {
     1320            case 'd':
     1321            {
     1322                pcszDisk = paScriptArgs[i].u.pcszString;
     1323                break;
     1324            }
     1325            default:
     1326                AssertMsgFailed(("Invalid argument given!\n"));
     1327        }
     1328    }
     1329
     1330    pDisk = tstVDIoGetDiskByName(pGlob, pcszDisk);
     1331
     1332    if (pDisk)
     1333        VDDumpImages(pDisk->pVD);
    12681334    else
    12691335        rc = VERR_NOT_FOUND;
  • trunk/src/VBox/Storage/testcase/tstVDShareable.vd

    r35789 r36131  
    1717
    1818# Init I/O RNG for generating random data for writes
    19 iorngcreate size=10M seed=1234567890
     19iorngcreate size=10M mode=manual seed=1234567890
    2020
    2121# Create disk containers.
Note: See TracChangeset for help on using the changeset viewer.

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