Changeset 79742 in vbox
- Timestamp:
- Jul 12, 2019 4:11:19 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132104
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vd-ifs.h
r76585 r79742 829 829 DECLR3CALLBACKMEMBER(int, pfnQueryBytes, (void *pvUser, const char *pszName, void *ppvData, size_t cbData)); 830 830 831 /** 832 * Set a named property to a specified string value, optionally creating if it doesn't exist. 833 * 834 * @return VBox status code. 835 * VERR_CFGM_VALUE_NOT_FOUND means that the key is not known and fCreate flag was not set. 836 * @param pvUser The opaque user data associated with this interface. 837 * @param fCreate Create property if it doesn't exist (if property exists, it is not an error) 838 * @param pszName Name of the key to query. 839 * @param pszValue String value to set the name property to. 840 */ 841 DECLR3CALLBACKMEMBER(int, pfnUpdate, (void *pvUser, bool fCreate, 842 const char *pszName, const char *pszValue)); 843 831 844 } VDINTERFACECONFIG, *PVDINTERFACECONFIG; 832 845 … … 1112 1125 } 1113 1126 1127 /** 1128 * Set property value to string (optionally create if non-existent). 1129 * 1130 * @return VBox status code. 1131 * @param pCfgIf Pointer to configuration callback table. 1132 * @param fCreate Create the property if it doesn't exist 1133 * @param pszName Name of property 1134 * @param pszValue String value to assign to property 1135 */ 1136 DECLINLINE(int) VDCFGUpdate(PVDINTERFACECONFIG pCfgIf, bool fCreate, const char *pszName, const char *pszValue) 1137 { 1138 int rc = pCfgIf->pfnUpdate(pCfgIf->Core.pvUser, fCreate, pszName, pszValue); 1139 return rc; 1140 } 1141 1142 /** 1143 * Set property value to Unsigned Int 64-bit (optionally create if non-existent). 1144 * 1145 * @return VBox status code. 1146 * @param pCfgIf Pointer to configuration callback table. 1147 * @param fCreate Create the property if it doesn't exist 1148 * @param pszName Name of property 1149 * @param pszValue String value to assign to property 1150 */ 1151 1152 DECLINLINE(int) VDCFGUpdateU64(PVDINTERFACECONFIG pCfgIf, bool fCreate, const char *pszName, uint64_t u64) 1153 { 1154 char *pszValue; 1155 RTStrAPrintf(&pszValue, "%ul", u64); 1156 int rc = VDCFGUpdate(pCfgIf, fCreate, pszName, pszValue); 1157 RTMemFree(pszValue); 1158 return rc; 1159 } 1160 1161 1162 1114 1163 /** Forward declaration of a VD socket. */ 1115 1164 typedef struct VDSOCKETINT *VDSOCKET; -
trunk/include/VBox/vd.h
r77855 r79742 354 354 * a good idea, as the average user won't understand it easily. */ 355 355 #define VD_CFGKEY_EXPERT RT_BIT(1) 356 /** Key only need at media creation, not to be retained in registry. 357 * Should not be exposed in the GUI */ 358 #define VD_CFGKEY_CREATEONLY RT_BIT(2) 356 359 /** @}*/ 357 360 -
trunk/src/VBox/Main/include/MediumImpl.h
r77857 r79742 350 350 static DECLCALLBACK(int) i_vdConfigQuerySize(void *pvUser, const char *pszName, 351 351 size_t *pcbValue); 352 static DECLCALLBACK(int) i_vdConfigUpdate(void *pvUser, bool fCreate, 353 const char *pszName, const char *pszValue); 354 352 355 static DECLCALLBACK(int) i_vdConfigQuery(void *pvUser, const char *pszName, 353 356 char *pszValue, size_t cchValue); -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r79479 r79742 847 847 m->vdIfConfig.pfnQuerySize = i_vdConfigQuerySize; 848 848 m->vdIfConfig.pfnQuery = i_vdConfigQuery; 849 m->vdIfConfig.pfnUpdate = i_vdConfigUpdate; 849 850 m->vdIfConfig.pfnQueryBytes = NULL; 850 851 … … 4674 4675 const Utf8Str &name = it->first; 4675 4676 const Utf8Str &value = it->second; 4676 /* do NOT store the plain InitiatorSecret */ 4677 if ( !fHaveInitiatorSecretEncrypted 4678 || !name.equals("InitiatorSecret")) 4679 data.properties[name] = value; 4680 } 4677 bool fCreateOnly = false; 4678 for (MediumFormat::PropertyArray::const_iterator itf = m->formatObj->i_getProperties().begin(); 4679 itf != m->formatObj->i_getProperties().end(); 4680 ++itf) 4681 { 4682 if (itf->strName.equals(name) && 4683 (itf->flags & VD_CFGKEY_CREATEONLY)) 4684 { 4685 fCreateOnly = true; 4686 break; 4687 } 4688 } 4689 if (!fCreateOnly) 4690 /* do NOT store the plain InitiatorSecret */ 4691 if ( !fHaveInitiatorSecretEncrypted 4692 || !name.equals("InitiatorSecret")) 4693 data.properties[name] = value; } 4681 4694 } 4682 4695 if (fHaveInitiatorSecretEncrypted) … … 8018 8031 memcpy(pszValue, psz, cch + 1); 8019 8032 return VINF_SUCCESS; 8033 } 8034 8035 DECLCALLBACK(int) Medium::i_vdConfigUpdate(void *pvUser, 8036 bool fCreate, 8037 const char *pszName, 8038 const char *pszValue) 8039 { 8040 int rv = VINF_SUCCESS; 8041 Utf8Str pName = Utf8Str(pszName); 8042 Medium *that = (Medium *)pvUser; 8043 AutoWriteLock mlock(that COMMA_LOCKVAL_SRC_POS); 8044 settings::StringsMap::const_iterator it = that->m->mapProperties.find(pName); 8045 if (it == that->m->mapProperties.end() && !fCreate) 8046 rv = VERR_CFGM_VALUE_NOT_FOUND; 8047 else 8048 that->m->mapProperties[pName] = Utf8Str(pszValue); 8049 mlock.release(); 8050 return rv; 8020 8051 } 8021 8052 -
trunk/src/VBox/Storage/VDI.cpp
r77622 r79742 44 44 static const VDCONFIGINFO vdiConfigInfo[] = 45 45 { 46 { "AllocationBlockSize", vdiAllocationBlockSize, VDCFGVALUETYPE_INTEGER, 0},46 { "AllocationBlockSize", vdiAllocationBlockSize, VDCFGVALUETYPE_INTEGER, VD_CFGKEY_CREATEONLY }, 47 47 { NULL, NULL, VDCFGVALUETYPE_INTEGER, 0 } 48 48 }; … … 541 541 pImage->uShiftOffset2Index = getPowerOfTwo(getImageBlockSize(&pImage->Header)); 542 542 pImage->offStartBlockData = getImageExtraBlockSize(&pImage->Header); 543 pImage->cbTotalBlockData = pImage->offStartBlockData 543 pImage->cbAllocationBlock = getImageBlockSize(&pImage->Header); 544 pImage->cbTotalBlockData = pImage->offStartBlockData 544 545 + getImageBlockSize(&pImage->Header); 545 546 } … … 706 707 int rc = VINF_SUCCESS; 707 708 uint32_t cbDataAlign = VDI_DATA_ALIGN; 708 uint32_t cbAllocationBlock = VDI_IMAGE_DEFAULT_BLOCK_SIZE;709 709 AssertPtr(pPCHSGeometry); 710 710 AssertPtr(pLCHSGeometry); … … 723 723 if (pImgCfg) 724 724 { 725 rc = VDCFGQueryU32Def(pImgCfg, "AllocationBlockSize", &cbAllocationBlock, VDI_IMAGE_DEFAULT_BLOCK_SIZE); 725 rc = VDCFGQueryU32Def(pImgCfg, "AllocationBlockSize", 726 &pImage->cbAllocationBlock, VDI_IMAGE_DEFAULT_BLOCK_SIZE); 726 727 if (RT_FAILURE(rc)) 727 728 rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS, … … 741 742 742 743 rc = vdiSetupImageState(pImage, uImageFlags, pszComment, cbSize, 743 cbAllocationBlock, cbDataAlign, pPCHSGeometry, pLCHSGeometry); 744 pImage->cbAllocationBlock, cbDataAlign, pPCHSGeometry, pLCHSGeometry); 745 744 746 if (RT_SUCCESS(rc)) 745 747 { … … 1013 1015 pRegion->cbMetadata = 0; 1014 1016 pRegion->cRegionBlocksOrBytes = getImageDiskSize(&pImage->Header); 1017 if (uOpenFlags & VD_OPEN_FLAGS_INFO) 1018 { 1019 PVDINTERFACECONFIG pImgCfg = VDIfConfigGet(pImage->pVDIfsImage); 1020 if (pImgCfg) 1021 { 1022 rc = VDCFGUpdateU64(pImgCfg, true, "AllocationBlockSize", pImage->cbAllocationBlock); 1023 if (RT_FAILURE(rc)) 1024 return rc; 1025 } 1026 } 1015 1027 } 1016 1028 else -
trunk/src/VBox/Storage/VDICore.h
r76578 r79742 554 554 /** Total size of image block (including the extra data). */ 555 555 unsigned cbTotalBlockData; 556 /** Allocation Block Size */ 557 unsigned cbAllocationBlock; 556 558 /** Container filename. (UTF-8) */ 557 559 const char *pszFilename;
Note:
See TracChangeset
for help on using the changeset viewer.