VirtualBox

Ignore:
Timestamp:
Oct 17, 2023 9:37:49 AM (20 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159533
Message:

Main/ConsoleImpl: Move the guest debug configuration out of the x86 config constructor into a separate method in order to be able to use it from the Armv8 variant later on, bugref:10528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp

    r101462 r101464  
    40574057}
    40584058
     4059
     4060int Console::i_configUsb(ComPtr<IMachine> pMachine, BusAssignmentManager *pBusMgr, PCFGMNODE pRoot, PCFGMNODE pDevices,
     4061                         KeyboardHIDType_T enmKbdHid, PointingHIDType_T enmPointingHid, PCFGMNODE *ppUsbDevices)
     4062{
     4063    int vrc = VINF_SUCCESS;
     4064    PCFGMNODE pDev = NULL;          /* /Devices/Dev/ */
     4065    PCFGMNODE pInst = NULL;         /* /Devices/Dev/0/ */
     4066    PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
     4067    PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
     4068    PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
     4069
     4070    com::SafeIfaceArray<IUSBController> usbCtrls;
     4071    HRESULT hrc = pMachine->COMGETTER(USBControllers)(ComSafeArrayAsOutParam(usbCtrls));
     4072    bool fOhciPresent = false; /**< Flag whether at least one OHCI controller is present. */
     4073    bool fXhciPresent = false; /**< Flag whether at least one XHCI controller is present. */
     4074
     4075    if (SUCCEEDED(hrc))
     4076    {
     4077        for (size_t i = 0; i < usbCtrls.size(); ++i)
     4078        {
     4079            USBControllerType_T enmCtrlType;
     4080            vrc = usbCtrls[i]->COMGETTER(Type)(&enmCtrlType);                                  H();
     4081            if (enmCtrlType == USBControllerType_OHCI)
     4082            {
     4083                fOhciPresent = true;
     4084                break;
     4085            }
     4086            else if (enmCtrlType == USBControllerType_XHCI)
     4087            {
     4088                fXhciPresent = true;
     4089                break;
     4090            }
     4091        }
     4092    }
     4093    else if (hrc != E_NOTIMPL)
     4094    {
     4095        H();
     4096    }
     4097
     4098    /*
     4099     * Currently EHCI is only enabled when an OHCI or XHCI controller is present as well.
     4100     */
     4101    if (fOhciPresent || fXhciPresent)
     4102        mfVMHasUsbController = true;
     4103
     4104    if (mfVMHasUsbController)
     4105    {
     4106        for (size_t i = 0; i < usbCtrls.size(); ++i)
     4107        {
     4108            USBControllerType_T enmCtrlType;
     4109            vrc = usbCtrls[i]->COMGETTER(Type)(&enmCtrlType);                                  H();
     4110
     4111            if (enmCtrlType == USBControllerType_OHCI)
     4112            {
     4113                InsertConfigNode(pDevices, "usb-ohci", &pDev);
     4114                InsertConfigNode(pDev,     "0", &pInst);
     4115                InsertConfigNode(pInst,    "Config", &pCfg);
     4116                InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
     4117                hrc = pBusMgr->assignPCIDevice("usb-ohci", pInst);                          H();
     4118                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4119                InsertConfigString(pLunL0, "Driver",               "VUSBRootHub");
     4120                InsertConfigNode(pLunL0,   "Config", &pCfg);
     4121
     4122                /*
     4123                 * Attach the status driver.
     4124                 */
     4125                i_attachStatusDriver(pInst, DeviceType_USB);
     4126            }
     4127#ifdef VBOX_WITH_EHCI
     4128            else if (enmCtrlType == USBControllerType_EHCI)
     4129            {
     4130                InsertConfigNode(pDevices, "usb-ehci", &pDev);
     4131                InsertConfigNode(pDev,     "0", &pInst);
     4132                InsertConfigNode(pInst,    "Config", &pCfg);
     4133                InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
     4134                hrc = pBusMgr->assignPCIDevice("usb-ehci", pInst);                  H();
     4135
     4136                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4137                InsertConfigString(pLunL0, "Driver",               "VUSBRootHub");
     4138                InsertConfigNode(pLunL0,   "Config", &pCfg);
     4139
     4140                /*
     4141                 * Attach the status driver.
     4142                 */
     4143                i_attachStatusDriver(pInst, DeviceType_USB);
     4144            }
     4145#endif
     4146            else if (enmCtrlType == USBControllerType_XHCI)
     4147            {
     4148                InsertConfigNode(pDevices, "usb-xhci", &pDev);
     4149                InsertConfigNode(pDev,     "0", &pInst);
     4150                InsertConfigNode(pInst,    "Config", &pCfg);
     4151                InsertConfigInteger(pInst, "Trusted", 1); /* boolean */
     4152                hrc = pBusMgr->assignPCIDevice("usb-xhci", pInst);                  H();
     4153
     4154                InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4155                InsertConfigString(pLunL0, "Driver",               "VUSBRootHub");
     4156                InsertConfigNode(pLunL0,   "Config", &pCfg);
     4157
     4158                InsertConfigNode(pInst,    "LUN#1", &pLunL1);
     4159                InsertConfigString(pLunL1, "Driver",               "VUSBRootHub");
     4160                InsertConfigNode(pLunL1,   "Config", &pCfg);
     4161
     4162                /*
     4163                 * Attach the status driver.
     4164                 */
     4165                i_attachStatusDriver(pInst, DeviceType_USB, 2);
     4166            }
     4167        } /* for every USB controller. */
     4168
     4169
     4170        /*
     4171         * Virtual USB Devices.
     4172         */
     4173        PCFGMNODE pUsbDevices = NULL;
     4174        InsertConfigNode(pRoot, "USB", &pUsbDevices);
     4175        *ppUsbDevices = pUsbDevices;
     4176
     4177#ifdef VBOX_WITH_USB
     4178        {
     4179            /*
     4180             * Global USB options, currently unused as we'll apply the 2.0 -> 1.1 morphing
     4181             * on a per device level now.
     4182             */
     4183            InsertConfigNode(pUsbDevices, "USBProxy", &pCfg);
     4184            InsertConfigNode(pCfg, "GlobalConfig", &pCfg);
     4185            // This globally enables the 2.0 -> 1.1 device morphing of proxied devices to keep windows quiet.
     4186            //InsertConfigInteger(pCfg, "Force11Device", true);
     4187            // The following breaks stuff, but it makes MSDs work in vista. (I include it here so
     4188            // that it's documented somewhere.) Users needing it can use:
     4189            //      VBoxManage setextradata "myvm" "VBoxInternal/USB/USBProxy/GlobalConfig/Force11PacketSize" 1
     4190            //InsertConfigInteger(pCfg, "Force11PacketSize", true);
     4191        }
     4192#endif
     4193
     4194#ifdef VBOX_WITH_USB_CARDREADER
     4195        BOOL aEmulatedUSBCardReaderEnabled = FALSE;
     4196        hrc = pMachine->COMGETTER(EmulatedUSBCardReaderEnabled)(&aEmulatedUSBCardReaderEnabled);    H();
     4197        if (aEmulatedUSBCardReaderEnabled)
     4198        {
     4199            InsertConfigNode(pUsbDevices, "CardReader", &pDev);
     4200            InsertConfigNode(pDev,     "0", &pInst);
     4201            InsertConfigNode(pInst,    "Config", &pCfg);
     4202
     4203            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4204# ifdef VBOX_WITH_USB_CARDREADER_TEST
     4205            InsertConfigString(pLunL0, "Driver", "DrvDirectCardReader");
     4206            InsertConfigNode(pLunL0,   "Config", &pCfg);
     4207# else
     4208            InsertConfigString(pLunL0, "Driver", "UsbCardReader");
     4209            InsertConfigNode(pLunL0,   "Config", &pCfg);
     4210# endif
     4211         }
     4212#endif
     4213
     4214        /* Virtual USB Mouse/Tablet */
     4215        if (   enmPointingHid == PointingHIDType_USBMouse
     4216            || enmPointingHid == PointingHIDType_USBTablet
     4217            || enmPointingHid == PointingHIDType_USBMultiTouch
     4218            || enmPointingHid == PointingHIDType_USBMultiTouchScreenPlusPad)
     4219        {
     4220            InsertConfigNode(pUsbDevices, "HidMouse", &pDev);
     4221            InsertConfigNode(pDev,     "0", &pInst);
     4222            InsertConfigNode(pInst,    "Config", &pCfg);
     4223
     4224            if (enmPointingHid == PointingHIDType_USBMouse)
     4225                InsertConfigString(pCfg,   "Mode", "relative");
     4226            else
     4227                InsertConfigString(pCfg,   "Mode", "absolute");
     4228            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4229            InsertConfigString(pLunL0, "Driver",        "MouseQueue");
     4230            InsertConfigNode(pLunL0,   "Config", &pCfg);
     4231            InsertConfigInteger(pCfg,  "QueueSize",            128);
     4232
     4233            InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     4234            InsertConfigString(pLunL1, "Driver",        "MainMouse");
     4235        }
     4236        if (   enmPointingHid == PointingHIDType_USBMultiTouch
     4237            || enmPointingHid == PointingHIDType_USBMultiTouchScreenPlusPad)
     4238        {
     4239            InsertConfigNode(pDev,     "1", &pInst);
     4240            InsertConfigNode(pInst,    "Config", &pCfg);
     4241
     4242            InsertConfigString(pCfg,   "Mode", "multitouch");
     4243            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4244            InsertConfigString(pLunL0, "Driver",        "MouseQueue");
     4245            InsertConfigNode(pLunL0,   "Config", &pCfg);
     4246            InsertConfigInteger(pCfg,  "QueueSize",            128);
     4247
     4248            InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     4249            InsertConfigString(pLunL1, "Driver",        "MainMouse");
     4250        }
     4251        if (enmPointingHid == PointingHIDType_USBMultiTouchScreenPlusPad)
     4252        {
     4253            InsertConfigNode(pDev,     "2", &pInst);
     4254            InsertConfigNode(pInst,    "Config", &pCfg);
     4255
     4256            InsertConfigString(pCfg,   "Mode", "touchpad");
     4257            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4258            InsertConfigString(pLunL0, "Driver",        "MouseQueue");
     4259            InsertConfigNode(pLunL0,   "Config", &pCfg);
     4260            InsertConfigInteger(pCfg,  "QueueSize",            128);
     4261
     4262            InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     4263            InsertConfigString(pLunL1, "Driver",        "MainMouse");
     4264        }
     4265
     4266        /* Virtual USB Keyboard */
     4267        if (enmKbdHid == KeyboardHIDType_USBKeyboard)
     4268        {
     4269            InsertConfigNode(pUsbDevices, "HidKeyboard", &pDev);
     4270            InsertConfigNode(pDev,     "0", &pInst);
     4271            InsertConfigNode(pInst,    "Config", &pCfg);
     4272
     4273            InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     4274            InsertConfigString(pLunL0, "Driver",               "KeyboardQueue");
     4275            InsertConfigNode(pLunL0,   "Config", &pCfg);
     4276            InsertConfigInteger(pCfg,  "QueueSize",            64);
     4277
     4278            InsertConfigNode(pLunL0,   "AttachedDriver", &pLunL1);
     4279            InsertConfigString(pLunL1, "Driver",               "MainKeyboard");
     4280        }
     4281    }
     4282
     4283    return VINF_SUCCESS;
     4284}
     4285
     4286
     4287int Console::i_configGuestDbg(ComPtr<IVirtualBox> pVBox, ComPtr<IMachine> pMachine, PCFGMNODE pRoot)
     4288{
     4289    PCFGMNODE pDbgf;
     4290    InsertConfigNode(pRoot, "DBGF", &pDbgf);
     4291
     4292    /* Paths to search for debug info and such things. */
     4293    Bstr bstr;
     4294    HRESULT hrc = pMachine->COMGETTER(SettingsFilePath)(bstr.asOutParam());          H();
     4295    Utf8Str strSettingsPath(bstr);
     4296    bstr.setNull();
     4297    strSettingsPath.stripFilename();
     4298    strSettingsPath.append("/");
     4299
     4300    char szHomeDir[RTPATH_MAX + 1];
     4301    int vrc2 = RTPathUserHome(szHomeDir, sizeof(szHomeDir) - 1);
     4302    if (RT_FAILURE(vrc2))
     4303        szHomeDir[0] = '\0';
     4304    RTPathEnsureTrailingSeparator(szHomeDir, sizeof(szHomeDir));
     4305
     4306
     4307    Utf8Str strPath;
     4308    strPath.append(strSettingsPath).append("debug/;");
     4309    strPath.append(strSettingsPath).append(";");
     4310    strPath.append("cache*").append(strSettingsPath).append("dbgcache/;"); /* handy for symlinking to actual cache */
     4311    strPath.append(szHomeDir);
     4312
     4313    InsertConfigString(pDbgf, "Path", strPath.c_str());
     4314
     4315    /* Tracing configuration. */
     4316    BOOL fTracingEnabled;
     4317    hrc = pMachine->COMGETTER(TracingEnabled)(&fTracingEnabled);                    H();
     4318    if (fTracingEnabled)
     4319        InsertConfigInteger(pDbgf, "TracingEnabled", 1);
     4320
     4321    hrc = pMachine->COMGETTER(TracingConfig)(bstr.asOutParam());                    H();
     4322    if (fTracingEnabled)
     4323        InsertConfigString(pDbgf, "TracingConfig", bstr);
     4324
     4325    /* Debugger console config. */
     4326    PCFGMNODE pDbgc;
     4327    InsertConfigNode(pRoot, "DBGC", &pDbgc);
     4328
     4329    hrc = pVBox->COMGETTER(HomeFolder)(bstr.asOutParam());                          H();
     4330    Utf8Str strVBoxHome = bstr;
     4331    bstr.setNull();
     4332    if (strVBoxHome.isNotEmpty())
     4333        strVBoxHome.append("/");
     4334    else
     4335    {
     4336        strVBoxHome = szHomeDir;
     4337        strVBoxHome.append("/.vbox");
     4338    }
     4339
     4340    Utf8Str strFile(strVBoxHome);
     4341    strFile.append("dbgc-history");
     4342    InsertConfigString(pDbgc, "HistoryFile", strFile);
     4343
     4344    strFile = strSettingsPath;
     4345    strFile.append("dbgc-init");
     4346    InsertConfigString(pDbgc, "LocalInitScript", strFile);
     4347
     4348    strFile = strVBoxHome;
     4349    strFile.append("dbgc-init");
     4350    InsertConfigString(pDbgc, "GlobalInitScript", strFile);
     4351
     4352    /*
     4353     * Configure guest debug settings.
     4354     */
     4355    ComObjPtr<IGuestDebugControl> ptrGstDbgCtrl;
     4356    GuestDebugProvider_T enmGstDbgProvider = GuestDebugProvider_None;
     4357
     4358    hrc = pMachine->COMGETTER(GuestDebugControl)(ptrGstDbgCtrl.asOutParam());           H();
     4359    hrc = ptrGstDbgCtrl->COMGETTER(DebugProvider)(&enmGstDbgProvider);                  H();
     4360    if (enmGstDbgProvider != GuestDebugProvider_None)
     4361    {
     4362        GuestDebugIoProvider_T enmGstDbgIoProvider = GuestDebugIoProvider_None;
     4363        hrc = ptrGstDbgCtrl->COMGETTER(DebugIoProvider)(&enmGstDbgIoProvider);          H();
     4364        hrc = ptrGstDbgCtrl->COMGETTER(DebugAddress)(bstr.asOutParam());                H();
     4365        Utf8Str strAddress = bstr;
     4366        bstr.setNull();
     4367
     4368        ULONG ulPort = 0;
     4369        hrc = ptrGstDbgCtrl->COMGETTER(DebugPort)(&ulPort);                             H();
     4370
     4371        PCFGMNODE pDbgSettings;
     4372        InsertConfigNode(pDbgc, "Dbg", &pDbgSettings);
     4373        InsertConfigString(pDbgSettings, "Address", strAddress);
     4374        InsertConfigInteger(pDbgSettings, "Port", ulPort);
     4375
     4376        switch (enmGstDbgProvider)
     4377        {
     4378            case GuestDebugProvider_Native:
     4379                InsertConfigString(pDbgSettings, "StubType", "Native");
     4380                break;
     4381            case GuestDebugProvider_GDB:
     4382                InsertConfigString(pDbgSettings, "StubType", "Gdb");
     4383                break;
     4384            case GuestDebugProvider_KD:
     4385                InsertConfigString(pDbgSettings, "StubType", "Kd");
     4386                break;
     4387            default:
     4388                AssertFailed();
     4389                break;
     4390        }
     4391
     4392        switch (enmGstDbgIoProvider)
     4393        {
     4394            case GuestDebugIoProvider_TCP:
     4395                InsertConfigString(pDbgSettings, "Provider", "tcp");
     4396                break;
     4397            case GuestDebugIoProvider_UDP:
     4398                InsertConfigString(pDbgSettings, "Provider", "udp");
     4399                break;
     4400            case GuestDebugIoProvider_IPC:
     4401                InsertConfigString(pDbgSettings, "Provider", "ipc");
     4402                break;
     4403            default:
     4404                AssertFailed();
     4405                break;
     4406        }
     4407    }
     4408
     4409    return VINF_SUCCESS;
     4410}
     4411
     4412
    40594413#undef H
    40604414#undef VRC
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette