Changeset 106023 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Sep 12, 2024 9:46:01 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r105978 r106023 4648 4648 * Notify all the NAT drivers. 4649 4649 */ 4650 /** @todo r=bird: This is the worst way of "enumerating" network devices4651 * ever conceived. */4652 ComPtr<IPlatform> ptrPlatform;4653 hrc = mMachine->COMGETTER(Platform)(ptrPlatform.asOutParam());4654 AssertComRCReturn(hrc, hrc);4655 4656 ChipsetType_T enmChipsetType;4657 hrc = ptrPlatform->COMGETTER(ChipsetType)(&enmChipsetType);4658 AssertComRCReturn(hrc, hrc);4659 4660 4650 SafeVMPtrQuiet ptrVM(this); 4661 4651 if (ptrVM.isOk()) 4662 { 4663 ULONG const ulInstanceMax = PlatformProperties::s_getMaxNetworkAdapters(enmChipsetType); 4664 4665 notifyNatDnsChange(ptrVM.rawUVM(), ptrVM.vtable(), "pcnet", ulInstanceMax, &DnsConfig.Core); 4666 notifyNatDnsChange(ptrVM.rawUVM(), ptrVM.vtable(), "e1000", ulInstanceMax, &DnsConfig.Core); 4667 notifyNatDnsChange(ptrVM.rawUVM(), ptrVM.vtable(), "virtio-net", ulInstanceMax, &DnsConfig.Core); 4668 } 4652 ptrVM.vtable()->pfnPDMR3DriverEnumInstances(ptrVM.rawUVM(), "NAT", Console::notifyNatDnsChangeCallback, &DnsConfig.Core); 4669 4653 4670 4654 return S_OK; 4671 4655 } 4672 4656 4673 4674 /** 4675 * This routine walks over all network device instances, checking if 4676 * device instance has DrvNAT attachment and triggering DrvNAT DNS 4677 * change callback. 4678 */ 4679 void Console::notifyNatDnsChange(PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice, ULONG ulInstanceMax, 4680 PCPDMINETWORKNATDNSCONFIG pDnsConfig) 4681 { 4682 Log(("notifyNatDnsChange: looking for DrvNAT attachment on %s device instances\n", pszDevice)); 4683 for (ULONG ulInstance = 0; ulInstance < ulInstanceMax; ulInstance++) 4684 { 4685 PPDMIBASE pBase; 4686 int vrc = pVMM->pfnPDMR3QueryDriverOnLun(pUVM, pszDevice, ulInstance, 0 /* iLun */, "NAT", &pBase); 4687 if (RT_FAILURE(vrc)) 4688 continue; 4689 4690 Log(("Instance %s#%d has DrvNAT attachment; do actual notify\n", pszDevice, ulInstance)); 4691 if (pBase) 4692 { 4693 PPDMINETWORKNATCONFIG pNetNatCfg = NULL; 4694 pNetNatCfg = (PPDMINETWORKNATCONFIG)pBase->pfnQueryInterface(pBase, PDMINETWORKNATCONFIG_IID); 4695 if (pNetNatCfg && pNetNatCfg->pfnNotifyDnsChanged) 4696 pNetNatCfg->pfnNotifyDnsChanged(pNetNatCfg, pDnsConfig); 4697 } 4698 } 4699 } 4700 4657 /** 4658 * @callback_method_impl{FNPDMENUMDRVINS,Helper for Console::i_onNATDnsChanged.} 4659 */ 4660 /*static*/ DECLCALLBACK(int) 4661 Console::notifyNatDnsChangeCallback(PPDMIBASE pIBase, uint32_t uDrvInstance, bool fUsbDev, const char *pszDevice, 4662 uint32_t uDevInstance, unsigned uLun, void *pvUser) 4663 { 4664 PPDMINETWORKNATCONFIG const pINetNatCfg = (PPDMINETWORKNATCONFIG)pIBase->pfnQueryInterface(pIBase, PDMINETWORKNATCONFIG_IID); 4665 if (pINetNatCfg && pINetNatCfg->pfnNotifyDnsChanged) 4666 { 4667 LogFunc(("Notifying instance #%u attached to %s%s#%u on lun #%u...\n", 4668 uDrvInstance, fUsbDev ? "usb device " : "", pszDevice, uDevInstance, uLun)); 4669 pINetNatCfg->pfnNotifyDnsChanged(pINetNatCfg, (PCPDMINETWORKNATDNSCONFIG)pvUser); 4670 } 4671 else 4672 LogFunc(("Not notifying instance #%u attached to %s%s#%u on lun #%u: pINetNatCfg=%p pfnNotifyDnsChanged=%p\n", 4673 uDrvInstance, fUsbDev ? "usb device " : "", pszDevice, uDevInstance, uLun, 4674 pINetNatCfg, pINetNatCfg ? pINetNatCfg->pfnNotifyDnsChanged : NULL)); 4675 4676 RT_NOREF(uDrvInstance, fUsbDev, pszDevice, uDevInstance, uLun); 4677 return VINF_SUCCESS; 4678 } 4701 4679 4702 4680 VMMDevMouseInterface *Console::i_getVMMDevMouseInterface()
Note:
See TracChangeset
for help on using the changeset viewer.