VirtualBox

Changeset 33904 in vbox


Ignore:
Timestamp:
Nov 9, 2010 2:56:28 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67560
Message:

Main: fix snapshot folder and log folder regression (since 4.0 directory changes)

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r33386 r33904  
    214214    else
    215215        RTPrintf("Config file:     %lS\n", settingsFilePath.raw());
     216
     217    Bstr snapshotFolder;
     218    rc = machine->COMGETTER(SnapshotFolder)(snapshotFolder.asOutParam());
     219    if (details == VMINFO_MACHINEREADABLE)
     220        RTPrintf("SnapFldr=\"%lS\"\n", snapshotFolder.raw());
     221    else
     222        RTPrintf("Snapshot folder: %lS\n", snapshotFolder.raw());
     223
     224    Bstr logFolder;
     225    rc = machine->COMGETTER(LogFolder)(logFolder.asOutParam());
     226    if (details == VMINFO_MACHINEREADABLE)
     227        RTPrintf("LogFldr=\"%lS\"\n", logFolder.raw());
     228    else
     229        RTPrintf("Log folder:      %lS\n", logFolder.raw());
    216230
    217231    Bstr strHardwareUuid;
  • trunk/src/VBox/Main/MachineImpl.cpp

    r33848 r33904  
    293293
    294294        mUserData->s.strName = strName;
    295         mUserData->s.fNameSync = true;
    296 
    297         /* initialize the default snapshots folder
    298          * (note: depends on the name value set above!) */
     295
     296        // the "name sync" flag determines whether the machine directory gets renamed along
     297        // with the machine file; say so if the settings file name is the same as the
     298        // settings file parent directory (machine directory)
     299        mUserData->s.fNameSync = isInOwnDir();
     300
     301        // initialize the default snapshots folder
    299302        rc = COMSETTER(SnapshotFolder)(NULL);
    300303        AssertComRC(rc);
     
    20832086    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    20842087
    2085     mUserData->m_strSnapshotFolderFull.cloneTo(aSnapshotFolder);
     2088    Utf8Str strFullSnapshotFolder;
     2089    calculateFullPath(mUserData->s.strSnapshotFolder, strFullSnapshotFolder);
     2090    strFullSnapshotFolder.cloneTo(aSnapshotFolder);
    20862091
    20872092    return S_OK;
     
    21112116
    21122117    Utf8Str strSnapshotFolder0(aSnapshotFolder);       // keep original
     2118
    21132119    Utf8Str strSnapshotFolder(strSnapshotFolder0);
    2114 
    21152120    if (strSnapshotFolder.isEmpty())
    2116     {
    2117         if (isInOwnDir())
    2118             /* the default snapshots folder is 'Snapshots' in the machine dir */
    2119             strSnapshotFolder = "Snapshots";
    2120         else
    2121             /* the default snapshots folder is {UUID}, for backwards
    2122              * compatibility and to resolve conflicts */
    2123             strSnapshotFolder = Utf8StrFmt("{%RTuuid}", mData->mUuid.raw());
    2124     }
    2125 
    2126     int vrc = calculateFullPath(strSnapshotFolder, strSnapshotFolder);
     2121        strSnapshotFolder = "Snapshots";
     2122    int vrc = calculateFullPath(strSnapshotFolder,
     2123                                strSnapshotFolder);
    21272124    if (RT_FAILURE(vrc))
    21282125        return setError(E_FAIL,
     
    21322129    setModified(IsModified_MachineData);
    21332130    mUserData.backup();
    2134     mUserData->s.strSnapshotFolder = strSnapshotFolder0;
    2135     mUserData->m_strSnapshotFolderFull = strSnapshotFolder;
     2131
     2132    copyPathRelativeToMachine(strSnapshotFolder, mUserData->s.strSnapshotFolder);
    21362133
    21372134    return S_OK;
     
    23402337    Utf8Str logFolder;
    23412338    getLogFolder(logFolder);
    2342 
    2343     Bstr (logFolder).cloneTo(aLogFolder);
     2339    logFolder.cloneTo(aLogFolder);
    23442340
    23452341    return S_OK;
     
    35913587        }
    35923588
     3589        Utf8Str strFullSnapshotFolder;
     3590        calculateFullPath(mUserData->s.strSnapshotFolder, strFullSnapshotFolder);
     3591
    35933592        ComObjPtr<Medium> diff;
    35943593        diff.createObject();
    35953594        rc = diff->init(mParent,
    35963595                        medium->getPreferredDiffFormat(),
    3597                         Utf8Str(mUserData->m_strSnapshotFolderFull).append(RTPATH_SLASH_STR),
     3596                        strFullSnapshotFolder.append(RTPATH_SLASH_STR),
    35983597                        medium->getFirstRegistryMachineId(),         // store this diff in the same registry as the parent
    35993598                        &fNeedsGlobalSaveSettings);
     
    45354534         * there (we don't check for errors because the user might have
    45364535         * some private files there that we don't want to delete) */
    4537         Assert(mUserData->m_strSnapshotFolderFull.length());
    4538         if (RTDirExists(mUserData->m_strSnapshotFolderFull.c_str()))
    4539             RTDirRemove(mUserData->m_strSnapshotFolderFull.c_str());
    4540 
    4541         /* delete the directory that contains the settings file, but only
    4542          * if it matches the VM name (i.e. a structure created by default in
    4543          * prepareSaveSettings()) */
    4544         {
    4545             Utf8Str settingsDir;
    4546             if (isInOwnDir(&settingsDir))
    4547                 RTDirRemove(settingsDir.c_str());
    4548         }
     4536        Utf8Str strFullSnapshotFolder;
     4537        calculateFullPath(mUserData->s.strSnapshotFolder, strFullSnapshotFolder);
     4538        Assert(!strFullSnapshotFolder.isEmpty());
     4539        if (RTDirExists(strFullSnapshotFolder.c_str()))
     4540            RTDirRemove(strFullSnapshotFolder.c_str());
     4541
     4542        // delete the directory that contains the settings file, but only
     4543        // if it matches the VM name
     4544        Utf8Str settingsDir;
     4545        if (isInOwnDir(&settingsDir))
     4546            RTDirRemove(settingsDir.c_str());
    45494547    }
    45504548
     
    58165814        aLogFolder = settingsDir;
    58175815    else
    5818     {
    58195816        /* Log folder is <Machines>/<VM_SnapshotFolder>/Logs */
    5820         Assert(!mUserData->m_strSnapshotFolderFull.isEmpty());
    5821         aLogFolder = mUserData->m_strSnapshotFolderFull;
    5822     }
     5817        calculateFullPath(mUserData->s.strSnapshotFolder, aLogFolder);
    58235818
    58245819    aLogFolder.append(RTPATH_DELIMITER);
     
    77177712            }
    77187713
    7719             /* update m_strConfigFileFull amd mConfigFile */
     7714            // update m_strConfigFileFull amd mConfigFile
    77207715            mData->m_strConfigFileFull = newConfigFile;
    77217716            // compute the relative path too
     
    77317726                if (pfNeedsGlobalSaveSettings)
    77327727                    *pfNeedsGlobalSaveSettings = true;
    7733             }
    7734 
    7735             /* update the snapshot folder */
    7736             if (RTPathStartsWith(mUserData->m_strSnapshotFolderFull.c_str(),
    7737                                  configDir.c_str()))
    7738             {
    7739                 mUserData->m_strSnapshotFolderFull = Utf8StrFmt("%s%s",
    7740                                                                 newConfigDir.c_str(),
    7741                                                                 mUserData->m_strSnapshotFolderFull.c_str() + configDir.length());
    7742                 copyPathRelativeToMachine(mUserData->m_strSnapshotFolderFull,
    7743                                           mUserData->s.strSnapshotFolder);
    77447728            }
    77457729
     
    86018585                                        aWeight);        // weight
    86028586
     8587            Utf8Str strFullSnapshotFolder;
     8588            calculateFullPath(mUserData->s.strSnapshotFolder, strFullSnapshotFolder);
     8589
    86038590            ComObjPtr<Medium> diff;
    86048591            diff.createObject();
    86058592            rc = diff->init(mParent,
    86068593                            pMedium->getPreferredDiffFormat(),
    8607                             Utf8Str(mUserData->m_strSnapshotFolderFull).append(RTPATH_SLASH_STR),
     8594                            strFullSnapshotFolder.append(RTPATH_SLASH_STR),
    86088595                            pMedium->getFirstRegistryMachineId(),        // store the diff in the same registry as the parent
    86098596                            pfNeedsSaveSettings);
     
    92309217/**
    92319218 *  Returns true if the settings file is located in the directory named exactly
    9232  *  as the machine. This will be true if the machine settings structure was
    9233  *  created by default in #openConfigLoader().
     9219 *  as the machine; this means, among other things, that the machine directory
     9220 *  should be auto-renamed.
    92349221 *
    92359222 *  @param aSettingsDir if not NULL, the full machine settings file directory
     
    92419228bool Machine::isInOwnDir(Utf8Str *aSettingsDir /* = NULL */) const
    92429229{
    9243     Utf8Str settingsDir = mData->m_strConfigFileFull;
    9244     settingsDir.stripFilename();
    9245     Utf8Str strDirName = RTPathFilename(settingsDir.c_str());
    9246 
    9247     AssertReturn(!strDirName.isEmpty(), false);
    9248 
    9249     /* if we don't rename anything on name change, return false shortly */
    9250     if (!mUserData->s.fNameSync)
    9251         return false;
    9252 
     9230    Utf8Str strMachineDirName(mData->m_strConfigFileFull);  // path/to/machinesfolder/vmname/vmname.vbox
     9231    strMachineDirName.stripFilename();                      // path/to/machinesfolder/vmname
    92539232    if (aSettingsDir)
    9254         *aSettingsDir = settingsDir;
    9255 
    9256     return strDirName == mUserData->s.strName;
     9233        *aSettingsDir = strMachineDirName;
     9234    strMachineDirName.stripPath();                          // vmname
     9235    Utf8Str strConfigFileOnly(mData->m_strConfigFileFull);  // path/to/machinesfolder/vmname/vmname.vbox
     9236    strConfigFileOnly.stripPath()                           // vmname.vbox
     9237                     .stripExt();                           // vmname
     9238
     9239    AssertReturn(!strMachineDirName.isEmpty(), false);
     9240    AssertReturn(!strConfigFileOnly.isEmpty(), false);
     9241
     9242    return strMachineDirName == strConfigFileOnly;
    92579243}
    92589244
     
    1055710543    if (mData->mMachineState == MachineState_Paused)
    1055810544    {
     10545        Utf8Str strFullSnapshotFolder;
     10546        calculateFullPath(mUserData->s.strSnapshotFolder, strFullSnapshotFolder);
    1055910547        stateFilePath = Utf8StrFmt("%s%c{%RTuuid}.sav",
    10560                                    mUserData->m_strSnapshotFolderFull.c_str(),
    10561                                    RTPATH_DELIMITER, mData->mUuid.raw());
     10548                                   strFullSnapshotFolder.c_str(),
     10549                                   RTPATH_DELIMITER,
     10550                                   mData->mUuid.raw());
    1056210551    }
    1056310552
     
    1092510914 *  @note Locks this object for reading.
    1092610915 */
    10927 HRESULT SessionMachine::onNATRedirectRuleChange(INetworkAdapter *networkAdapter, BOOL aNatRuleRemove, IN_BSTR aRuleName, 
     10916HRESULT SessionMachine::onNATRedirectRuleChange(INetworkAdapter *networkAdapter, BOOL aNatRuleRemove, IN_BSTR aRuleName,
    1092810917                                 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort)
    1092910918{
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r33590 r33904  
    13861386         || mData->mMachineState == MachineState_Saved)
    13871387    {
     1388        Utf8Str strFullSnapshotFolder;
     1389        calculateFullPath(mUserData->s.strSnapshotFolder, strFullSnapshotFolder);
    13881390        strStateFilePath = Utf8StrFmt("%s%c{%RTuuid}.sav",
    1389                                       mUserData->m_strSnapshotFolderFull.c_str(),
     1391                                      strFullSnapshotFolder.c_str(),
    13901392                                      RTPATH_DELIMITER,
    13911393                                      snapshotId.raw());
     
    18551857                Utf8Str snapStateFilePath = aTask.pSnapshot->stateFilePath();
    18561858
     1859                Utf8Str strFullSnapshotFolder;
     1860                calculateFullPath(mUserData->s.strSnapshotFolder, strFullSnapshotFolder);
    18571861                Utf8Str stateFilePath = Utf8StrFmt("%s%c{%RTuuid}.sav",
    1858                                                    mUserData->m_strSnapshotFolderFull.c_str(),
     1862                                                   strFullSnapshotFolder.c_str(),
    18591863                                                   RTPATH_DELIMITER,
    18601864                                                   mData->mUuid.raw());
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r33898 r33904  
    16671667        <link to="#registerMachine"/>.
    16681668
    1669         The specified settings file name can be absolute
    1670         (full path) or relative to the <link to="IVirtualBox::homeFolder">
    1671           VirtualBox home directory</link>. This file must exist
    1672         and must be a valid machine settings file whose contents
    1673         will be used to construct the machine object.
     1669        The specified settings file name must be fully qualified.
     1670        The file must exist and be a valid machine XML settings file
     1671        whose contents will be used to construct the machine object.
    16741672
    16751673        <result name="VBOX_E_FILE_ERROR">
  • trunk/src/VBox/Main/include/MachineImpl.h

    r33848 r33904  
    215215    {
    216216        settings::MachineUserData s;
    217         Utf8Str m_strSnapshotFolderFull;
    218217    };
    219218
     
    614613    // callback handlers
    615614    virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
    616     virtual HRESULT onNATRedirectRuleChange(INetworkAdapter * /* networkAdapter */, BOOL /* Remove */, IN_BSTR /* Rule name */, 
     615    virtual HRESULT onNATRedirectRuleChange(INetworkAdapter * /* networkAdapter */, BOOL /* Remove */, IN_BSTR /* Rule name */,
    617616                                 NATProtocol_T /* proto */, IN_BSTR /* host ip */, LONG /* host port */, IN_BSTR /* guest ip */, LONG /* guest port */) { return S_OK; }
    618617    virtual HRESULT onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
     
    957956
    958957    HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
    959     HRESULT onNATRedirectRuleChange(INetworkAdapter *networkAdapter, BOOL aNatRuleRemove, IN_BSTR aRuleName, 
     958    HRESULT onNATRedirectRuleChange(INetworkAdapter *networkAdapter, BOOL aNatRuleRemove, IN_BSTR aRuleName,
    960959                                 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
    961960    HRESULT onStorageControllerChange();
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