Changeset 27324 in vbox for trunk/src/VBox/Main
- Timestamp:
- Mar 12, 2010 11:25:58 AM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl2.cpp
r27304 r27324 529 529 530 530 /* 531 * I/O settings (cach, max bandwidth, ...). 532 */ 533 PCFGMNODE pPDMAc; 534 PCFGMNODE pPDMAcFile; 535 rc = CFGMR3InsertNode(pPDM, "AsyncCompletion", &pPDMAc); RC_CHECK(); 536 rc = CFGMR3InsertNode(pPDMAc, "File", &pPDMAcFile); RC_CHECK(); 537 538 /* I/O manager type */ 539 IoMgrType_T ioMgrType; 540 hrc = pMachine->COMGETTER(IoMgr)(&ioMgrType); H(); 541 if (ioMgrType == IoMgrType_Async) 542 rc = CFGMR3InsertString(pPDMAcFile, "IoMgr", "Async"); 543 else if (ioMgrType == IoMgrType_Simple) 544 rc = CFGMR3InsertString(pPDMAcFile, "IoMgr", "Simple"); 545 else 546 rc = VERR_INVALID_PARAMETER; 547 RC_CHECK(); 548 549 /* I/O backend type */ 550 IoBackendType_T ioBackendType; 551 hrc = pMachine->COMGETTER(IoBackend)(&ioBackendType); H(); 552 if (ioBackendType == IoBackendType_Buffered) 553 rc = CFGMR3InsertString(pPDMAcFile, "FileBackend", "Buffered"); 554 else if (ioBackendType == IoBackendType_Unbuffered) 555 rc = CFGMR3InsertString(pPDMAcFile, "FileBackend", "NonBuffered"); 556 else 557 rc = VERR_INVALID_PARAMETER; 558 RC_CHECK(); 559 560 /* Builtin I/O cache */ 561 BOOL fIoCache = true; 562 hrc = pMachine->COMGETTER(IoCacheEnabled)(&fIoCache); H(); 563 rc = CFGMR3InsertInteger(pPDMAcFile, "CacheEnabled", fIoCache); RC_CHECK(); 564 565 /* I/O cache size */ 566 ULONG ioCacheSize = 5; 567 hrc = pMachine->COMGETTER(IoCacheSize)(&ioCacheSize); H(); 568 rc = CFGMR3InsertInteger(pPDMAcFile, "CacheSize", ioCacheSize * _1M); RC_CHECK(); 569 570 /* Maximum I/O bandwidth */ 571 ULONG ioBandwidthMax = 0; 572 hrc = pMachine->COMGETTER(IoBandwidthMax)(&ioBandwidthMax); H(); 573 if (ioBandwidthMax != 0) 574 { 575 rc = CFGMR3InsertInteger(pPDMAcFile, "VMTransferPerSecMax", ioBandwidthMax * _1M); RC_CHECK(); 576 } 577 578 /* 531 579 * Devices 532 580 */ -
trunk/src/VBox/Main/MachineImpl.cpp
r27256 r27324 202 202 for (size_t i = 0; i < RT_ELEMENTS(mCPUAttached); i++) 203 203 mCPUAttached[i] = false; 204 205 mIoMgrType = IoMgrType_Async; 206 #if defined(RT_OS_LINUX) 207 mIoBackendType = IoBackendType_Unbuffered; 208 #else 209 mIoBackendType = IoBackendType_Buffered; 210 #endif 211 mIoCacheEnabled = true; 212 mIoCacheSize = 5; /* 5MB */ 213 mIoBandwidthMax = 0; /* Unlimited */ 204 214 } 205 215 … … 2371 2381 mUserData.backup(); 2372 2382 mUserData->mRTCUseUTC = aEnabled; 2383 2384 return S_OK; 2385 } 2386 2387 STDMETHODIMP Machine::COMGETTER(IoMgr)(IoMgrType_T *aIoMgrType) 2388 { 2389 CheckComArgOutPointerValid(aIoMgrType); 2390 2391 AutoCaller autoCaller(this); 2392 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2393 2394 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2395 2396 *aIoMgrType = mHWData->mIoMgrType; 2397 2398 return S_OK; 2399 } 2400 2401 STDMETHODIMP Machine::COMSETTER(IoMgr)(IoMgrType_T aIoMgrType) 2402 { 2403 if ( aIoMgrType != IoMgrType_Async 2404 && aIoMgrType != IoMgrType_Simple) 2405 return E_INVALIDARG; 2406 2407 AutoCaller autoCaller(this); 2408 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2409 2410 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2411 2412 HRESULT rc = checkStateDependency(MutableStateDep); 2413 if (FAILED(rc)) return rc; 2414 2415 setModified(IsModified_MachineData); 2416 mHWData.backup(); 2417 mHWData->mIoMgrType = aIoMgrType; 2418 2419 return S_OK; 2420 } 2421 2422 STDMETHODIMP Machine::COMGETTER(IoBackend)(IoBackendType_T *aIoBackendType) 2423 { 2424 CheckComArgOutPointerValid(aIoBackendType); 2425 2426 AutoCaller autoCaller(this); 2427 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2428 2429 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2430 2431 *aIoBackendType = mHWData->mIoBackendType; 2432 2433 return S_OK; 2434 } 2435 2436 STDMETHODIMP Machine::COMSETTER(IoBackend)(IoBackendType_T aIoBackendType) 2437 { 2438 if ( aIoBackendType != IoBackendType_Buffered 2439 && aIoBackendType != IoBackendType_Unbuffered) 2440 return E_INVALIDARG; 2441 2442 AutoCaller autoCaller(this); 2443 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2444 2445 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2446 2447 HRESULT rc = checkStateDependency(MutableStateDep); 2448 if (FAILED(rc)) return rc; 2449 2450 setModified(IsModified_MachineData); 2451 mHWData.backup(); 2452 mHWData->mIoBackendType = aIoBackendType; 2453 2454 return S_OK; 2455 } 2456 2457 STDMETHODIMP Machine::COMGETTER(IoCacheEnabled)(BOOL *aEnabled) 2458 { 2459 CheckComArgOutPointerValid(aEnabled); 2460 2461 AutoCaller autoCaller(this); 2462 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2463 2464 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2465 2466 *aEnabled = mHWData->mIoCacheEnabled; 2467 2468 return S_OK; 2469 } 2470 2471 STDMETHODIMP Machine::COMSETTER(IoCacheEnabled)(BOOL aEnabled) 2472 { 2473 AutoCaller autoCaller(this); 2474 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2475 2476 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2477 2478 HRESULT rc = checkStateDependency(MutableStateDep); 2479 if (FAILED(rc)) return rc; 2480 2481 setModified(IsModified_MachineData); 2482 mHWData.backup(); 2483 mHWData->mIoCacheEnabled = aEnabled; 2484 2485 return S_OK; 2486 } 2487 2488 STDMETHODIMP Machine::COMGETTER(IoCacheSize)(ULONG *aIoCacheSize) 2489 { 2490 CheckComArgOutPointerValid(aIoCacheSize); 2491 2492 AutoCaller autoCaller(this); 2493 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2494 2495 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2496 2497 *aIoCacheSize = mHWData->mIoCacheSize; 2498 2499 return S_OK; 2500 } 2501 2502 STDMETHODIMP Machine::COMSETTER(IoCacheSize)(ULONG aIoCacheSize) 2503 { 2504 AutoCaller autoCaller(this); 2505 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2506 2507 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2508 2509 HRESULT rc = checkStateDependency(MutableStateDep); 2510 if (FAILED(rc)) return rc; 2511 2512 setModified(IsModified_MachineData); 2513 mHWData.backup(); 2514 mHWData->mIoCacheSize = aIoCacheSize; 2515 2516 return S_OK; 2517 } 2518 2519 STDMETHODIMP Machine::COMGETTER(IoBandwidthMax)(ULONG *aIoBandwidthMax) 2520 { 2521 CheckComArgOutPointerValid(aIoBandwidthMax); 2522 2523 AutoCaller autoCaller(this); 2524 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2525 2526 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2527 2528 *aIoBandwidthMax = mHWData->mIoBandwidthMax; 2529 2530 return S_OK; 2531 } 2532 2533 STDMETHODIMP Machine::COMSETTER(IoBandwidthMax)(ULONG aIoBandwidthMax) 2534 { 2535 AutoCaller autoCaller(this); 2536 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2537 2538 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2539 2540 HRESULT rc = checkStateDependency(MutableStateDep); 2541 if (FAILED(rc)) return rc; 2542 2543 setModified(IsModified_MachineData); 2544 mHWData.backup(); 2545 mHWData->mIoBandwidthMax = aIoBandwidthMax; 2373 2546 2374 2547 return S_OK; … … 6409 6582 mHWData->mStatisticsUpdateInterval = data.ulStatisticsUpdateInterval; 6410 6583 6584 // IO settings 6585 mHWData->mIoMgrType = data.ioSettings.ioMgrType; 6586 mHWData->mIoBackendType = data.ioSettings.ioBackendType; 6587 mHWData->mIoCacheEnabled = data.ioSettings.fIoCacheEnabled; 6588 mHWData->mIoCacheSize = data.ioSettings.ulIoCacheSize; 6589 mHWData->mIoBandwidthMax = data.ioSettings.ulIoBandwidthMax; 6590 6411 6591 #ifdef VBOX_WITH_GUEST_PROPS 6412 6592 /* Guest properties (optional) */ … … 7434 7614 data.ulMemoryBalloonSize = mHWData->mMemoryBalloonSize; 7435 7615 data.ulStatisticsUpdateInterval = mHWData->mStatisticsUpdateInterval; 7616 7617 // IO settings 7618 data.ioSettings.ioMgrType = mHWData->mIoMgrType; 7619 data.ioSettings.ioBackendType = mHWData->mIoBackendType; 7620 data.ioSettings.fIoCacheEnabled = mHWData->mIoCacheEnabled; 7621 data.ioSettings.ulIoCacheSize = mHWData->mIoCacheSize; 7622 data.ioSettings.ulIoBandwidthMax = mHWData->mIoBandwidthMax; 7436 7623 7437 7624 // guest properties -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r27166 r27324 1178 1178 </enum> 1179 1179 1180 1180 <enum 1181 name="IoMgrType" 1182 uuid="35567419-4d2a-4256-a74e-efcae33493a2" 1183 > 1184 <desc> 1185 Type of the I/O manager used for the image files in a virtual machine. 1186 </desc> 1187 <const name="Simple" value="1"> 1188 <desc>Simple manager. Normally only used if the default one runs into an 1189 error. </desc> 1190 </const> 1191 <const name="Async" value="2"> 1192 <desc>Asynchronous manager using the async I/O API on the host if present. 1193 This is the default manager.</desc> 1194 </const> 1195 </enum> 1196 1197 <enum 1198 name="IoBackendType" 1199 uuid="2a7e16d1-4e6b-4d5d-b0c9-b9bbe6c5b2ad" 1200 > 1201 <desc> 1202 Type of I/O backend used for the image files in a virtual machine. 1203 </desc> 1204 <const name="Buffered" value="1"> 1205 <desc>Image files will use the host cache if possible. 1206 This type does not work with the Async I/O manager on Linux hosts. 1207 Default on all hosts except Linux.</desc> 1208 </const> 1209 <const name="Unbuffered" value="2"> 1210 <desc>Image files will not use the host cache. 1211 This should be used on OS X and Linux hosts if a high I/O load is expected 1212 or many virtual machines are running to prevent I/O cache 1213 related hangs. Default on Linux hosts.</desc> 1214 </const> 1215 </enum> 1181 1216 1182 1217 <!-- … … 4232 4267 <interface 4233 4268 name="IMachine" extends="$unknown" 4234 uuid=" f2816298-7408-4c44-a117-0ed8ea09b9bc"4269 uuid="8d8f6fbb-54c1-4604-b68e-17619d458611" 4235 4270 wsmap="managed" 4236 4271 > … … 4771 4806 </attribute> 4772 4807 4808 <attribute name="ioMgr" type="IoMgrType"> 4809 <desc> 4810 Selects the I/O manager to use for the virtual machine. 4811 </desc> 4812 </attribute> 4813 4814 <attribute name="ioBackend" type="IoBackendType"> 4815 <desc> 4816 Selects the I/O backend to use for the virtual machine. 4817 </desc> 4818 </attribute> 4819 4820 <attribute name="ioCacheEnabled" type="boolean"> 4821 <desc> 4822 When set to @a true, the builtin I/O cache of the virtual machine 4823 will be enabled. 4824 </desc> 4825 </attribute> 4826 4827 <attribute name="ioCacheSize" type="unsigned long"> 4828 <desc> 4829 Maximum size of the I/O cache in MB. 4830 </desc> 4831 </attribute> 4832 4833 <attribute name="ioBandwidthMax" type="unsigned long"> 4834 <desc> 4835 The maximum number of MB the VM is allowed to transfer per second. 4836 0 means unlimited bandwidth. 4837 </desc> 4838 </attribute> 4839 4773 4840 <method name="setBootOrder"> 4774 4841 <desc> -
trunk/src/VBox/Main/include/MachineImpl.h
r27256 r27324 305 305 KeyboardHidType_T mKeyboardHidType; 306 306 PointingHidType_T mPointingHidType; 307 308 IoMgrType_T mIoMgrType; 309 IoBackendType_T mIoBackendType; 310 BOOL mIoCacheEnabled; 311 ULONG mIoCacheSize; 312 ULONG mIoBandwidthMax; 307 313 }; 308 314 … … 433 439 STDMETHOD(COMGETTER(PointingHidType)) (PointingHidType_T *aPointingHidType); 434 440 STDMETHOD(COMSETTER(PointingHidType)) (PointingHidType_T aPointingHidType); 441 STDMETHOD(COMGETTER(IoMgr)) (IoMgrType_T *aIoMgrType); 442 STDMETHOD(COMSETTER(IoMgr)) (IoMgrType_T aIoMgrType); 443 STDMETHOD(COMGETTER(IoBackend)) (IoBackendType_T *aIoBackendType); 444 STDMETHOD(COMSETTER(IoBackend)) (IoBackendType_T aIoBackendType); 445 STDMETHOD(COMGETTER(IoCacheEnabled)) (BOOL *aEnabled); 446 STDMETHOD(COMSETTER(IoCacheEnabled)) (BOOL aEnabled); 447 STDMETHOD(COMGETTER(IoCacheSize)) (ULONG *aIoCacheSize); 448 STDMETHOD(COMSETTER(IoCacheSize)) (ULONG aIoCacheSize); 449 STDMETHOD(COMGETTER(IoBandwidthMax)) (ULONG *aIoBandwidthMax); 450 STDMETHOD(COMSETTER(IoBandwidthMax)) (ULONG aIoBandwidthMax); 435 451 436 452 // IMachine methods -
trunk/src/VBox/Main/xml/Settings.cpp
r27171 r27324 1613 1613 } 1614 1614 1615 /** 1616 * IoSettings constructor. 1617 */ 1618 IoSettings::IoSettings() 1619 { 1620 ioMgrType = IoMgrType_Async; 1621 #if defined(RT_OS_LINUX) 1622 ioBackendType = IoBackendType_Unbuffered; 1623 #else 1624 ioBackendType = IoBackendType_Buffered; 1625 #endif 1626 fIoCacheEnabled = true; 1627 ulIoCacheSize = 5; 1628 ulIoBandwidthMax = 0; 1629 }; 1630 1615 1631 //////////////////////////////////////////////////////////////////////////////// 1616 1632 // … … 2354 2370 hw.clipboardMode = ClipboardMode_Bidirectional; 2355 2371 else 2356 throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in Clipbo rd/@mode attribute"), strTemp.c_str());2372 throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in Clipboard/@mode attribute"), strTemp.c_str()); 2357 2373 } 2358 2374 } … … 2366 2382 else if (pelmHwChild->nameEquals("GuestProperties")) 2367 2383 readGuestProperties(*pelmHwChild, hw); 2384 else if (pelmHwChild->nameEquals("IO")) 2385 { 2386 Utf8Str strTemp; 2387 const xml::ElementNode *pelmIoChild; 2388 2389 if ((pelmIoChild = pelmHwChild->findChildElement("IoMgr"))) 2390 { 2391 if (pelmIoChild->getAttributeValue("type", strTemp)) 2392 { 2393 if (strTemp == "Async") 2394 hw.ioSettings.ioMgrType = IoMgrType_Async; 2395 else if (strTemp == "Simple") 2396 hw.ioSettings.ioMgrType = IoMgrType_Simple; 2397 else 2398 throw ConfigFileError(this, pelmIoChild, N_("Invalid value '%s' in IoMgr/@type attribute"), strTemp.c_str()); 2399 } 2400 } 2401 2402 if ((pelmIoChild = pelmHwChild->findChildElement("IoBackend"))) 2403 { 2404 if (pelmIoChild->getAttributeValue("type", strTemp)) 2405 { 2406 if (strTemp == "Unbuffered") 2407 hw.ioSettings.ioBackendType = IoBackendType_Unbuffered; 2408 else if (strTemp == "Buffered") 2409 hw.ioSettings.ioBackendType = IoBackendType_Buffered; 2410 else 2411 throw ConfigFileError(this, pelmIoChild, N_("Invalid value '%s' in IoBackend/@type attribute"), strTemp.c_str()); 2412 } 2413 } 2414 if ((pelmIoChild = pelmHwChild->findChildElement("IoCache"))) 2415 { 2416 pelmIoChild->getAttributeValue("enabled", hw.ioSettings.fIoCacheEnabled); 2417 pelmIoChild->getAttributeValue("size", hw.ioSettings.ulIoCacheSize); 2418 } 2419 if ((pelmIoChild = pelmHwChild->findChildElement("IoBandwidth"))) 2420 { 2421 pelmIoChild->getAttributeValue("max", hw.ioSettings.ulIoBandwidthMax); 2422 } 2423 } 2368 2424 } 2369 2425 … … 3313 3369 pelmClip->setAttribute("mode", pcszClip); 3314 3370 3371 if (m->sv >= SettingsVersion_v1_10) 3372 { 3373 xml::ElementNode *pelmIo = pelmHardware->createChild("IO"); 3374 xml::ElementNode *pelmIoCache; 3375 xml::ElementNode *pelmIoBandwidth; 3376 const char *pcszTemp; 3377 3378 switch (hw.ioSettings.ioMgrType) 3379 { 3380 case IoMgrType_Simple: pcszTemp = "Simple"; break; 3381 case IoMgrType_Async: 3382 default: 3383 pcszTemp = "Async"; break; 3384 } 3385 3386 pelmIo->createChild("IoMgr")->setAttribute("type", pcszTemp); 3387 3388 switch (hw.ioSettings.ioBackendType) 3389 { 3390 case IoBackendType_Buffered: pcszTemp = "Buffered"; break; 3391 case IoBackendType_Unbuffered: 3392 default: 3393 pcszTemp = "Unbuffered"; break; 3394 } 3395 3396 pelmIo->createChild("IoBackend")->setAttribute("type", pcszTemp); 3397 3398 pelmIoCache = pelmIo->createChild("IoCache"); 3399 pelmIoCache->setAttribute("enabled", hw.ioSettings.fIoCacheEnabled); 3400 pelmIoCache->setAttribute("size", hw.ioSettings.ulIoCacheSize); 3401 pelmIoBandwidth = pelmIo->createChild("IoBandwidth"); 3402 pelmIoBandwidth->setAttribute("max", hw.ioSettings.ulIoBandwidthMax); 3403 } 3404 3315 3405 xml::ElementNode *pelmGuest = pelmHardware->createChild("Guest"); 3316 3406 pelmGuest->setAttribute("memoryBalloonSize", hw.ulMemoryBalloonSize); … … 3586 3676 ) 3587 3677 m->sv = SettingsVersion_v1_10; 3678 3679 // Check for non default I/O settings and bump the settings version. 3680 if (m->sv < SettingsVersion_v1_10) 3681 { 3682 if ( hardwareMachine.ioSettings.fIoCacheEnabled != true 3683 || hardwareMachine.ioSettings.ulIoCacheSize != 5 3684 || hardwareMachine.ioSettings.ulIoBandwidthMax != 0 3685 || hardwareMachine.ioSettings.ioMgrType != IoMgrType_Async) 3686 m->sv = SettingsVersion_v1_10; 3687 3688 #if defined(RT_OS_LINUX) 3689 if (hardwareMachine.ioSettings.ioBackendType != IoBackendType_Unbuffered) 3690 m->sv = SettingsVersion_v1_10; 3691 #else 3692 if (hardwareMachine.ioSettings.ioBackendType != IoBackendType_Buffered) 3693 m->sv = SettingsVersion_v1_10; 3694 #endif 3695 } 3588 3696 } 3589 3697
Note:
See TracChangeset
for help on using the changeset viewer.