Changeset 101274 in vbox
- Timestamp:
- Sep 26, 2023 6:13:37 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r101168 r101274 1562 1562 static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T enmDrvType); 1563 1563 static AudioDriverType_T getHostDefaultAudioDriver(); 1564 static bool convertGuestOSTypeSuffix(com::Utf8Str &str, const char *pszToReplace, const char *pszReplacement); 1564 1565 1565 1566 private: … … 1586 1587 void readGroups(const xml::ElementNode &elmGroups, StringsList &llGroups); 1587 1588 bool readSnapshot(const com::Guid &curSnapshotUuid, const xml::ElementNode &elmSnapshot, Snapshot &snap); 1588 void convertOldOSType_pre1_5(com::Utf8Str &str); 1589 void convertGuestOSTypeFromPre1_5(com::Utf8Str &str); 1590 void convertGuestOSTypeFromPre1_20(com::Utf8Str &str); 1591 void convertGuestOSTypeToPre1_20(com::Utf8Str &str); 1589 1592 void readMachine(const xml::ElementNode &elmMachine); 1590 1593 void readMachineEncrypted(const xml::ElementNode &elmMachine, PCVBOXCRYPTOIF pCryptoIf, const char *pszPassword); -
trunk/src/VBox/Main/xml/Settings.cpp
r101200 r101274 6829 6829 const char *pcszOld; 6830 6830 const char *pcszNew; 6831 } aConvert OSTypes[] =6831 } aConvertGuestOSTypesPre1_5[] = 6832 6832 { 6833 6833 { "unknown", "Other" }, … … 6868 6868 }; 6869 6869 6870 void MachineConfigFile::convertOldOSType_pre1_5(Utf8Str &str) 6871 { 6872 for (unsigned u = 0; 6873 u < RT_ELEMENTS(aConvertOSTypes); 6874 ++u) 6875 { 6876 if (str == aConvertOSTypes[u].pcszOld) 6877 { 6878 str = aConvertOSTypes[u].pcszNew; 6870 void MachineConfigFile::convertGuestOSTypeFromPre1_5(Utf8Str &str) 6871 { 6872 for (size_t u = 0; u < RT_ELEMENTS(aConvertGuestOSTypesPre1_5); ++u) 6873 if (str == aConvertGuestOSTypesPre1_5[u].pcszOld) 6874 { 6875 str = aConvertGuestOSTypesPre1_5[u].pcszNew; 6879 6876 break; 6880 6877 } 6881 } 6878 } 6879 6880 /** 6881 * Static function to convert a guest OS type ID suffix. 6882 * 6883 * @returns \c true if suffix got converted, or \c false if not. 6884 * @param strOsType Guest OS type ID to convert. 6885 * @param pszToReplace Suffix to replace. 6886 * @param pszReplacement What to replace the suffix with. 6887 */ 6888 /* static */ 6889 bool MachineConfigFile::convertGuestOSTypeSuffix(com::Utf8Str &strOsType, const char *pszToReplace, const char *pszReplacement) 6890 { 6891 AssertPtrReturn(pszToReplace, false); 6892 AssertPtrReturn(pszReplacement, false); 6893 6894 size_t const cchSuffix = strlen(pszToReplace); 6895 size_t const idxSuffix = strOsType.find(pszToReplace); 6896 if (idxSuffix == strOsType.length() - cchSuffix) /* Be extra cautious to only replace the real suffix. */ 6897 { 6898 strOsType.replace(idxSuffix, cchSuffix, pszReplacement); 6899 return true; 6900 } 6901 return false; 6902 } 6903 6904 /** 6905 * Converts guest OS type IDs to be compatible with settings >= v1.20. 6906 * 6907 * @param str Guest OS type ID to convert. 6908 * 6909 * @note Settings < v1.20 require converting some guest OS type IDs, so that the rest of Main can recognize them. 6910 * We always work with the latest guest OS type ID internally. 6911 * 6912 * However, we never write back those modified guest OS type IDs for settings < v1.20, as this would break 6913 * compatibility with older VBox versions. 6914 */ 6915 void MachineConfigFile::convertGuestOSTypeFromPre1_20(Utf8Str &str) 6916 { 6917 convertGuestOSTypeSuffix(str, "_64", "_x64"); 6918 } 6919 6920 /** 6921 * Converts guest OS type IDs to be compatible with settings < v1.20. 6922 * 6923 * @param str Guest OS type ID to convert. 6924 * 6925 * @note For settings < v1.20 we have to make sure that we replace the new guest OS type ID suffix "_x64" 6926 * with "_64" so that we don't break loading (valid) settings for old(er) VBox versions, which don't 6927 * know about the new suffix. 6928 */ 6929 void MachineConfigFile::convertGuestOSTypeToPre1_20(Utf8Str &str) 6930 { 6931 convertGuestOSTypeSuffix(str, "_x64", "_64"); 6882 6932 } 6883 6933 … … 6902 6952 elmMachine.getAttributeValue("OSType", machineUserData.strOsType); 6903 6953 if (m->sv < SettingsVersion_v1_5) 6904 convertOldOSType_pre1_5(machineUserData.strOsType); 6954 convertGuestOSTypeFromPre1_5(machineUserData.strOsType); 6955 if (m->sv <= SettingsVersion_v1_19) 6956 convertGuestOSTypeFromPre1_20(machineUserData.strOsType); 6905 6957 6906 6958 elmMachine.getAttributeValue("stateKeyId", strStateKeyId); … … 9070 9122 if (machineUserData.strDescription.length()) 9071 9123 elmMachine.createChild("Description")->addContent(machineUserData.strDescription); 9072 elmMachine.setAttribute("OSType", machineUserData.strOsType); 9073 9124 9125 com::Utf8Str strOsType = machineUserData.strOsType; 9126 if (m->sv < SettingsVersion_v1_20) 9127 convertGuestOSTypeToPre1_20(strOsType); 9128 /* else use the unmodified guest OS type ID. */ 9129 elmMachine.setAttribute("OSType", strOsType); 9074 9130 9075 9131 if (m->sv >= SettingsVersion_v1_19)
Note:
See TracChangeset
for help on using the changeset viewer.