VirtualBox

Changeset 25848 in vbox for trunk/src/VBox/Devices/VMMDev


Ignore:
Timestamp:
Jan 14, 2010 10:12:21 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56635
Message:

CPU hotplug: Merge the third patch. Guest additions interface for the CPU hot-plug monitor

Location:
trunk/src/VBox/Devices/VMMDev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r25732 r25848  
    16241624        }
    16251625
     1626        case VMMDevReq_GetCpuHotPlugRequest:
     1627        {
     1628            VMMDevGetCpuHotPlugRequest *pReqCpuHotPlug = (VMMDevGetCpuHotPlugRequest *)pRequestHeader;
     1629
     1630            if (pRequestHeader->size != sizeof(VMMDevGetCpuHotPlugRequest))
     1631            {
     1632                pRequestHeader->rc = VERR_INVALID_PARAMETER;
     1633            }
     1634            else
     1635            {
     1636                pReqCpuHotPlug->enmEventType = pThis->enmCpuHotPlugEvent;
     1637                pReqCpuHotPlug->idCpuCore    = pThis->idCpuCore;
     1638                pReqCpuHotPlug->idCpuPackage = pThis->idCpuPackage;
     1639                pReqCpuHotPlug->header.rc    = VINF_SUCCESS;
     1640
     1641                /* Clear the event */
     1642                pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_None;
     1643                pThis->idCpuCore          = UINT32_MAX;
     1644                pThis->idCpuPackage       = UINT32_MAX;
     1645            }
     1646            break;
     1647        }
     1648
     1649        case VMMDevReq_SetCpuHotPlugStatus:
     1650        {
     1651            VMMDevCpuHotPlugStatusRequest *pReqCpuHotPlugStatus = (VMMDevCpuHotPlugStatusRequest *)pRequestHeader;
     1652
     1653            if (pRequestHeader->size != sizeof(VMMDevCpuHotPlugStatusRequest))
     1654            {
     1655                pRequestHeader->rc = VERR_INVALID_PARAMETER;
     1656            }
     1657            else
     1658            {
     1659                pRequestHeader->rc = VINF_SUCCESS;
     1660
     1661                if (pReqCpuHotPlugStatus->enmStatusType == VMMDevCpuStatusType_Disable)
     1662                    pThis->fCpuHotPlugEventsEnabled = false;
     1663                else if (pReqCpuHotPlugStatus->enmStatusType == VMMDevCpuStatusType_Enable)
     1664                    pThis->fCpuHotPlugEventsEnabled = true;
     1665                else
     1666                    pRequestHeader->rc = VERR_INVALID_PARAMETER;
     1667            }
     1668            break;
     1669        }
     1670
    16261671#ifdef DEBUG
    16271672        case VMMDevReq_LogString:
     
    21112156}
    21122157
     2158/**
     2159 * Notification that a CPU is about to be unplugged from the VM.
     2160 * The guest has to eject the CPU.
     2161 *
     2162 * @returns VBox status code.
     2163 * @param   idCpu    The id of the CPU.
     2164 * @param   idCpuCore    The core id of the CPU to remove.
     2165 * @param   idCpuPackage The package id of the CPU to remove.
     2166 */
     2167static DECLCALLBACK(int) vmmdevCpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
     2168{
     2169    int rc = VINF_SUCCESS;
     2170    VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
     2171
     2172    Log(("vmmdevCpuHotUnplug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
     2173
     2174    PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     2175
     2176    if (pThis->fCpuHotPlugEventsEnabled)
     2177    {
     2178        pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Unplug;
     2179        pThis->idCpuCore          = idCpuCore;
     2180        pThis->idCpuPackage       = idCpuPackage;
     2181        VMMDevNotifyGuest (pThis, VMMDEV_EVENT_CPU_HOTPLUG);
     2182    }
     2183    else
     2184        rc = VERR_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
     2185
     2186    PDMCritSectLeave(&pThis->CritSect);
     2187    return rc;
     2188}
     2189
     2190/**
     2191 * Notification that a CPU was attached to the VM
     2192 * The guest may use it now.
     2193 *
     2194 * @returns VBox status code.
     2195 * @param   idCpuCore    The core id of the CPU to add.
     2196 * @param   idCpuPackage The package id of the CPU to add.
     2197 */
     2198static DECLCALLBACK(int) vmmdevCpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
     2199{
     2200    int rc = VINF_SUCCESS;
     2201    VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
     2202
     2203    Log(("vmmdevCpuPlug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
     2204
     2205    PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
     2206
     2207    if (pThis->fCpuHotPlugEventsEnabled)
     2208    {
     2209        pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Plug;
     2210        pThis->idCpuCore          = idCpuCore;
     2211        pThis->idCpuPackage       = idCpuPackage;
     2212        VMMDevNotifyGuest(pThis, VMMDEV_EVENT_CPU_HOTPLUG);
     2213    }
     2214    else
     2215        rc = VERR_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
     2216
     2217    PDMCritSectLeave(&pThis->CritSect);
     2218    return rc;
     2219}
    21132220
    21142221/* -=-=-=-=-=- Saved State -=-=-=-=-=- */
     
    24092516    pThis->Port.pfnSetStatisticsInterval  = vmmdevSetStatisticsInterval;
    24102517    pThis->Port.pfnVRDPChange             = vmmdevVRDPChange;
     2518    pThis->Port.pfnCpuHotUnplug           = vmmdevCpuHotUnplug;
     2519    pThis->Port.pfnCpuHotPlug             = vmmdevCpuHotPlug;
    24112520
    24122521    /* Shared folder LED */
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r24076 r25848  
    198198        R3PTRTYPE(PPDMILEDCONNECTORS)       pLedsConnector;
    199199    } SharedFolders;
     200
     201    /** FLag whether CPU hotplug events are monitored */
     202    bool                 fCpuHotPlugEventsEnabled;
     203    /** CPU hotplug event */
     204    VMMDevCpuEventType   enmCpuHotPlugEvent;
     205    /** Core id of the CPU to change */
     206    uint32_t             idCpuCore;
     207    /** Package id of the CPU to changhe */
     208    uint32_t             idCpuPackage;
    200209} VMMDevState;
    201210AssertCompileMemberAlignment(VMMDevState, CritSect, 8);
Note: See TracChangeset for help on using the changeset viewer.

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