VirtualBox

Changeset 21806 in vbox for trunk/src


Ignore:
Timestamp:
Jul 27, 2009 10:14:11 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
50410
Message:

Storage/VBoxHDD: resurrect the facility to dump information about disk images, and bare minimum fix for creating diff images.

Location:
trunk/src/VBox
Files:
11 edited

Legend:

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

    r20374 r21806  
    838838    pThis->VDIErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    839839    pThis->VDIErrorCallbacks.pfnError     = drvvdErrorCallback;
     840    pThis->VDIErrorCallbacks.pfnMessage   = NULL;
    840841
    841842    rc = VDInterfaceAdd(&pThis->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR,
  • trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp

    r18678 r21806  
    33363336    {
    33373337        /** @todo put something useful here */
    3338         RTLogPrintf("Header: cVolume=%u\n", pImage->cVolume);
     3338        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: cVolume=%u\n", pImage->cVolume);
    33393339    }
    33403340}
  • trunk/src/VBox/Devices/Storage/ParallelsHDDCore.cpp

    r21373 r21806  
    960960    if (pImage)
    961961    {
    962         RTLogPrintf("Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u\n",
     962        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u\n",
    963963                    pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors,
    964964                    pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors);
  • trunk/src/VBox/Devices/Storage/RawHDDCore.cpp

    r18066 r21806  
    987987    if (pImage)
    988988    {
    989         RTLogPrintf("Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n",
     989        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n",
    990990                    pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors,
    991991                    pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors,
  • trunk/src/VBox/Devices/Storage/VBoxHDD.cpp

    r21371 r21806  
    706706    return rc;
    707707}
     708
     709/**
     710 * internal: send output to the log (unconditionally).
     711 */
     712int vdLogMessage(void *pvUser, const char *pszFormat, ...)
     713{
     714    NOREF(pvUser);
     715    va_list args;
     716    va_start(args, pszFormat);
     717    RTLogPrintf(pszFormat, args);
     718    va_end(args);
     719    return VINF_SUCCESS;
     720}
     721
    708722
    709723/**
     
    15331547
    15341548        pImage->uOpenFlags = uOpenFlags & VD_OPEN_FLAGS_HONOR_SAME;
     1549        uImageFlags |= VD_IMAGE_FLAGS_DIFF;
    15351550        rc = pImage->Backend->pfnCreate(pImage->pszFilename, pDisk->cbSize,
    1536                                         uImageFlags, pszComment,
    1537                                         &pDisk->PCHSGeometry,
     1551                                        uImageFlags | VD_IMAGE_FLAGS_DIFF,
     1552                                        pszComment, &pDisk->PCHSGeometry,
    15381553                                        &pDisk->LCHSGeometry, pUuid,
    15391554                                        uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME,
     
    15461561        if (RT_SUCCESS(rc) && pDisk->cImages != 0)
    15471562        {
    1548             pImage->uImageFlags |= VD_IMAGE_FLAGS_DIFF;
     1563            pImage->uImageFlags = uImageFlags;
    15491564
    15501565            /* Switch previous image to read-only mode. */
     
    34753490        AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    34763491
    3477         RTLogPrintf("--- Dumping VD Disk, Images=%u\n", pDisk->cImages);
     3492        int (*pfnMessage)(void *, const char *, ...) = NULL;
     3493        void *pvUser = pDisk->pInterfaceError->pvUser;
     3494
     3495        if (pDisk->pInterfaceErrorCallbacks && VALID_PTR(pDisk->pInterfaceErrorCallbacks->pfnMessage))
     3496            pfnMessage = pDisk->pInterfaceErrorCallbacks->pfnMessage;
     3497        else
     3498        {
     3499            pDisk->pInterfaceErrorCallbacks->pfnMessage = vdLogMessage;
     3500            pfnMessage = vdLogMessage;
     3501        }
     3502
     3503        pfnMessage(pvUser, "--- Dumping VD Disk, Images=%u\n", pDisk->cImages);
    34783504        for (PVDIMAGE pImage = pDisk->pBase; pImage; pImage = pImage->pNext)
    34793505        {
    3480             RTLogPrintf("Dumping VD image \"%s\" (Backend=%s)\n",
    3481                         pImage->pszFilename, pImage->Backend->pszBackendName);
     3506            pfnMessage(pvUser, "Dumping VD image \"%s\" (Backend=%s)\n",
     3507                       pImage->pszFilename, pImage->Backend->pszBackendName);
    34823508            pImage->Backend->pfnDump(pImage->pvBackendData);
    34833509        }
  • trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp

    r19251 r21806  
    17211721    PVDIIMAGEDESC pImage = (PVDIIMAGEDESC)pBackendData;
    17221722
    1723     RTLogPrintf("Dumping VDI image \"%s\" mode=%s uOpenFlags=%X File=%08X\n",
     1723    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Dumping VDI image \"%s\" mode=%s uOpenFlags=%X File=%08X\n",
    17241724                pImage->pszFilename,
    17251725                (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) ? "r/o" : "r/w",
    17261726                pImage->uOpenFlags,
    17271727                pImage->File);
    1728     RTLogPrintf("Header: Version=%08X Type=%X Flags=%X Size=%llu\n",
     1728    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: Version=%08X Type=%X Flags=%X Size=%llu\n",
    17291729                pImage->PreHeader.u32Version,
    17301730                getImageType(&pImage->Header),
    17311731                getImageFlags(&pImage->Header),
    17321732                getImageDiskSize(&pImage->Header));
    1733     RTLogPrintf("Header: cbBlock=%u cbBlockExtra=%u cBlocks=%u cBlocksAllocated=%u\n",
     1733    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: cbBlock=%u cbBlockExtra=%u cBlocks=%u cBlocksAllocated=%u\n",
    17341734                getImageBlockSize(&pImage->Header),
    17351735                getImageExtraBlockSize(&pImage->Header),
    17361736                getImageBlocks(&pImage->Header),
    17371737                getImageBlocksAllocated(&pImage->Header));
    1738     RTLogPrintf("Header: offBlocks=%u offData=%u\n",
     1738    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: offBlocks=%u offData=%u\n",
    17391739                getImageBlocksOffset(&pImage->Header),
    17401740                getImageDataOffset(&pImage->Header));
    17411741    PVDIDISKGEOMETRY pg = getImageLCHSGeometry(&pImage->Header);
    17421742    if (pg)
    1743         RTLogPrintf("Header: Geometry: C/H/S=%u/%u/%u cbSector=%u\n",
     1743        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: Geometry: C/H/S=%u/%u/%u cbSector=%u\n",
    17441744                    pg->cCylinders, pg->cHeads, pg->cSectors, pg->cbSector);
    1745     RTLogPrintf("Header: uuidCreation={%RTuuid}\n", getImageCreationUUID(&pImage->Header));
    1746     RTLogPrintf("Header: uuidModification={%RTuuid}\n", getImageModificationUUID(&pImage->Header));
    1747     RTLogPrintf("Header: uuidParent={%RTuuid}\n", getImageParentUUID(&pImage->Header));
     1745    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidCreation={%RTuuid}\n", getImageCreationUUID(&pImage->Header));
     1746    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidModification={%RTuuid}\n", getImageModificationUUID(&pImage->Header));
     1747    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidParent={%RTuuid}\n", getImageParentUUID(&pImage->Header));
    17481748    if (GET_MAJOR_HEADER_VERSION(&pImage->Header) >= 1)
    1749         RTLogPrintf("Header: uuidParentModification={%RTuuid}\n", getImageParentModificationUUID(&pImage->Header));
    1750     RTLogPrintf("Image:  fFlags=%08X offStartBlocks=%u offStartData=%u\n",
     1749        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidParentModification={%RTuuid}\n", getImageParentModificationUUID(&pImage->Header));
     1750    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Image:  fFlags=%08X offStartBlocks=%u offStartData=%u\n",
    17511751                pImage->uImageFlags, pImage->offStartBlocks, pImage->offStartData);
    1752     RTLogPrintf("Image:  uBlockMask=%08X cbTotalBlockData=%u uShiftOffset2Index=%u offStartBlockData=%u\n",
     1752    pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Image:  uBlockMask=%08X cbTotalBlockData=%u uShiftOffset2Index=%u offStartBlockData=%u\n",
    17531753                pImage->uBlockMask,
    17541754                pImage->cbTotalBlockData,
     
    17681768    if (cBlocksNotFree != getImageBlocksAllocated(&pImage->Header))
    17691769    {
    1770         RTLogPrintf("!! WARNING: %u blocks actually allocated (cBlocksAllocated=%u) !!\n",
     1770        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "!! WARNING: %u blocks actually allocated (cBlocksAllocated=%u) !!\n",
    17711771                cBlocksNotFree, getImageBlocksAllocated(&pImage->Header));
    17721772    }
    17731773    if (cBadBlocks)
    17741774    {
    1775         RTLogPrintf("!! WARNING: %u bad blocks found !!\n",
     1775        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "!! WARNING: %u bad blocks found !!\n",
    17761776                cBadBlocks);
    17771777    }
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r21060 r21806  
    56825682    if (pImage)
    56835683    {
    5684         RTLogPrintf("Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n",
     5684        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n",
    56855685                    pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors,
    56865686                    pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors,
    56875687                    VMDK_BYTE2SECTOR(pImage->cbSize));
    5688         RTLogPrintf("Header: uuidCreation={%RTuuid}\n", &pImage->ImageUuid);
    5689         RTLogPrintf("Header: uuidModification={%RTuuid}\n", &pImage->ModificationUuid);
    5690         RTLogPrintf("Header: uuidParent={%RTuuid}\n", &pImage->ParentUuid);
    5691         RTLogPrintf("Header: uuidParentModification={%RTuuid}\n", &pImage->ParentModificationUuid);
     5688        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidCreation={%RTuuid}\n", &pImage->ImageUuid);
     5689        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidModification={%RTuuid}\n", &pImage->ModificationUuid);
     5690        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidParent={%RTuuid}\n", &pImage->ParentUuid);
     5691        pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: uuidParentModification={%RTuuid}\n", &pImage->ParentModificationUuid);
    56925692    }
    56935693}
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r21556 r21806  
    156156                "       Assigns a new UUID to the given image file. This way, multiple copies\n"
    157157                "       of a container can be registered.\n"
     158                "\n"
     159                : "",
     160            (u64Cmd & USAGE_DUMPHDINFO) ?
     161                "  dumphdinfo <filepath>\n"
     162                "       Prints information about the image at the given location.\n"
    158163                "\n"
    159164                : "",
     
    491496}
    492497
    493 static int handleSetHDUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
     498static int CmdSetHDUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
    494499{
    495500    /* we need exactly one parameter: the image file */
     
    520525    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    521526    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
     527    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
    522528
    523529    rc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
     
    545551    else
    546552        RTPrintf("UUID changed to: %s\n", uuid.toString().raw());
     553
     554    VDCloseAll(pDisk);
     555
     556    return RT_FAILURE(rc);
     557}
     558
     559
     560static int handleVDMessage(void *pvUser, const char *pszFormat, ...)
     561{
     562    NOREF(pvUser);
     563    va_list args;
     564    va_start(args, pszFormat);
     565    int rc = RTPrintfV(pszFormat, args);
     566    va_end(args);
     567    return rc;
     568}
     569
     570static int CmdDumpHDInfo(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
     571{
     572    /* we need exactly one parameter: the image file */
     573    if (argc != 1)
     574    {
     575        return errorSyntax(USAGE_SETHDUUID, "Not enough parameters");
     576    }
     577
     578    /* just try it */
     579    char *pszFormat = NULL;
     580    int rc = VDGetFormat(argv[0], &pszFormat);
     581    if (RT_FAILURE(rc))
     582    {
     583        RTPrintf("Format autodetect failed: %Rrc\n", rc);
     584        return 1;
     585    }
     586
     587    PVBOXHDD pDisk = NULL;
     588
     589    PVDINTERFACE     pVDIfs = NULL;
     590    VDINTERFACE      vdInterfaceError;
     591    VDINTERFACEERROR vdInterfaceErrorCallbacks;
     592    vdInterfaceErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
     593    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
     594    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
     595    vdInterfaceErrorCallbacks.pfnMessage   = handleVDMessage;
     596
     597    rc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
     598                        &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
     599    AssertRC(rc);
     600
     601    rc = VDCreate(pVDIfs, &pDisk);
     602    if (RT_FAILURE(rc))
     603    {
     604        RTPrintf("Error while creating the virtual disk container: %Rrc\n", rc);
     605        return 1;
     606    }
     607
     608    /* Open the image */
     609    rc = VDOpen(pDisk, pszFormat, argv[0], VD_OPEN_FLAGS_NORMAL, NULL);
     610    if (RT_FAILURE(rc))
     611    {
     612        RTPrintf("Error while opening the image: %Rrc\n", rc);
     613        return 1;
     614    }
     615
     616    VDDumpImages(pDisk);
    547617
    548618    VDCloseAll(pDisk);
     
    12271297    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    12281298    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
     1299    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
    12291300
    12301301    vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
     
    13361407    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    13371408    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
     1409    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
    13381410
    13391411    int vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
     
    14171489    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    14181490    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
     1491    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
    14191492
    14201493    int vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
     
    15811654    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    15821655    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
     1656    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
    15831657
    15841658    vrc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
     
    17031777    //    return CmdUnloadSyms(argc - 1 , &a->argv[1]);
    17041778    if (!strcmp(pszCmd, "sethduuid") || !strcmp(pszCmd, "setvdiuuid"))
    1705         return handleSetHDUUID(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
     1779        return CmdSetHDUUID(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
     1780    if (!strcmp(pszCmd, "dumphdinfo"))
     1781        return CmdDumpHDInfo(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
    17061782    if (!strcmp(pszCmd, "listpartitions"))
    17071783        return CmdListPartitions(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r21612 r21806  
    9696#define USAGE_HOSTONLYIFS           RT_BIT_64(46)
    9797#define USAGE_DHCPSERVER            RT_BIT_64(47)
     98#define USAGE_DUMPHDINFO            RT_BIT_64(48)
    9899#define USAGE_ALL                   (~(uint64_t)0)
    99100/** @} */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r21038 r21806  
    814814    vdInterfaceErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    815815    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
     816    vdInterfaceErrorCallbacks.pfnMessage   = NULL;
    816817
    817818    rc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r21394 r21806  
    665665    mm.vdIfCallsError.enmInterface = VDINTERFACETYPE_ERROR;
    666666    mm.vdIfCallsError.pfnError = vdErrorCall;
     667    mm.vdIfCallsError.pfnMessage = NULL;
    667668
    668669    /* Initialize the callbacks of the VD progress interface */
     
    32503251
    32513252            /** @todo This kind of opening of images is assuming that diff
    3252              * images can be opened as base images. Not very clean, and should
    3253              * be fixed eventually. */
     3253             * images can be opened as base images. Should be fixed ASAP. */
    32543254            vrc = VDOpen(hdd,
    32553255                         Utf8Str(mm.format),
     
    32753275                if (mm.setParentId)
    32763276                {
    3277                     vrc = VDSetUuid(hdd, 0, mm.parentId);
     3277                    vrc = VDSetParentUuid(hdd, 0, mm.parentId);
    32783278                    ComAssertRCThrow(vrc, E_FAIL);
    32793279                }
     
    39003900                    that->mm.vdProgress = task->progress;
    39013901
     3902                    /** @todo add VD_IMAGE_FLAGS_DIFF to the image flags, to
     3903                     * be on the safe side. */
    39023904                    vrc = VDCreateDiff (hdd, targetFormat, targetLocation,
    39033905                                        task->d.variant,
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