VirtualBox

Changeset 38204 in vbox for trunk/src/VBox/Storage


Ignore:
Timestamp:
Jul 27, 2011 4:14:59 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73172
Message:

tstVDIo: New testcase for image cloning

Location:
trunk/src/VBox/Storage/testcase
Files:
1 added
2 edited

Legend:

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

    r37308 r38204  
    300300static DECLCALLBACK(int) vdScriptHandlerMerge(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    301301static DECLCALLBACK(int) vdScriptHandlerCompact(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
     302static DECLCALLBACK(int) vdScriptHandlerCopy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    302303static DECLCALLBACK(int) vdScriptHandlerClose(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
    303304static DECLCALLBACK(int) vdScriptHandlerIoRngCreate(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs);
     
    377378};
    378379
     380/* Compact a disk */
     381const VDSCRIPTARGDESC g_aArgCopy[] =
     382{
     383    /* pcszName    chId enmType                          fFlags */
     384    {"diskfrom",   's', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY},
     385    {"diskto",     'd', VDSCRIPTARGTYPE_STRING,          VDSCRIPTARGDESC_FLAG_MANDATORY},
     386    {"imagefrom",  'i', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, VDSCRIPTARGDESC_FLAG_MANDATORY},
     387    {"backend",    'b', VDSCRIPTARGTYPE_STRING,          0},
     388    {"filename",   'f', VDSCRIPTARGTYPE_STRING,          0},
     389    {"movebyrename", 'm', VDSCRIPTARGTYPE_BOOL,          0},
     390    {"size",       'z', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, 0},
     391    {"fromsame",   'o', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, 0},
     392    {"tosame",     't', VDSCRIPTARGTYPE_UNSIGNED_NUMBER, 0}
     393};
     394
    379395/* close action */
    380396const VDSCRIPTARGDESC g_aArgClose[] =
     
    481497    {"merge",                      g_aArgMerge,                       RT_ELEMENTS(g_aArgMerge),                      vdScriptHandlerMerge},
    482498    {"compact",                    g_aArgCompact,                     RT_ELEMENTS(g_aArgCompact),                    vdScriptHandlerCompact},
     499    {"copy",                       g_aArgCopy,                        RT_ELEMENTS(g_aArgCopy),                       vdScriptHandlerCopy},
    483500    {"iorngcreate",                g_aArgIoRngCreate,                 RT_ELEMENTS(g_aArgIoRngCreate),                vdScriptHandlerIoRngCreate},
    484501    {"iorngdestroy",               NULL,                              0,                                             vdScriptHandlerIoRngDestroy},
     
    11851202             */
    11861203            rc = VDCompact(pDisk->pVD, nImage, NULL);
     1204        }
     1205    }
     1206
     1207    return rc;
     1208}
     1209
     1210static DECLCALLBACK(int) vdScriptHandlerCopy(PVDTESTGLOB pGlob, PVDSCRIPTARG paScriptArgs, unsigned cScriptArgs)
     1211{
     1212    int rc = VINF_SUCCESS;
     1213    const char *pcszDiskFrom = NULL;
     1214    const char *pcszDiskTo = NULL;
     1215    PVDDISK pDiskFrom = NULL;
     1216    PVDDISK pDiskTo = NULL;
     1217    unsigned nImageFrom = 0;
     1218    const char *pcszBackend = NULL;
     1219    const char *pcszFilename = NULL;
     1220    bool fMoveByRename = false;
     1221    uint64_t cbSize = 0;
     1222    unsigned nImageFromSame = VD_IMAGE_CONTENT_UNKNOWN;
     1223    unsigned nImageToSame = VD_IMAGE_CONTENT_UNKNOWN;
     1224
     1225    for (unsigned i = 0; i < cScriptArgs; i++)
     1226    {
     1227        switch (paScriptArgs[i].chId)
     1228        {
     1229            case 's':
     1230            {
     1231                pcszDiskFrom = paScriptArgs[i].u.pcszString;
     1232                break;
     1233            }
     1234            case 'd':
     1235            {
     1236                pcszDiskTo = paScriptArgs[i].u.pcszString;
     1237                break;
     1238            }
     1239            case 'i':
     1240            {
     1241                nImageFrom = (unsigned)paScriptArgs[i].u.u64;
     1242                break;
     1243            }
     1244            case 'b':
     1245            {
     1246                pcszBackend = paScriptArgs[i].u.pcszString;
     1247                break;
     1248            }
     1249            case 'f':
     1250            {
     1251                pcszFilename = paScriptArgs[i].u.pcszString;
     1252                break;
     1253            }
     1254            case 'm':
     1255            {
     1256                fMoveByRename = paScriptArgs[i].u.fFlag;
     1257                break;
     1258            }
     1259            case 'z':
     1260            {
     1261                cbSize = paScriptArgs[i].u.u64;
     1262                break;
     1263            }
     1264            case 'o':
     1265            {
     1266                nImageFromSame = (unsigned)paScriptArgs[i].u.u64;
     1267                break;
     1268            }
     1269            case 't':
     1270            {
     1271                nImageToSame = (unsigned)paScriptArgs[i].u.u64;
     1272                break;
     1273            }
     1274
     1275            default:
     1276                AssertMsgFailed(("Invalid argument given!\n"));
     1277        }
     1278
     1279        if (RT_FAILURE(rc))
     1280            break;
     1281    }
     1282
     1283    if (RT_SUCCESS(rc))
     1284    {
     1285        pDiskFrom = tstVDIoGetDiskByName(pGlob, pcszDiskFrom);
     1286        pDiskTo = tstVDIoGetDiskByName(pGlob, pcszDiskTo);
     1287        if (!pDiskFrom || !pDiskTo)
     1288            rc = VERR_NOT_FOUND;
     1289        else
     1290        {
     1291            /** @todo: Provide progress interface to test that cancelation
     1292             * works as intended.
     1293             */
     1294            rc = VDCopyEx(pDiskFrom->pVD, nImageFrom, pDiskTo->pVD, pcszBackend, pcszFilename,
     1295                          fMoveByRename, cbSize, nImageFromSame, nImageToSame,
     1296                          VD_IMAGE_FLAGS_NONE, NULL, VD_OPEN_FLAGS_ASYNC_IO,
     1297                          NULL, pGlob->pInterfacesImages, NULL);
    11871298        }
    11881299    }
  • trunk/src/VBox/Storage/testcase/tstVDIo.vd

    r36135 r38204  
    2525io disk=test async=yes max-reqs=32 mode=seq blocksize=64k off=0-200M size=200M writes=100
    2626io disk=test async=yes max-reqs=32 mode=seq blocksize=64k off=0-200M size=200M writes=0
    27 create disk=test mode=diff name=tstShared2.vmdk type=dynamic backend=VMDK size=20M
     27create disk=test mode=diff name=tstShared2.vmdk type=dynamic backend=VMDK size=200M
    2828io disk=test async=yes max-reqs=32 mode=rnd blocksize=64k off=0-200M size=200M writes=50
    29 create disk=test mode=diff name=tstShared3.vmdk type=dynamic backend=VMDK size=20M
     29create disk=test mode=diff name=tstShared3.vmdk type=dynamic backend=VMDK size=200M
    3030io disk=test async=yes max-reqs=32 mode=rnd blocksize=64k off=0-200M size=200M writes=50
    3131close disk=test mode=single delete=yes
     
    4040io disk=test async=yes max-reqs=32 mode=seq blocksize=64k off=0-200M size=200M writes=100
    4141io disk=test async=yes max-reqs=32 mode=seq blocksize=64k off=0-200M size=200M writes=0
    42 create disk=test mode=diff name=tstShared2.vdi type=dynamic backend=VDI size=20M
     42create disk=test mode=diff name=tstShared2.vdi type=dynamic backend=VDI size=200M
    4343io disk=test async=yes max-reqs=32 mode=rnd blocksize=64k off=0-200M size=200M writes=50
    44 create disk=test mode=diff name=tstShared3.vdi type=dynamic backend=VDI size=20M
     44create disk=test mode=diff name=tstShared3.vdi type=dynamic backend=VDI size=200M
    4545io disk=test async=yes max-reqs=32 mode=rnd blocksize=64k off=0-200M size=200M writes=50
    4646close disk=test mode=single delete=yes
     
    5555io disk=test async=yes max-reqs=32 mode=seq blocksize=64k off=0-200M size=200M writes=100
    5656io disk=test async=yes max-reqs=32 mode=seq blocksize=64k off=0-200M size=200M writes=0
    57 create disk=test mode=diff name=tstShared2.vhd type=dynamic backend=VHD size=20M
     57create disk=test mode=diff name=tstShared2.vhd type=dynamic backend=VHD size=200M
    5858io disk=test async=yes max-reqs=32 mode=rnd blocksize=64k off=0-200M size=200M writes=50
    59 create disk=test mode=diff name=tstShared3.vhd type=dynamic backend=VHD size=20M
     59create disk=test mode=diff name=tstShared3.vhd type=dynamic backend=VHD size=200M
    6060io disk=test async=yes max-reqs=32 mode=rnd blocksize=64k off=0-200M size=200M writes=50
    6161close disk=test mode=single delete=yes
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