VirtualBox

Changeset 24583 in vbox for trunk/src


Ignore:
Timestamp:
Nov 11, 2009 2:54:01 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
54718
Message:

DrvVD,ConsoleImpl2.cpp: Added a TempReadOnly argument for use on the teleporation target so we can teleport using images without hitting VERR_SHARING_VIOLATION.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

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

    r23950 r24583  
    903903            fValid = CFGMR3AreValuesValid(pCurNode,
    904904                                          "Format\0Path\0"
    905                                           "ReadOnly\0HonorZeroWrites\0"
     905                                          "ReadOnly\0TempReadOnly\0HonorZeroWrites\0"
    906906                                          "HostIPStack\0");
    907907        }
     
    921921        if (pCurNode == pCfgHandle)
    922922        {
    923             rc = CFGMR3QueryBool(pCurNode, "HostIPStack", &fHostIP);
    924             if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    925             {
    926                 fHostIP = true;
    927                 rc = VINF_SUCCESS;
    928             }
    929             else if (RT_FAILURE(rc))
     923            rc = CFGMR3QueryBoolDef(pCurNode, "HostIPStack", &fHostIP, true);
     924            if (RT_FAILURE(rc))
    930925            {
    931926                rc = PDMDRV_SET_ERROR(pDrvIns, rc,
     
    934929            }
    935930
    936             rc = CFGMR3QueryBool(pCurNode, "HonorZeroWrites", &fHonorZeroWrites);
    937             if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    938             {
    939                 fHonorZeroWrites = false;
    940                 rc = VINF_SUCCESS;
    941             }
    942             else if (RT_FAILURE(rc))
     931            rc = CFGMR3QueryBoolDef(pCurNode, "HonorZeroWrites", &fHonorZeroWrites, false);
     932            if (RT_FAILURE(rc))
    943933            {
    944934                rc = PDMDRV_SET_ERROR(pDrvIns, rc,
     
    947937            }
    948938
    949             rc = CFGMR3QueryBool(pCurNode, "ReadOnly", &fReadOnly);
    950             if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    951             {
    952                 fReadOnly = false;
    953                 rc = VINF_SUCCESS;
    954             }
    955             else if (RT_FAILURE(rc))
     939            rc = CFGMR3QueryBoolDef(pCurNode, "ReadOnly", &fReadOnly, false);
     940            if (RT_FAILURE(rc))
    956941            {
    957942                rc = PDMDRV_SET_ERROR(pDrvIns, rc,
    958943                                      N_("DrvVD: Configuration error: Querying \"ReadOnly\" as boolean failed"));
     944                break;
     945            }
     946
     947            rc = CFGMR3QueryBoolDef(pCurNode, "TempReadOnly", &pThis->fTempReadOnly, false);
     948            if (RT_FAILURE(rc))
     949            {
     950                rc = PDMDRV_SET_ERROR(pDrvIns, rc,
     951                                      N_("DrvVD: Configuration error: Querying \"TempReadOnly\" as boolean failed"));
     952                break;
     953            }
     954            if (fReadOnly && pThis->fTempReadOnly)
     955            {
     956                rc = PDMDRV_SET_ERROR(pDrvIns, rc,
     957                                      N_("DrvVD: Configuration error: Both \"ReadOnly\" and \"TempReadOnly\" are set"));
    959958                break;
    960959            }
     
    10581057         */
    10591058        unsigned uOpenFlags;
    1060         if (fReadOnly || iLevel != 0)
     1059        if (fReadOnly || pThis->fTempReadOnly || iLevel != 0)
    10611060            uOpenFlags = VD_OPEN_FLAGS_READONLY;
    10621061        else
     
    10671066            uOpenFlags |= VD_OPEN_FLAGS_ASYNC_IO;
    10681067
    1069         /* Try to open backend in asyc I/O mode first. */
     1068        /* Try to open backend in async I/O mode first. */
    10701069        rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage);
    10711070        if (rc == VERR_NOT_SUPPORTED)
     
    10841083            if (   VDIsReadOnly(pThis->pDisk)
    10851084                && !fReadOnly
     1085                && !pThis->fTempReadOnly
    10861086                && iLevel == 0)
    10871087            {
    10881088                rc = PDMDrvHlpVMSetError(pDrvIns, VERR_VD_IMAGE_READ_ONLY, RT_SRC_POS,
    1089                                          N_("Failed to open image '%s' for writing due to wrong "
    1090                                             "permissions"), pszName);
     1089                                         N_("Failed to open image '%s' for writing due to wrong permissions"),
     1090                                         pszName);
    10911091                break;
    10921092            }
     
    11821182 * @param   pDrvIns     The driver instance data.
    11831183 */
    1184 static DECLCALLBACK(void) drvvdResume(PPDMDRVINS pDrvIns)
     1184static DECLCALLBACK(void) drvvdResumeOrPowerOn(PPDMDRVINS pDrvIns)
    11851185{
    11861186    LogFlow(("%s:\n", __FUNCTION__));
     
    12111211    AssertRC(rc);
    12121212}
     1213
    12131214
    12141215/**
     
    12381239    NULL,
    12391240    /* pfnPowerOn */
    1240     NULL,
     1241    drvvdResumeOrPowerOn,
    12411242    /* pfnReset */
    12421243    NULL,
     
    12441245    drvvdSuspend,
    12451246    /* pfnResume */
    1246     drvvdResume,
     1247    drvvdResumeOrPowerOn,
    12471248    /* pfnAttach */
    12481249    NULL,
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r24579 r24583  
    10571057                    {
    10581058                        rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1);                          RC_CHECK();
     1059                    }
     1060                    /* Start without exclusive write access to the images. */
     1061                    /** @todo Live Migration: I don't quite like this, we risk screwing up when
     1062                     *        we're resuming the VM if some 3rd dude have any of the VDIs open
     1063                     *        with write sharing denied.  However, if the two VMs are sharing a
     1064                     *        image it really is necessary....
     1065                     *
     1066                     *        So, on the "lock-media" command, the target teleporter should also
     1067                     *        make DrvVD undo TempReadOnly.  It gets interesting if we fail after
     1068                     *        that. Grumble. */
     1069                    else if (pConsole->mMachineState == MachineState_TeleportingIn)
     1070                    {
     1071                        rc = CFGMR3InsertInteger(pCfg, "TempReadOnly", 1);                      RC_CHECK();
    10591072                    }
    10601073
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