Changeset 98097 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 16, 2023 9:50:10 PM (2 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r98095 r98097 709 709 void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue); 710 710 void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Bstr &rBstrValue); 711 void InsertConfigStringF(PCFGMNODE pNode, const char *pcszName, const char *pszFormat, ...); 711 712 void InsertConfigPassword(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue); 712 713 void InsertConfigBytes(PCFGMNODE pNode, const char *pcszName, const void *pvBytes, size_t cbBytes); 713 714 void InsertConfigInteger(PCFGMNODE pNode, const char *pcszName, uint64_t u64Integer); 714 715 void InsertConfigNode(PCFGMNODE pNode, const char *pcszName, PCFGMNODE *ppChild); 715 void InsertConfigNodeF(PCFGMNODE pNode, PCFGMNODE *ppChild, const char *pszNameFormat, ...) ;716 void InsertConfigNodeF(PCFGMNODE pNode, PCFGMNODE *ppChild, const char *pszNameFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4); 716 717 void RemoveConfigValue(PCFGMNODE pNode, const char *pcszName); 717 718 int SetBiosDiskInfo(ComPtr<IMachine> pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg, -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r98095 r98097 305 305 * Helper that calls CFGMR3InsertString and throws an RTCError if that 306 306 * fails (C-string variant). 307 * @param pNode See CFGMR3InsertString N.308 * @param pcszName See CFGMR3InsertString N.307 * @param pNode See CFGMR3InsertString. 308 * @param pcszName See CFGMR3InsertString. 309 309 * @param pcszValue The string value. 310 310 */ … … 342 342 InsertConfigString(pNode, pcszName, Utf8Str(rBstrValue)); 343 343 } 344 345 /** 346 * Helper that calls CFGMR3InsertStringFV and throws an RTCError if that fails. 347 * @param pNode See CFGMR3InsertStringF. 348 * @param pcszName See CFGMR3InsertStringF. 349 * @param pszFormat See CFGMR3InsertStringF. 350 * @param ... See CFGMR3InsertStringF. 351 */ 352 void Console::InsertConfigStringF(PCFGMNODE pNode, const char *pcszName, const char *pszFormat, ...) 353 { 354 va_list va; 355 va_start(va, pszFormat); 356 int vrc = mpVMM->pfnCFGMR3InsertStringFV(pNode, pcszName, pszFormat, va); 357 va_end(va); 358 if (RT_FAILURE(vrc)) 359 throw ConfigError("CFGMR3InsertStringFV", vrc, pcszName); 360 } 361 344 362 345 363 /** … … 607 625 for (size_t iDev = 0; iDev < assignments.size(); iDev++) 608 626 { 609 PCIBusAddress HostPCIAddress, GuestPCIAddress; 610 ComPtr<IPCIDeviceAttachment> assignment = assignments[iDev]; 611 LONG host, guest; 612 Bstr aDevName; 613 627 ComPtr<IPCIDeviceAttachment> const assignment = assignments[iDev]; 628 629 LONG host; 614 630 hrc = assignment->COMGETTER(HostAddress)(&host); H(); 631 LONG guest; 615 632 hrc = assignment->COMGETTER(GuestAddress)(&guest); H(); 616 hrc = assignment->COMGETTER(Name)(aDevName.asOutParam()); H(); 617 618 InsertConfigNode(pPCIDevs, Utf8StrFmt("%d", iDev).c_str(), &pInst); 633 Bstr bstrDevName; 634 hrc = assignment->COMGETTER(Name)(bstrDevName.asOutParam()); H(); 635 636 InsertConfigNodeF(pPCIDevs, &pInst, "%d", iDev); 619 637 InsertConfigInteger(pInst, "Trusted", 1); 620 638 621 HostPCIAddress.fromLong(host);639 PCIBusAddress HostPCIAddress(host); 622 640 Assert(HostPCIAddress.valid()); 623 641 InsertConfigNode(pInst, "Config", &pCfg); 624 InsertConfigString(pCfg, "DeviceName", aDevName);642 InsertConfigString(pCfg, "DeviceName", bstrDevName); 625 643 626 644 InsertConfigInteger(pCfg, "DetachHostDriver", 1); … … 629 647 InsertConfigInteger(pCfg, "HostPCIFunctionNo", HostPCIAddress.miFn); 630 648 631 GuestPCIAddress.fromLong(guest);649 PCIBusAddress GuestPCIAddress(guest); 632 650 Assert(GuestPCIAddress.valid()); 633 651 hrc = pBusMgr->assignHostPCIDevice("pciraw", pInst, HostPCIAddress, GuestPCIAddress, true); … … 647 665 InsertConfigString(pLunL1, "Driver", "MainPciRaw"); 648 666 InsertConfigNode(pLunL1, "Config", &pCfg); 649 PCIRawDev* pMainDev = new PCIRawDev(this); 667 PCIRawDev *pMainDev = new PCIRawDev(this); 668 # error This is not allowed any more 650 669 InsertConfigInteger(pCfg, "Object", (uintptr_t)pMainDev); 651 670 } … … 746 765 { 747 766 AssertPtr(pcszDevice); 748 Utf8StrFmt deviceInstance("%s/%u", pcszDevice, uInstance); 749 InsertConfigString(pCfg, "DeviceInstance", deviceInstance.c_str()); 767 InsertConfigStringF(pCfg, "DeviceInstance", "%s/%u", pcszDevice, uInstance); 750 768 } 751 769 InsertConfigInteger(pCfg, "First", 0); … … 1052 1070 Assert(pRoot); 1053 1071 1054 // InsertConfigString throws1072 // catching throws from InsertConfigString and friends. 1055 1073 try 1056 1074 { … … 3328 3346 InsertConfigNodeF(pInst, &pLunL0, "LUN#%u", idxAudioLun); 3329 3347 InsertConfigString(pLunL0, "Driver", "AUDIO"); 3330 AudioDriverCfg DrvCfgVRDE(pszAudioDevice, 0 /* Instance */, idxAudioLun, "AudioVRDE", 3331 !!fAudioEnabledIn, !!fAudioEnabledOut); 3332 vrc = mAudioVRDE->InitializeConfig(&DrvCfgVRDE); 3333 AssertRCStmt(vrc, throw ConfigError(__FUNCTION__, vrc, "mAudioVRDE->InitializeConfig failed")); 3348 { 3349 AudioDriverCfg DrvCfgVRDE(pszAudioDevice, 0 /* Instance */, idxAudioLun, "AudioVRDE", 3350 !!fAudioEnabledIn, !!fAudioEnabledOut); 3351 vrc = mAudioVRDE->InitializeConfig(&DrvCfgVRDE); 3352 AssertRCStmt(vrc, throw ConfigError(__FUNCTION__, vrc, "mAudioVRDE->InitializeConfig failed")); 3353 } 3334 3354 idxAudioLun++; 3335 3355 #endif … … 3339 3359 InsertConfigNodeF(pInst, &pLunL0, "LUN#%u", idxAudioLun); 3340 3360 InsertConfigString(pLunL0, "Driver", "AUDIO"); 3341 AudioDriverCfg DrvCfgVideoRec(pszAudioDevice, 0 /* Instance */, idxAudioLun, "AudioVideoRec", 3342 false /*a_fEnabledIn*/, true /*a_fEnabledOut*/); 3343 vrc = mRecording.mAudioRec->InitializeConfig(&DrvCfgVideoRec); 3344 AssertRCStmt(vrc, throw ConfigError(__FUNCTION__, vrc, "Recording.mAudioRec->InitializeConfig failed")); 3361 { 3362 AudioDriverCfg DrvCfgVideoRec(pszAudioDevice, 0 /* Instance */, idxAudioLun, "AudioVideoRec", 3363 false /*a_fEnabledIn*/, true /*a_fEnabledOut*/); 3364 vrc = mRecording.mAudioRec->InitializeConfig(&DrvCfgVideoRec); 3365 AssertRCStmt(vrc, throw ConfigError(__FUNCTION__, vrc, "Recording.mAudioRec->InitializeConfig failed")); 3366 } 3345 3367 idxAudioLun++; 3346 3368 #endif … … 3540 3562 case TpmType_v1_2: 3541 3563 case TpmType_v2_0: 3542 {3543 3564 InsertConfigString(pLunL0, "Driver", "TpmEmuTpms"); 3544 3565 InsertConfigNode(pLunL0, "Config", &pCfg); … … 3547 3568 InsertConfigString(pLunL1, "Driver", "NvramStore"); 3548 3569 break; 3549 }3550 3570 case TpmType_Host: 3551 {3552 3571 #if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS) 3553 3572 InsertConfigString(pLunL0, "Driver", "TpmHost"); … … 3555 3574 #endif 3556 3575 break; 3557 }3558 3576 case TpmType_Swtpm: 3559 { 3560 Bstr location; 3561 hrc = ptrTpm->COMGETTER(Location)(location.asOutParam()); H(); 3562 3577 hrc = ptrTpm->COMGETTER(Location)(bstr.asOutParam()); H(); 3563 3578 InsertConfigString(pLunL0, "Driver", "TpmEmu"); 3564 3579 InsertConfigNode(pLunL0, "Config", &pCfg); 3565 InsertConfigString(pCfg, "Location", location);3580 InsertConfigString(pCfg, "Location", bstr); 3566 3581 break; 3567 }3568 3582 default: 3569 3583 AssertFailedBreak(); … … 4396 4410 hrc = ptrBiosSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime); H(); 4397 4411 InsertConfigInteger(pCfg, "LogoTime", logoDisplayTime); 4398 Bstr logoImagePath;4399 hrc = ptrBiosSettings->COMGETTER(LogoImagePath)( logoImagePath.asOutParam());H();4400 InsertConfigString(pCfg, "LogoFile", Utf8Str(!logoImagePath.isEmpty() ? logoImagePath : ""));4412 Bstr bstrLogoImagePath; 4413 hrc = ptrBiosSettings->COMGETTER(LogoImagePath)(bstrLogoImagePath.asOutParam()); H(); 4414 InsertConfigString(pCfg, "LogoFile", bstrLogoImagePath); 4401 4415 4402 4416 /* … … 4953 4967 if (!fHotplug && !fAttachDetach) 4954 4968 { 4955 USBStorageDevice UsbMsd = USBStorageDevice();4969 USBStorageDevice UsbMsd; 4956 4970 4957 4971 UsbMsd.iPort = uInstance; … … 4959 4973 AssertRCReturn(vrc, vrc); 4960 4974 4961 char szUuid[RTUUID_STR_LENGTH + 1]; 4962 vrc = RTUuidToStr(&UsbMsd.mUuid, szUuid, sizeof(szUuid)); 4963 AssertRCReturn(vrc, vrc); 4964 InsertConfigString(pCtlInst, "UUID", szUuid); 4975 InsertConfigStringF(pCtlInst, "UUID", "%RTuuid", &UsbMsd.mUuid); 4965 4976 4966 4977 mUSBStorageDevices.push_back(UsbMsd); … … 5277 5288 InsertConfigNode(pCfg, "Plugins", &pCfgPlugins); 5278 5289 InsertConfigNode(pCfgPlugins, s_szVDPlugin, &pCfgPlugin); 5279 InsertConfigString(pCfgPlugin, "Path", strPlugin .c_str());5290 InsertConfigString(pCfgPlugin, "Path", strPlugin); 5280 5291 } 5281 5292 } … … 5423 5434 SafeArray<BSTR> aNames; 5424 5435 SafeArray<BSTR> aValues; 5425 HRESULT hrc = pMedium->GetProperties(NULL, ComSafeArrayAsOutParam(aNames), 5426 ComSafeArrayAsOutParam(aValues)); 5427 5436 HRESULT hrc = pMedium->GetProperties(NULL, ComSafeArrayAsOutParam(aNames), ComSafeArrayAsOutParam(aValues)); 5428 5437 if ( SUCCEEDED(hrc) 5429 5438 && aNames.size() != 0) … … 5435 5444 if (aValues[ii] && *aValues[ii]) 5436 5445 { 5437 Utf8Str name= aNames[ii];5438 Utf8Str value = aValues[ii];5439 size_t offSlash = name.find("/", 0);5440 if ( offSlash != name.npos5441 && ! name.startsWith("Special/"))5446 Utf8Str const strName = aNames[ii]; 5447 Utf8Str const strValue = aValues[ii]; 5448 size_t offSlash = strName.find("/", 0); 5449 if ( offSlash != strName.npos 5450 && !strName.startsWith("Special/")) 5442 5451 { 5443 5452 com::Utf8Str strFilter; 5444 com::Utf8Str strKey; 5445 5446 hrc = strFilter.assignEx(name, 0, offSlash); 5453 hrc = strFilter.assignEx(strName, 0, offSlash); 5447 5454 if (FAILED(hrc)) 5448 5455 break; 5449 5456 5450 hrc = strKey.assignEx(name, offSlash + 1, name.length() - offSlash - 1); /* Skip slash */ 5457 com::Utf8Str strKey; 5458 hrc = strKey.assignEx(strName, offSlash + 1, strName.length() - offSlash - 1); /* Skip slash */ 5451 5459 if (FAILED(hrc)) 5452 5460 break; … … 5456 5464 InsertConfigNode(pVDC, strFilter.c_str(), &pCfgFilterConfig); 5457 5465 5458 InsertConfigString(pCfgFilterConfig, strKey.c_str(), value);5466 InsertConfigString(pCfgFilterConfig, strKey.c_str(), strValue); 5459 5467 } 5460 5468 else 5461 5469 { 5462 InsertConfigString(pVDC, name.c_str(), value);5463 if ( name.compare("HostIPStack") == 05464 && value.compare("0") == 0)5470 InsertConfigString(pVDC, strName.c_str(), strValue); 5471 if ( strName.compare("HostIPStack") == 0 5472 && strValue.compare("0") == 0) 5465 5473 *pfHostIP = false; 5466 5474 } 5467 5475 5468 if ( name.compare("CRYPT/KeyId") == 05476 if ( strName.compare("CRYPT/KeyId") == 0 5469 5477 && pfEncrypted) 5470 5478 *pfEncrypted = true; … … 5479 5487 /** 5480 5488 * Configure proxy parameters the Network configuration tree. 5489 * 5481 5490 * Parameters may differ depending on the IP address being accessed. 5482 5491 * … … 5492 5501 int Console::i_configProxy(ComPtr<IVirtualBox> virtualBox, PCFGMNODE pCfg, const char *pcszPrefix, const com::Utf8Str &strIpAddr) 5493 5502 { 5503 /** @todo r=bird: This code doesn't handle cleanup correctly and may leak 5504 * when hitting errors or throwing exceptions (bad_alloc). */ 5494 5505 RTHTTPPROXYINFO ProxyInfo; 5495 5506 ComPtr<ISystemProperties> systemProperties; … … 5623 5634 } 5624 5635 5625 InsertConfigString( pCfg, Utf8StrFmt("%sProxyType",pcszPrefix).c_str(), pszProxyType);5626 InsertConfigInteger( pCfg, Utf8StrFmt("%sProxyPort",pcszPrefix).c_str(), ProxyInfo.uProxyPort);5636 InsertConfigString( pCfg, Utf8StrFmt("%sProxyType", pcszPrefix).c_str(), pszProxyType); 5637 InsertConfigInteger( pCfg, Utf8StrFmt("%sProxyPort", pcszPrefix).c_str(), ProxyInfo.uProxyPort); 5627 5638 if (ProxyInfo.pszProxyHost) 5628 InsertConfigString (pCfg, Utf8StrFmt("%sProxyHost", pcszPrefix).c_str(), Utf8StrFmt("%RTnaipv4", addr.uAddr.IPv4));5639 InsertConfigStringF( pCfg, Utf8StrFmt("%sProxyHost", pcszPrefix).c_str(), "%RTnaipv4", addr.uAddr.IPv4); 5629 5640 if (ProxyInfo.pszProxyUsername) 5630 InsertConfigString( pCfg, Utf8StrFmt("%sProxyUser",pcszPrefix).c_str(), ProxyInfo.pszProxyUsername);5641 InsertConfigString( pCfg, Utf8StrFmt("%sProxyUser", pcszPrefix).c_str(), ProxyInfo.pszProxyUsername); 5631 5642 if (ProxyInfo.pszProxyPassword) 5632 5643 InsertConfigPassword(pCfg, Utf8StrFmt("%sProxyPassword", pcszPrefix).c_str(), ProxyInfo.pszProxyPassword); … … 5789 5800 hrc = virtualBox->COMGETTER(HomeFolder)(bstr.asOutParam()); H(); 5790 5801 if (!bstr.isEmpty()) 5791 InsertConfigString (pCfg, "TFTPPrefix", Utf8StrFmt("%ls%c%s", bstr.raw(), RTPATH_DELIMITER, "TFTP"));5802 InsertConfigStringF(pCfg, "TFTPPrefix", "%ls%c%s", bstr.raw(), RTPATH_DELIMITER, "TFTP"); 5792 5803 hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H(); 5793 InsertConfigString (pCfg, "BootFile", Utf8StrFmt("%ls.pxe", bstr.raw()));5804 InsertConfigStringF(pCfg, "BootFile", "%ls.pxe", bstr.raw()); 5794 5805 5795 5806 hrc = natEngine->COMGETTER(Network)(bstr.asOutParam()); H(); … … 5800 5811 ULONG uSlot; 5801 5812 hrc = aNetworkAdapter->COMGETTER(Slot)(&uSlot); H(); 5802 InsertConfigString (pCfg, "Network", Utf8StrFmt("10.0.%d.0/24", uSlot+2));5813 InsertConfigStringF(pCfg, "Network", "10.0.%d.0/24", uSlot+2); 5803 5814 } 5804 5815 hrc = natEngine->COMGETTER(HostIP)(bstr.asOutParam()); H(); … … 5911 5922 continue; 5912 5923 5913 InsertConfigNode (pPFTree, Utf8StrFmt("%u", i).c_str(), &pPF);5924 InsertConfigNodeF(pPFTree, &pPF, "%u", i); 5914 5925 5915 5926 if (!strName.isEmpty()) … … 6656 6667 if (values[ii] && *values[ii]) 6657 6668 { 6658 Utf8Str name = names[ii];6659 Utf8Str value = values[ii];6660 InsertConfigString(pCfg, name.c_str(), value);6669 Utf8Str const strName(names[ii]); 6670 Utf8Str const strValue(values[ii]); 6671 InsertConfigString(pCfg, strName.c_str(), strValue); 6661 6672 } 6662 6673 } … … 6781 6792 InsertConfigString(pLunL0, "Driver", "VMNet"); 6782 6793 InsertConfigNode(pLunL0, "Config", &pCfg); 6783 // InsertConfigString(pCfg, "Trunk", Utf8Str(bstr).c_str());6784 // InsertConfigString (pCfg, "Network", BstrFmt("HostOnlyNetworking-%ls", bstr.raw()));6794 // InsertConfigString(pCfg, "Trunk", bstr); 6795 // InsertConfigStringF(pCfg, "Network", "HostOnlyNetworking-%ls", bstr.raw()); 6785 6796 InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetAdp); 6786 InsertConfigString(pCfg, "Id", Utf8Str(bstrId).c_str());6787 InsertConfigString(pCfg, "NetworkMask", Utf8Str(bstrNetMask).c_str());6788 InsertConfigString(pCfg, "LowerIP", Utf8Str(bstrLowerIP).c_str());6789 InsertConfigString(pCfg, "UpperIP", Utf8Str(bstrUpperIP).c_str());6797 InsertConfigString(pCfg, "Id", bstrId); 6798 InsertConfigString(pCfg, "NetworkMask", bstrNetMask); 6799 InsertConfigString(pCfg, "LowerIP", bstrLowerIP); 6800 InsertConfigString(pCfg, "UpperIP", bstrUpperIP); 6790 6801 // InsertConfigString(pCfg, "IfPolicyPromisc", pszPromiscuousGuestPolicy); 6791 6802 networkName.setNull(); // We do not want DHCP server on our network!
Note:
See TracChangeset
for help on using the changeset viewer.