VirtualBox

Changeset 56035 in vbox for trunk/src


Ignore:
Timestamp:
May 22, 2015 4:03:35 PM (10 years ago)
Author:
vboxsync
Message:

Main/Machine+USBController+StorageController: Mix of deleting useless functionality, fixing of missing sanity checks and adding some additional functionality. The removed functionality is the possibility to specify patters of guest properties which will trigger notifications, which wasn't useful as it is per VM, sabotaging other API clients (e.g. the VM process assumes it gets the notifications it needs). The storage controller setters were lacking a lot of state and consistency sanity checking, which is now fixed. Both the USB and storage controllers can now be renamed (no API client uses this functionality though), all with very pessimistic assumptions (only when the VM is powered off).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r55977 r56035  
    35803580  <interface
    35813581    name="IInternalMachineControl" extends="$unknown"
    3582     uuid="2cfec73b-4447-4ff8-bae5-e4306e6197e8"
     3582    uuid="ec36f437-ad4d-4512-94dd-f4c568143aa7"
    35833583    internal="yes"
    35843584    wsmap="suppress"
     
    38073807        </desc>
    38083808      </param>
    3809       <param name="notify" type="boolean" dir="return">
    3810         <desc>
    3811           Returns if a guest property change notification event should be fired.
    3812         </desc>
    3813       </param>
    38143809    </method>
    38153810
     
    41704165  <interface
    41714166    name="IMachine" extends="$unknown"
    4172     uuid="520a0c22-8dbc-458d-b637-31eb078b5526"
     4167    uuid="6bf820b3-a08f-49a7-ac08-b88efbd3a313"
    41734168    wsmap="managed"
    41744169    wrap-hint-server-addinterfaces="IInternalMachineControl"
     
    48004795    </attribute>
    48014796
    4802     <attribute name="guestPropertyNotificationPatterns" type="wstring">
    4803       <desc>
    4804         A comma-separated list of simple glob patterns. Changes to guest
    4805         properties whose name matches one of the patterns will generate an
    4806         <link to="IGuestPropertyChangedEvent"/> signal.
    4807       </desc>
    4808     </attribute>
    4809 
    48104797    <attribute name="teleporterEnabled" type="boolean">
    48114798      <desc>
     
    60486035    <method name="getStorageControllerByInstance" const="yes">
    60496036      <desc>
    6050         Returns a storage controller with the given instance number.
     6037        Returns a storage controller of a specific storage bus
     6038        with the given instance number.
    60516039
    60526040        <result name="VBOX_E_OBJECT_NOT_FOUND">
     
    60546042        </result>
    60556043      </desc>
     6044      <param name="connectionType" type="StorageBus" dir="in"/>
    60566045      <param name="instance" type="unsigned long" dir="in"/>
    60576046      <param name="storageController" type="IStorageController" dir="return"/>
     
    1780417793  <interface
    1780517794    name="IUSBController" extends="$unknown"
    17806     uuid="d2745291-65f7-4d75-9556-38047d802319"
     17795    uuid="2598fa52-3044-4ff5-8a61-2b09088a9e3c"
    1780717796    wsmap="managed"
    1780817797    >
    1780917798
    17810     <attribute name="name" type="wstring" readonly="yes">
     17799    <attribute name="name" type="wstring">
    1781117800      <desc>
    1781217801        The USB Controller name.
     
    1781417803    </attribute>
    1781517804
    17816     <attribute name="type" type="USBControllerType" readonly="yes">
     17805    <attribute name="type" type="USBControllerType">
    1781717806      <desc>
    1781817807        The USB Controller type.
     
    1948719476  <interface
    1948819477    name="IStorageController" extends="$unknown"
    19489     uuid="a1556333-09b6-46d9-bfb7-fc239b7fbe1e"
     19478    uuid="802bb9c0-fe71-43ab-b55a-322fdf77358f"
    1949019479    wsmap="managed"
    1949119480    >
     
    1950919498    </desc>
    1951019499
    19511     <attribute name="name" type="wstring" readonly="yes">
     19500    <attribute name="name" type="wstring">
    1951219501      <desc>
    1951319502        Name of the storage controller, as originally specified with
  • trunk/src/VBox/Main/include/MachineImpl.h

    r55977 r56035  
    307307        typedef std::map<Utf8Str, GuestProperty> GuestPropertyMap;
    308308        GuestPropertyMap    mGuestProperties;
    309         Utf8Str             mGuestPropertyNotificationPatterns;
    310309
    311310        FirmwareType_T      mFirmwareType;
     
    591590    void i_releaseStateDependency();
    592591
     592    HRESULT i_getStorageControllerByName(const Utf8Str &aName,
     593                                         ComObjPtr<StorageController> &aStorageController,
     594                                         bool aSetError = false);
     595
     596    HRESULT i_getUSBControllerByName(const Utf8Str &aName,
     597                                     ComObjPtr<USBController> &aUSBController,
     598                                     bool aSetError = false);
     599
    593600    HRESULT i_getBandwidthGroup(const Utf8Str &strBandwidthGroup,
    594601                                ComObjPtr<BandwidthGroup> &pBandwidthGroup,
     
    643650                                 bool aSetError = false);
    644651
    645     HRESULT i_getStorageControllerByName(const Utf8Str &aName,
    646                                          ComObjPtr<StorageController> &aStorageController,
    647                                          bool aSetError = false);
    648 
    649652    HRESULT i_getMediumAttachmentsOfController(const Utf8Str &aName,
    650653                                               MediaData::AttachmentList &aAttachments);
    651 
    652     HRESULT i_getUSBControllerByName(const Utf8Str &aName,
    653                                      ComObjPtr<USBController> &aUSBController,
    654                                      bool aSetError = false);
    655654
    656655    ULONG   i_getUSBControllerCountByType(USBControllerType_T enmType);
     
    943942    HRESULT getDnDMode(DnDMode_T *aDnDMode);
    944943    HRESULT setDnDMode(DnDMode_T aDnDMode);
    945     HRESULT getGuestPropertyNotificationPatterns(com::Utf8Str &aGuestPropertyNotificationPatterns);
    946     HRESULT setGuestPropertyNotificationPatterns(const com::Utf8Str &aGuestPropertyNotificationPatterns);
    947944    HRESULT getTeleporterEnabled(BOOL *aTeleporterEnabled);
    948945    HRESULT setTeleporterEnabled(BOOL aTeleporterEnabled);
     
    10691066    HRESULT getStorageControllerByName(const com::Utf8Str &aName,
    10701067                                       ComPtr<IStorageController> &aStorageController);
    1071     HRESULT getStorageControllerByInstance(ULONG aInstance,
     1068    HRESULT getStorageControllerByInstance(StorageBus_T aConnectionType,
     1069                                           ULONG aInstance,
    10721070                                           ComPtr<IStorageController> &aStorageController);
    10731071    HRESULT removeStorageController(const com::Utf8Str &aName);
     
    12331231                              const com::Utf8Str &aValue,
    12341232                              LONG64 aTimestamp,
    1235                               const com::Utf8Str &aFlags,
    1236                               BOOL *aNotify);
     1233                              const com::Utf8Str &aFlags);
    12371234    HRESULT lockMedia();
    12381235    HRESULT unlockMedia();
     
    13821379                              const com::Utf8Str &aValue,
    13831380                              LONG64 aTimestamp,
    1384                               const com::Utf8Str &aFlags,
    1385                               BOOL *aNotify);
     1381                              const com::Utf8Str &aFlags);
    13861382    HRESULT lockMedia();
    13871383    HRESULT unlockMedia();
  • trunk/src/VBox/Main/include/StorageControllerImpl.h

    r49644 r56035  
    7272    // Wrapped IStorageController properties
    7373    HRESULT getName(com::Utf8Str &aName);
     74    HRESULT setName(const com::Utf8Str &aName);
    7475    HRESULT getMaxDevicesPerPortCount(ULONG *aMaxDevicesPerPortCount);
    7576    HRESULT getMinPortCount(ULONG *aMinPortCount);
  • trunk/src/VBox/Main/include/USBControllerImpl.h

    r49871 r56035  
    77
    88/*
    9  * Copyright (C) 2005-2013 Oracle Corporation
     9 * Copyright (C) 2005-2015 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6161    // wrapped IUSBController properties
    6262    HRESULT getName(com::Utf8Str &aName);
     63    HRESULT setName(const com::Utf8Str &aName);
    6364    HRESULT getType(USBControllerType_T *aType);
     65    HRESULT setType(USBControllerType_T aType);
    6466    HRESULT getUSBStandard(USHORT *aUSBStandard);
    6567
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r56030 r56035  
    17591759    Bstr flags(pCBData->pcszFlags);
    17601760    ComObjPtr<Console> pConsole = reinterpret_cast<Console *>(pvExtension);
    1761     BOOL fNotify = FALSE;
    17621761    HRESULT hrc = pConsole->mControl->PushGuestProperty(name.raw(),
    17631762                                                        value.raw(),
    17641763                                                        pCBData->u64Timestamp,
    1765                                                         flags.raw(),
    1766                                                         &fNotify);
     1764                                                        flags.raw());
    17671765    if (SUCCEEDED(hrc))
     1766    {
     1767        fireGuestPropertyChangedEvent(pConsole->mEventSource, pConsole->i_getId().raw(), name.raw(), value.raw(), flags.raw());
    17681768        rc = VINF_SUCCESS;
     1769    }
    17691770    else
    17701771    {
     
    17731774        rc = Global::vboxStatusCodeFromCOM(hrc);
    17741775    }
    1775     if (fNotify)
    1776         fireGuestPropertyChangedEvent(pConsole->mEventSource, pConsole->i_getId().raw(), name.raw(), value.raw(), flags.raw());
    17771776    return rc;
    17781777}
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r56019 r56035  
    207207    mClipboardMode = ClipboardMode_Disabled;
    208208    mDnDMode = DnDMode_Disabled;
    209     mGuestPropertyNotificationPatterns = "";
    210209
    211210    mFirmwareType = FirmwareType_BIOS;
     
    28452844}
    28462845
    2847 HRESULT Machine::getGuestPropertyNotificationPatterns(com::Utf8Str &aGuestPropertyNotificationPatterns)
    2848 {
    2849     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2850 
    2851     try
    2852     {
    2853         aGuestPropertyNotificationPatterns = mHWData->mGuestPropertyNotificationPatterns;
    2854     }
    2855     catch (...)
    2856     {
    2857         return VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    2858     }
    2859 
    2860     return S_OK;
    2861 }
    2862 
    2863 HRESULT Machine::setGuestPropertyNotificationPatterns(const com::Utf8Str &aGuestPropertyNotificationPatterns)
    2864 {
    2865     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    2866 
    2867     HRESULT rc = i_checkStateDependency(MutableOrSavedOrRunningStateDep);
    2868     if (FAILED(rc)) return rc;
    2869 
    2870     i_setModified(IsModified_MachineData);
    2871     mHWData.backup();
    2872     mHWData->mGuestPropertyNotificationPatterns = aGuestPropertyNotificationPatterns;
    2873     return rc;
    2874 }
    2875 
    28762846HRESULT Machine::getStorageControllers(std::vector<ComPtr<IStorageController> > &aStorageControllers)
    28772847{
     
    57525722        }
    57535723
    5754         if (   SUCCEEDED(rc)
    5755             && (   mHWData->mGuestPropertyNotificationPatterns.isEmpty()
    5756                 || RTStrSimplePatternMultiMatch(mHWData->mGuestPropertyNotificationPatterns.c_str(),
    5757                                                 RTSTR_MAX,
    5758                                                 aName.c_str(),
    5759                                                 RTSTR_MAX,
    5760                                                 NULL)
    5761                )
    5762            )
     5724        if (SUCCEEDED(rc))
    57635725        {
    57645726            alock.release();
     
    60976059}
    60986060
    6099 HRESULT Machine::getStorageControllerByInstance(ULONG aInstance,
     6061HRESULT Machine::getStorageControllerByInstance(StorageBus_T aConnectionType,
     6062                                                ULONG aInstance,
    61006063                                                ComPtr<IStorageController> &aStorageController)
    61016064{
     
    61066069         ++it)
    61076070    {
    6108         if ((*it)->i_getInstance() == aInstance)
     6071        if (   (*it)->i_getStorageBus() == aConnectionType
     6072            && (*it)->i_getInstance() == aInstance)
    61096073        {
    61106074            (*it).queryInterfaceTo(aStorageController.asOutParam());
     
    90809044            ++it;
    90819045        }
    9082 
    9083         mHWData->mGuestPropertyNotificationPatterns = data.strNotificationPatterns;
    90849046#endif /* VBOX_WITH_GUEST_PROPS defined */
    90859047
     
    1038210344        }
    1038310345
    10384         data.strNotificationPatterns = mHWData->mGuestPropertyNotificationPatterns;
    1038510346        /* I presume this doesn't require a backup(). */
    1038610347        mData->mGuestPropertiesModified = FALSE;
     
    1339313354                                          const com::Utf8Str &aValue,
    1339413355                                          LONG64 aTimestamp,
    13395                                           const com::Utf8Str &aFlags,
    13396                                           BOOL *aNotify)
     13356                                          const com::Utf8Str &aFlags)
    1339713357{
    1339813358    LogFlowThisFunc(("\n"));
     
    1340013360#ifdef VBOX_WITH_GUEST_PROPS
    1340113361    using namespace guestProp;
    13402 
    13403     *aNotify = FALSE;
    1340413362
    1340513363    try
     
    1346913427        }
    1347013428
    13471         /*
    13472          * Send a callback notification if appropriate
    13473          */
    13474         if (    mHWData->mGuestPropertyNotificationPatterns.isEmpty()
    13475              || RTStrSimplePatternMultiMatch(mHWData->mGuestPropertyNotificationPatterns.c_str(),
    13476                                              RTSTR_MAX,
    13477                                              aName.c_str(),
    13478                                              RTSTR_MAX, NULL)
    13479            )
    13480         {
    13481             alock.release();
    13482 
    13483             mParent->i_onGuestPropertyChange(mData->mUuid,
    13484                                              Bstr(aName).raw(),
    13485                                              Bstr(aValue).raw(),
    13486                                              Bstr(aFlags).raw());
    13487             *aNotify = TRUE;
    13488         }
     13429        alock.release();
     13430
     13431        mParent->i_onGuestPropertyChange(mData->mUuid,
     13432                                         Bstr(aName).raw(),
     13433                                         Bstr(aValue).raw(),
     13434                                         Bstr(aFlags).raw());
    1348913435    }
    1349013436    catch (...)
     
    1475714703                                   const com::Utf8Str &aValue,
    1475814704                                   LONG64 aTimestamp,
    14759                                    const com::Utf8Str &aFlags,
    14760                                    BOOL *aNotify)
     14705                                   const com::Utf8Str &aFlags)
    1476114706{
    1476214707    NOREF(aName);
     
    1476414709    NOREF(aTimestamp);
    1476514710    NOREF(aFlags);
    14766     NOREF(aNotify);
    1476714711    ReturnComNotImplemented();
    1476814712}
  • trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp

    r54971 r56035  
    323323    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    324324
    325     /* mName is constant during life time, no need to lock */
    326     aName = m->bd.data()->strName;
     325    aName = m->bd->strName;
     326
     327    return S_OK;
     328}
     329
     330HRESULT StorageController::setName(const com::Utf8Str &aName)
     331{
     332    /* the machine needs to be mutable */
     333    AutoMutableStateDependency adep(m->pParent);
     334    if (FAILED(adep.rc())) return adep.rc();
     335
     336    AutoMultiWriteLock2 alock(m->pParent, this COMMA_LOCKVAL_SRC_POS);
     337
     338    if (m->bd->strName != aName)
     339    {
     340        ComObjPtr<StorageController> ctrl;
     341        HRESULT rc = m->pParent->i_getStorageControllerByName(aName, ctrl, false /* aSetError */);
     342        if (SUCCEEDED(rc))
     343            return setError(VBOX_E_OBJECT_IN_USE,
     344                            tr("Storage controller named '%s' already exists"),
     345                            aName.c_str());
     346
     347        m->bd.backup();
     348        m->bd->strName = aName;
     349
     350        m->pParent->i_setModified(Machine::IsModified_Storage);
     351        alock.release();
     352
     353        m->pParent->i_onStorageControllerChange();
     354    }
    327355
    328356    return S_OK;
     
    331359HRESULT StorageController::getBus(StorageBus_T *aBus)
    332360{
    333     CheckComArgOutPointerValid(aBus);
    334 
    335361    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    336362
     
    342368HRESULT StorageController::getControllerType(StorageControllerType_T *aControllerType)
    343369{
    344     CheckComArgOutPointerValid(aControllerType);
    345 
    346370    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    347371
     
    353377HRESULT StorageController::setControllerType(StorageControllerType_T aControllerType)
    354378{
     379    /* the machine needs to be mutable */
     380    AutoMutableStateDependency adep(m->pParent);
     381    if (FAILED(adep.rc())) return adep.rc();
     382
    355383    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    356384
     
    400428        default:
    401429            AssertMsgFailed(("Invalid controller type %d\n", m->bd->mStorageBus));
     430            rc = E_INVALIDARG;
    402431    }
    403432
     
    407436                        aControllerType);
    408437
    409     m->bd->mStorageControllerType = aControllerType;
     438    if (m->bd->mStorageControllerType != aControllerType)
     439    {
     440        m->bd.backup();
     441        m->bd->mStorageControllerType = aControllerType;
     442
     443        alock.release();
     444        AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);        // m->pParent is const, needs no locking
     445        m->pParent->i_setModified(Machine::IsModified_Storage);
     446        mlock.release();
     447
     448        m->pParent->i_onStorageControllerChange();
     449    }
    410450
    411451    return S_OK;
     
    414454HRESULT StorageController::getMaxDevicesPerPortCount(ULONG *aMaxDevicesPerPortCount)
    415455{
    416     CheckComArgOutPointerValid(aMaxDevicesPerPortCount);
    417 
    418456    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    419457
     
    425463HRESULT StorageController::getMinPortCount(ULONG *aMinPortCount)
    426464{
    427     CheckComArgOutPointerValid(aMinPortCount);
    428 
    429465    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    430466
     
    435471HRESULT StorageController::getMaxPortCount(ULONG *aMaxPortCount)
    436472{
    437     CheckComArgOutPointerValid(aMaxPortCount);
    438 
    439473    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    440474    HRESULT rc = m->pSystemProperties->GetMaxPortCountForStorageBus(m->bd->mStorageBus, aMaxPortCount);
     
    445479HRESULT StorageController::getPortCount(ULONG *aPortCount)
    446480{
    447     CheckComArgOutPointerValid(aPortCount);
    448 
    449481    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    450482
     
    456488HRESULT StorageController::setPortCount(ULONG aPortCount)
    457489{
    458     LogFlowThisFunc(("aPortCount=%u\n", aPortCount));
     490    /* the machine needs to be mutable */
     491    AutoMutableStateDependency adep(m->pParent);
     492    if (FAILED(adep.rc())) return adep.rc();
     493
     494    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    459495
    460496    switch (m->bd->mStorageBus)
     
    529565    }
    530566
    531     AutoCaller autoCaller(this);
    532     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    533 
    534     /* the machine needs to be mutable */
    535     AutoMutableStateDependency adep(m->pParent);
    536     if (FAILED(adep.rc())) return adep.rc();
    537 
    538     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    539 
    540567    if (m->bd->mPortCount != aPortCount)
    541568    {
     
    556583HRESULT StorageController::getInstance(ULONG *aInstance)
    557584{
    558     /* The machine doesn't need to be mutable. */
    559 
    560585    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    561586
     
    566591
    567592HRESULT StorageController::setInstance(ULONG aInstance)
    568 {
    569     /* The machine doesn't need to be mutable. */
    570 
    571     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    572 
    573     m->bd->mInstance = aInstance;
    574 
    575     return S_OK;
    576 }
    577 
    578 HRESULT StorageController::getUseHostIOCache(BOOL *fUseHostIOCache)
    579 {
    580     /* The machine doesn't need to be mutable. */
    581 
    582     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    583 
    584     *fUseHostIOCache = m->bd->fUseHostIOCache;
    585 
    586     return S_OK;
    587 }
    588 
    589 HRESULT StorageController::setUseHostIOCache(BOOL fUseHostIOCache)
    590593{
    591594    /* the machine needs to be mutable */
     
    595598    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    596599
    597     if (m->bd->fUseHostIOCache != !!fUseHostIOCache)
     600    if (m->bd->mInstance != aInstance)
    598601    {
    599602        m->bd.backup();
    600         m->bd->fUseHostIOCache = !!fUseHostIOCache;
     603        m->bd->mInstance = aInstance;
    601604
    602605        alock.release();
     
    611614}
    612615
     616HRESULT StorageController::getUseHostIOCache(BOOL *fUseHostIOCache)
     617{
     618    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     619
     620    *fUseHostIOCache = m->bd->fUseHostIOCache;
     621
     622    return S_OK;
     623}
     624
     625HRESULT StorageController::setUseHostIOCache(BOOL fUseHostIOCache)
     626{
     627    /* the machine needs to be mutable */
     628    AutoMutableStateDependency adep(m->pParent);
     629    if (FAILED(adep.rc())) return adep.rc();
     630
     631    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     632
     633    if (m->bd->fUseHostIOCache != !!fUseHostIOCache)
     634    {
     635        m->bd.backup();
     636        m->bd->fUseHostIOCache = !!fUseHostIOCache;
     637
     638        alock.release();
     639        AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS);        // m->pParent is const, needs no locking
     640        m->pParent->i_setModified(Machine::IsModified_Storage);
     641        mlock.release();
     642
     643        m->pParent->i_onStorageControllerChange();
     644    }
     645
     646    return S_OK;
     647}
     648
    613649HRESULT StorageController::getBootable(BOOL *fBootable)
    614650{
    615 
    616     /* The machine doesn't need to be mutable. */
    617 
    618651    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    619652
  • trunk/src/VBox/Main/src-server/USBControllerImpl.cpp

    r50721 r56035  
    55
    66/*
    7  * Copyright (C) 2005-2013 Oracle Corporation
     7 * Copyright (C) 2005-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    238238HRESULT USBController::getName(com::Utf8Str &aName)
    239239{
    240     /* strName is constant during life time, no need to lock */
     240    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     241
    241242    aName = m->bd->strName;
    242243
     
    244245}
    245246
     247HRESULT USBController::setName(const com::Utf8Str &aName)
     248{
     249    /* the machine needs to be mutable */
     250    AutoMutableStateDependency adep(m->pParent);
     251    if (FAILED(adep.rc())) return adep.rc();
     252
     253    AutoMultiWriteLock2 alock(m->pParent, this COMMA_LOCKVAL_SRC_POS);
     254
     255    if (m->bd->strName != aName)
     256    {
     257        ComObjPtr<USBController> ctrl;
     258        HRESULT rc = m->pParent->i_getUSBControllerByName(aName, ctrl, false /* aSetError */);
     259        if (SUCCEEDED(rc))
     260            return setError(VBOX_E_OBJECT_IN_USE,
     261                            tr("USB controller named '%s' already exists"),
     262                            aName.c_str());
     263
     264        m->bd.backup();
     265        m->bd->strName = aName;
     266
     267        m->pParent->i_setModified(Machine::IsModified_USB);
     268        alock.release();
     269
     270        m->pParent->i_onUSBControllerChange();
     271    }
     272
     273    return S_OK;
     274}
     275
    246276HRESULT USBController::getType(USBControllerType_T *aType)
    247277{
     
    249279
    250280    *aType = m->bd->enmType;
     281
     282    return S_OK;
     283}
     284
     285HRESULT USBController::setType(USBControllerType_T aType)
     286{
     287    /* the machine needs to be mutable */
     288    AutoMutableStateDependency adep(m->pParent);
     289    if (FAILED(adep.rc())) return adep.rc();
     290
     291    AutoMultiWriteLock2 alock(m->pParent, this COMMA_LOCKVAL_SRC_POS);
     292
     293    if (m->bd->enmType != aType)
     294    {
     295        m->bd.backup();
     296        m->bd->enmType = aType;
     297
     298        m->pParent->i_setModified(Machine::IsModified_USB);
     299        alock.release();
     300
     301        m->pParent->i_onUSBControllerChange();
     302    }
    251303
    252304    return S_OK;
  • trunk/src/VBox/Main/xml/Settings.cpp

    r55677 r56035  
    20822082                  && (fPageFusionEnabled        == h.fPageFusionEnabled)
    20832083                  && (llGuestProperties         == h.llGuestProperties)
    2084                   && (strNotificationPatterns   == h.strNotificationPatterns)
    20852084                  && (ioSettings                == h.ioSettings)
    20862085                  && (pciAttachments            == h.pciAttachments)
     
    26912690        hw.llGuestProperties.push_back(prop);
    26922691    }
    2693 
    2694     elmGuestProperties.getAttributeValue("notificationPatterns", hw.strNotificationPatterns);
    26952692}
    26962693
     
    48534850        pelmProp->setAttribute("flags", prop.strFlags);
    48544851    }
    4855 
    4856     if (hw.strNotificationPatterns.length())
    4857         pelmGuestProps->setAttribute("notificationPatterns", hw.strNotificationPatterns);
    48584852}
    48594853
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