VirtualBox

Changeset 101459 in vbox for trunk/src


Ignore:
Timestamp:
Oct 17, 2023 8:26:12 AM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159528
Message:

Main/ConsoleImpl: Move the VMM device 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

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r101458 r101459  
    838838    int i_configAudioCtrl(ComPtr<IVirtualBox> pVBox, ComPtr<IMachine> pMachine, BusAssignmentManager *pBusMgr, PCFGMNODE pDevices,
    839839                          bool fOsXGuest, bool *pfAudioEnabled);
     840    int i_configVmmDev(ComPtr<IMachine> pMachine, BusAssignmentManager *pBusMgr, PCFGMNODE pDevices);
    840841
    841842    static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState,
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp

    r101458 r101459  
    4848#include "NvramStoreImpl.h"
    4949#include "BusAssignmentManager.h"
     50#ifdef VBOX_WITH_SHARED_CLIPBOARD
     51# include "GuestShClPrivate.h"
     52#endif
    5053#ifdef VBOX_WITH_DRAG_AND_DROP
    5154# include "GuestImpl.h"
     
    38173820}
    38183821
     3822
     3823int Console::i_configVmmDev(ComPtr<IMachine> pMachine, BusAssignmentManager *pBusMgr, PCFGMNODE pDevices)
     3824{
     3825    VMMDev *pVMMDev = m_pVMMDev; Assert(pVMMDev);
     3826
     3827    int vrc = VINF_SUCCESS;
     3828    PCFGMNODE pDev = NULL;          /* /Devices/Dev/ */
     3829    PCFGMNODE pInst = NULL;         /* /Devices/Dev/0/ */
     3830    PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
     3831    PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
     3832
     3833    /*
     3834     * VMM Device
     3835     */
     3836    InsertConfigNode(pDevices, "VMMDev", &pDev);
     3837    InsertConfigNode(pDev,     "0", &pInst);
     3838    InsertConfigNode(pInst,    "Config", &pCfg);
     3839    InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
     3840    HRESULT hrc = pBusMgr->assignPCIDevice("VMMDev", pInst);                            H();
     3841
     3842    Bstr hwVersion;
     3843    hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam());                 H();
     3844    if (hwVersion.compare(Bstr("1").raw()) == 0) /* <= 2.0.x */
     3845        InsertConfigInteger(pCfg, "HeapEnabled", 0);
     3846    Bstr snapshotFolder;
     3847    hrc = pMachine->COMGETTER(SnapshotFolder)(snapshotFolder.asOutParam());             H();
     3848    InsertConfigString(pCfg, "GuestCoreDumpDir", snapshotFolder);
     3849
     3850    /* the VMM device's Main driver */
     3851    InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     3852    InsertConfigString(pLunL0, "Driver",               "HGCM");
     3853    InsertConfigNode(pLunL0,   "Config", &pCfg);
     3854
     3855    /*
     3856     * Attach the status driver.
     3857     */
     3858    i_attachStatusDriver(pInst, DeviceType_SharedFolder);
     3859
     3860#ifdef VBOX_WITH_SHARED_CLIPBOARD
     3861    /*
     3862     * Shared Clipboard.
     3863     */
     3864    {
     3865        ClipboardMode_T enmClipboardMode = ClipboardMode_Disabled;
     3866        hrc = pMachine->COMGETTER(ClipboardMode)(&enmClipboardMode); H();
     3867# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     3868        BOOL fFileTransfersEnabled;
     3869        hrc = pMachine->COMGETTER(ClipboardFileTransfersEnabled)(&fFileTransfersEnabled); H();
     3870#endif
     3871
     3872        /* Load the service */
     3873        vrc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");
     3874        if (RT_SUCCESS(vrc))
     3875        {
     3876            LogRel(("Shared Clipboard: Service loaded\n"));
     3877
     3878            /* Set initial clipboard mode. */
     3879            vrc = i_changeClipboardMode(enmClipboardMode);
     3880            AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial clipboard mode (%d): vrc=%Rrc\n",
     3881                                             enmClipboardMode, vrc));
     3882
     3883            /* Setup the service. */
     3884            VBOXHGCMSVCPARM parm;
     3885            HGCMSvcSetU32(&parm, !i_useHostClipboard());
     3886            vrc = pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHCL_HOST_FN_SET_HEADLESS, 1, &parm);
     3887            AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial headless mode (%RTbool): vrc=%Rrc\n",
     3888                                             !i_useHostClipboard(), vrc));
     3889
     3890# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     3891            vrc = i_changeClipboardFileTransferMode(RT_BOOL(fFileTransfersEnabled));
     3892            AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial file transfer mode (%u): vrc=%Rrc\n",
     3893                                             fFileTransfersEnabled, vrc));
     3894# endif
     3895            GuestShCl::createInstance(this /* pConsole */);
     3896            vrc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtShCl, "VBoxSharedClipboard",
     3897                                                   &GuestShCl::hgcmDispatcher,
     3898                                                   GuestShClInst());
     3899            if (RT_FAILURE(vrc))
     3900                Log(("Cannot register VBoxSharedClipboard extension, vrc=%Rrc\n", vrc));
     3901        }
     3902        else
     3903            LogRel(("Shared Clipboard: Not available, vrc=%Rrc\n", vrc));
     3904        vrc = VINF_SUCCESS;  /* None of the potential failures above are fatal. */
     3905    }
     3906#endif /* VBOX_WITH_SHARED_CLIPBOARD */
     3907
     3908    /*
     3909     * HGCM HostChannel.
     3910     */
     3911    {
     3912        Bstr value;
     3913        hrc = pMachine->GetExtraData(Bstr("HGCM/HostChannel").raw(),
     3914                                     value.asOutParam());
     3915
     3916        if (   hrc   == S_OK
     3917            && value == "1")
     3918        {
     3919            vrc = pVMMDev->hgcmLoadService("VBoxHostChannel", "VBoxHostChannel");
     3920            if (RT_FAILURE(vrc))
     3921            {
     3922                LogRel(("VBoxHostChannel is not available, vrc=%Rrc\n", vrc));
     3923                /* That is not a fatal failure. */
     3924                vrc = VINF_SUCCESS;
     3925            }
     3926        }
     3927    }
     3928
     3929#ifdef VBOX_WITH_DRAG_AND_DROP
     3930    /*
     3931     * Drag and Drop.
     3932     */
     3933    {
     3934        DnDMode_T enmMode = DnDMode_Disabled;
     3935        hrc = pMachine->COMGETTER(DnDMode)(&enmMode);                                   H();
     3936
     3937        /* Load the service */
     3938        vrc = pVMMDev->hgcmLoadService("VBoxDragAndDropSvc", "VBoxDragAndDropSvc");
     3939        if (RT_FAILURE(vrc))
     3940        {
     3941            LogRel(("Drag and drop service is not available, vrc=%Rrc\n", vrc));
     3942            /* That is not a fatal failure. */
     3943            vrc = VINF_SUCCESS;
     3944        }
     3945        else
     3946        {
     3947            vrc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtDragAndDrop, "VBoxDragAndDropSvc",
     3948                                                   &GuestDnD::notifyDnDDispatcher,
     3949                                                   GuestDnDInst());
     3950            if (RT_FAILURE(vrc))
     3951                Log(("Cannot register VBoxDragAndDropSvc extension, vrc=%Rrc\n", vrc));
     3952            else
     3953            {
     3954                LogRel(("Drag and drop service loaded\n"));
     3955                vrc = i_changeDnDMode(enmMode);
     3956            }
     3957        }
     3958    }
     3959#endif /* VBOX_WITH_DRAG_AND_DROP */
     3960
     3961    return vrc;
     3962}
     3963
    38193964#undef H
    38203965#undef VRC
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigX86.cpp

    r101458 r101459  
    4747#include "DisplayImpl.h"
    4848#include "NvramStoreImpl.h"
    49 #ifdef VBOX_WITH_SHARED_CLIPBOARD
    50 # include "GuestShClPrivate.h"
    51 #endif
    52 #ifdef VBOX_WITH_DRAG_AND_DROP
    53 # include "GuestImpl.h"
    54 # include "GuestDnDPrivate.h"
    55 #endif
    5649#include "PlatformImpl.h"
    5750#include "VMMDev.h"
     
    9588#include <VBox/vmm/gcm.h>
    9689#include <VBox/version.h>
    97 #ifdef VBOX_WITH_SHARED_CLIPBOARD
    98 # include <VBox/HostServices/VBoxClipboardSvc.h>
    99 #endif
    10090#ifdef VBOX_WITH_GUEST_PROPS
    10191# include <VBox/HostServices/GuestPropertySvc.h>
     
    472462{
    473463    RT_NOREF(pVM /* when everything is disabled */);
    474     VMMDev         *pVMMDev   = m_pVMMDev; Assert(pVMMDev);
    475464    ComPtr<IMachine> pMachine = i_machine();
    476465
     
    26792668        }
    26802669
    2681         /*
    2682          * VMM Device
    2683          */
    2684         InsertConfigNode(pDevices, "VMMDev", &pDev);
    2685         InsertConfigNode(pDev,     "0", &pInst);
    2686         InsertConfigNode(pInst,    "Config", &pCfg);
    2687         InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
    2688         hrc = pBusMgr->assignPCIDevice("VMMDev", pInst);                                    H();
    2689 
    2690         Bstr hwVersion;
    2691         hrc = pMachine->COMGETTER(HardwareVersion)(hwVersion.asOutParam());                 H();
    2692         if (hwVersion.compare(Bstr("1").raw()) == 0) /* <= 2.0.x */
    2693             InsertConfigInteger(pCfg, "HeapEnabled", 0);
    2694         Bstr snapshotFolder;
    2695         hrc = pMachine->COMGETTER(SnapshotFolder)(snapshotFolder.asOutParam());             H();
    2696         InsertConfigString(pCfg, "GuestCoreDumpDir", snapshotFolder);
    2697 
    2698         /* the VMM device's Main driver */
    2699         InsertConfigNode(pInst,    "LUN#0", &pLunL0);
    2700         InsertConfigString(pLunL0, "Driver",               "HGCM");
    2701         InsertConfigNode(pLunL0,   "Config", &pCfg);
    2702 
    2703         /*
    2704          * Attach the status driver.
    2705          */
    2706         i_attachStatusDriver(pInst, DeviceType_SharedFolder);
     2670        vrc = i_configVmmDev(pMachine, pBusMgr, pDevices);                                      VRC();
    27072671
    27082672        /*
     
    27122676        vrc = i_configAudioCtrl(virtualBox, pMachine, pBusMgr, pDevices,
    27132677                                fOsXGuest, &fAudioEnabled);                                     VRC();
    2714 
    2715 #ifdef VBOX_WITH_SHARED_CLIPBOARD
    2716         /*
    2717          * Shared Clipboard.
    2718          */
    2719         {
    2720             ClipboardMode_T enmClipboardMode = ClipboardMode_Disabled;
    2721             hrc = pMachine->COMGETTER(ClipboardMode)(&enmClipboardMode); H();
    2722 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    2723             BOOL fFileTransfersEnabled;
    2724             hrc = pMachine->COMGETTER(ClipboardFileTransfersEnabled)(&fFileTransfersEnabled); H();
    2725 #endif
    2726 
    2727             /* Load the service */
    2728             vrc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");
    2729             if (RT_SUCCESS(vrc))
    2730             {
    2731                 LogRel(("Shared Clipboard: Service loaded\n"));
    2732 
    2733                 /* Set initial clipboard mode. */
    2734                 vrc = i_changeClipboardMode(enmClipboardMode);
    2735                 AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial clipboard mode (%d): vrc=%Rrc\n",
    2736                                                  enmClipboardMode, vrc));
    2737 
    2738                 /* Setup the service. */
    2739                 VBOXHGCMSVCPARM parm;
    2740                 HGCMSvcSetU32(&parm, !i_useHostClipboard());
    2741                 vrc = pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHCL_HOST_FN_SET_HEADLESS, 1, &parm);
    2742                 AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial headless mode (%RTbool): vrc=%Rrc\n",
    2743                                                  !i_useHostClipboard(), vrc));
    2744 
    2745 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    2746                 vrc = i_changeClipboardFileTransferMode(RT_BOOL(fFileTransfersEnabled));
    2747                 AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial file transfer mode (%u): vrc=%Rrc\n",
    2748                                                  fFileTransfersEnabled, vrc));
    2749 # endif
    2750                 GuestShCl::createInstance(this /* pConsole */);
    2751                 vrc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtShCl, "VBoxSharedClipboard",
    2752                                                        &GuestShCl::hgcmDispatcher,
    2753                                                        GuestShClInst());
    2754                 if (RT_FAILURE(vrc))
    2755                     Log(("Cannot register VBoxSharedClipboard extension, vrc=%Rrc\n", vrc));
    2756             }
    2757             else
    2758                 LogRel(("Shared Clipboard: Not available, vrc=%Rrc\n", vrc));
    2759             vrc = VINF_SUCCESS;  /* None of the potential failures above are fatal. */
    2760         }
    2761 #endif /* VBOX_WITH_SHARED_CLIPBOARD */
    2762 
    2763         /*
    2764          * HGCM HostChannel.
    2765          */
    2766         {
    2767             Bstr value;
    2768             hrc = pMachine->GetExtraData(Bstr("HGCM/HostChannel").raw(),
    2769                                          value.asOutParam());
    2770 
    2771             if (   hrc   == S_OK
    2772                 && value == "1")
    2773             {
    2774                 vrc = pVMMDev->hgcmLoadService("VBoxHostChannel", "VBoxHostChannel");
    2775                 if (RT_FAILURE(vrc))
    2776                 {
    2777                     LogRel(("VBoxHostChannel is not available, vrc=%Rrc\n", vrc));
    2778                     /* That is not a fatal failure. */
    2779                     vrc = VINF_SUCCESS;
    2780                 }
    2781             }
    2782         }
    2783 
    2784 #ifdef VBOX_WITH_DRAG_AND_DROP
    2785         /*
    2786          * Drag and Drop.
    2787          */
    2788         {
    2789             DnDMode_T enmMode = DnDMode_Disabled;
    2790             hrc = pMachine->COMGETTER(DnDMode)(&enmMode);                                   H();
    2791 
    2792             /* Load the service */
    2793             vrc = pVMMDev->hgcmLoadService("VBoxDragAndDropSvc", "VBoxDragAndDropSvc");
    2794             if (RT_FAILURE(vrc))
    2795             {
    2796                 LogRel(("Drag and drop service is not available, vrc=%Rrc\n", vrc));
    2797                 /* That is not a fatal failure. */
    2798                 vrc = VINF_SUCCESS;
    2799             }
    2800             else
    2801             {
    2802                 vrc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtDragAndDrop, "VBoxDragAndDropSvc",
    2803                                                        &GuestDnD::notifyDnDDispatcher,
    2804                                                        GuestDnDInst());
    2805                 if (RT_FAILURE(vrc))
    2806                     Log(("Cannot register VBoxDragAndDropSvc extension, vrc=%Rrc\n", vrc));
    2807                 else
    2808                 {
    2809                     LogRel(("Drag and drop service loaded\n"));
    2810                     vrc = i_changeDnDMode(enmMode);
    2811                 }
    2812             }
    2813         }
    2814 #endif /* VBOX_WITH_DRAG_AND_DROP */
    28152678
    28162679#if defined(VBOX_WITH_TPM)
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