~ubuntu-branches/ubuntu/natty/virtualbox-ose/natty-updates

« back to all changes in this revision

Viewing changes to src/VBox/Main/ConsoleImpl2.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-10-15 02:12:28 UTC
  • mfrom: (0.3.10 upstream) (0.4.19 sid)
  • Revision ID: james.westby@ubuntu.com-20101015021228-5e6vbxgtes8mg189
Tags: 3.2.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - VirtualBox should go in Accessories, not in System tools.
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add ubuntu-01-fix-build-gcc45.patch to fix FTBFS due to uninitalized
  variables. Thanks to Lubomir Rintel <lkundrak@v3.sk> for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
349
349
    /* Save the VM pointer in the machine object */
350
350
    pConsole->mpVM = pVM;
351
351
 
 
352
    VMMDev *pVMMDev = pConsole->m_pVMMDev;
 
353
    Assert(pVMMDev);
 
354
 
352
355
    ComPtr<IMachine> pMachine = pConsole->machine();
353
356
 
354
357
    int             rc;
483
486
     * Hardware virtualization extensions.
484
487
     */
485
488
    BOOL fHWVirtExEnabled;
486
 
    BOOL fHwVirtExtForced;
 
489
    BOOL fHwVirtExtForced = false;
487
490
#ifdef VBOX_WITH_RAW_MODE
488
491
    hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Enabled, &fHWVirtExEnabled); H();
489
492
    if (cCpus > 1) /** @todo SMP: This isn't nice, but things won't work on mac otherwise. */
490
 
        fHWVirtExEnabled = TRUE;
 
493
        fHWVirtExEnabled = true;
491
494
# ifdef RT_OS_DARWIN
492
495
    fHwVirtExtForced = fHWVirtExEnabled;
493
496
# else
499
502
                        || cCpus > 1);
500
503
# endif
501
504
#else  /* !VBOX_WITH_RAW_MODE */
502
 
    fHWVirtExEnabled = fHwVirtExtForced = TRUE;
 
505
    fHWVirtExEnabled = fHwVirtExtForced = true;
503
506
#endif /* !VBOX_WITH_RAW_MODE */
 
507
    /* only honor the property value if there was no other reason to enable it */
 
508
    if (!fHwVirtExtForced)
 
509
    {
 
510
        hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_Force, &fHwVirtExtForced); H();
 
511
    }
504
512
    rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced",      fHwVirtExtForced);          RC_CHECK();
505
513
 
506
514
    PCFGMNODE pHWVirtExt;
877
885
    rc = CFGMR3InsertInteger(pCfg,  "LogoTime", logoDisplayTime);                       RC_CHECK();
878
886
    Bstr logoImagePath;
879
887
    hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam());           H();
880
 
    rc = CFGMR3InsertString(pCfg,   "LogoFile", logoImagePath ? Utf8Str(logoImagePath).c_str() : ""); RC_CHECK();
 
888
    rc = CFGMR3InsertString(pCfg,   "LogoFile", !logoImagePath.isEmpty() ? Utf8Str(logoImagePath).c_str() : ""); RC_CHECK();
881
889
 
882
890
    /*
883
891
     * Boot menu
1439
1447
         */
1440
1448
        Bstr macAddr;
1441
1449
        hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam());              H();
1442
 
        Assert(macAddr);
 
1450
        Assert(!macAddr.isEmpty());
1443
1451
        Utf8Str macAddrUtf8 = macAddr;
1444
1452
        char *macStr = (char*)macAddrUtf8.raw();
1445
1453
        Assert(strlen(macStr) == 12);
1624
1632
    rc = CFGMR3InsertNode(pInst,    "LUN#0", &pLunL0);                                  RC_CHECK();
1625
1633
    rc = CFGMR3InsertString(pLunL0, "Driver",               "HGCM");                    RC_CHECK();
1626
1634
    rc = CFGMR3InsertNode(pLunL0,   "Config", &pCfg);                                   RC_CHECK();
1627
 
    VMMDev *pVMMDev = pConsole->mVMMDev;
1628
1635
    rc = CFGMR3InsertInteger(pCfg,  "Object", (uintptr_t)pVMMDev);                      RC_CHECK();
1629
1636
 
1630
1637
    /*
1946
1953
        if (mode != ClipboardMode_Disabled)
1947
1954
        {
1948
1955
            /* Load the service */
1949
 
            rc = pConsole->mVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");
 
1956
            rc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");
1950
1957
 
1951
1958
            if (RT_FAILURE(rc))
1952
1959
            {
1990
1997
                    }
1991
1998
                }
1992
1999
 
1993
 
                pConsole->mVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
 
2000
                pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE, 1, &parm);
1994
2001
 
1995
2002
                Log(("Set VBoxSharedClipboard mode\n"));
1996
2003
            }
2008
2015
        if (fEnabled)
2009
2016
        {
2010
2017
            /* Load the service */
2011
 
            rc = pConsole->mVMMDev->hgcmLoadService("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
 
2018
            rc = pVMMDev->hgcmLoadService("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
2012
2019
            if (RT_FAILURE(rc))
2013
2020
            {
2014
2021
                LogRel(("Failed to load Shared OpenGL service %Rrc\n", rc));
2026
2033
                parm.u.pointer.addr = (IConsole*) (Console*) pConsole;
2027
2034
                parm.u.pointer.size = sizeof(IConsole *);
2028
2035
 
2029
 
                rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_CONSOLE,
2030
 
                                                     SHCRGL_CPARMS_SET_CONSOLE, &parm);
 
2036
                rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_CONSOLE,
 
2037
                                           SHCRGL_CPARMS_SET_CONSOLE, &parm);
2031
2038
                if (!RT_SUCCESS(rc))
2032
2039
                    AssertMsgFailed(("SHCRGL_HOST_FN_SET_CONSOLE failed with %Rrc\n", rc));
2033
2040
 
2034
2041
                parm.u.pointer.addr = pVM;
2035
2042
                parm.u.pointer.size = sizeof(pVM);
2036
 
                rc = pConsole->mVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VM,
2037
 
                                                     SHCRGL_CPARMS_SET_VM, &parm);
 
2043
                rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VM,
 
2044
                                           SHCRGL_CPARMS_SET_VM, &parm);
2038
2045
                if (!RT_SUCCESS(rc))
2039
2046
                    AssertMsgFailed(("SHCRGL_HOST_FN_SET_VM failed with %Rrc\n", rc));
2040
2047
            }
2527
2534
             * Ext4 bug: Check if the host I/O cache is disabled and the disk image is located
2528
2535
             *           on an ext4 partition. Later we have to check the Linux kernel version!
2529
2536
             * This bug apparently applies to the XFS file system as well.
 
2537
             * Linux 2.6.36 is known to be fixed (tested with 2.6.36-rc4).
2530
2538
             */
 
2539
 
 
2540
            char szOsRelease[128];
 
2541
            rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szOsRelease, sizeof(szOsRelease));
 
2542
            bool fKernelHasODirectBug =    RT_FAILURE(rc)
 
2543
                                        || (RTStrVersionCompare(szOsRelease, "2.6.36-rc4") < 0);
 
2544
 
2531
2545
            if (   (uCaps & MediumFormatCapabilities_Asynchronous)
2532
2546
                && !fUseHostIOCache
2533
 
                && (   enmFsTypeFile == RTFSTYPE_EXT4
2534
 
                    || enmFsTypeFile == RTFSTYPE_XFS))
2535
 
            {
2536
 
                setVMRuntimeErrorCallbackF(pVM, this, 0,
2537
 
                        "Ext4PartitionDetected",
2538
 
                        N_("The host I/O cache for at least one controller is disabled "
2539
 
                           "and the medium '%ls' for this VM "
2540
 
                           "is located on an %s partition. There is a known Linux "
2541
 
                           "kernel bug which can lead to the corruption of the virtual "
2542
 
                           "disk image under these conditions.\n"
2543
 
                           "Either enable the host I/O cache permanently in the VM "
2544
 
                           "settings or put the disk image and the snapshot folder "
2545
 
                           "onto a different file system.\n"
2546
 
                           "The host I/O cache will now be enabled for this medium"),
2547
 
                        strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
2548
 
                fUseHostIOCache = true;
2549
 
            }
2550
 
            else if (   (uCaps & MediumFormatCapabilities_Asynchronous)
2551
 
                     && !fUseHostIOCache
2552
 
                     && (   enmFsTypeSnap == RTFSTYPE_EXT4
2553
 
                         || enmFsTypeSnap == RTFSTYPE_XFS)
2554
 
                     && !mfSnapshotFolderExt4WarningShown)
2555
 
            {
2556
 
                setVMRuntimeErrorCallbackF(pVM, this, 0,
2557
 
                        "Ext4PartitionDetected",
2558
 
                        N_("The host I/O cache for at least one controller is disabled "
2559
 
                           "and the snapshot folder for this VM "
2560
 
                           "is located on an %s partition. There is a known Linux "
2561
 
                           "kernel bug which can lead to the corruption of the virtual "
2562
 
                           "disk image under these conditions.\n"
2563
 
                           "Either enable the host I/O cache permanently in the VM "
2564
 
                           "settings or put the disk image and the snapshot folder "
2565
 
                           "onto a different file system.\n"
2566
 
                           "The host I/O cache will now be enabled for this medium"),
2567
 
                        enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
2568
 
                fUseHostIOCache = true;
2569
 
                mfSnapshotFolderExt4WarningShown = true;
 
2547
                && fKernelHasODirectBug)
 
2548
            {
 
2549
                if (   enmFsTypeFile == RTFSTYPE_EXT4
 
2550
                    || enmFsTypeFile == RTFSTYPE_XFS)
 
2551
                {
 
2552
                    setVMRuntimeErrorCallbackF(pVM, this, 0,
 
2553
                            "Ext4PartitionDetected",
 
2554
                            N_("The host I/O cache for at least one controller is disabled "
 
2555
                               "and the medium '%ls' for this VM "
 
2556
                               "is located on an %s partition. There is a known Linux "
 
2557
                               "kernel bug which can lead to the corruption of the virtual "
 
2558
                               "disk image under these conditions.\n"
 
2559
                               "Either enable the host I/O cache permanently in the VM "
 
2560
                               "settings or put the disk image and the snapshot folder "
 
2561
                               "onto a different file system.\n"
 
2562
                               "The host I/O cache will now be enabled for this medium"),
 
2563
                            strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
 
2564
                    fUseHostIOCache = true;
 
2565
                }
 
2566
                else if (  (   enmFsTypeSnap == RTFSTYPE_EXT4
 
2567
                            || enmFsTypeSnap == RTFSTYPE_XFS)
 
2568
                         && !mfSnapshotFolderExt4WarningShown)
 
2569
                {
 
2570
                    setVMRuntimeErrorCallbackF(pVM, this, 0,
 
2571
                            "Ext4PartitionDetected",
 
2572
                            N_("The host I/O cache for at least one controller is disabled "
 
2573
                               "and the snapshot folder for this VM "
 
2574
                               "is located on an %s partition. There is a known Linux "
 
2575
                               "kernel bug which can lead to the corruption of the virtual "
 
2576
                               "disk image under these conditions.\n"
 
2577
                               "Either enable the host I/O cache permanently in the VM "
 
2578
                               "settings or put the disk image and the snapshot folder "
 
2579
                               "onto a different file system.\n"
 
2580
                               "The host I/O cache will now be enabled for this medium"),
 
2581
                            enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
 
2582
                    fUseHostIOCache = true;
 
2583
                    mfSnapshotFolderExt4WarningShown = true;
 
2584
                }
2570
2585
            }
2571
2586
#endif
2572
2587
        }
3949
3964
/**
3950
3965
 * Set an array of guest properties
3951
3966
 */
3952
 
static void configSetProperties(VMMDev * const pVMMDev, void *names,
3953
 
                                void *values, void *timestamps, void *flags)
 
3967
static void configSetProperties(VMMDev * const pVMMDev,
 
3968
                                void *names,
 
3969
                                void *values,
 
3970
                                void *timestamps,
 
3971
                                void *flags)
3954
3972
{
3955
3973
    VBOXHGCMSVCPARM parms[4];
3956
3974
 
3967
3985
    parms[3].u.pointer.addr = flags;
3968
3986
    parms[3].u.pointer.size = 0;  /* We don't actually care. */
3969
3987
 
3970
 
    pVMMDev->hgcmHostCall ("VBoxGuestPropSvc", guestProp::SET_PROPS_HOST, 4,
3971
 
                           &parms[0]);
 
3988
    pVMMDev->hgcmHostCall("VBoxGuestPropSvc",
 
3989
                          guestProp::SET_PROPS_HOST,
 
3990
                          4,
 
3991
                          &parms[0]);
3972
3992
}
3973
3993
 
3974
3994
/**
3975
3995
 * Set a single guest property
3976
3996
 */
3977
 
static void configSetProperty(VMMDev * const pVMMDev, const char *pszName,
3978
 
                              const char *pszValue, const char *pszFlags)
 
3997
static void configSetProperty(VMMDev * const pVMMDev,
 
3998
                              const char *pszName,
 
3999
                              const char *pszValue,
 
4000
                              const char *pszFlags)
3979
4001
{
3980
4002
    VBOXHGCMSVCPARM parms[4];
3981
4003
 
4031
4053
#ifdef VBOX_WITH_GUEST_PROPS
4032
4054
    AssertReturn(pvConsole, VERR_GENERAL_FAILURE);
4033
4055
    ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole);
 
4056
    AssertReturn(pConsole->m_pVMMDev, VERR_GENERAL_FAILURE);
4034
4057
 
4035
4058
    /* Load the service */
4036
 
    int rc = pConsole->mVMMDev->hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc");
 
4059
    int rc = pConsole->m_pVMMDev->hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc");
4037
4060
 
4038
4061
    if (RT_FAILURE(rc))
4039
4062
    {
4051
4074
         */
4052
4075
 
4053
4076
        /* Sysprep execution by VBoxService. */
4054
 
        configSetProperty(pConsole->mVMMDev,
 
4077
        configSetProperty(pConsole->m_pVMMDev,
4055
4078
                          "/VirtualBox/HostGuest/SysprepExec", "",
4056
4079
                          "TRANSIENT, RDONLYGUEST");
4057
 
        configSetProperty(pConsole->mVMMDev,
 
4080
        configSetProperty(pConsole->m_pVMMDev,
4058
4081
                          "/VirtualBox/HostGuest/SysprepArgs", "",
4059
4082
                          "TRANSIENT, RDONLYGUEST");
4060
4083
 
4107
4130
                    papszFlags[i] = szEmpty;
4108
4131
            }
4109
4132
            if (RT_SUCCESS(rc))
4110
 
                configSetProperties(pConsole->mVMMDev,
 
4133
                configSetProperties(pConsole->m_pVMMDev,
4111
4134
                                    (void *)papszNames,
4112
4135
                                    (void *)papszValues,
4113
4136
                                    (void *)pau64Timestamps,
4135
4158
         * will override them.
4136
4159
         */
4137
4160
        /* Set the VBox version string as a guest property */
4138
 
        configSetProperty(pConsole->mVMMDev, "/VirtualBox/HostInfo/VBoxVer",
 
4161
        configSetProperty(pConsole->m_pVMMDev, "/VirtualBox/HostInfo/VBoxVer",
4139
4162
                          VBOX_VERSION_STRING, "TRANSIENT, RDONLYGUEST");
4140
4163
        /* Set the VBox SVN revision as a guest property */
4141
 
        configSetProperty(pConsole->mVMMDev, "/VirtualBox/HostInfo/VBoxRev",
 
4164
        configSetProperty(pConsole->m_pVMMDev, "/VirtualBox/HostInfo/VBoxRev",
4142
4165
                          RTBldCfgRevisionStr(), "TRANSIENT, RDONLYGUEST");
4143
4166
 
4144
4167
        /*
4173
4196
    ComObjPtr<Console> pConsole = static_cast<Console *>(pvConsole);
4174
4197
 
4175
4198
    /* Load the service */
4176
 
    int rc = pConsole->mVMMDev->hgcmLoadService("VBoxGuestControlSvc", "VBoxGuestControlSvc");
 
4199
    int rc = pConsole->m_pVMMDev->hgcmLoadService("VBoxGuestControlSvc", "VBoxGuestControlSvc");
4177
4200
 
4178
4201
    if (RT_FAILURE(rc))
4179
4202
    {