VirtualBox

Changeset 26061 in vbox


Ignore:
Timestamp:
Jan 27, 2010 10:18:30 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56980
Message:

VBoxService,VBoxGuestLib: CPU hot plugging cleanup + review.

Location:
trunk
Files:
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLib.h

    r25975 r26061  
    502502/** @name CPU hotplug monitor
    503503 * @{ */
    504 VBGLR3DECL(int)     VbglR3CpuHotplugInit(void);
    505 VBGLR3DECL(int)     VbglR3CpuHotplugTerm(void);
    506 VBGLR3DECL(int)     VbglR3CpuHotplugWaitForEvent(VMMDevCpuEventType *penmEventType, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
     504VBGLR3DECL(int)     VbglR3CpuHotPlugInit(void);
     505VBGLR3DECL(int)     VbglR3CpuHotPlugTerm(void);
     506VBGLR3DECL(int)     VbglR3CpuHotPlugWaitForEvent(VMMDevCpuEventType *penmEventType, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
    507507/** @} */
    508508
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibCpuHotPlug.cpp

    r26058 r26061  
    3434 * @returns VBox status code.
    3535 */
    36 VBGLR3DECL(int) VbglR3CpuHotplugInit(void)
     36VBGLR3DECL(int) VbglR3CpuHotPlugInit(void)
    3737{
    3838    int rc = VbglR3CtlFilterMask(VMMDEV_EVENT_CPU_HOTPLUG, 0);
     
    5858 * @returns VBox status.
    5959 */
    60 VBGLR3DECL(int) VbglR3CpuHotplugTerm(void)
     60VBGLR3DECL(int) VbglR3CpuHotPlugTerm(void)
    6161{
    6262    /* Clear the events. */
     
    7878 * @param   pidCpuPackage   Where to store the CPU package ID on success.
    7979 */
    80 VBGLR3DECL(int) VbglR3CpuHotplugWaitForEvent(VMMDevCpuEventType *penmEventType, uint32_t *pidCpuCore, uint32_t *pidCpuPackage)
     80VBGLR3DECL(int) VbglR3CpuHotPlugWaitForEvent(VMMDevCpuEventType *penmEventType, uint32_t *pidCpuCore, uint32_t *pidCpuPackage)
    8181{
    8282    AssertPtrReturn(penmEventType, VERR_INVALID_POINTER);
  • trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk

    r25975 r26061  
    55
    66#
    7 # Copyright (C) 2007 Sun Microsystems, Inc.
     7# Copyright (C) 2007-2010 Sun Microsystems, Inc.
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    4242 endif
    4343endif
     44if1of ($(KBUILD_TARGET), linux)
     45 VBoxService_DEFS        += VBOXSERVICE_CPUHOTPLUG
     46endif
     47
    4448VBoxService_SOURCES       = \
    4549        VBoxService.cpp \
     
    5660 endif
    5761endif
     62if1of ($(KBUILD_TARGET), linux)
     63 VBoxService_SOURCES     += \
     64        VBoxServiceCpuHotPlug.cpp
     65endif
    5866VBoxService_SOURCES.win  += \
    5967        VBoxService-win.rc \
     
    6371        VBoxServiceClipboard-os2.cpp
    6472
    65 # CPU hotplug support only for Linux guests at the moment
    66 VBoxService_DEFS.linux += VBOXSERVICE_CPUHOTPLUG
    67 VBoxService_SOURCES.linux += \
    68         VBoxServiceCpuHotplug.cpp
    69 
    7073VBoxService_LIBS          = \
    7174        $(VBOX_LIB_IPRT_GUEST_R3) \
     
    7477ifdef VBOX_WITH_GUEST_PROPS
    7578 VBoxService_LIBS.win    += \
    76         Secur32.lib \
    77         WtsApi32.lib \
    78         Psapi.lib
     79        Secur32.lib \
     80        WtsApi32.lib \
     81        Psapi.lib
    7982 VBoxService_LIBS.solaris += \
    80         nsl
     83        nsl
    8184endif
    8285
     
    8487# VBoxServiceNT - NT4 version of VBoxService.
    8588#
    86 VBoxServiceNT_TEMPLATE    = VBOXGUESTR3EXE
    87 VBoxServiceNT_EXTENDS     = VBoxService
    88 VBoxServiceNT_DEFS.win    = _WIN32_WINNT=0x0400 TARGET_NT4
     89VBoxServiceNT_TEMPLATE = VBOXGUESTR3EXE
     90VBoxServiceNT_EXTENDS  = VBoxService
     91VBoxServiceNT_DEFS.win = _WIN32_WINNT=0x0400 TARGET_NT4
    8992
    90 #VBoxServiceVMInfo.cpp uses VBOX_SVN_REV.
    9193VBoxServiceVMInfo.cpp_DEFS = VBOX_SVN_REV=$(VBOX_SVN_REV)
    9294VBoxServiceVMInfo.cpp_DEPS = $(VBOX_SVN_REV_KMK)
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp

    r25975 r26061  
    55
    66/*
    7  * Copyright (C) 2007-2009 Sun Microsystems, Inc.
     7 * Copyright (C) 2007-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    9292#endif
    9393#ifdef VBOXSERVICE_CPUHOTPLUG /* Disabled by default. Use --enable-cpuhotplug to enable */
    94     { &g_CpuHotplug, NIL_RTTHREAD, false, false, false, false },
     94    { &g_CpuHotPlug, NIL_RTTHREAD, false, false, false, false },
    9595#endif
    9696};
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceCpuHotPlug.cpp

    r26014 r26061  
    11/* $Id$ */
    22/** @file
    3  * VBoxService - Guest Additions Cpu Hotplug Service.
     3 * VBoxService - Guest Additions CPU Hot Plugging Service.
    44 */
    55
    66/*
    7  * Copyright (C) 2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323*   Header Files                                                               *
    2424*******************************************************************************/
     25#include <iprt/assert.h>
     26#include <iprt/dir.h>
     27#include <iprt/file.h>
     28#include <iprt/mem.h>
     29#include <iprt/string.h>
    2530#include <iprt/thread.h>
    26 #include <iprt/string.h>
    27 #include <iprt/file.h>
    28 #include <iprt/assert.h>
    29 #include <iprt/mem.h>
    30 #include <iprt/dir.h>
    3131#include <VBox/VBoxGuestLib.h>
    3232#include "VBoxServiceInternal.h"
     
    3737#endif
    3838
    39 /**
    40  * Paths to access the CPU device
    41  */
    42 #ifdef RT_OS_LINUX
    43 # define SYSFS_ACPI_CPU_PATH "/sys/devices/LNXSYSTM:00/device:00"
    44 # define SYSFS_CPU_PATH "/sys/devices/system/cpu"
     39
     40/*******************************************************************************
     41*   Defined Constants And Macros                                               *
     42*******************************************************************************/
     43#ifdef RT_OS_LINUX
     44/** @name Paths to access the CPU device
     45 * @{
     46 */
     47# define SYSFS_ACPI_CPU_PATH    "/sys/devices/LNXSYSTM:00/device:00"
     48# define SYSFS_CPU_PATH         "/sys/devices/system/cpu"
     49/** @} */
    4550#endif
    4651
    47 /*******************************************************************************
    48 *   Global Variables                                                           *
    49 *******************************************************************************/
    5052
    5153#ifdef RT_OS_LINUX
     
    5860 * @param   idCpuPackage The package ID of the CPU.
    5961 */
    60 static int cpuHotplugGetACPIDevicePath(char **ppszPath, uint32_t idCpuCore, uint32_t idCpuPackage)
    61 {
    62     int rc = VINF_SUCCESS;
     62static int VBoxServiceCpuHotPlugGetACPIDevicePath(char **ppszPath, uint32_t idCpuCore, uint32_t idCpuPackage)
     63{
     64    AssertPtr(ppszPath);
     65
    6366    PRTDIR pDirDevices = NULL;
    64 
    65     AssertPtrReturn(ppszPath, VERR_INVALID_PARAMETER);
    66 
    67     rc = RTDirOpen(&pDirDevices, SYSFS_ACPI_CPU_PATH);  /*could use RTDirOpenFiltered*/
    68 
     67    int rc = RTDirOpen(&pDirDevices, SYSFS_ACPI_CPU_PATH);  /*could use RTDirOpenFiltered*/
    6968    if (RT_SUCCESS(rc))
    7069    {
    7170        RTDIRENTRY DirFolderContent;
    72 
    7371        while (RT_SUCCESS(RTDirRead(pDirDevices, &DirFolderContent, NULL))) /* Assumption that szName has always enough space */
    7472        {
    75             if (!RTStrNCmp(DirFolderContent.szName, "LNXCPU", 6))
     73            if (!strncmp(DirFolderContent.szName, "LNXCPU", 6))
    7674            {
    77                 char *pszSysDevPath = NULL;
    78 
    7975                /* Get the sysdev */
    80                 rc = RTStrAPrintf(&pszSysDevPath, "%s/%s", SYSFS_ACPI_CPU_PATH, DirFolderContent.szName);
     76                uint32_t idCore    = RTLinuxSysFsReadIntFile(10, "%s/%s/sysdev/topology/core_id",
     77                                                             SYSFS_ACPI_CPU_PATH, DirFolderContent.szName);
     78                uint32_t idPackage = RTLinuxSysFsReadIntFile(10, "%s/%s/sysdev/topology/physical_package_id",
     79                                                             SYSFS_ACPI_CPU_PATH, DirFolderContent.szName);
     80                if (   idCore    == idCpuCore
     81                    && idPackage == idCpuPackage)
     82                {
     83                    /* Return the path */
     84                    rc = RTStrAPrintf(ppszPath, "%s/%s", SYSFS_ACPI_CPU_PATH, DirFolderContent.szName);
     85                    break;
     86                }
     87            }
     88        }
     89
     90        RTDirClose(pDirDevices);
     91    }
     92
     93    return rc;
     94}
     95#endif /* RT_OS_LINUX */
     96
     97
     98/** @copydoc VBOXSERVICE::pfnPreInit */
     99static DECLCALLBACK(int) VBoxServiceCpuHotPlugPreInit(void)
     100{
     101    return VINF_SUCCESS;
     102}
     103
     104
     105/** @copydoc VBOXSERVICE::pfnOption */
     106static DECLCALLBACK(int) VBoxServiceCpuHotPlugOption(const char **ppszShort, int argc, char **argv, int *pi)
     107{
     108    return VINF_SUCCESS;
     109}
     110
     111
     112/** @copydoc VBOXSERVICE::pfnInit */
     113static DECLCALLBACK(int) VBoxServiceCpuHotPlugInit(void)
     114{
     115    return VINF_SUCCESS;
     116}
     117
     118
     119/**
     120 * Handles VMMDevCpuEventType_Plug.
     121 *
     122 * @param   idCpuCore       The CPU core ID.
     123 * @param   idCpuPackage    The CPU package ID.
     124 */
     125static void VBoxServiceCpuHotPlugHandlePlugEvent(uint32_t idCpuCore, uint32_t idCpuPackage)
     126{
     127#ifdef RT_OS_LINUX
     128    /*
     129     * The topology directory is not available until the CPU is online. So we just iterate over all directories
     130     * and enable every CPU which is not online already.
     131     */
     132    /** @todo Maybe use udev to monitor events from the kernel */
     133    PRTDIR pDirDevices = NULL;
     134    int rc = RTDirOpen(&pDirDevices, SYSFS_CPU_PATH);  /*could use RTDirOpenFiltered*/
     135    if (RT_SUCCESS(rc))
     136    {
     137        RTDIRENTRY DirFolderContent;
     138        while (RT_SUCCESS(RTDirRead(pDirDevices, &DirFolderContent, NULL))) /* Assumption that szName has always enough space */
     139        {
     140/** @todo r-bird: This code is bringing all CPUs online; the idCpuCore and
     141 *        idCpuPackage parameters are unused!   */
     142            /*
     143             * Check if this is a CPU object.
     144             * cpu0 is excluded because it is not possible to change the state
     145             * of the first CPU on Linux (it doesn't even have an online file)
     146             * and cpuidle is no CPU device. Prevents error messages later.
     147             */
     148            if(   !strncmp(DirFolderContent.szName, "cpu", 3)
     149                && strncmp(DirFolderContent.szName, "cpu0", 4)
     150                && strncmp(DirFolderContent.szName, "cpuidle", 7))
     151            {
     152                /* Get the sysdev */
     153                RTFILE hFileCpuOnline = NIL_RTFILE;
     154                rc = RTFileOpenF(&hFileCpuOnline, RTFILE_O_WRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
     155                                 "%s/%s/online", SYSFS_CPU_PATH, DirFolderContent.szName);
    81156                if (RT_SUCCESS(rc))
    82157                {
    83                     uint32_t idCore    = RTLinuxSysFsReadIntFile(10, "%s/sysdev/topology/core_id", pszSysDevPath);
    84                     uint32_t idPackage = RTLinuxSysFsReadIntFile(10, "%s/sysdev/topology/physical_package_id", pszSysDevPath);
    85 
    86                     if (   (idCore == idCpuCore)
    87                         && (idPackage == idCpuPackage))
     158                    /* Write a 1 to online the CPU */
     159                    rc = RTFileWrite(hFileCpuOnline, "1", 1, NULL);
     160                    RTFileClose(hFileCpuOnline);
     161                    if (RT_SUCCESS(rc))
    88162                    {
    89                         /* Return the path */
    90                         *ppszPath = pszSysDevPath;
     163                        VBoxServiceVerbose(1, "CpuHotPlug: CPU %u/%u was brought online\n", idCpuPackage, idCpuCore);
    91164                        break;
    92165                    }
    93                     RTStrFree(pszSysDevPath);
     166                    /* Error means CPU not present or online already  */
    94167                }
    95168                else
    96                     break;
     169                    VBoxServiceError("CpuHotPlug: Failed to open \"%s/%s/online\" rc=%Rrc\n",
     170                                     SYSFS_CPU_PATH, DirFolderContent.szName, rc);
    97171            }
    98172        }
    99 
    100         RTDirClose(pDirDevices);
    101173    }
    102 
    103     return rc;
    104 }
     174    else
     175        VBoxServiceError("CpuHotPlug: Failed to open path %s rc=%Rrc\n", SYSFS_CPU_PATH, rc);
     176#else
     177# error "Port me"
    105178#endif
    106 
    107 /** @copydoc VBOXSERVICE::pfnPreInit */
    108 static DECLCALLBACK(int) VBoxServiceCpuHotplugPreInit(void)
    109 {
    110     return VINF_SUCCESS;
    111 }
    112 
    113 
    114 /** @copydoc VBOXSERVICE::pfnOption */
    115 static DECLCALLBACK(int) VBoxServiceCpuHotplugOption(const char **ppszShort, int argc, char **argv, int *pi)
    116 {
    117     return VINF_SUCCESS;
    118 }
    119 
    120 
    121 /** @copydoc VBOXSERVICE::pfnInit */
    122 static DECLCALLBACK(int) VBoxServiceCpuHotplugInit(void)
    123 {
    124     return VINF_SUCCESS;
     179}
     180
     181
     182/**
     183 * Handles VMMDevCpuEventType_Unplug.
     184 *
     185 * @param   idCpuCore       The CPU core ID.
     186 * @param   idCpuPackage    The CPU package ID.
     187 */
     188static void VBoxServiceCpuHotPlugHandleUnplugEvent(uint32_t idCpuCore, uint32_t idCpuPackage)
     189{
     190#ifdef RT_OS_LINUX
     191    char *pszCpuDevicePath = NULL;
     192    int rc = VBoxServiceCpuHotPlugGetACPIDevicePath(&pszCpuDevicePath, idCpuCore, idCpuPackage);
     193    if (RT_SUCCESS(rc))
     194    {
     195        RTFILE hFileCpuEject;
     196        rc = RTFileOpenF(&hFileCpuEject, RTFILE_O_WRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
     197                         "%s/eject", pszCpuDevicePath);
     198        if (RT_SUCCESS(rc))
     199        {
     200            /* Write a 1 to eject the CPU */
     201            rc = RTFileWrite(hFileCpuEject, "1", 1, NULL);
     202            if (RT_SUCCESS(rc))
     203                VBoxServiceVerbose(1, "CpuHotPlug: CPU %u/%u was ejected\n", idCpuPackage, idCpuCore);
     204            else
     205                VBoxServiceError("CpuHotPlug: Failed to eject CPU %u/%u rc=%Rrc\n", idCpuPackage, idCpuCore, rc);
     206
     207            RTFileClose(hFileCpuEject);
     208        }
     209        else
     210            VBoxServiceError("CpuHotPlug: Failed to open \"%s/eject\" rc=%Rrc\n", pszCpuDevicePath, rc);
     211        RTStrFree(pszCpuDevicePath);
     212    }
     213    else
     214        VBoxServiceError("CpuHotPlug: Failed to get CPU device path rc=%Rrc\n", rc);
     215#else
     216# error "Port me"
     217#endif
    125218}
    126219
    127220
    128221/** @copydoc VBOXSERVICE::pfnWorker */
    129 DECLCALLBACK(int) VBoxServiceCpuHotplugWorker(bool volatile *pfShutdown)
    130 {
    131     int rc = VINF_SUCCESS;
    132 
     222DECLCALLBACK(int) VBoxServiceCpuHotPlugWorker(bool volatile *pfShutdown)
     223{
    133224    /*
    134225     * Tell the control thread that it can continue spawning services.
     
    139230     * Enable the CPU hotplug notifier.
    140231     */
    141     rc = VbglR3CpuHotplugInit();
     232    int rc = VbglR3CpuHotPlugInit();
    142233    if (RT_FAILURE(rc))
    143234        return rc;
     
    148239    for (;;)
    149240    {
    150         uint32_t idCpuCore    = UINT32_MAX;
    151         uint32_t idCpuPackage = UINT32_MAX;
    152         VMMDevCpuEventType enmEventType = VMMDevCpuEventType_None;
    153 
    154         /* Wait for CPU hotplug event. */
    155         rc = VbglR3CpuHotplugWaitForEvent(&enmEventType, &idCpuCore, &idCpuPackage);
    156         if (RT_FAILURE(rc) && (rc != VERR_INTERRUPTED))
    157             break;
    158 
    159         VBoxServiceVerbose(3, "CPUHotplug: Event happened idCpuCore=%u idCpuPackage=%u enmEventType=%d\n", idCpuCore, idCpuPackage, enmEventType);
    160 
    161         if (enmEventType == VMMDevCpuEventType_Plug)
    162         {
    163 #ifdef RT_OS_LINUX
    164             /*
    165              * The topology directory is not available until the CPU is online. So we just iterate over all directories
    166              * and enable every CPU which is not online already.
    167              */
    168             /** @todo Maybe use udev to monitor events from the kernel */
    169             PRTDIR pDirDevices = NULL;
    170 
    171             rc = RTDirOpen(&pDirDevices, SYSFS_CPU_PATH);  /*could use RTDirOpenFiltered*/
    172 
    173             if(RT_SUCCESS(rc))
     241        /* Wait for CPU hot plugging event. */
     242        uint32_t            idCpuCore;
     243        uint32_t            idCpuPackage;
     244        VMMDevCpuEventType  enmEventType;
     245        rc = VbglR3CpuHotPlugWaitForEvent(&enmEventType, &idCpuCore, &idCpuPackage);
     246        if (RT_SUCCESS(rc))
     247        {
     248            VBoxServiceVerbose(3, "CpuHotPlug: Event happened idCpuCore=%u idCpuPackage=%u enmEventType=%d\n",
     249                               idCpuCore, idCpuPackage, enmEventType);
     250            switch (enmEventType)
    174251            {
    175                 RTDIRENTRY DirFolderContent;
    176 
    177                 while(RT_SUCCESS(RTDirRead(pDirDevices, &DirFolderContent, NULL))) /* Assumption that szName has always enough space */
     252                case VMMDevCpuEventType_Plug:
     253                    VBoxServiceCpuHotPlugHandlePlugEvent(idCpuCore, idCpuPackage);
     254                    break;
     255
     256                case VMMDevCpuEventType_Unplug:
     257                    VBoxServiceCpuHotPlugHandleUnplugEvent(idCpuCore, idCpuPackage);
     258                    break;
     259
     260                default:
    178261                {
    179                     /** Check if this is a CPU object.
    180                      *  cpu0 is excluded because it is not possbile
    181                      *  to change the state of the first CPU
    182                      *  (it doesn't even have an online file)
    183                      *  and cpuidle is no CPU device.
    184                      *  Prevents error messages later.
    185                      */
    186                     if(   !RTStrNCmp(DirFolderContent.szName, "cpu", 3)
    187                         && RTStrNCmp(DirFolderContent.szName, "cpu0", 4)
    188                         && RTStrNCmp(DirFolderContent.szName, "cpuidle", 7))
    189                     {
    190                         char *pszSysDevPath = NULL;
    191 
    192                         /* Get the sysdev */
    193                         rc = RTStrAPrintf(&pszSysDevPath, "%s/%s/online", SYSFS_CPU_PATH, DirFolderContent.szName);
    194                         if (RT_SUCCESS(rc))
    195                         {
    196                             RTFILE FileCpuOnline = NIL_RTFILE;
    197 
    198                             rc = RTFileOpen(&FileCpuOnline, pszSysDevPath, RTFILE_O_WRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    199                             if (RT_SUCCESS(rc))
    200                             {
    201                                 /* Write a 1 to online the CPU */
    202                                 rc = RTFileWrite(FileCpuOnline, "1", 1, NULL);
    203                                 if (RT_SUCCESS(rc))
    204                                 {
    205                                     VBoxServiceVerbose(1, "CPUHotplug: CPU %u/%u was brought online\n", idCpuPackage, idCpuCore);
    206                                     RTFileClose(FileCpuOnline);
    207                                     break;
    208                                 }
    209                                 /* Error means CPU not present or online already  */
    210 
    211                                 RTFileClose(FileCpuOnline);
    212                             }
    213                             else
    214                                 VBoxServiceError("CPUHotplug: Failed to open online path %s rc=%Rrc\n", pszSysDevPath, rc);
    215 
    216                             RTStrFree(pszSysDevPath);
    217                         }
    218                     }
     262                    static uint32_t s_iErrors = 0;
     263                    if (s_iErrors++ < 10)
     264                        VBoxServiceError("CpuHotPlug: Unknown event: idCpuCore=%u idCpuPackage=%u enmEventType=%d\n",
     265                                         idCpuCore, idCpuPackage, enmEventType);
     266                    break;
    219267                }
    220268            }
    221             else
    222                 VBoxServiceError("CPUHotplug: Failed to open path %s rc=%Rrc\n", SYSFS_CPU_PATH, rc);
    223 #else
    224 # error "Port me"
    225 #endif
    226         }
    227         else if (enmEventType == VMMDevCpuEventType_Unplug)
    228         {
    229 #ifdef RT_OS_LINUX
    230             char *pszCpuDevicePath = NULL;
    231 
    232             rc = cpuHotplugGetACPIDevicePath(&pszCpuDevicePath, idCpuCore, idCpuPackage);
    233             if (RT_SUCCESS(rc))
    234             {
    235                 char *pszPathEject = NULL;
    236 
    237                 rc = RTStrAPrintf(&pszPathEject, "%s/eject", pszCpuDevicePath);
    238                 if (RT_SUCCESS(rc))
    239                 {
    240                     RTFILE FileCpuEject = NIL_RTFILE;
    241 
    242                     rc = RTFileOpen(&FileCpuEject, pszPathEject, RTFILE_O_WRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    243                     if (RT_SUCCESS(rc))
    244                     {
    245                         /* Write a 1 to eject the CPU */
    246                         rc = RTFileWrite(FileCpuEject, "1", 1, NULL);
    247                         if (RT_SUCCESS(rc))
    248                             VBoxServiceVerbose(1, "CPUHotplug: CPU %u/%u was ejected\n", idCpuPackage, idCpuCore);
    249                         else
    250                             VBoxServiceError("CPUHotplug: Failed to eject CPU %u/%u rc=%Rrc\n", idCpuPackage, idCpuCore, rc);
    251 
    252                         RTFileClose(FileCpuEject);
    253                     }
    254                     else
    255                         VBoxServiceError("CPUHotplug: Failed to open eject path %s rc=%Rrc\n", pszPathEject, rc);
    256                 }
    257                 else
    258                     VBoxServiceError("CPUHotplug: Failed to allocate eject path rc=%Rrc\n", rc);
    259 
    260                 RTStrFree(pszCpuDevicePath);
    261             }
    262             else
    263                 VBoxServiceError("CPUHotplug: Failed to get CPU device path rc=%Rrc\n", rc);
    264 #else
    265 # error "Port me"
    266 #endif
    267         }
    268         /* Ignore invalid values. */
     269        }
     270        else if (rc != VERR_INTERRUPTED && rc != VERR_TRY_AGAIN)
     271        {
     272            VBoxServiceError("CpuHotPlug: VbglR3CpuHotPlugWaitForEvent returned %Rrc\n", rc);
     273            break;
     274        }
    269275
    270276        if (*pfShutdown)
     
    272278    }
    273279
    274     VbglR3CpuHotplugTerm();
     280    VbglR3CpuHotPlugTerm();
    275281    return rc;
    276282}
     
    278284
    279285/** @copydoc VBOXSERVICE::pfnStop */
    280 static DECLCALLBACK(void) VBoxServiceCpuHotplugStop(void)
     286static DECLCALLBACK(void) VBoxServiceCpuHotPlugStop(void)
    281287{
    282288    VbglR3InterruptEventWaits();
     
    286292
    287293/** @copydoc VBOXSERVICE::pfnTerm */
    288 static DECLCALLBACK(void) VBoxServiceCpuHotplugTerm(void)
     294static DECLCALLBACK(void) VBoxServiceCpuHotPlugTerm(void)
    289295{
    290296    return;
     
    295301 * The 'timesync' service description.
    296302 */
    297 VBOXSERVICE g_CpuHotplug =
     303VBOXSERVICE g_CpuHotPlug =
    298304{
    299305    /* pszName. */
    300306    "cpuhotplug",
    301307    /* pszDescription. */
    302     "CPU hotplug monitor",
     308    "CPU hot plugging monitor",
    303309    /* pszUsage. */
    304310    NULL,
     
    306312    NULL,
    307313    /* methods */
    308     VBoxServiceCpuHotplugPreInit,
    309     VBoxServiceCpuHotplugOption,
    310     VBoxServiceCpuHotplugInit,
    311     VBoxServiceCpuHotplugWorker,
    312     VBoxServiceCpuHotplugStop,
    313     VBoxServiceCpuHotplugTerm
     314    VBoxServiceCpuHotPlugPreInit,
     315    VBoxServiceCpuHotPlugOption,
     316    VBoxServiceCpuHotPlugInit,
     317    VBoxServiceCpuHotPlugWorker,
     318    VBoxServiceCpuHotPlugStop,
     319    VBoxServiceCpuHotPlugTerm
    314320};
    315321
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r25975 r26061  
    55
    66/*
    7  * Copyright (C) 2007-2009 Sun Microsystems, Inc.
     7 * Copyright (C) 2007-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    9595#ifdef RT_OS_WINDOWS
    9696/** The service name (needed for mutex creation on Windows). */
    97 #define VBOXSERVICE_NAME          "VBoxService"
     97# define VBOXSERVICE_NAME           "VBoxService"
    9898/** The friendly service name. */
    99 #define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
     99# define VBOXSERVICE_FRIENDLY_NAME "VirtualBox Guest Additions Service"
    100100/** The service description (only W2K+ atm) */
    101 #define VBOXSERVICE_DESCRIPTION   "Manages VM runtime information, time synchronization, remote sysprep execution and miscellaneous utilities for guest operating systems."
     101# define VBOXSERVICE_DESCRIPTION    "Manages VM runtime information, time synchronization, remote sysprep execution and miscellaneous utilities for guest operating systems."
    102102/** The following constant may be defined by including NtStatus.h. */
    103 #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
     103# define STATUS_SUCCESS            ((NTSTATUS)0x00000000L)
    104104/** Structure for storing the looked up user information. */
    105105typedef struct
    106106{
    107     WCHAR szUser [_MAX_PATH];
    108     WCHAR szAuthenticationPackage [_MAX_PATH];
    109     WCHAR szLogonDomain [_MAX_PATH];
     107    WCHAR szUser[_MAX_PATH];
     108    WCHAR szAuthenticationPackage[_MAX_PATH];
     109    WCHAR szLogonDomain[_MAX_PATH];
    110110} VBOXSERVICEVMINFOUSER, *PVBOXSERVICEVMINFOUSER;
    111111/** Structure for the file information lookup. */
    112112typedef struct
    113113{
    114     char* pszFilePath;
    115     char* pszFileName;
     114    char *pszFilePath;
     115    char *pszFileName;
    116116} VBOXSERVICEVMINFOFILE, *PVBOXSERVICEVMINFOFILE;
    117117/** Function prototypes for dynamic loading. */
    118118typedef DWORD (WINAPI* fnWTSGetActiveConsoleSessionId)();
    119 #endif
     119#endif /* RT_OS_WINDOWS */
    120120
    121121RT_C_DECLS_BEGIN
     
    138138extern VBOXSERVICE g_VMInfo;
    139139extern VBOXSERVICE g_Exec;
    140 extern VBOXSERVICE g_CpuHotplug;
     140extern VBOXSERVICE g_CpuHotPlug;
    141141
    142142#ifdef RT_OS_WINDOWS
     
    151151/** Reports our current status to the SCM. */
    152152extern BOOL VBoxServiceWinSetStatus(DWORD dwStatus, DWORD dwCheckPoint);
    153 #ifdef VBOX_WITH_GUEST_PROPS
     153# ifdef VBOX_WITH_GUEST_PROPS
    154154/** Detects wheter a user is logged on based on the enumerated processes. */
    155 extern BOOL VBoxServiceVMInfoWinIsLoggedIn(VBOXSERVICEVMINFOUSER* a_pUserInfo,
     155extern BOOL VBoxServiceVMInfoWinIsLoggedIn(VBOXSERVICEVMINFOUSER *a_pUserInfo,
    156156                                           PLUID a_pSession,
    157157                                           PLUID a_pLuid,
     
    159159/** Gets logon user IDs from enumerated processes. */
    160160extern DWORD VBoxServiceVMInfoWinGetLUIDsFromProcesses(PLUID *ppLuid);
    161 #endif /* VBOX_WITH_GUEST_PROPS */
     161# endif /* VBOX_WITH_GUEST_PROPS */
    162162#endif /* RT_OS_WINDOWS */
    163163
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