VirtualBox

Changeset 9528 in vbox


Ignore:
Timestamp:
Jun 9, 2008 10:12:30 AM (17 years ago)
Author:
vboxsync
Message:

fixes in setparentuuid and read/write to support diff images.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm.h

    r9212 r9528  
    49264926
    49274927/**
     4928 * Sets a bit range within a bitmap.
     4929 *
     4930 * @param   pvBitmap    Pointer to the bitmap.
     4931 * @param   iBitStart   The First bit to set.
     4932 * @param   iBitEnd     The first bit not to set.
     4933 */
     4934DECLINLINE(void) ASMBitSetRange(volatile void *pvBitmap, int32_t iBitStart, int32_t iBitEnd)
     4935{
     4936    if (iBitStart < iBitEnd)
     4937    {
     4938        volatile uint32_t *pu32 = (volatile uint32_t *)pvBitmap + (iBitStart >> 5);
     4939        int iStart = iBitStart & ~31;
     4940        int iEnd   = iBitEnd & ~31;
     4941        if (iStart == iEnd)
     4942            *pu32 |= ((1 << (iBitEnd - iBitStart)) - 1) << iBitStart;
     4943        else
     4944        {
     4945            /* bits in first dword. */
     4946            if (iBitStart & 31)
     4947            {
     4948                *pu32 |= ~((1 << (iBitStart & 31)) - 1);
     4949                pu32++;
     4950                iBitStart = iStart + 32;
     4951            }
     4952
     4953            /* whole dword. */
     4954            if (iBitStart != iEnd)
     4955                ASMMemFill32(pu32, (iEnd - iBitStart) >> 3, ~0);
     4956
     4957            /* bits in last dword. */
     4958            if (iBitEnd & 31)
     4959            {
     4960                pu32 = (volatile uint32_t *)pvBitmap + (iBitEnd >> 5);
     4961                *pu32 |= (1 << (iBitEnd & 31)) - 1;
     4962            }
     4963        }
     4964    }
     4965}
     4966
     4967
     4968/**
    49284969 * Finds the first clear bit in a bitmap.
    49294970 *
  • trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp

    r9262 r9528  
    14841484        pImage->uOpenFlags = uOpenFlags & VD_OPEN_FLAGS_HONOR_SAME;
    14851485        rc = pImage->Backend->pfnCreate(pImage->pszFilename,
    1486                                         VD_IMAGE_TYPE_NORMAL, pDisk->cbSize,
     1486                                        VD_IMAGE_TYPE_DIFF, pDisk->cbSize,
    14871487                                        uImageFlags, pszComment,
    14881488                                        &pDisk->PCHSGeometry,
  • trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp

    r9263 r9528  
    812812    if (   !VALID_PTR(pszFilename)
    813813        || !*pszFilename
    814         || (enmType != VD_IMAGE_TYPE_NORMAL && enmType != VD_IMAGE_TYPE_FIXED)
     814        || (enmType != VD_IMAGE_TYPE_NORMAL && enmType != VD_IMAGE_TYPE_FIXED
     815            && enmType != VD_IMAGE_TYPE_DIFF)
    815816        || cbSize < VDI_IMAGE_DEFAULT_BLOCK_SIZE
    816817        || !VALID_PTR(pPCHSGeometry)
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r9084 r9528  
    35883588        goto out;
    35893589    }
     3590
     3591    /* @todo A quick hack to support differencing images in VMDK. */
     3592    if (enmType == VD_IMAGE_TYPE_DIFF)
     3593        enmType = VD_IMAGE_TYPE_NORMAL;
    35903594
    35913595    /* Check remaining arguments. */
  • trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp

    r9490 r9528  
    393393                if (((uint8_t*)pvBuf)[i] != pSegment->u8Value)
    394394                {
    395                     RTPrintf("ERROR: Segment at %Lx of %d bytes is corrupt at offset %x (found %x instead of %x)\n",
     395                    RTPrintf("ERROR: Segment at %Lx of %x bytes is corrupt at offset %x (found %x instead of %x)\n",
    396396                             pSegment->u64Offset, pSegment->u32Length, i, ((uint8_t*)pvBuf)[i],
    397397                             pSegment->u8Value);
    398                     RTLogPrintf("ERROR: Segment at %Lx of %d bytes is corrupt at offset %x (found %x instead of %x)\n",
     398                    RTLogPrintf("ERROR: Segment at %Lx of %x bytes is corrupt at offset %x (found %x instead of %x)\n",
    399399                             pSegment->u64Offset, pSegment->u32Length, i, ((uint8_t*)pvBuf)[i],
    400400                             pSegment->u8Value);
     
    476476    generateRandomSegments(&ctx, paDiffSegments, nSegments, _1M, u64DiskSize, u32SectorSize, 128u, 255u);
    477477
    478     /*PSEGMENT pSegment;
    479     RTPrintf("Base segments:\n");
     478    PSEGMENT pSegment;
     479    /*RTPrintf("Base segments:\n");
    480480    for (pSegment = paBaseSegments; pSegment->u32Length; pSegment++)
    481         RTPrintf("off: %08Lx len: %04x val: %02x\n", pSegment->u64Offset, pSegment->u32Length, pSegment->u8Value);*/
     481        RTPrintf("off: %08Lx len: %05x val: %02x\n", pSegment->u64Offset, pSegment->u32Length, pSegment->u8Value);*/
    482482    writeSegmentsToDisk(pVD, pvBuf, paBaseSegments);
    483483
     
    489489    /*RTPrintf("\nDiff segments:\n");
    490490    for (pSegment = paDiffSegments; pSegment->u32Length; pSegment++)
    491         RTPrintf("off: %08Lx len: %04x val: %02x\n", pSegment->u64Offset, pSegment->u32Length, pSegment->u8Value);*/
     491        RTPrintf("off: %08Lx len: %05x val: %02x\n", pSegment->u64Offset, pSegment->u32Length, pSegment->u8Value);*/
    492492    writeSegmentsToDisk(pVD, pvBuf, paDiffSegments);
    493493
     
    501501    /*RTPrintf("\nMerged segments:\n");
    502502    for (pSegment = paMergeSegments; pSegment->u32Length; pSegment++)
    503         RTPrintf("off: %08Lx len: %04x val: %02x\n", pSegment->u64Offset, pSegment->u32Length, pSegment->u8Value);*/
     503        RTPrintf("off: %08Lx len: %05x val: %02x\n", pSegment->u64Offset, pSegment->u32Length, pSegment->u8Value);*/
    504504    rc = readAndCompareSegments(pVD, pvBuf, paMergeSegments);
    505505    CHECK("readAndCompareSegments()");
     
    565565    initializeRandomGenerator(&ctx, u32Seed);
    566566    generateRandomSegments(&ctx, paSegments, nSegments, _1M, u64DiskSize, u32SectorSize, 0u, 127u);
     567    /*for (PSEGMENT pSegment = paSegments; pSegment->u32Length; pSegment++)
     568        RTPrintf("off: %08Lx len: %05x val: %02x\n", pSegment->u64Offset, pSegment->u32Length, pSegment->u8Value);*/
    567569
    568570    writeSegmentsToDisk(pVD, pvBuf, paSegments);
     
    611613    RTFileDelete("tmpVDBase.vhd");
    612614    RTFileDelete("tmpVDDiff.vhd");
    613 
     615#if 1
    614616    rc = tstVDCreateDelete("VDI", "tmpVDCreate.vdi", 2 * _4G,
    615617                           VD_IMAGE_TYPE_NORMAL, VD_IMAGE_FLAGS_NONE,
     
    708710        g_cErrors++;
    709711    }
    710 #if 0
     712#endif
     713
    711714    rc = tstVDOpenCreateWriteMerge("VHD", "tmpVDBase.vhd", "tmpVDDiff.vhd", u32Seed);
    712715    if (VBOX_FAILURE(rc))
     
    715718        g_cErrors++;
    716719    }
    717 #endif
     720
    718721    /*
    719722     * Clean up any leftovers.
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