Changeset 28727 in vbox
- Timestamp:
- Apr 26, 2010 7:37:29 AM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r28698 r28727 1794 1794 CFGMR3Dump(pInst); 1795 1795 1796 #undef RC_CHECK 1797 1796 1798 return VINF_SUCCESS; 1797 1799 } … … 3043 3045 HRESULT rc = S_OK; 3044 3046 const char *pszDevice = NULL; 3045 unsigned uInstance = 0;3046 unsigned uLun = 0;3047 BOOL fHostDrive = FALSE;3048 Utf8Str location;3049 Utf8Str format;3050 BOOL fPassthrough = FALSE;3051 3047 3052 3048 SafeIfaceArray<IStorageController> ctrls; 3053 3049 rc = mMachine->COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(ctrls)); 3054 3050 AssertComRC(rc); 3051 IMedium *pMedium; 3052 rc = aMediumAttachment->COMGETTER(Medium)(&pMedium); 3053 AssertComRC(rc); 3054 Bstr mediumLocation; 3055 if (pMedium) 3056 { 3057 rc = pMedium->COMGETTER(Location)(mediumLocation.asOutParam()); 3058 AssertComRC(rc); 3059 } 3060 3055 3061 Bstr attCtrlName; 3056 3062 rc = aMediumAttachment->COMGETTER(Controller)(attCtrlName.asOutParam()); … … 3078 3084 pszDevice = convertControllerTypeToDev(enmCtrlType); 3079 3085 3080 /** @todo support multiple instances of a controller */3081 uInstance = 0;3082 3083 LONG device;3084 rc = aMediumAttachment->COMGETTER(Device)(&device);3085 AssertComRC(rc);3086 LONG port;3087 rc = aMediumAttachment->COMGETTER(Port)(&port);3088 AssertComRC(rc);3089 3086 StorageBus_T enmBus; 3090 3087 rc = ctrl->COMGETTER(Bus)(&enmBus); 3091 3088 AssertComRC(rc); 3092 rc = convertBusPortDeviceToLun(enmBus, port, device, uLun); 3093 AssertComRCReturnRC(rc); 3094 3095 ComPtr<IMedium> medium; 3096 rc = aMediumAttachment->COMGETTER(Medium)(medium.asOutParam()); 3097 if (SUCCEEDED(rc) && !medium.isNull()) 3098 { 3099 Bstr loc; 3100 rc = medium->COMGETTER(Location)(loc.asOutParam()); 3101 AssertComRC(rc); 3102 location = loc; 3103 Bstr fmt; 3104 rc = medium->COMGETTER(Format)(fmt.asOutParam()); 3105 AssertComRC(rc); 3106 format = fmt; 3107 rc = medium->COMGETTER(HostDrive)(&fHostDrive); 3108 AssertComRC(rc); 3109 } 3110 rc = aMediumAttachment->COMGETTER(Passthrough)(&fPassthrough); 3089 ULONG uInstance; 3090 rc = ctrl->COMGETTER(Instance)(&uInstance); 3111 3091 AssertComRC(rc); 3112 3092 … … 3122 3102 PVMREQ pReq; 3123 3103 int vrc = VMR3ReqCall(mpVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 3124 (PFNRT)Console::change Drive, 9,3125 this, pszDevice, uInstance, uLun, !!fHostDrive, location.raw(), format.raw(), !!fPassthrough, fForce);3104 (PFNRT)Console::changeRemovableMedium, 6, 3105 this, pszDevice, uInstance, enmBus, aMediumAttachment, fForce); 3126 3106 3127 3107 /* leave the lock before waiting for a result (EMT will call us back!) */ … … 3143 3123 } 3144 3124 3145 if (! location.isEmpty())3125 if (!pMedium) 3146 3126 return setError(E_FAIL, 3147 tr("Could not mount the media/drive '% s' (%Rrc)"),3148 location.raw(), vrc);3127 tr("Could not mount the media/drive '%ls' (%Rrc)"), 3128 mediumLocation.raw(), vrc); 3149 3129 3150 3130 return setError(E_FAIL, … … 3159 3139 * 3160 3140 * @param pThis Pointer to the Console object. 3161 * @param p szDeviceThe PDM device name.3141 * @param pcszDevice The PDM device name. 3162 3142 * @param uInstance The PDM device instance. 3163 3143 * @param uLun The PDM LUN number of the drive. … … 3171 3151 * 3172 3152 * @thread EMT 3173 * @note Locks the Console object for writing.3174 * @todo the error handling in this method needs to be improved seriously - what if mounting fails...3175 3153 */ 3176 DECLCALLBACK(int) Console::changeDrive(Console *pThis, const char *pszDevice, unsigned uInstance, unsigned uLun, 3177 bool fHostDrive, const char *pszPath, const char *pszFormat, bool fPassthrough, bool fForce) 3178 { 3179 /// @todo change this to use the same code as in ConsoleImpl2.cpp 3180 LogFlowFunc(("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u fHostDrive=%d pszPath=%p:{%s} pszFormat=%p:{%s} fPassthrough=%d fForce=%d\n", 3181 pThis, pszDevice, pszDevice, uInstance, uLun, fHostDrive, pszPath, pszPath, pszFormat, pszFormat, fPassthrough, fForce)); 3154 DECLCALLBACK(int) Console::changeRemovableMedium(Console *pThis, 3155 const char *pcszDevice, 3156 unsigned uInstance, 3157 StorageBus_T enmBus, 3158 IMediumAttachment *aMediumAtt, 3159 bool fForce) 3160 { 3161 LogFlowFunc(("pThis=%p uInstance=%u pszDevice=%p:{%s} enmBus=%u, aMediumAtt=%p, fForce=%d\n", 3162 pThis, uInstance, pcszDevice, enmBus, fForce)); 3182 3163 3183 3164 AssertReturn(pThis, VERR_INVALID_PARAMETER); … … 3185 3166 AutoCaller autoCaller(pThis); 3186 3167 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 3187 3188 /* protect mpVM */3189 AutoVMCaller autoVMCaller(pThis);3190 if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();3191 3168 3192 3169 PVM pVM = pThis->mpVM; … … 3228 3205 } 3229 3206 3207 /* Determine the base path for the device instance. */ 3208 PCFGMNODE pCtlInst; 3209 pCtlInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, 3210 uInstance); 3211 AssertReturn(pCtlInst, VERR_INTERNAL_ERROR); 3212 3230 3213 int rc = VINF_SUCCESS; 3231 3214 int rcRet = VINF_SUCCESS; 3232 3215 3233 /* 3234 In general locking the object before doing VMR3* calls is quite safe 3235 here, since we're on EMT. Anyway we lock for write after eventually 3236 suspending the vm. The reason is that in the vmstateChangeCallback the 3237 var mVMStateChangeCallbackDisabled is checked under a lock also, which 3238 can lead to an dead lock. The write lock is necessary because we 3239 indirectly modify the meDVDState/meFloppyState members (pointed to by 3240 peState). 3241 */ 3242 AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS); 3243 3244 do 3245 { 3246 /* 3247 * Unmount existing media / detach host drive. 3248 */ 3249 PPDMIBASE pBase; 3250 rc = PDMR3QueryLun(pVM, pszDevice, uInstance, uLun, &pBase); 3251 if (RT_FAILURE(rc)) 3252 { 3253 if (rc == VERR_PDM_LUN_NOT_FOUND || rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 3254 rc = VINF_SUCCESS; 3255 AssertRC(rc); 3256 } 3257 else 3258 { 3259 PPDMIMOUNT pIMount = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMOUNT); 3260 AssertBreakStmt(pIMount, rc = VERR_INVALID_POINTER); 3261 3262 /* 3263 * Unmount the media. 3264 */ 3265 rc = pIMount->pfnUnmount(pIMount, fForce); 3266 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 3267 rc = VINF_SUCCESS; 3268 3269 if (RT_SUCCESS(rc)) 3270 { 3271 rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG); 3272 if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 3273 rc = VINF_SUCCESS; 3274 } 3275 } 3276 3277 if (RT_FAILURE(rc)) 3278 { 3279 rcRet = rc; 3280 break; 3281 } 3282 3283 /** @todo this does a very thorough job. usually it's too much, 3284 * as a simple medium change (without changing between host attachment 3285 * and image) could be done with a lot less effort, by just using the 3286 * pfnUnmount and pfnMount interfaces. Later. */ 3287 3288 /* 3289 * Construct a new driver configuration. 3290 */ 3291 PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%d/", pszDevice, uInstance); 3292 AssertRelease(pInst); 3293 /* nuke anything which might have been left behind. */ 3294 CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%d", uLun)); 3295 3296 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } } while (0) 3297 3298 PCFGMNODE pLunL0; 3299 PCFGMNODE pCfg; 3300 rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%d", uLun); RC_CHECK(); 3301 3302 if (fHostDrive) 3303 { 3304 rc = CFGMR3InsertString(pLunL0, "Driver", !strcmp(pszDevice, "i82078") ? "HostFloppy" : "HostDVD"); RC_CHECK(); 3305 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 3306 Assert(pszPath && *pszPath); 3307 rc = CFGMR3InsertString(pCfg, "Path", pszPath); RC_CHECK(); 3308 if (strcmp(pszDevice, "i82078")) 3309 { 3310 rc = CFGMR3InsertInteger(pCfg, "Passthrough", fPassthrough); RC_CHECK(); 3311 } 3312 } 3313 else 3314 { 3315 /* create a new block driver config */ 3316 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 3317 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 3318 rc = CFGMR3InsertString(pCfg, "Type", !strcmp(pszDevice, "i82078") ? "Floppy 1.44" : "DVD"); RC_CHECK(); 3319 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 3320 } 3321 3322 /* 3323 * Attach the driver. 3324 */ 3325 rc = PDMR3DeviceAttach(pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG, &pBase); RC_CHECK(); 3326 3327 if (!fHostDrive && pszPath && *pszPath) 3328 { 3329 PCFGMNODE pLunL1; 3330 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 3331 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 3332 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 3333 rc = CFGMR3InsertString(pCfg, "Path", pszPath); RC_CHECK(); 3334 rc = CFGMR3InsertString(pCfg, "Format", pszFormat); RC_CHECK(); 3335 if (strcmp(pszDevice, "i82078")) 3336 { 3337 rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK(); 3338 } 3339 /** @todo later pass full VDConfig information and parent images */ 3340 } 3341 3342 /* Dump the new controller configuration. */ 3343 CFGMR3Dump(pInst); 3344 3345 if (!fHostDrive && pszPath && *pszPath) 3346 { 3347 PPDMIMOUNT pIMount = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMOUNT); 3348 if (!pIMount) 3349 { 3350 AssertFailed(); 3351 return rc; 3352 } 3353 3354 rc = pIMount->pfnMount(pIMount, NULL , NULL); 3355 } 3356 3357 #undef RC_CHECK 3358 3359 if (RT_FAILURE(rc) && RT_SUCCESS(rcRet)) 3360 rcRet = rc; 3361 3362 } 3363 while (0); 3364 3365 /* 3366 Unlock before resuming because the vmstateChangeCallback problem 3367 described above. 3368 */ 3369 alock.release(); 3216 rcRet = Console::configMediumAttachment(pCtlInst, pcszDevice, uInstance, 3217 enmBus, aMediumAtt, 3218 pThis->mMachineState, 3219 NULL /* phrc */, 3220 true /* fAttachDetach */, 3221 fForce /* fForceUnmount */, 3222 pVM, NULL /* paLedDevType */); 3223 /** @todo this dumps everything attached to this device instance, which 3224 * is more than necessary. Dumping the changed LUN would be enough. */ 3225 CFGMR3Dump(pCtlInst); 3370 3226 3371 3227 /* … … 3677 3533 AssertRelease(pInst); 3678 3534 3679 rcRet = configNetwork(pThis,pszDevice, uInstance, uLun, aNetworkAdapter, pCfg, pLunL0, pInst, true);3535 rcRet = pThis->configNetwork(pszDevice, uInstance, uLun, aNetworkAdapter, pCfg, pLunL0, pInst, true); 3680 3536 3681 3537 /* … … 7350 7206 * @param pVM The VM handle. 7351 7207 * @param lInstance The instance of the controller. 7352 * @param enmController The type of the controller.7208 * @param pcszDevice The name of the controller type. 7353 7209 * @param enmBus The storage bus type of the controller. 7354 7210 * @param aMediumAtt The medium attachment. 7211 * @param aMachineState The current machine state. 7355 7212 * @param phrc Where to store com error - only valid if we return VERR_GENERAL_FAILURE. 7356 7213 * @return VBox status code. 7357 7214 */ 7358 static DECLCALLBACK(int) reconfigureMedium(PVM pVM, ULONG lInstance, 7359 StorageControllerType_T enmController, 7360 StorageBus_T enmBus, 7361 IMediumAttachment *aMediumAtt, 7362 HRESULT *phrc) 7215 /* static */ 7216 DECLCALLBACK(int) Console::reconfigureMediumAttachment(PVM pVM, 7217 const char *pcszDevice, 7218 unsigned uInstance, 7219 StorageBus_T enmBus, 7220 IMediumAttachment *aMediumAtt, 7221 MachineState_T aMachineState, 7222 HRESULT *phrc) 7363 7223 { 7364 7224 LogFlowFunc(("pVM=%p aMediumAtt=%p phrc=%p\n", pVM, aMediumAtt, phrc)); … … 7371 7231 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc (%#x)\n", hrc, hrc)); *phrc = hrc; return VERR_GENERAL_FAILURE; } } while (0) 7372 7232 7373 /* 7374 * Figure out medium and other attachment details. 7375 */ 7376 ComPtr<IMedium> medium; 7377 hrc = aMediumAtt->COMGETTER(Medium)(medium.asOutParam()); H(); 7378 LONG lDev; 7379 hrc = aMediumAtt->COMGETTER(Device)(&lDev); H(); 7380 LONG lPort; 7381 hrc = aMediumAtt->COMGETTER(Port)(&lPort); H(); 7233 /* Ignore attachments other than hard disks, since at the moment they are 7234 * not subject to snapshotting in general. */ 7382 7235 DeviceType_T lType; 7383 7236 hrc = aMediumAtt->COMGETTER(Type)(&lType); H(); 7384 7385 unsigned iLUN; 7386 const char *pcszDevice = Console::convertControllerTypeToDev(enmController); 7387 AssertMsgReturn(pcszDevice, ("invalid disk controller type: %d\n", enmController), VERR_GENERAL_FAILURE); 7388 hrc = Console::convertBusPortDeviceToLun(enmBus, lPort, lDev, iLUN); H(); 7389 7390 /* Ignore attachments other than hard disks, since at the moment they are 7391 * not subject to snapshotting in general. */ 7392 if (lType != DeviceType_HardDisk || medium.isNull()) 7237 if (lType != DeviceType_HardDisk) 7393 7238 return VINF_SUCCESS; 7394 7239 7395 /** @todo this should be unified with the relevant part of 7396 * Console::configConstructor to avoid inconsistencies. */ 7397 7398 /* 7399 * Is there an existing LUN? If not create it. 7400 */ 7401 PCFGMNODE pCfg; 7402 PCFGMNODE pLunL1; 7403 7404 /* SCSI has an extra driver between the device and the block driver. */ 7405 if (enmBus == StorageBus_SCSI) 7406 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN); 7407 else 7408 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/", pcszDevice, lInstance, iLUN); 7409 7410 if (!pLunL1) 7411 { 7412 PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, lInstance); 7413 AssertReturn(pInst, VERR_INTERNAL_ERROR); 7414 7415 PCFGMNODE pLunL0; 7416 rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", iLUN); RC_CHECK(); 7417 7418 if (enmBus == StorageBus_SCSI) 7419 { 7420 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); 7421 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 7422 7423 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 7424 } 7425 7426 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 7427 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 7428 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK(); 7429 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK(); 7430 7431 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 7432 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 7433 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 7434 } 7435 else 7436 { 7437 #ifdef VBOX_STRICT 7438 char *pszDriver; 7439 rc = CFGMR3QueryStringAlloc(pLunL1, "Driver", &pszDriver); RC_CHECK(); 7440 Assert(!strcmp(pszDriver, "VD")); 7441 MMR3HeapFree(pszDriver); 7442 #endif 7443 7444 pCfg = CFGMR3GetChild(pLunL1, "Config"); 7445 AssertReturn(pCfg, VERR_INTERNAL_ERROR); 7446 7447 /* Here used to be a lot of code checking if things have changed, 7448 * but that's not really worth it, as with snapshots there is always 7449 * some change, so the code was just logging useless information in 7450 * a hard to analyze form. */ 7451 7452 /* 7453 * Detach the driver and replace the config node. 7454 */ 7455 rc = PDMR3DeviceDetach(pVM, pcszDevice, 0, iLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG); RC_CHECK(); 7456 CFGMR3RemoveNode(pCfg); 7457 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 7458 } 7459 7460 /* 7461 * Create the driver configuration. 7462 */ 7463 hrc = medium->COMGETTER(Location)(bstr.asOutParam()); H(); 7464 LogFlowFunc(("LUN#%u: leaf location '%ls'\n", iLUN, bstr.raw())); 7465 rc = CFGMR3InsertString(pCfg, "Path", Utf8Str(bstr).c_str()); RC_CHECK(); 7466 hrc = medium->COMGETTER(Format)(bstr.asOutParam()); H(); 7467 LogFlowFunc(("LUN#%u: leaf format '%ls'\n", iLUN, bstr.raw())); 7468 rc = CFGMR3InsertString(pCfg, "Format", Utf8Str(bstr).c_str()); RC_CHECK(); 7469 7470 /* Pass all custom parameters. */ 7471 bool fHostIP = true; 7472 SafeArray<BSTR> names; 7473 SafeArray<BSTR> values; 7474 hrc = medium->GetProperties(NULL, 7475 ComSafeArrayAsOutParam(names), 7476 ComSafeArrayAsOutParam(values)); H(); 7477 7478 if (names.size() != 0) 7479 { 7480 PCFGMNODE pVDC; 7481 rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK(); 7482 for (size_t i = 0; i < names.size(); ++ i) 7483 { 7484 if (values[i] && *values[i]) 7485 { 7486 Utf8Str name = names[i]; 7487 Utf8Str value = values[i]; 7488 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); 7489 if ( !(name.compare("HostIPStack")) 7490 && !(value.compare("0"))) 7491 fHostIP = false; 7492 } 7493 } 7494 } 7495 7496 /* Create an inversed tree of parents. */ 7497 ComPtr<IMedium> parentMedium = medium; 7498 for (PCFGMNODE pParent = pCfg;;) 7499 { 7500 hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam()); H(); 7501 if (medium.isNull()) 7502 break; 7503 7504 PCFGMNODE pCur; 7505 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK(); 7506 hrc = medium->COMGETTER(Location)(bstr.asOutParam()); H(); 7507 rc = CFGMR3InsertString(pCur, "Path", Utf8Str(bstr).c_str()); RC_CHECK(); 7508 7509 hrc = medium->COMGETTER(Format)(bstr.asOutParam()); H(); 7510 rc = CFGMR3InsertString(pCur, "Format", Utf8Str(bstr).c_str()); RC_CHECK(); 7511 7512 /* Pass all custom parameters. */ 7513 SafeArray<BSTR> aNames; 7514 SafeArray<BSTR> aValues; 7515 hrc = medium->GetProperties(NULL, 7516 ComSafeArrayAsOutParam(aNames), 7517 ComSafeArrayAsOutParam(aValues)); H(); 7518 7519 if (aNames.size() != 0) 7520 { 7521 PCFGMNODE pVDC; 7522 rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK(); 7523 for (size_t i = 0; i < aNames.size(); ++ i) 7524 { 7525 if (aValues[i] && *aValues[i]) 7526 { 7527 Utf8Str name = aNames[i]; 7528 Utf8Str value = aValues[i]; 7529 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 7530 if ( !(name.compare("HostIPStack")) 7531 && !(value.compare("0"))) 7532 fHostIP = false; 7533 } 7534 } 7535 } 7536 7537 /* Custom code: put marker to not use host IP stack to driver 7538 * configuration node. Simplifies life of DrvVD a bit. */ 7539 if (!fHostIP) 7540 { 7541 rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK(); 7542 } 7543 7544 7545 /* next */ 7546 pParent = pCur; 7547 parentMedium = medium; 7548 } 7549 7550 CFGMR3Dump(CFGMR3GetRoot(pVM)); 7551 7552 /* 7553 * Attach the new driver. 7554 */ 7555 rc = PDMR3DeviceAttach(pVM, pcszDevice, 0, iLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/); RC_CHECK(); 7240 /* Determine the base path for the device instance. */ 7241 PCFGMNODE pCtlInst; 7242 pCtlInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, uInstance); 7243 AssertReturn(pCtlInst, VERR_INTERNAL_ERROR); 7244 7245 /* Update the device instance configuration. */ 7246 rc = Console::configMediumAttachment(pCtlInst, pcszDevice, uInstance, 7247 enmBus, aMediumAtt, aMachineState, 7248 phrc, true /* fAttachDetach */, 7249 false /* fForceUnmount */, pVM, 7250 NULL /* paLedDevType */); 7251 /** @todo this dumps everything attached to this device instance, which 7252 * is more than necessary. Dumping the changed LUN would be enough. */ 7253 CFGMR3Dump(pCtlInst); 7254 RC_CHECK(); 7255 7256 #undef RC_CHECK 7257 #undef H 7556 7258 7557 7259 LogFlowFunc(("Returns success\n")); 7558 return rc;7260 return VINF_SUCCESS; 7559 7261 } 7560 7262 … … 7596 7298 that->mptrCancelableProgress.setNull(); 7597 7299 return autoCaller.rc(); 7300 } 7301 7302 /* protect mpVM */ 7303 AutoVMCaller autoVMCaller(that); 7304 if (FAILED(autoVMCaller.rc())) 7305 { 7306 that->mptrCancelableProgress.setNull(); 7307 return autoVMCaller.rc(); 7598 7308 } 7599 7309 … … 7705 7415 if (FAILED(rc)) 7706 7416 throw rc; 7417 const char *pcszDevice = Console::convertControllerTypeToDev(enmController); 7707 7418 7708 7419 /* 7709 * don't leave the lock since reconfigureMedium isn't going7710 * to access Console.7420 * don't leave the lock since reconfigureMediumAttachment 7421 * isn't going to need the Console lock. 7711 7422 */ 7712 7423 vrc = VMR3ReqCallWait(that->mpVM, 7713 7424 VMCPUID_ANY, 7714 (PFNRT)reconfigureMedium ,7715 6,7425 (PFNRT)reconfigureMediumAttachment, 7426 7, 7716 7427 that->mpVM, 7428 pcszDevice, 7717 7429 lInstance, 7718 enmController,7719 7430 enmBus, 7720 7431 atts[i], 7432 that->mMachineState, 7721 7433 &rc); 7722 7434 if (RT_FAILURE(vrc)) -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r28580 r28727 231 231 empty.asOutParam(), aFilePath.asOutParam(), &fPresent); 232 232 if (RT_FAILURE(rc)) 233 AssertComRCReturn 233 AssertComRCReturn(rc, VERR_FILE_NOT_FOUND); 234 234 235 235 if (!fPresent) … … 279 279 BOOL fIs64BitGuest = false; 280 280 281 #if !defined 281 #if !defined(VBOX_WITH_XPCOM) 282 282 { 283 283 /* initialize COM */ … … 285 285 COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE | 286 286 COINIT_SPEED_OVER_MEMORY); 287 LogFlow 288 AssertComRCReturn 287 LogFlow(("Console::configConstructor(): CoInitializeEx()=%08X\n", hrc)); 288 AssertComRCReturn(hrc, VERR_GENERAL_FAILURE); 289 289 } 290 290 #endif 291 291 292 292 AssertReturn(pvConsole, VERR_GENERAL_FAILURE); 293 ComObjPtr<Console> pConsole = static_cast <Console *>(pvConsole);293 ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole); 294 294 295 295 AutoCaller autoCaller(pConsole); 296 AssertComRCReturn 296 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 297 297 298 298 /* lock the console because we widely use internal fields and methods */ … … 933 933 if (SchemaDefs::MaxBootPosition > 9) 934 934 { 935 AssertMsgFailed 936 935 AssertMsgFailed(("Too many boot devices %d\n", 936 SchemaDefs::MaxBootPosition)); 937 937 return VERR_INVALID_PARAMETER; 938 938 } … … 943 943 944 944 char szParamName[] = "BootDeviceX"; 945 szParamName[sizeof 945 szParamName[sizeof(szParamName) - 2] = ((char (pos - 1)) + '0'); 946 946 947 947 const char *pszBootDevice; … … 1260 1260 for (size_t j = 0; j < atts.size(); ++j) 1261 1261 { 1262 ComPtr<IMedium> medium; 1263 hrc = atts[j]->COMGETTER(Medium)(medium.asOutParam()); H(); 1264 LONG lDev; 1265 hrc = atts[j]->COMGETTER(Device)(&lDev); H(); 1266 LONG lPort; 1267 hrc = atts[j]->COMGETTER(Port)(&lPort); H(); 1268 DeviceType_T lType; 1269 hrc = atts[j]->COMGETTER(Type)(&lType); H(); 1270 1271 unsigned uLUN; 1272 hrc = pConsole->convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); H(); 1273 rc = CFGMR3InsertNodeF(pCtlInst, &pLunL0, "LUN#%u", uLUN); RC_CHECK(); 1274 1275 /* SCSI has a another driver between device and block. */ 1276 if (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS) 1277 { 1278 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); 1279 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1280 1281 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 1282 } 1283 1284 BOOL fHostDrive = FALSE; 1285 if (!medium.isNull()) 1286 { 1287 hrc = medium->COMGETTER(HostDrive)(&fHostDrive); H(); 1288 } 1289 1290 if (fHostDrive) 1291 { 1292 Assert(!medium.isNull()); 1293 if (lType == DeviceType_DVD) 1294 { 1295 rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK(); 1296 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1297 1298 hrc = medium->COMGETTER(Location)(&str); H(); 1299 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1300 STR_FREE(); 1301 1302 BOOL fPassthrough; 1303 hrc = atts[j]->COMGETTER(Passthrough)(&fPassthrough); H(); 1304 rc = CFGMR3InsertInteger(pCfg, "Passthrough", !!fPassthrough); RC_CHECK(); 1305 } 1306 else if (lType == DeviceType_Floppy) 1307 { 1308 rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK(); 1309 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1310 1311 hrc = medium->COMGETTER(Location)(&str); H(); 1312 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1313 STR_FREE(); 1314 } 1315 } 1316 else 1317 { 1318 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 1319 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 1320 switch (lType) 1321 { 1322 case DeviceType_DVD: 1323 rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK(); 1324 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 1325 break; 1326 case DeviceType_Floppy: 1327 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK(); 1328 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 1329 break; 1330 case DeviceType_HardDisk: 1331 default: 1332 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK(); 1333 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK(); 1334 } 1335 1336 if (!medium.isNull()) 1337 { 1338 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 1339 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 1340 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 1341 1342 hrc = medium->COMGETTER(Location)(&str); H(); 1343 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 1344 STR_FREE(); 1345 1346 hrc = medium->COMGETTER(Format)(&str); H(); 1347 rc = CFGMR3InsertStringW(pCfg, "Format", str); RC_CHECK(); 1348 STR_FREE(); 1349 1350 /* DVDs are always readonly */ 1351 if (lType == DeviceType_DVD) 1352 { 1353 rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK(); 1354 } 1355 /* Start without exclusive write access to the images. */ 1356 /** @todo Live Migration: I don't quite like this, we risk screwing up when 1357 * we're resuming the VM if some 3rd dude have any of the VDIs open 1358 * with write sharing denied. However, if the two VMs are sharing a 1359 * image it really is necessary.... 1360 * 1361 * So, on the "lock-media" command, the target teleporter should also 1362 * make DrvVD undo TempReadOnly. It gets interesting if we fail after 1363 * that. Grumble. */ 1364 else if (pConsole->mMachineState == MachineState_TeleportingIn) 1365 { 1366 rc = CFGMR3InsertInteger(pCfg, "TempReadOnly", 1); RC_CHECK(); 1367 } 1368 1369 /* Pass all custom parameters. */ 1370 bool fHostIP = true; 1371 SafeArray<BSTR> names; 1372 SafeArray<BSTR> values; 1373 hrc = medium->GetProperties(NULL, 1374 ComSafeArrayAsOutParam(names), 1375 ComSafeArrayAsOutParam(values)); H(); 1376 1377 if (names.size() != 0) 1378 { 1379 PCFGMNODE pVDC; 1380 rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK(); 1381 for (size_t ii = 0; ii < names.size(); ++ii) 1382 { 1383 if (values[ii] && *values[ii]) 1384 { 1385 Utf8Str name = names[ii]; 1386 Utf8Str value = values[ii]; 1387 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 1388 if ( name.compare("HostIPStack") == 0 1389 && value.compare("0") == 0) 1390 fHostIP = false; 1391 } 1392 } 1393 } 1394 1395 /* Create an inversed tree of parents. */ 1396 ComPtr<IMedium> parentMedium = medium; 1397 for (PCFGMNODE pParent = pCfg;;) 1398 { 1399 hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam()); H(); 1400 if (medium.isNull()) 1401 break; 1402 1403 PCFGMNODE pCur; 1404 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK(); 1405 hrc = medium->COMGETTER(Location)(&str); H(); 1406 rc = CFGMR3InsertStringW(pCur, "Path", str); RC_CHECK(); 1407 STR_FREE(); 1408 1409 hrc = medium->COMGETTER(Format)(&str); H(); 1410 rc = CFGMR3InsertStringW(pCur, "Format", str); RC_CHECK(); 1411 STR_FREE(); 1412 1413 /* Pass all custom parameters. */ 1414 SafeArray<BSTR> aNames; 1415 SafeArray<BSTR> aValues; 1416 hrc = medium->GetProperties(NULL, 1417 ComSafeArrayAsOutParam(aNames), 1418 ComSafeArrayAsOutParam(aValues)); H(); 1419 1420 if (aNames.size() != 0) 1421 { 1422 PCFGMNODE pVDC; 1423 rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK(); 1424 for (size_t ii = 0; ii < aNames.size(); ++ii) 1425 { 1426 if (aValues[ii] && *aValues[ii]) 1427 { 1428 Utf8Str name = aNames[ii]; 1429 Utf8Str value = aValues[ii]; 1430 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 1431 if ( name.compare("HostIPStack") == 0 1432 && value.compare("0") == 0) 1433 fHostIP = false; 1434 } 1435 } 1436 } 1437 1438 /* Custom code: put marker to not use host IP stack to driver 1439 * configuration node. Simplifies life of DrvVD a bit. */ 1440 if (!fHostIP) 1441 { 1442 rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK(); 1443 } 1444 1445 /* next */ 1446 pParent = pCur; 1447 parentMedium = medium; 1448 } 1449 } 1450 } 1451 1452 if (paLedDevType) 1453 paLedDevType[uLUN] = lType; 1262 rc = Console::configMediumAttachment(pCtlInst, pszCtrlDev, 1263 ulInstance, enmBus, atts[j], 1264 pConsole->mMachineState, 1265 NULL /* phrc */, 1266 false /* fAttachDetach */, 1267 false /* fForceUnmount */, 1268 NULL /* pVM */, 1269 paLedDevType); RC_CHECK(); 1454 1270 } 1455 1271 H(); … … 1637 1453 * Configure the network card now 1638 1454 */ 1639 rc = configNetwork(pConsole, pszAdapterName, ulInstance, 0, networkAdapter, 1640 pCfg, pLunL0, pInst, false /*fAttachDetach*/); RC_CHECK(); 1455 rc = pConsole->configNetwork(pszAdapterName, ulInstance, 0, 1456 networkAdapter, pCfg, pLunL0, pInst, 1457 false /*fAttachDetach*/); RC_CHECK(); 1641 1458 } 1642 1459 … … 1673 1490 { 1674 1491 ComPtr<ISerialPort> serialPort; 1675 hrc = pMachine->GetSerialPort 1492 hrc = pMachine->GetSerialPort(ulInstance, serialPort.asOutParam()); H(); 1676 1493 BOOL fEnabled = FALSE; 1677 1494 if (serialPort) … … 1901 1718 # endif 1902 1719 #endif /* RT_OS_LINUX */ 1903 #if defined (RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS)1720 #if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS) 1904 1721 case AudioDriverType_OSS: 1905 1722 { … … 2102 1919 { 2103 1920 /* Load the service */ 2104 rc = pConsole->mVMMDev->hgcmLoadService 1921 rc = pConsole->mVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard"); 2105 1922 2106 1923 if (RT_FAILURE(rc)) … … 2146 1963 } 2147 1964 2148 pConsole->mVMMDev->hgcmHostCall 1965 pConsole->mVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm); 2149 1966 2150 1967 Log(("Set VBoxSharedClipboard mode\n")); … … 2164 1981 { 2165 1982 /* Load the service */ 2166 rc = pConsole->mVMMDev->hgcmLoadService 1983 rc = pConsole->mVMMDev->hgcmLoadService("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL"); 2167 1984 if (RT_FAILURE(rc)) 2168 1985 { … … 2422 2239 2423 2240 /* Register VM state change handler */ 2424 int rc2 = VMR3AtStateRegister 2241 int rc2 = VMR3AtStateRegister(pVM, Console::vmstateChangeCallback, pConsole); 2425 2242 AssertRC(rc2); 2426 2243 if (RT_SUCCESS(rc)) … … 2428 2245 2429 2246 /* Register VM runtime error handler */ 2430 rc2 = VMR3AtRuntimeErrorRegister 2247 rc2 = VMR3AtRuntimeErrorRegister(pVM, Console::setVMRuntimeErrorCallback, pConsole); 2431 2248 AssertRC(rc2); 2432 2249 if (RT_SUCCESS(rc)) 2433 2250 rc = rc2; 2434 2251 2435 LogFlowFunc 2252 LogFlowFunc(("vrc = %Rrc\n", rc)); 2436 2253 LogFlowFuncLeave(); 2437 2254 … … 2450 2267 } 2451 2268 2269 /* static */ 2270 int Console::configMediumAttachment(PCFGMNODE pCtlInst, const char *pcszDevice, 2271 unsigned uInstance, StorageBus_T enmBus, 2272 IMediumAttachment *pMediumAtt, 2273 MachineState_T aMachineState, 2274 HRESULT *phrc, bool fAttachDetach, 2275 bool fForceUnmount, PVM pVM, 2276 DeviceType_T *paLedDevType) 2277 { 2278 int rc = VINF_SUCCESS; 2279 HRESULT hrc; 2280 BSTR str = NULL; 2281 2282 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2283 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2284 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2285 2286 LONG lDev; 2287 hrc = pMediumAtt->COMGETTER(Device)(&lDev); H(); 2288 LONG lPort; 2289 hrc = pMediumAtt->COMGETTER(Port)(&lPort); H(); 2290 DeviceType_T lType; 2291 hrc = pMediumAtt->COMGETTER(Type)(&lType); H(); 2292 2293 unsigned uLUN; 2294 PCFGMNODE pLunL0 = NULL; 2295 PCFGMNODE pCfg = NULL; 2296 hrc = Console::convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); H(); 2297 2298 /* First check if the LUN already exists. */ 2299 pLunL0 = CFGMR3GetChildF(pCtlInst, "LUN#%u", uLUN); 2300 if (pLunL0) 2301 { 2302 if (fAttachDetach) 2303 { 2304 if (lType != DeviceType_HardDisk) 2305 { 2306 /* Unmount existing media only for floppy and DVD drives. */ 2307 PPDMIBASE pBase; 2308 rc = PDMR3QueryLun(pVM, pcszDevice, uInstance, uLUN, &pBase); 2309 if (RT_FAILURE(rc)) 2310 { 2311 if (rc == VERR_PDM_LUN_NOT_FOUND || rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 2312 rc = VINF_SUCCESS; 2313 AssertRC(rc); 2314 } 2315 else 2316 { 2317 PPDMIMOUNT pIMount = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMOUNT); 2318 AssertReturn(pIMount, VERR_INVALID_POINTER); 2319 2320 /* Unmount the media. */ 2321 rc = pIMount->pfnUnmount(pIMount, fForceUnmount); 2322 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 2323 rc = VINF_SUCCESS; 2324 } 2325 } 2326 2327 rc = PDMR3DeviceDetach(pVM, pcszDevice, 0, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG); 2328 if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 2329 rc = VINF_SUCCESS; 2330 RC_CHECK(); 2331 2332 CFGMR3RemoveNode(pLunL0); 2333 } 2334 else 2335 AssertFailedReturn(VERR_INTERNAL_ERROR); 2336 } 2337 2338 rc = CFGMR3InsertNodeF(pCtlInst, &pLunL0, "LUN#%u", uLUN); RC_CHECK(); 2339 2340 /* SCSI has a another driver between device and block. */ 2341 if (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS) 2342 { 2343 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); 2344 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2345 2346 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 2347 } 2348 2349 ComPtr<IMedium> pMedium; 2350 hrc = pMediumAtt->COMGETTER(Medium)(pMedium.asOutParam()); H(); 2351 BOOL fPassthrough; 2352 hrc = pMediumAtt->COMGETTER(Passthrough)(&fPassthrough); H(); 2353 rc = Console::configMedium(pLunL0, !!fPassthrough, lType, 2354 pMedium, aMachineState, phrc); RC_CHECK(); 2355 2356 if (fAttachDetach) 2357 { 2358 /* Attach the new driver. */ 2359 rc = PDMR3DeviceAttach(pVM, pcszDevice, 0, uLUN, 2360 PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/); RC_CHECK(); 2361 2362 /* There is no need to handle removable medium mounting, as we 2363 * unconditionally replace everthing including the block driver level. 2364 * This means the new medium will be picked up automatically. */ 2365 } 2366 2367 if (paLedDevType) 2368 paLedDevType[uLUN] = lType; 2369 2370 #undef STR_FREE 2371 #undef H 2372 #undef RC_CHECK 2373 2374 return VINF_SUCCESS;; 2375 } 2376 2377 int Console::configMedium(PCFGMNODE pLunL0, 2378 bool fPassthrough, 2379 DeviceType_T enmType, 2380 IMedium *pMedium, 2381 MachineState_T aMachineState, 2382 HRESULT *phrc) 2383 { 2384 int rc = VINF_SUCCESS; 2385 HRESULT hrc; 2386 BSTR str = NULL; 2387 2388 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2389 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2390 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); if (phrc) *phrc = hrc; return VERR_GENERAL_FAILURE; } } while (0) 2391 2392 PCFGMNODE pLunL1 = NULL; 2393 PCFGMNODE pCfg = NULL; 2394 2395 BOOL fHostDrive = FALSE; 2396 if (pMedium) 2397 { 2398 hrc = pMedium->COMGETTER(HostDrive)(&fHostDrive); H(); 2399 } 2400 2401 if (fHostDrive) 2402 { 2403 Assert(pMedium); 2404 if (enmType == DeviceType_DVD) 2405 { 2406 rc = CFGMR3InsertString(pLunL0, "Driver", "HostDVD"); RC_CHECK(); 2407 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2408 2409 hrc = pMedium->COMGETTER(Location)(&str); H(); 2410 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 2411 STR_FREE(); 2412 2413 rc = CFGMR3InsertInteger(pCfg, "Passthrough", fPassthrough); RC_CHECK(); 2414 } 2415 else if (enmType == DeviceType_Floppy) 2416 { 2417 rc = CFGMR3InsertString(pLunL0, "Driver", "HostFloppy"); RC_CHECK(); 2418 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2419 2420 hrc = pMedium->COMGETTER(Location)(&str); H(); 2421 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 2422 STR_FREE(); 2423 } 2424 } 2425 else 2426 { 2427 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 2428 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2429 switch (enmType) 2430 { 2431 case DeviceType_DVD: 2432 rc = CFGMR3InsertString(pCfg, "Type", "DVD"); RC_CHECK(); 2433 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 2434 break; 2435 case DeviceType_Floppy: 2436 rc = CFGMR3InsertString(pCfg, "Type", "Floppy 1.44"); RC_CHECK(); 2437 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 2438 break; 2439 case DeviceType_HardDisk: 2440 default: 2441 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK(); 2442 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK(); 2443 } 2444 2445 if (pMedium) 2446 { 2447 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 2448 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 2449 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 2450 2451 hrc = pMedium->COMGETTER(Location)(&str); H(); 2452 rc = CFGMR3InsertStringW(pCfg, "Path", str); RC_CHECK(); 2453 STR_FREE(); 2454 2455 hrc = pMedium->COMGETTER(Format)(&str); H(); 2456 rc = CFGMR3InsertStringW(pCfg, "Format", str); RC_CHECK(); 2457 STR_FREE(); 2458 2459 /* DVDs are always readonly */ 2460 if (enmType == DeviceType_DVD) 2461 { 2462 rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK(); 2463 } 2464 2465 /* Start without exclusive write access to the images. */ 2466 /** @todo Live Migration: I don't quite like this, we risk screwing up when 2467 * we're resuming the VM if some 3rd dude have any of the VDIs open 2468 * with write sharing denied. However, if the two VMs are sharing a 2469 * image it really is necessary.... 2470 * 2471 * So, on the "lock-media" command, the target teleporter should also 2472 * make DrvVD undo TempReadOnly. It gets interesting if we fail after 2473 * that. Grumble. */ 2474 else if (aMachineState == MachineState_TeleportingIn) 2475 { 2476 rc = CFGMR3InsertInteger(pCfg, "TempReadOnly", 1); RC_CHECK(); 2477 } 2478 2479 /* Pass all custom parameters. */ 2480 bool fHostIP = true; 2481 SafeArray<BSTR> names; 2482 SafeArray<BSTR> values; 2483 hrc = pMedium->GetProperties(NULL, 2484 ComSafeArrayAsOutParam(names), 2485 ComSafeArrayAsOutParam(values)); H(); 2486 2487 if (names.size() != 0) 2488 { 2489 PCFGMNODE pVDC; 2490 rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC); RC_CHECK(); 2491 for (size_t ii = 0; ii < names.size(); ++ii) 2492 { 2493 if (values[ii] && *values[ii]) 2494 { 2495 Utf8Str name = names[ii]; 2496 Utf8Str value = values[ii]; 2497 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 2498 if ( name.compare("HostIPStack") == 0 2499 && value.compare("0") == 0) 2500 fHostIP = false; 2501 } 2502 } 2503 } 2504 2505 /* Create an inversed tree of parents. */ 2506 IMedium *pParentMedium = pMedium; 2507 for (PCFGMNODE pParent = pCfg;;) 2508 { 2509 hrc = pParentMedium->COMGETTER(Parent)(&pMedium); H(); 2510 if (!pMedium) 2511 break; 2512 2513 PCFGMNODE pCur; 2514 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK(); 2515 hrc = pMedium->COMGETTER(Location)(&str); H(); 2516 rc = CFGMR3InsertStringW(pCur, "Path", str); RC_CHECK(); 2517 STR_FREE(); 2518 2519 hrc = pMedium->COMGETTER(Format)(&str); H(); 2520 rc = CFGMR3InsertStringW(pCur, "Format", str); RC_CHECK(); 2521 STR_FREE(); 2522 2523 /* Pass all custom parameters. */ 2524 SafeArray<BSTR> aNames; 2525 SafeArray<BSTR> aValues; 2526 hrc = pMedium->GetProperties(NULL, 2527 ComSafeArrayAsOutParam(aNames), 2528 ComSafeArrayAsOutParam(aValues)); H(); 2529 2530 if (aNames.size() != 0) 2531 { 2532 PCFGMNODE pVDC; 2533 rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC); RC_CHECK(); 2534 for (size_t ii = 0; ii < aNames.size(); ++ii) 2535 { 2536 if (aValues[ii] && *aValues[ii]) 2537 { 2538 Utf8Str name = aNames[ii]; 2539 Utf8Str value = aValues[ii]; 2540 rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str()); RC_CHECK(); 2541 if ( name.compare("HostIPStack") == 0 2542 && value.compare("0") == 0) 2543 fHostIP = false; 2544 } 2545 } 2546 } 2547 2548 /* Custom code: put marker to not use host IP stack to driver 2549 * configuration node. Simplifies life of DrvVD a bit. */ 2550 if (!fHostIP) 2551 { 2552 rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0); RC_CHECK(); 2553 } 2554 2555 /* next */ 2556 pParent = pCur; 2557 pParentMedium = pMedium; 2558 } 2559 } 2560 } 2561 2562 #undef STR_FREE 2563 #undef H 2564 #undef RC_CHECK 2565 2566 return VINF_SUCCESS; 2567 } 2568 2452 2569 /** 2453 2570 * Construct the Network configuration tree … … 2455 2572 * @returns VBox status code. 2456 2573 * 2457 * @param pThis Pointer to the Console object.2458 2574 * @param pszDevice The PDM device name. 2459 2575 * @param uInstance The PDM device instance. … … 2467 2583 * configuration. 2468 2584 * 2469 * @note Locks th e Consoleobject for writing.2585 * @note Locks this object for writing. 2470 2586 */ 2471 /*static*/ int Console::configNetwork(Console *pThis, const char *pszDevice, 2472 unsigned uInstance, unsigned uLun, 2473 INetworkAdapter *aNetworkAdapter, 2474 PCFGMNODE pCfg, PCFGMNODE pLunL0, 2475 PCFGMNODE pInst, bool fAttachDetach) 2587 int Console::configNetwork(const char *pszDevice, unsigned uInstance, 2588 unsigned uLun, INetworkAdapter *aNetworkAdapter, 2589 PCFGMNODE pCfg, PCFGMNODE pLunL0, PCFGMNODE pInst, 2590 bool fAttachDetach) 2476 2591 { 2592 AutoCaller autoCaller(this); 2593 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 2594 2477 2595 int rc = VINF_SUCCESS; 2478 2479 AutoCaller autoCaller(pThis); 2480 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 2596 HRESULT hrc; 2597 BSTR str = NULL; 2598 2599 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2600 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2601 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2481 2602 2482 2603 /* … … 2485 2606 * meAttachmentType member. 2486 2607 */ 2487 AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS); 2488 2489 PVM pVM = pThis->mpVM; 2490 BSTR str = NULL; 2491 2492 #define STR_FREE() do { if (str) { SysFreeString(str); str = NULL; } } while (0) 2493 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); STR_FREE(); return rc; } } while (0) 2494 #define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc\n", hrc)); STR_FREE(); return VERR_GENERAL_FAILURE; } } while (0) 2495 2496 HRESULT hrc; 2497 ComPtr<IMachine> pMachine = pThis->machine(); 2608 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2609 2610 PVM pVM = mpVM; 2611 2612 ComPtr<IMachine> pMachine = machine(); 2498 2613 2499 2614 ComPtr<IVirtualBox> virtualBox; … … 2512 2627 { 2513 2628 const char *pszNetDriver = "IntNet"; 2514 if ( pThis->meAttachmentType[uInstance] == NetworkAttachmentType_NAT)2629 if (meAttachmentType[uInstance] == NetworkAttachmentType_NAT) 2515 2630 pszNetDriver = "NAT"; 2516 2631 #if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX) 2517 if ( pThis->meAttachmentType[uInstance] == NetworkAttachmentType_Bridged)2632 if (meAttachmentType[uInstance] == NetworkAttachmentType_Bridged) 2518 2633 pszNetDriver = "HostInterface"; 2519 2634 #endif … … 2701 2816 Log2((#res " %s pos:%d, ppos:%d\n", res.raw(), pos, ppos)); \ 2702 2817 ppos = pos + 1; \ 2703 } while (0)2818 } while (0) 2704 2819 ITERATE_TO_NEXT_TERM(strName, utf, pos, ppos); 2705 2820 ITERATE_TO_NEXT_TERM(strProto, utf, pos, ppos); … … 2758 2873 { 2759 2874 #if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT) 2760 hrc = pThis->attachToTapInterface(aNetworkAdapter);2875 hrc = attachToTapInterface(aNetworkAdapter); 2761 2876 if (FAILED(hrc)) 2762 2877 { … … 2777 2892 } 2778 2893 2779 Assert((int) pThis->maTapFD[uInstance] >= 0);2780 if ((int) pThis->maTapFD[uInstance] >= 0)2894 Assert((int)maTapFD[uInstance] >= 0); 2895 if ((int)maTapFD[uInstance] >= 0) 2781 2896 { 2782 2897 if (fSniffer) … … 2790 2905 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK(); 2791 2906 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2792 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]); RC_CHECK();2907 rc = CFGMR3InsertInteger(pCfg, "FileHandle", maTapFD[uInstance]); RC_CHECK(); 2793 2908 } 2794 2909 … … 2972 3087 */ 2973 3088 if (!strncmp(pszHifName, "tap", sizeof "tap" - 1)) { 2974 hrc = pThis->attachToTapInterface(aNetworkAdapter);3089 hrc = attachToTapInterface(aNetworkAdapter); 2975 3090 if (FAILED(hrc)) 2976 3091 { … … 2991 3106 } 2992 3107 2993 Assert((int) pThis->maTapFD[uInstance] >= 0);2994 if ((int) pThis->maTapFD[uInstance] >= 0)3108 Assert((int)maTapFD[uInstance] >= 0); 3109 if ((int)maTapFD[uInstance] >= 0) 2995 3110 { 2996 3111 rc = CFGMR3InsertString(pLunL0, "Driver", "HostInterface"); RC_CHECK(); 2997 3112 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2998 rc = CFGMR3InsertInteger(pCfg, "FileHandle", pThis->maTapFD[uInstance]);RC_CHECK();3113 rc = CFGMR3InsertInteger(pCfg, "FileHandle", maTapFD[uInstance]); RC_CHECK(); 2999 3114 } 3000 3115 break; … … 3016 3131 if ((Req.ifr_flags & IFF_UP) == 0) 3017 3132 { 3018 setVMRuntimeErrorCallbackF(pVM, pThis, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName);3133 setVMRuntimeErrorCallbackF(pVM, this, 0, "BridgedInterfaceDown", "Bridged interface %s is down. Guest will not be able to use this interface", pszHifName); 3019 3134 } 3020 3135 … … 3510 3625 } 3511 3626 3512 pThis->meAttachmentType[uInstance] = eAttachmentType;3627 meAttachmentType[uInstance] = eAttachmentType; 3513 3628 3514 3629 #undef STR_FREE … … 3565 3680 parms[2].u.pointer.addr = (void *)pszFlags; 3566 3681 parms[2].u.pointer.size = strlen(pszFlags) + 1; 3567 pVMMDev->hgcmHostCall 3568 3682 pVMMDev->hgcmHostCall("VBoxGuestPropSvc", guestProp::SET_PROP_HOST, 3, 3683 &parms[0]); 3569 3684 } 3570 3685 … … 3581 3696 VBOXHGCMSVCPARM paParm; 3582 3697 paParm.setUInt32(eFlags); 3583 int rc = pVMMDev->hgcmHostCall 3584 3585 3698 int rc = pVMMDev->hgcmHostCall("VBoxGuestPropSvc", 3699 guestProp::SET_GLOBAL_FLAGS_HOST, 1, 3700 &paParm); 3586 3701 if (RT_FAILURE(rc)) 3587 3702 { … … 3604 3719 #ifdef VBOX_WITH_GUEST_PROPS 3605 3720 AssertReturn(pvConsole, VERR_GENERAL_FAILURE); 3606 ComObjPtr<Console> pConsole = static_cast <Console *>(pvConsole);3721 ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole); 3607 3722 3608 3723 /* Load the service */ 3609 int rc = pConsole->mVMMDev->hgcmLoadService 3724 int rc = pConsole->mVMMDev->hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc"); 3610 3725 3611 3726 if (RT_FAILURE(rc)) … … 3744 3859 #ifdef VBOX_WITH_GUEST_CONTROL 3745 3860 AssertReturn(pvConsole, VERR_GENERAL_FAILURE); 3746 ComObjPtr<Console> pConsole = static_cast <Console *>(pvConsole);3861 ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole); 3747 3862 3748 3863 /* Load the service */ 3749 int rc = pConsole->mVMMDev->hgcmLoadService 3864 int rc = pConsole->mVMMDev->hgcmLoadService("VBoxGuestControlSvc", "VBoxGuestControlSvc"); 3750 3865 3751 3866 if (RT_FAILURE(rc)) -
trunk/src/VBox/Main/include/ConsoleImpl.h
r27788 r28727 5 5 6 6 /* 7 * Copyright (C) 2006-20 09Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 103 103 104 104 // public initializers/uninitializers for internal purposes only 105 HRESULT init 105 HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl); 106 106 void uninit(); 107 107 108 108 // IConsole properties 109 STDMETHOD(COMGETTER(Machine)) 110 STDMETHOD(COMGETTER(State)) 111 STDMETHOD(COMGETTER(Guest)) 112 STDMETHOD(COMGETTER(Keyboard)) 113 STDMETHOD(COMGETTER(Mouse)) 114 STDMETHOD(COMGETTER(Display)) 115 STDMETHOD(COMGETTER(Debugger)) 116 STDMETHOD(COMGETTER(USBDevices)) (ComSafeArrayOut(IUSBDevice *, aUSBDevices));117 STDMETHOD(COMGETTER(RemoteUSBDevices)) (ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices));118 STDMETHOD(COMGETTER(RemoteDisplayInfo)) 119 STDMETHOD(COMGETTER(SharedFolders)) (ComSafeArrayOut(ISharedFolder *, aSharedFolders));109 STDMETHOD(COMGETTER(Machine))(IMachine **aMachine); 110 STDMETHOD(COMGETTER(State))(MachineState_T *aMachineState); 111 STDMETHOD(COMGETTER(Guest))(IGuest **aGuest); 112 STDMETHOD(COMGETTER(Keyboard))(IKeyboard **aKeyboard); 113 STDMETHOD(COMGETTER(Mouse))(IMouse **aMouse); 114 STDMETHOD(COMGETTER(Display))(IDisplay **aDisplay); 115 STDMETHOD(COMGETTER(Debugger))(IMachineDebugger **aDebugger); 116 STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IUSBDevice *, aUSBDevices)); 117 STDMETHOD(COMGETTER(RemoteUSBDevices))(ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices)); 118 STDMETHOD(COMGETTER(RemoteDisplayInfo))(IRemoteDisplayInfo **aRemoteDisplayInfo); 119 STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders)); 120 120 121 121 // IConsole methods 122 STDMETHOD(PowerUp) 123 STDMETHOD(PowerUpPaused) 124 STDMETHOD(PowerDown) 122 STDMETHOD(PowerUp)(IProgress **aProgress); 123 STDMETHOD(PowerUpPaused)(IProgress **aProgress); 124 STDMETHOD(PowerDown)(IProgress **aProgress); 125 125 STDMETHOD(Reset)(); 126 126 STDMETHOD(Pause)(); … … 130 130 STDMETHOD(GetPowerButtonHandled)(BOOL *aHandled); 131 131 STDMETHOD(GetGuestEnteredACPIMode)(BOOL *aEntered); 132 STDMETHOD(SaveState) 133 STDMETHOD(AdoptSavedState) 132 STDMETHOD(SaveState)(IProgress **aProgress); 133 STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile); 134 134 STDMETHOD(ForgetSavedState)(BOOL aRemove); 135 STDMETHOD(GetDeviceActivity) 136 137 STDMETHOD(AttachUSBDevice) 138 STDMETHOD(DetachUSBDevice) 139 STDMETHOD(FindUSBDeviceByAddress) 140 STDMETHOD(FindUSBDeviceById) 141 STDMETHOD(CreateSharedFolder) 142 STDMETHOD(RemoveSharedFolder) 135 STDMETHOD(GetDeviceActivity)(DeviceType_T aDeviceType, 136 DeviceActivity_T *aDeviceActivity); 137 STDMETHOD(AttachUSBDevice)(IN_BSTR aId); 138 STDMETHOD(DetachUSBDevice)(IN_BSTR aId, IUSBDevice **aDevice); 139 STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IUSBDevice **aDevice); 140 STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IUSBDevice **aDevice); 141 STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable); 142 STDMETHOD(RemoveSharedFolder)(IN_BSTR aName); 143 143 STDMETHOD(TakeSnapshot)(IN_BSTR aName, IN_BSTR aDescription, 144 144 IProgress **aProgress); … … 146 146 STDMETHOD(RestoreSnapshot)(ISnapshot *aSnapshot, IProgress **aProgress); 147 147 STDMETHOD(Teleport)(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress); 148 STDMETHOD(RegisterCallback) 148 STDMETHOD(RegisterCallback)(IConsoleCallback *aCallback); 149 149 STDMETHOD(UnregisterCallback)(IConsoleCallback *aCallback); 150 150 … … 169 169 ConsoleVRDPServer *consoleVRDPServer() const { return mConsoleVRDPServer; } 170 170 171 HRESULT updateMachineState 171 HRESULT updateMachineState(MachineState_T aMachineState); 172 172 173 173 // events from IInternalSessionControl 174 HRESULT onNetworkAdapterChange 175 HRESULT onSerialPortChange 176 HRESULT onParallelPortChange 177 HRESULT onStorageControllerChange 174 HRESULT onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter); 175 HRESULT onSerialPortChange(ISerialPort *aSerialPort); 176 HRESULT onParallelPortChange(IParallelPort *aParallelPort); 177 HRESULT onStorageControllerChange(); 178 178 HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce); 179 179 HRESULT onCPUChange(ULONG aCPU, BOOL aRemove); 180 180 HRESULT onVRDPServerChange(); 181 181 HRESULT onUSBControllerChange(); 182 HRESULT onSharedFolderChange 183 HRESULT onUSBDeviceAttach 184 HRESULT onUSBDeviceDetach 185 HRESULT getGuestProperty 186 HRESULT setGuestProperty 187 HRESULT enumerateGuestProperties 182 HRESULT onSharedFolderChange(BOOL aGlobal); 183 HRESULT onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs); 184 HRESULT onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError); 185 HRESULT getGuestProperty(IN_BSTR aKey, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags); 186 HRESULT setGuestProperty(IN_BSTR aKey, IN_BSTR aValue, IN_BSTR aFlags); 187 HRESULT enumerateGuestProperties(IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags)); 188 188 VMMDev *getVMMDev() { return mVMMDev; } 189 AudioSniffer *getAudioSniffer 190 191 int VRDPClientLogon 192 void VRDPClientConnect 193 void VRDPClientDisconnect 194 void VRDPInterceptAudio 195 void VRDPInterceptUSB 196 void VRDPInterceptClipboard 197 198 void processRemoteUSBDevices 189 AudioSniffer *getAudioSniffer() { return mAudioSniffer; } 190 191 int VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain); 192 void VRDPClientConnect(uint32_t u32ClientId); 193 void VRDPClientDisconnect(uint32_t u32ClientId, uint32_t fu32Intercepted); 194 void VRDPInterceptAudio(uint32_t u32ClientId); 195 void VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept); 196 void VRDPInterceptClipboard(uint32_t u32ClientId); 197 198 void processRemoteUSBDevices(uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevList, uint32_t cbDevList); 199 199 200 200 // callback callers (partly; for some events console callbacks are notified … … 204 204 uint32_t width, uint32_t height, 205 205 void *pShape); 206 void onMouseCapabilityChange 207 void onStateChange 206 void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor); 207 void onStateChange(MachineState_T aMachineState); 208 208 void onAdditionsStateChange(); 209 209 void onAdditionsOutdated(); 210 void onKeyboardLedsChange 211 void onUSBDeviceStateChange 212 213 void onRuntimeError 214 HRESULT onShowWindow 210 void onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock); 211 void onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached, 212 IVirtualBoxErrorInfo *aError); 213 void onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage); 214 HRESULT onShowWindow(BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId); 215 215 void onRemoteDisplayInfoChange(); 216 216 … … 240 240 { 241 241 public: 242 AutoVMCallerBase (Console *aThat) : mThat (aThat), mRC(S_OK)242 AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(S_OK) 243 243 { 244 244 Assert(aThat); 245 mRC = aThat->addVMCaller 245 mRC = aThat->addVMCaller(taQuiet, taAllowNullVM); 246 246 } 247 247 ~AutoVMCallerBase() … … 262 262 { 263 263 AssertReturnVoid(!SUCCEEDED(mRC)); 264 mRC = mThat->addVMCaller 264 mRC = mThat->addVMCaller(taQuiet, taAllowNullVM); 265 265 } 266 266 /** Returns the result of Console::addVMCaller() */ … … 272 272 HRESULT mRC; 273 273 private: 274 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP 275 DECLARE_CLS_NEW_DELETE_NOOP 274 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase) 275 DECLARE_CLS_NEW_DELETE_NOOP(AutoVMCallerBase) 276 276 }; 277 277 … … 282 282 * with mpVM. The usage pattern is: 283 283 * <code> 284 * AutoVMCaller autoVMCaller 284 * AutoVMCaller autoVMCaller(this); 285 285 * if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc(); 286 286 * ... … … 326 326 typedef AutoVMCallerBase <taQuiet, true> Base; 327 327 public: 328 SafeVMPtrBase (Console *aThat) : Base (aThat), mpVM(NULL)328 SafeVMPtrBase(Console *aThat) : Base(aThat), mpVM(NULL) 329 329 { 330 330 if (SUCCEEDED(Base::mRC)) … … 337 337 private: 338 338 PVM mpVM; 339 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP 340 DECLARE_CLS_NEW_DELETE_NOOP 339 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase) 340 DECLARE_CLS_NEW_DELETE_NOOP(SafeVMPtrBase) 341 341 }; 342 342 … … 348 348 * destruction. Intended for Console children. The usage pattern is: 349 349 * <code> 350 * Console::SaveVMPtr pVM 350 * Console::SaveVMPtr pVM(mParent); 351 351 * if (FAILED(pVM.rc())) return pVM.rc(); 352 352 * ... 353 * VMR3ReqCall 353 * VMR3ReqCall(pVM, ... 354 354 * ... 355 * printf 355 * printf("%p\n", pVM.raw()); 356 356 * </code> 357 357 * … … 367 367 * failure to the caller. The usage pattern is: 368 368 * <code> 369 * Console::SaveVMPtrQuiet pVM 369 * Console::SaveVMPtrQuiet pVM(mParent); 370 370 * if (pVM.rc()) 371 * VMR3ReqCall 371 * VMR3ReqCall(pVM, ... 372 372 * return S_OK; 373 373 * </code> … … 384 384 SharedFolderData() {} 385 385 SharedFolderData(Bstr aHostPath, BOOL aWritable) 386 : mHostPath 387 , mWritable 386 : mHostPath(aHostPath) 387 , mWritable(aWritable) {} 388 388 SharedFolderData(const SharedFolderData& aThat) 389 : mHostPath 390 , mWritable 389 : mHostPath(aThat.mHostPath) 390 , mWritable(aThat.mWritable) {} 391 391 Bstr mHostPath; 392 392 BOOL mWritable; … … 400 400 typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList; 401 401 402 HRESULT addVMCaller 402 HRESULT addVMCaller(bool aQuiet = false, bool aAllowNullVM = false); 403 403 void releaseVMCaller(); 404 404 405 HRESULT consoleInitReleaseLog 406 407 HRESULT powerUp 408 HRESULT powerDown 405 HRESULT consoleInitReleaseLog(const ComPtr<IMachine> aMachine); 406 407 HRESULT powerUp(IProgress **aProgress, bool aPaused); 408 HRESULT powerDown(Progress *aProgress = NULL); 409 409 410 410 HRESULT callTapSetupApplication(bool isStatic, RTFILE tapFD, Bstr &tapDevice, … … 419 419 HRESULT setMachineStateLocally(MachineState_T aMachineState) 420 420 { 421 return setMachineState 421 return setMachineState(aMachineState, false /* aUpdateServer */); 422 422 } 423 423 424 HRESULT findSharedFolder 425 426 427 428 HRESULT fetchSharedFolders 429 bool findOtherSharedFolder 430 431 432 HRESULT createSharedFolder 433 HRESULT removeSharedFolder 424 HRESULT findSharedFolder(CBSTR aName, 425 ComObjPtr<SharedFolder> &aSharedFolder, 426 bool aSetError = false); 427 428 HRESULT fetchSharedFolders(BOOL aGlobal); 429 bool findOtherSharedFolder(IN_BSTR aName, 430 SharedFolderDataMap::const_iterator &aIt); 431 432 HRESULT createSharedFolder(CBSTR aName, SharedFolderData aData); 433 HRESULT removeSharedFolder(CBSTR aName); 434 434 435 435 static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole); 436 437 static int configMediumAttachment(PCFGMNODE pCtlInst, 438 const char *pcszDevice, 439 unsigned uInstance, 440 StorageBus_T enmBus, 441 IMediumAttachment *pMediumAtt, 442 MachineState_T aMachineState, 443 HRESULT *phrc, bool fAttachDetach, 444 bool fForceUnmount, PVM pVM, 445 DeviceType_T *paLedDevType); 446 static int configMedium(PCFGMNODE pLunL0, bool fPassthrough, 447 DeviceType_T enmType, IMedium *pMedium, 448 MachineState_T aMachineState, HRESULT *phrc); 449 static DECLCALLBACK(int) reconfigureMediumAttachment(PVM pVM, 450 const char *pcszDevice, 451 unsigned uInstance, 452 StorageBus_T enmBus, 453 IMediumAttachment *aMediumAtt, 454 MachineState_T aMachineState, 455 HRESULT *phrc); 456 static DECLCALLBACK(int) changeRemovableMedium(Console *pThis, 457 const char *pcszDevice, 458 unsigned uInstance, 459 StorageBus_T enmBus, 460 IMediumAttachment *aMediumAtt, 461 bool fForce); 462 463 int configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun, 464 INetworkAdapter *aNetworkAdapter, PCFGMNODE pCfg, 465 PCFGMNODE pLunL0, PCFGMNODE pInst, bool fAttachDetach); 466 436 467 static DECLCALLBACK(int) configGuestProperties(void *pvConsole); 437 468 static DECLCALLBACK(int) configGuestControl(void *pvConsole); 438 static int configNetwork(Console *pThis, const char *pszDevice,439 unsigned uInstance, unsigned uLun,440 INetworkAdapter *aNetworkAdapter,441 PCFGMNODE pCfg, PCFGMNODE pLunL0,442 PCFGMNODE pInst, bool fAttachDetach);443 469 static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState, 444 470 VMSTATE aOldState, void *aUser); 445 static DECLCALLBACK(int) changeDrive (Console *pThis, const char *pszDevice, 446 unsigned uInstance, unsigned uLun, 447 bool fHostDrive, const char *pszPath, 448 const char *pszFormat, bool fPassthrough, 449 bool fForce); 450 static DECLCALLBACK(int) unplugCpu (Console *pThis, unsigned uCpu); 451 static DECLCALLBACK(int) plugCpu (Console *pThis, unsigned uCpu); 471 static DECLCALLBACK(int) unplugCpu(Console *pThis, unsigned uCpu); 472 static DECLCALLBACK(int) plugCpu(Console *pThis, unsigned uCpu); 452 473 HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce); 453 474 HRESULT doCPURemove(ULONG aCpu); … … 455 476 456 477 #ifdef VBOX_DYNAMIC_NET_ATTACH 457 HRESULT doNetworkAdapterChange 458 459 static DECLCALLBACK(int) changeNetworkAttachment 460 461 478 HRESULT doNetworkAdapterChange(const char *pszDevice, unsigned uInstance, 479 unsigned uLun, INetworkAdapter *aNetworkAdapter); 480 static DECLCALLBACK(int) changeNetworkAttachment(Console *pThis, const char *pszDevice, 481 unsigned uInstance, unsigned uLun, 482 INetworkAdapter *aNetworkAdapter); 462 483 #endif /* VBOX_DYNAMIC_NET_ATTACH */ 463 484 464 485 #ifdef VBOX_WITH_USB 465 HRESULT attachUSBDevice 466 HRESULT detachUSBDevice 467 468 static DECLCALLBACK(int) usbAttachCallback 486 HRESULT attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs); 487 HRESULT detachUSBDevice(USBDeviceList::iterator &aIt); 488 489 static DECLCALLBACK(int) usbAttachCallback(Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid, 469 490 bool aRemote, const char *aAddress, ULONG aMaskedIfs); 470 static DECLCALLBACK(int) usbDetachCallback 491 static DECLCALLBACK(int) usbDetachCallback(Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid); 471 492 #endif 472 493 … … 478 499 const char *pszFormat, va_list args); 479 500 480 static DECLCALLBACK(void) setVMRuntimeErrorCallbackF 501 static DECLCALLBACK(void) setVMRuntimeErrorCallbackF(PVM pVM, void *pvUser, uint32_t fFatal, 481 502 const char *pszErrorId, 482 503 const char *pszFormat, ...); 483 static DECLCALLBACK(void) setVMRuntimeErrorCallback 504 static DECLCALLBACK(void) setVMRuntimeErrorCallback(PVM pVM, void *pvUser, uint32_t fFatal, 484 505 const char *pszErrorId, 485 506 const char *pszFormat, va_list va); 486 507 487 HRESULT captureUSBDevices 488 void detachAllUSBDevices 489 490 static DECLCALLBACK (int) powerUpThread(RTTHREAD Thread, void *pvUser);491 static DECLCALLBACK (int) saveStateThread(RTTHREAD Thread, void *pvUser);492 static DECLCALLBACK (int) powerDownThread(RTTHREAD Thread, void *pvUser);508 HRESULT captureUSBDevices(PVM pVM); 509 void detachAllUSBDevices(bool aDone); 510 511 static DECLCALLBACK(int) powerUpThread(RTTHREAD Thread, void *pvUser); 512 static DECLCALLBACK(int) saveStateThread(RTTHREAD Thread, void *pvUser); 513 static DECLCALLBACK(int) powerDownThread(RTTHREAD Thread, void *pvUser); 493 514 494 515 static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID); … … 505 526 506 527 HRESULT loadDataFromSavedState(); 507 int loadStateFileExecInternal 508 509 static DECLCALLBACK(void) saveStateFileExec 510 static DECLCALLBACK(int) loadStateFileExec 528 int loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version); 529 530 static DECLCALLBACK(void) saveStateFileExec(PSSMHANDLE pSSM, void *pvUser); 531 static DECLCALLBACK(int) loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass); 511 532 512 533 #ifdef VBOX_WITH_GUEST_PROPS … … 518 539 ComSafeArrayOut(BSTR, aFlags)); 519 540 520 bool enabledGuestPropertiesVRDP 521 void updateGuestPropertiesVRDPLogon 522 void updateGuestPropertiesVRDPDisconnect 541 bool enabledGuestPropertiesVRDP(void); 542 void updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain); 543 void updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId); 523 544 #endif 524 545
Note:
See TracChangeset
for help on using the changeset viewer.