- Timestamp:
- Dec 2, 2008 10:29:29 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDisk2Impl.cpp
r14866 r14929 37 37 #include <iprt/path.h> 38 38 #include <iprt/file.h> 39 #include <iprt/tcp.h> 39 40 40 41 #include <list> … … 440 441 441 442 /* Initialize the callbacks of the VD config interface */ 442 mm.vdIfCallsConfig.cbSize = sizeof (VDINTERFACE PROGRESS);443 mm.vdIfCallsConfig.cbSize = sizeof (VDINTERFACECONFIG); 443 444 mm.vdIfCallsConfig.enmInterface = VDINTERFACETYPE_CONFIG; 444 /// @todo later 445 // mm.vdIfCallsConfig.pfnAreValuesValid = ...; 446 // mm.vdIfCallsConfig.pfnQueryBytes = ...; 445 mm.vdIfCallsConfig.pfnAreKeysValid = vdConfigAreKeysValid; 446 mm.vdIfCallsConfig.pfnQuerySize = vdConfigQuerySize; 447 mm.vdIfCallsConfig.pfnQuery = vdConfigQuery; 448 449 /* Initialize the callbacks of the VD TCP interface (we always use the host 450 * IP stack for now) */ 451 mm.vdIfCallsTcpNet.cbSize = sizeof (VDINTERFACETCPNET); 452 mm.vdIfCallsTcpNet.enmInterface = VDINTERFACETYPE_TCPNET; 453 mm.vdIfCallsTcpNet.pfnClientConnect = RTTcpClientConnect; 454 mm.vdIfCallsTcpNet.pfnClientClose = RTTcpClientClose; 455 mm.vdIfCallsTcpNet.pfnSelectOne = RTTcpSelectOne; 456 mm.vdIfCallsTcpNet.pfnRead = RTTcpRead; 457 mm.vdIfCallsTcpNet.pfnWrite = RTTcpWrite; 458 mm.vdIfCallsTcpNet.pfnFlush = RTTcpFlush; 447 459 448 460 /* Initialize the per-disk interface chain */ … … 453 465 &mm.vdIfCallsError, this, &mm.vdDiskIfaces); 454 466 AssertRCReturn (vrc, E_FAIL); 467 455 468 vrc = VDInterfaceAdd (&mm.vdIfProgress, 456 469 "HardDisk2::vdInterfaceProgress", 457 470 VDINTERFACETYPE_PROGRESS, 458 471 &mm.vdIfCallsProgress, this, &mm.vdDiskIfaces); 472 AssertRCReturn (vrc, E_FAIL); 473 474 vrc = VDInterfaceAdd (&mm.vdIfConfig, 475 "HardDisk2::vdInterfaceConfig", 476 VDINTERFACETYPE_CONFIG, 477 &mm.vdIfCallsConfig, this, &mm.vdDiskIfaces); 478 AssertRCReturn (vrc, E_FAIL); 479 480 vrc = VDInterfaceAdd (&mm.vdIfTcpNet, 481 "HardDisk2::vdInterfaceTcpNet", 482 VDINTERFACETYPE_TCPNET, 483 &mm.vdIfCallsTcpNet, this, &mm.vdDiskIfaces); 459 484 AssertRCReturn (vrc, E_FAIL); 460 485 … … 2651 2676 flags |= VD_OPEN_FLAGS_READONLY; 2652 2677 2653 vrc = VDOpen (hdd, Utf8Str (mm.format), location, flags, NULL); 2678 vrc = VDOpen (hdd, Utf8Str (mm.format), location, flags, 2679 mm.vdDiskIfaces); 2654 2680 if (RT_FAILURE (vrc)) 2655 2681 { … … 2930 2956 error = Utf8StrFmt (" (%Rrc)", aVRC); 2931 2957 else 2932 error = Utf8StrFmt (". %s (%Rrc)", mm.vdError.raw(), aVRC);2958 error = Utf8StrFmt (".\n%s", mm.vdError.raw()); 2933 2959 2934 2960 mm.vdError.setNull(); … … 2958 2984 AssertReturnVoid (that != NULL); 2959 2985 2960 that->mm.vdError = Utf8StrFmtVA (pszFormat, va); 2986 if (that->mm.vdError.isEmpty()) 2987 that->mm.vdError = 2988 Utf8StrFmt ("%s (%Rrc)", Utf8StrFmtVA (pszFormat, va).raw(), rc); 2989 else 2990 that->mm.vdError = 2991 Utf8StrFmt ("%s.\n%s (%Rrc)", that->mm.vdError.raw(), 2992 Utf8StrFmtVA (pszFormat, va).raw(), rc); 2961 2993 } 2962 2994 … … 2980 3012 that->mm.vdProgress->notifyProgress (RT_MIN (uPercent, 99)); 2981 3013 } 3014 3015 return VINF_SUCCESS; 3016 } 3017 3018 /* static */ 3019 DECLCALLBACK(bool) HardDisk2::vdConfigAreKeysValid (void *pvUser, 3020 const char *pszzValid) 3021 { 3022 HardDisk2 *that = static_cast <HardDisk2 *> (pvUser); 3023 AssertReturn (that != NULL, VERR_GENERAL_FAILURE); 3024 3025 /* we always return true since the only keys we have are those found in 3026 * VDBACKENDINFO */ 3027 return true; 3028 } 3029 3030 /* static */ 3031 DECLCALLBACK(int) HardDisk2::vdConfigQuerySize (void *pvUser, const char *pszName, 3032 size_t *pcbValue) 3033 { 3034 AssertReturn (VALID_PTR (pcbValue), VERR_INVALID_POINTER); 3035 3036 HardDisk2 *that = static_cast <HardDisk2 *> (pvUser); 3037 AssertReturn (that != NULL, VERR_GENERAL_FAILURE); 3038 3039 Data::PropertyMap::const_iterator it = 3040 that->mm.properties.find (Bstr (pszName)); 3041 if (it == that->mm.properties.end()) 3042 return VERR_CFGM_VALUE_NOT_FOUND; 3043 3044 /* we interpret null values as "no value" in HardDisk2 */ 3045 if (it->second.isNull()) 3046 return VERR_CFGM_VALUE_NOT_FOUND; 3047 3048 *pcbValue = it->second.length() + 1 /* include terminator */; 3049 3050 return VINF_SUCCESS; 3051 } 3052 3053 /* static */ 3054 DECLCALLBACK(int) HardDisk2::vdConfigQuery (void *pvUser, const char *pszName, 3055 char *pszValue, size_t cchValue) 3056 { 3057 AssertReturn (VALID_PTR (pszValue), VERR_INVALID_POINTER); 3058 3059 HardDisk2 *that = static_cast <HardDisk2 *> (pvUser); 3060 AssertReturn (that != NULL, VERR_GENERAL_FAILURE); 3061 3062 Data::PropertyMap::const_iterator it = 3063 that->mm.properties.find (Bstr (pszName)); 3064 if (it == that->mm.properties.end()) 3065 return VERR_CFGM_VALUE_NOT_FOUND; 3066 3067 Utf8Str value = it->second; 3068 if (value.length() >= cchValue) 3069 return VERR_CFGM_NOT_ENOUGH_SPACE; 3070 3071 /* we interpret null values as "no value" in HardDisk2 */ 3072 if (it->second.isNull()) 3073 return VERR_CFGM_VALUE_NOT_FOUND; 3074 3075 memcpy (pszValue, value, value.length()); 2982 3076 2983 3077 return VINF_SUCCESS; -
trunk/src/VBox/Main/include/HardDisk2Impl.h
r14783 r14929 249 249 void *pvUser); 250 250 251 static DECLCALLBACK(bool) vdConfigAreKeysValid (void *pvUser, 252 const char *pszzValid); 253 static DECLCALLBACK(int) vdConfigQuerySize (void *pvUser, const char *pszName, 254 size_t *pcbValue); 255 static DECLCALLBACK(int) vdConfigQuery (void *pvUser, const char *pszName, 256 char *pszValue, size_t cchValue); 257 251 258 static DECLCALLBACK(int) taskThread (RTTHREAD thread, void *pvUser); 252 259 … … 288 295 VDINTERFACECONFIG vdIfCallsConfig; 289 296 297 VDINTERFACE vdIfTcpNet; 298 VDINTERFACETCPNET vdIfCallsTcpNet; 299 290 300 PVDINTERFACE vdDiskIfaces; 291 301 };
Note:
See TracChangeset
for help on using the changeset viewer.